Jpp
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
2
#include <string>
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
21
string
host_name;
22
23
try
{
24
25
JParser<>
zap(
"Example program to print IP address."
);
26
27
zap[
'H'
] =
make_field
(host_name) =
"localhost"
;
28
29
zap(argc, argv);
30
}
31
catch
(
const
exception &error) {
32
FATAL
(error.what() << endl);
33
}
34
35
36
using namespace
JPP;
37
38
int
ip =
getIPnumber
(host_name);
39
40
cout <<
"IP number "
<< ip << endl;
41
cout <<
"IP address "
<<
getIPaddress
(ip) << endl;
42
cout <<
"host name "
<<
getHostname
(ip) << endl;
43
cout <<
"subaddress "
44
<< dec <<
getSubaddress
(ip) <<
" (dec)"
<<
' '
45
<< hex <<
getSubaddress
(ip) <<
" (hex)"
<< endl;
46
}
JSYSTEM::getIPnumber
int getIPnumber(const std::string &host_name)
Get IP number.
Definition:
JNetwork.hh:115
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1410
JSYSTEM::getIPaddress
std::string getIPaddress(const int ip)
Get IP address (decimal-dot notation).
Definition:
JNetwork.hh:150
JSYSTEM::getSubaddress
unsigned short getSubaddress(const int ip)
Get host identifier within network.
Definition:
JNetwork.hh:186
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1836
JMessage.hh
General purpose messaging.
JSYSTEM::getHostname
std::string getHostname()
Get host name.
Definition:
JNetwork.hh:75
FATAL
#define FATAL(A)
Definition:
JMessage.hh:65
JParser.hh
Utility class to parse command line options.
JNetwork.hh
Hostname and IP address functions.
main
int main(int argc, char *argv[])
Definition:
Main.cpp:15
Generated by
1.8.5