Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JEEP::JArgs Class Reference

Data structure to store command line arguments. More...

#include <JArgs.hh>

Inheritance diagram for JEEP::JArgs:
std::vector< std::string >

Public Member Functions

 JArgs ()
 Default constructor.
 
 JArgs (const int argc, const char *const argv[])
 Constructor.
 
 JArgs (const std::string &PID, JArgs::const_iterator __begin, JArgs::const_iterator __end)
 Constructor.
 
 JArgs (const std::string &buffer)
 Constructor.
 
std::string str (const char ws=' ') const
 Convert to string consisting of sequence of tokens separated by given white space character.
 
const char * c_str (const char ws=' ') const
 Convert to character array consisting of sequence of tokens separated by given white space character.
 

Public Attributes

std::string PID
 

Friends

std::istream & operator>> (std::istream &in, JArgs &args)
 Stream input.
 
std::ostream & operator<< (std::ostream &out, const JArgs &args)
 Stream output.
 

Detailed Description

Data structure to store command line arguments.

Definition at line 24 of file JArgs.hh.

Constructor & Destructor Documentation

◆ JArgs() [1/4]

JEEP::JArgs::JArgs ( )
inline

Default constructor.

Definition at line 31 of file JArgs.hh.

32 {}

◆ JArgs() [2/4]

JEEP::JArgs::JArgs ( const int argc,
const char *const argv[] )
inline

Constructor.


The first argument (if any) is assumed to be the process name (PID).

Parameters
argcnumber of command line arguments
argvarray of command line arguments

Definition at line 42 of file JArgs.hh.

43 {
44 if (argc > 0) {
45
46 PID = argv[0];
47
48 for (int i = 1; i != argc; ++i) {
49 push_back(argv[i]);
50 }
51
52 } else {
53
54 PID = "";
55 }
56 }
std::string PID
Definition JArgs.hh:167

◆ JArgs() [3/4]

JEEP::JArgs::JArgs ( const std::string & PID,
JArgs::const_iterator __begin,
JArgs::const_iterator __end )
inline

Constructor.


Parameters
PIDprocess identifier
__beginbegin of command line arguments
__endend of command line arguments

Definition at line 66 of file JArgs.hh.

67 {
68 this->PID = PID;
69
70 for (const_iterator i = __begin; i != __end; ++i) {
71 push_back(*i);
72 }
73 }

◆ JArgs() [4/4]

JEEP::JArgs::JArgs ( const std::string & buffer)
inline

Constructor.

Parameters
bufferinput

Definition at line 81 of file JArgs.hh.

82 {
83 using namespace std;
84
85 istringstream is(buffer);
86
87 PID = "";
88
89 for (string word; is >> word; ) {
90 push_back(word);
91 }
92 }

Member Function Documentation

◆ str()

std::string JEEP::JArgs::str ( const char ws = ' ') const
inline

Convert to string consisting of sequence of tokens separated by given white space character.

Parameters
wswhite space character
Returns
string

Definition at line 101 of file JArgs.hh.

102 {
103 std::string buffer = PID;
104
105 for (const_iterator i = this->begin(); i != this->end(); ++i) {
106 buffer += ws;
107 buffer += *i;
108 }
109
110 return buffer;
111 }

◆ c_str()

const char * JEEP::JArgs::c_str ( const char ws = ' ') const
inline

Convert to character array consisting of sequence of tokens separated by given white space character.

Parameters
wswhite space character
Returns
character array

Definition at line 120 of file JArgs.hh.

121 {
122 static std::string buffer;
123
124 buffer = this->str(ws);
125
126 return buffer.c_str();
127 }
std::string str(const char ws=' ') const
Convert to string consisting of sequence of tokens separated by given white space character.
Definition JArgs.hh:101

Friends And Related Symbol Documentation

◆ operator>>

std::istream & operator>> ( std::istream & in,
JArgs & args )
friend

Stream input.

Parameters
ininput stream
argsargs
Returns
input stream

Definition at line 137 of file JArgs.hh.

138 {
139 //in >> args.PID;
140
141 for (std::string buffer; in >> buffer; ) {
142 args.push_back(buffer);
143 }
144
145 return in;
146 }

◆ operator<<

std::ostream & operator<< ( std::ostream & out,
const JArgs & args )
friend

Stream output.

Parameters
outoutput stream
argsargs
Returns
output stream

Definition at line 156 of file JArgs.hh.

157 {
158 out << args.PID;
159
160 for (JArgs::const_iterator i = args.begin(); i != args.end(); ++i) {
161 out << ' ' << *i;
162 }
163
164 return out;
165 }

Member Data Documentation

◆ PID

std::string JEEP::JArgs::PID

Definition at line 167 of file JArgs.hh.


The documentation for this class was generated from the following file: