Follow this link to skip to the main content

claraty::Arglist Class Reference

#include <string_util.h>

List of all members.

Public Member Functions

 Arglist (char **argv=NULL)
 Arglist (const std::vector< std::string > &argv)
String_Rep shift ()
String_Rep peek () const
int size () const
bool empty () const
 operator bool () const
bool next_is_number () const
bool next_is_flag () const
std::string peek_join (const std::string &delim=" ")
std::string join (const std::string &delim=" ")

Private Attributes

unsigned int idx
std::vector< std::string > args


Detailed Description

Definition at line 205 of file string_util.h.


Constructor & Destructor Documentation

claraty::Arglist::Arglist ( char **  argv = NULL  )  [inline]

Definition at line 209 of file string_util.h.

References args, and idx.

00209                             {
00210     idx= 0;
00211     if (argv) for (; *argv; argv++)
00212       args.push_back(*argv);
00213   }

claraty::Arglist::Arglist ( const std::vector< std::string > &  argv  )  [inline]

Definition at line 214 of file string_util.h.

References args, and idx.

00214                                             {
00215     idx= 0;
00216     args= argv;
00217   }


Member Function Documentation

String_Rep claraty::Arglist::shift (  )  [inline]

Definition at line 218 of file string_util.h.

References args, and idx.

00218                      {
00219     assert(idx < args.size());
00220     return args[idx++];
00221   }

String_Rep claraty::Arglist::peek (  )  const [inline]

Definition at line 222 of file string_util.h.

References args, and idx.

Referenced by next_is_flag(), and next_is_number().

00222                           {
00223     assert(idx < args.size());
00224     return args[idx];
00225   }

int claraty::Arglist::size (  )  const [inline]

Definition at line 226 of file string_util.h.

References args, and idx.

Referenced by empty().

00226                    {
00227     return args.size() - idx;
00228   }

bool claraty::Arglist::empty (  )  const [inline]

Definition at line 229 of file string_util.h.

References size().

Referenced by next_is_flag(), next_is_number(), and operator bool().

00229                      {
00230     return size() <= 0;
00231   }

Here is the call graph for this function:

claraty::Arglist::operator bool (  )  const [inline]

Definition at line 232 of file string_util.h.

References empty().

00232                         {
00233     return !empty();
00234   }

Here is the call graph for this function:

bool claraty::Arglist::next_is_number (  )  const [inline]

Definition at line 235 of file string_util.h.

References empty(), claraty::String_Rep::is_number(), and peek().

00235                               {
00236     return !empty() && peek().is_number();
00237   }

Here is the call graph for this function:

bool claraty::Arglist::next_is_flag (  )  const [inline]

Definition at line 238 of file string_util.h.

References empty(), claraty::String_Rep::is_flag(), and peek().

00238                             {
00239     return !empty() && peek().is_flag();
00240   }

Here is the call graph for this function:

std::string claraty::Arglist::peek_join ( const std::string &  delim = " "  )  [inline]

Definition at line 241 of file string_util.h.

References args, idx, and claraty::string_join().

00241                                                   {
00242     assert(idx <= args.size());
00243     return string_join(args.begin()+idx, args.end(), delim);
00244   }

Here is the call graph for this function:

std::string claraty::Arglist::join ( const std::string &  delim = " "  )  [inline]

Definition at line 245 of file string_util.h.

References args, idx, and claraty::string_join().

00245                                              {
00246     assert(idx <= args.size());
00247     std::string ret= string_join(args.begin()+idx, args.end(), delim);
00248     idx= args.size();
00249     return ret;
00250   }

Here is the call graph for this function:


Member Data Documentation

unsigned int claraty::Arglist::idx [private]

Definition at line 206 of file string_util.h.

Referenced by Arglist(), join(), peek(), peek_join(), shift(), and size().

std::vector<std::string> claraty::Arglist::args [private]

Definition at line 207 of file string_util.h.

Referenced by Arglist(), join(), peek(), peek_join(), shift(), and size().


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