/// directly sends the quoted text to oss /// and returns if a quote was found /// empties the given buffer in to oss if one is given /// works only if a quote char is found where the iss cursor is. bool JLDIO::skipOverQuotes(std::ostringstream& oss, std::istringstream& iss, std::list<char> *bufferToEmpty) { char charBuffer = iss.peek(); if(charBuffer == '\'' || charBuffer == '\"') { if(bufferToEmpty && !bufferToEmpty->empty()) { oss << listToString(*bufferToEmpty); bufferToEmpty->clear(); } // std::cout<<"Skipping: "; char matchedChar = charBuffer; iss.get(charBuffer); assert(matchedChar == charBuffer); do { oss << charBuffer; // std::cout<<charBuffer; } while(iss.get(charBuffer) && charBuffer != matchedChar); if(iss.good()) oss << charBuffer; // std::cout<<charBuffer<<"\n"; return true; } return false; }
bool ossimWkt::parseObject( std::istringstream& is, const std::string& prefix, const std::string& object, ossimKeywordlist& kwl ) { bool result = false; result = parseName( is, prefix, object, kwl ); if ( result && is.good() ) { char c; ossim_uint32 myObjectIndex = 0; ossim_uint32 paramIndex = 0; while ( is.good() ) { is.get(c); if ( is.good() ) { if ( c == ',' ) { parseParam( is, prefix, object, myObjectIndex, paramIndex, kwl ); } else if ( (c == ']') || (c == ')') ) { break; // End of object. } } } } return result; }
void LoadArray(std::istringstream &buf, pnlVector<Type> &array, char delim = ' ') { char ch; int ich; Type val; buf >> ch; ASSERT(ch == '[' || !buf.good()); array.reserve(16); array.resize(0); for(;buf.good();) { do { ich = buf.peek(); if(ich == ']') { buf >> ch; return; } else if(ich == delim || (delim == ' ' && isspace(ich))) { buf.get(ch); } } while(buf.good() && (ich == delim || (delim == ' ' && isspace(ich)))); if(!buf.good()) { break; } buf >> val; array.push_back(val); }
bool ossimWkt::parseName( std::istringstream& is, const std::string& prefix, const std::string& object, ossimKeywordlist& kwl ) { bool result = false; char c; std::string name; // Find the first quote: while ( is.good() ) { is.get(c); if ( is.good() ) { if ( c == '"' ) { break; } } } // Get the name: while ( is.good() ) { is.get(c); if ( is.good() ) { if ( c != '"' ) { name.push_back(c); } else { break; // End quote: } } } if ( name.size() ) { // Add to keyword list. std::string key; if ( prefix.size() ) { key += prefix; } key += object; key += ".name"; kwl.addPair( key, name ); result = true; } return result; }
void MotionPeriod:: commandLine( const std::string& cmdLine, std::istringstream& cmdArgs, std::ostream& os ) { if( cmdLine == "help" ) { os << "MotionPeriod:"<<endl <<" - size " <<endl <<" - period <rank> [<value>]" <<endl <<" - amplitude <rank> [<value>] " <<endl <<" - init <rank> [<value>] " <<endl <<" - type <rank> [const|sin|cos] " <<endl; } // else if( cmdLine == "period" ) // { // unsigned int rank; unsigned int period; // cmdArgs >> rank >>std::ws; // if( rank>=this->size ) { os <<"!! Error size too large." << std::endl; } // if( cmdArgs.good() ) // { cmdArgs>>period; motionParams[rank].period = period; } // else { os << "period[" << rank << "] = " << motionParams[rank].period << std::endl; } // } SOT_PARAMS_CONFIG(period,unsigned int) SOT_PARAMS_CONFIG(amplitude,double) SOT_PARAMS_CONFIG(initPeriod,unsigned int) SOT_PARAMS_CONFIG(initAmplitude,double) else if( cmdLine == "size" ) { unsigned int rank(0); cmdArgs >> std::ws; if( cmdArgs.good() ) { cmdArgs>>rank; resize( rank ); }
void TaskConti:: commandLine( const std::string& cmdLine ,std::istringstream& cmdArgs ,std::ostream& os ) { if( cmdLine=="help" ) { os << "TaskConti: "<<endl << " - touch <sot.control>"<<endl << " - timeRef" << endl << " - mu [<val>]" << endl; Task::commandLine( cmdLine,cmdArgs,os ); } else if( cmdLine=="touch" ) { Signal<ml::Vector,int> & sig = dynamic_cast< Signal<ml::Vector,int>& > (dg::PoolStorage::getInstance()->getSignal(cmdArgs)); timeRef = TIME_REF_TO_BE_SET; //sig.getTime(); q0 = sig.accessCopy(); } else if( cmdLine=="timeRef" ) { os << "timeRef = "; if( timeRef == TIME_REF_TO_BE_SET ) os << "to be set."; else if( timeRef == TIME_REF_UNSIGNIFICANT ) os << "no signaificant"; else os << timeRef; os << std::endl; } else if( cmdLine=="mu" ) { cmdArgs >> std::ws; if(! cmdArgs.good() ) os << "mu = " << mu << std::endl; else { cmdArgs >> mu; } }
void TimeStamp:: commandLine( const std::string& cmdLine, std::istringstream& cmdArgs, std::ostream& os ) { if( cmdLine=="help" ) { os << "TimeStamp: "<<std::endl << " - offset [{<value>|now}] : set/get the offset for double sig." << std::endl; Entity::commandLine( cmdLine,cmdArgs,os ); } else if( cmdLine=="offset" ) { cmdArgs >> std::ws; if( cmdArgs.good() ) { std::string offnow; cmdArgs >> offnow; if(offnow=="now") { gettimeofday( &val,NULL ); offsetValue = val.tv_sec; } else { offsetValue = atoi(offnow.c_str()); } offsetSet = ( offsetValue>0 ); } else {
/*! \brief Overloading method of SimplePlugin */ void FilteringAnalyticalTrajectoryByPreviewControl::CallMethod(std::string &Method, std::istringstream &strm) { if (Method==":samplingperiod") { std::string aws; if (strm.good()) { strm >> m_SamplingPeriod; Resize(); }
inline bool AsciiXmlParser::loadString( std::string const stringToParse ) /* this loads stringToParse into the internal stringstream for parsing. if * there was a problem loading the file, false is returned. if there was a * file open, it is now closed. */ { resetContent(); stringParsingStream.clear(); stringParsingStream.str( stringToParse ); textStream = &stringParsingStream; return stringParsingStream.good(); }
static void setupEnvVar(std::istringstream& iss, const char** var, const char* varname) { std::string line; std::string value; std::getline(iss, line); if (!iss.good() || line.find(varname) == std::string::npos) { INT_FATAL(astr("Parsing ", varname)); } value = line.substr(line.find('=')+1, std::string::npos); *var = astr(value.c_str()); // astr call is to canonicalize parseCmdLineConfig(varname, astr("\"", *var, "\"")); }
void skipCharacter(std::istringstream& is, char char_to_skip) { for (;;) { int c = is.get(); if ( !is.good() ) { break; } else { if (c != char_to_skip) { is.unget(); break; } } } }
bool ossimWkt::parseWktGroup( std::istringstream& is, ossimKeywordlist& kwl ) { bool result = false; if ( is.good() ) { char c; // Get the wkt group name up to '[', e.g. "PROJCS[". std::string prefix = ""; std::string object; // std::string v; while ( is.good() ) { is.get(c); if ( is.good() ) { // Look for parens or square brackets. if ( (c != '[') && (c != '(') ) { object.push_back(c); } else { result = parseObject( is, prefix, object, kwl ); } } else { break; } } } return result; }
void SotH:: commandLine( const std::string& cmdLine,std::istringstream& cmdArgs, std::ostream& os ) { sotDEBUGIN(15); if( cmdLine == "help") { os << "Stack of Tasks Inequality: "<<endl << " - fillMemorySignal [boolean] "<<endl; Sot::commandLine( cmdLine,cmdArgs,os ); } else if( cmdLine == "fillMemorySignal") { cmdArgs >> std::ws; if( cmdArgs.good() ) { cmdArgs >> fillMemorySignal; }
void FeatureGeneric:: commandLine( const std::string& cmdLine, std::istringstream& cmdArgs, std::ostream& os ) { if( cmdLine == "help" ) { os << "FeatureGeneric: " << " - dimDefault [<int>]: get/set the dimension value. " << std::endl; } else if( cmdLine == "dimDefault" ) { cmdArgs >>std::ws; if( cmdArgs.good() ) { unsigned int val; cmdArgs>>val; dimensionDefault = val; }
void FeaturePoint6d:: commandLine( const std::string& cmdLine, std::istringstream& cmdArgs, std::ostream& os ) { if( cmdLine=="help" ) { os << "FeaturePoint: "<<endl << " - frame [{desired|current}]: get/set the computation frame."<<endl << " - keep: modify the desired position to servo at current pos."<<endl; Entity::commandLine( cmdLine,cmdArgs,os ); } else if( cmdLine=="frame" ) { cmdArgs>>std::ws; if(cmdArgs.good()) { std::string frameStr; cmdArgs >> frameStr; if( frameStr =="current" ) { computationFrame_ = FRAME_CURRENT; } else { computationFrame_ = FRAME_DESIRED; } }
void NeckLimitation:: commandLine( const std::string& cmdLine, std::istringstream& cmdArgs, std::ostream& os ) { sotDEBUG(25) << "Cmd " << cmdLine <<std::endl; if( cmdLine == "help" ) { os << "NeckLimitation: " << std::endl << " - rank [<pan> <tilt>]: get/set the rank of " << "the angles in the joint vector." << std::endl << " - coeff [<linear> <affine>]: get/set the coefficient of " << "the affine limit. " << std::endl << " - sign [{+1|-1}]: if -1, the tilt is check to be" << " above the limit. " << std::endl; } else if( cmdLine == "rank" ) { cmdArgs >> std::ws; if(! cmdArgs.good() ) { os << "rank = [pan=" << panRank << ", tilt=" << tiltRank << "]" << std::endl; } else { cmdArgs >> panRank >> tiltRank; } }
/// gets the next char from iss and places it in output /// bypasses characters in quotes /// empties the given buffer in to oss before hand if possible /// returns false upon failure (i.e. returns iss.good()) bool JLDIO::getNextChar(char& output, std::ostringstream& oss, std::istringstream& iss, std::list<char> *bufferToEmpty) { skipOverQuotes(oss, iss, bufferToEmpty); iss.get(output); return iss.good(); }
bool ossimWkt::parseParam( std::istringstream& is, const std::string& prefix, const std::string& object, ossim_uint32& objectIndex, ossim_uint32& paramIndex, ossimKeywordlist& kwl ) { bool result = false; char c; std::string name; // Get the name: while ( is.good() ) { int i = is.peek(); // Don't gobble the trailing comma or bracket. if ( (i == ',') || (i == ']') || (i == ')') ) { // End of param. if ( name.size() ) { // Add to keyword list. std::string key; if ( prefix.size() ) { key += prefix; } key += object; key += ".param"; key += ossimString::toString(paramIndex).string(); kwl.addPair( key, name ); name = ""; ++paramIndex; result = true; } break; // Next param or at end of object. } is.get(c); if ( is.good() ) { // Look nexted object. if ( (c == '[') || (c == '(') ) { std::string myPrefix; if ( prefix.size() ) { myPrefix += prefix; } myPrefix += object; myPrefix += "."; //--- // Special hack for duplicated keyword "PARAMETER" //--- if ( name == "PARAMETER" ) { name += ossimString::toString(objectIndex).string(); ++objectIndex; } result = parseObject( is, myPrefix, name, kwl ); name = ""; } else { name.push_back(c); } } } return result; }