Jpp
15.0.1-rc.2-highQE
the software that should make you happy
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
examples
JSystem
JNetwork.cc
Go to the documentation of this file.
1
#include <string>
2
#include <vector>
3
#include <iostream>
4
#include <iomanip>
5
6
#include "
JSystem/JNetwork.hh
"
7
#include "
Jeep/JParser.hh
"
8
#include "
Jeep/JMessage.hh
"
9
10
11
/**
12
* \file
13
*
14
* Example program to print IP address.
15
* \author mdejong
16
*/
17
int
main
(
int
argc,
char
* argv[])
18
{
19
using namespace
std;
20
using namespace
JPP;
21
22
string
host_name;
23
24
try
{
25
26
JParser<>
zap(
"Example program to print IP address."
);
27
28
zap[
'H'
] =
make_field
(host_name) =
"localhost"
;
29
30
zap(argc, argv);
31
}
32
catch
(
const
exception &error) {
33
FATAL
(error.what() << endl);
34
}
35
36
37
int
ip =
getIPnumber
(host_name);
38
39
cout <<
"IP number "
<< ip << endl;
40
cout <<
"IP address "
<<
getIPaddress
(ip) << endl;
41
cout <<
"host name "
<<
getHostname
(ip) << endl;
42
cout <<
"subaddress "
43
<< dec <<
getSubaddress
(ip) <<
" (dec)"
<<
' '
44
<< hex <<
getSubaddress
(ip) <<
" (hex)"
<< endl;
45
46
cout << endl;
47
48
vector<string>
result
=
getListOfIPaddresses
();
49
50
for
(
vector<string>::const_iterator
i =
result
.begin(); i !=
result
.end(); ++i) {
51
cout <<
"IP address "
<< *i << endl;
52
}
53
}
JSYSTEM::getIPnumber
int getIPnumber(const std::string &host_name)
Get IP number.
Definition:
JNetwork.hh:117
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1500
main
int main(int argc, char *argv[])
Definition:
Main.cc:15
JSYSTEM::getIPaddress
std::string getIPaddress(const int ip)
Get IP address (decimal-dot notation).
Definition:
JNetwork.hh:154
JSYSTEM::getSubaddress
unsigned short getSubaddress(const int ip)
Get host identifier within network.
Definition:
JNetwork.hh:190
std::vector
Definition:
JSTDTypes.hh:12
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1961
JTOOLS::result
return result
Definition:
JPolint.hh:727
JMessage.hh
General purpose messaging.
JSYSTEM::getHostname
std::string getHostname()
Get host name.
Definition:
JNetwork.hh:77
FATAL
#define FATAL(A)
Definition:
JMessage.hh:67
JParser.hh
Utility class to parse command line options.
JSYSTEM::getListOfIPaddresses
std::vector< std::string > getListOfIPaddresses()
Get list of IP address (decimal-dot notation).
Definition:
JNetwork.hh:216
JNetwork.hh
Hostname and IP address functions.
Generated by
1.8.5