/** * Pass input arguments, note that argv[0] from the command line should be removed */ bool ConfigIO :: parseArgs (int nArgs, const char **argv) { if (nArgs > 0) if (_strcmpi(argv [0], "help") == 0 || _strcmpi(argv [0], "?") == 0 || _strcmpi(argv [0], "/h") == 0 || _strcmpi(argv [0], "/?") == 0) { std::cout << "------------------------------------------" << std::endl; std::cout << "Valid parameters for this application: " << std::endl; for (size_t f = 0; f < parameters.size (); f ++) std::cout << " * " << getTypeAsString(parameters[f]) << " " << parameters[f].name << " [" << getValueAsString(parameters[f]) << "]" << std::endl; std::cout << "------------------------------------------" << std::endl; exit(0); } for (int i = 0; i < nArgs; i ++) loadParam (argv [i]); return true; }
string const Spacing::writeEnvirBegin(bool useSetSpace) const { string const name = envName(space, useSetSpace); if (space == Other) return "\\begin{" + name + "}{" + getValueAsString() + '}'; else return name.empty() ? string() : "\\begin{" + name + '}'; }
void Spacing::writeFile(ostream & os, bool para) const { if (space == Default) return; string cmd = para ? "\\paragraph_spacing " : "\\spacing "; if (getSpace() == Spacing::Other) { os << cmd << spacing_string[getSpace()] << ' ' << getValueAsString() << "\n"; } else { os << cmd << spacing_string[getSpace()] << "\n"; } }
int SNMPObject::compareValue(SNMPObject * pOther) const { switch(_syntax) { case SNMP_SYNTAX_OCTETS: case SNMP_SYNTAX_OPAQUE: case SNMP_SYNTAX_BITS: case SNMP_SYNTAX_OID: case SNMP_SYNTAX_NSAPADDR: case SNMP_SYNTAX_IPADDR: return getValueAsString().compare(pOther->getValueAsString()); case SNMP_SYNTAX_INT: if(getInt() < pOther->getInt()) { return -1; } else if(getInt() == pOther->getInt()) { return 0; } else { return 1; } case SNMP_SYNTAX_CNTR64: case SNMP_SYNTAX_CNTR32: case SNMP_SYNTAX_GAUGE32: case SNMP_SYNTAX_UINT32: case SNMP_SYNTAX_TIMETICKS: if(getUInt() < pOther->getUInt()) { return -1; } else if(getUInt() == pOther->getUInt()) { return 0; } else { return 1; } case SNMP_SYNTAX_NULL: case SNMP_SYNTAX_NOSUCHOBJECT: case SNMP_SYNTAX_NOSUCHINSTANCE: case SNMP_SYNTAX_ENDOFMIBVIEW: return 0; } return 0; }
std::string Configuration::replaceVariable(const string &_value) { string pat = "$"; int currentPosition = 0; string value = _value; while(currentPosition < value.size()) { int loc = Utility::findSubStringFromPosition(currentPosition,value,pat); if(0 > loc || value.size() == loc)break; if(loc && '\\' == value[loc - 1]) { currentPosition = loc + 1; continue; } string temStr = ""; for(int i = loc + 1; i < value.size(); ++i) { if(value[i] == ' ' || value[i] == '\t' || value[i] == '$') { currentPosition = i + 1; break; } else temStr.push_back(value[i]); if(true == hasKey(temStr)) { string newValue = getValueAsString(temStr); value = value.substr(0,loc) + newValue + value.substr(i + 1); currentPosition = loc + 1; break; } } } return value; }
string const Spacing::writePreamble(bool useSetSpace) const { string preamble; switch (space) { case Default: case Single: // we dont use setspace.sty so dont print anything //return "\\singlespacing\n"; break; case Onehalf: preamble = useSetSpace ? "\\OnehalfSpacing\n" : "\\onehalfspacing\n"; break; case Double: preamble = useSetSpace ? "\\DoubleSpacing\n" : "\\doublespacing\n"; break; case Other: preamble = (useSetSpace ? "\\setSpacing{" : "\\setstretch{") + getValueAsString() + "}\n"; break; } return preamble; }
bool MyConfig::getValueAsBool(std::string key) { return Ogre::StringConverter::parseBool(getValueAsString(key)); }
Ogre::Real MyConfig::getValueAsReal(std::string key) { return Ogre::StringConverter::parseReal(getValueAsString(key)); }
int MyConfig::getValueAsInt(std::string key) { return atoi(getValueAsString(key).c_str()); }
std::string SNMPObject::getDisplayInformation() const { std::stringstream ss; //ss << getOID() << " = " << getValueAsString() << " [" << getSyntaxAsString() + "]"; ss << getValueAsString(); return ss.str(); }
Common::String ChangeSceneCommand::debugString() const { return Common::String::format("SCENE%d.%s %s %s", _sceneId, getRegisterAsString(), getOperationAsString(), getValueAsString().c_str()); }
/** * This is a helper slot to enable reading of arbitrary values as Strings from * within the scripts. This method forwards execution to getValueAsString(). */ QString ScriptedFitnessFunction::getStringValue(const QString &valueName) { return getValueAsString(valueName); }
double Spacing::getValue() const { return convert<double>(getValueAsString()); }
std::string Configuration::get(const string &key) { std:string value = getValueAsString(key); if("" == value)return value; return replaceVariable(value); }
Ogre::Vector3 MyConfig::getValueAsVector3(std::string key) { return Ogre::StringConverter::parseVector3(getValueAsString(key)); }
Ogre::ColourValue MyConfig::getValueAsColourValue(std::string key) { return Ogre::StringConverter::parseColourValue(getValueAsString(key)); }
System::String ^ DataArrayCommand::getOnlyValueAsString(){ return getValueAsString(); }