00001 #include "validargument.h"
00002
00003 namespace n2nc {
00004 namespace utils {
00005 namespace args {
00006
00007 ValidArgument::ValidArgument(string name){
00008 this->name = name ;
00009 this->paramrequired = false ;
00010 }
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 ValidArgument::~ValidArgument()
00023 {
00024 }
00025
00026 string ValidArgument::toString(){
00027 string conflict("") ;
00028 char stemp[255];
00029 if (this->conflictsto.size()){
00030 conflict = " Conflicts with: " + explode(this->conflictsto, ",");
00031 }
00032
00033 string toformat ;
00034 toformat = this->name + "{" + explode(this->paramlist,",") + explode(this->paramlist_pattern,",") + "}" ;
00035
00036 ::sprintf(stemp,"%-44s",toformat.c_str());
00037 toformat = stemp + this->comment + conflict ;
00038 return toformat ;
00039
00040 }
00041
00043 string explode(vector<string>& sl, string delimiter){
00044 string temp("");
00045 if(!sl.size()) return "Nothing" ;
00046 for(int i=0; i < sl.size() ; i++){
00047 temp += sl[i] + delimiter ;
00048 }
00049 if (sl.size() > 0){
00050 temp = temp.substr(0, temp.size() - delimiter.size());
00051 }
00052 return temp ;
00053 }
00054
00055 ValidArgument* ValidArgument::find(string name, vector<ValidArgument>& valids){
00056 for(int i=0; i < valids.size() ; i++){
00057 if(valids[i].name == name){
00058 return &(valids[i]);
00059 }
00060 }
00061 return NULL ;
00062 }
00063
00064
00065 }
00066 }
00067 }
00068
00069
00070