proj home

Files   Classes   Functions   Hierarchy  

commandline.cpp File Reference

#include <iostream>
#include <sstream>
#include <string>
#include <fstream>
#include <map>
#include <commandline.h>

Include dependency graph for commandline.cpp:

Go to the source code of this file.

Functions

bool splitstring (string &sleft, string &sright, stringc &s, char const delim)
void readToMap (map< string, string > &m, int argc, char **argv)
void writeMap (string &s, map< string, string > const &m)


Function Documentation

void readToMap ( map< string, string > &  m,
int  argc,
char **  argv 
)

Definition at line 220 of file commandline.cpp.

References splitstring().

00221 {
00222   for (uint i=1; i<(uint)argc; ++i)
00223   {
00224     string s1, s2;
00225     if (splitstring(s1,s2,string(argv[i]),'='))
00226       m[s1] = s2;
00227    }
00228 }

bool splitstring ( string &  sleft,
string &  sright,
stringc s,
char const  delim 
)

Definition at line 236 of file commandline.cpp.

Referenced by commandline::commandline(), commandline::read(), and readToMap().

00242 {
00243 //cout << "s=*" << s << "*" << endl;
00244 
00245   string::size_type k = s.find(delim);
00246   uint len = s.length();
00247   if (k<1 || (k>=len-1) || len==0)
00248     return false;
00249 
00250   sleft = s;
00251   sleft.erase(k);
00252   sright = s;
00253   sright.erase(0,k+1);
00254 
00255 //cout << "sright=*" << sright << "*" << endl;
00256 
00257   return true;
00258 }

void writeMap ( string &  s,
map< string, string > const &  m 
)

Definition at line 261 of file commandline.cpp.

00262 {
00263   string s2;
00264   map<string,string>::const_iterator i=m.begin();
00265   for(;i!=m.end();++i)
00266     s2 += (i->first + "=" + i->second + " ");
00267 
00268   s = s2;
00269 }


Generated on Fri Mar 4 00:49:42 2011 for Chelton Evans Source by  doxygen 1.5.8