本文整理汇总了C++中StringParser类的典型用法代码示例。如果您正苦于以下问题:C++ StringParser类的具体用法?C++ StringParser怎么用?C++ StringParser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StringParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parse
void parse (const std::string& s, T& out) {
StringParser p (s);
parse (p, out);
p.skipWs ();
if (!p.eof ())
throw ParseException (typeid (T), p.value (), 0, p.pos (), "Got garbage at end of string");
}
示例2: retval
bool SelectionParser::parse(vespalib::stringref s)
{
bool retval(false);
IdSpecParser id(_bucketIdFactory);
if (id.parse(s)) {
OperatorParser op;
if (op.parse(id.getRemaining())) {
if (id.isUserSpec()) {
IntegerParser v;
if (v.parse(op.getRemaining())) {
setNode(Node::UP(new Compare(id.stealValue(), *op.getOperator(), v.stealValue(), _bucketIdFactory)));
retval = true;
}
setRemaining(v.getRemaining());
} else {
StringParser v;
if (v.parse(op.getRemaining())) {
setNode(Node::UP(new Compare(id.stealValue(), *op.getOperator(), v.stealValue(), _bucketIdFactory)));
retval = true;
}
setRemaining(v.getRemaining());
}
} else {
setRemaining(op.getRemaining());
}
} else {
setRemaining(id.getRemaining());
}
return retval;
}
示例3: mergeServerDbTable
string mergeServerDbTable(const StringParser & parser)
{
string ret = d_makeWithQuotes(parser.getServer());
if (!parser.getDbName().empty())
{
ret += string(",") + d_makeWithQuotes(parser.getDbName()) + ',' +
d_makeWithQuotes(parser.getTableName());
}
return ret;
}
示例4: parser
void ExprParser::parseArguments (const std::string& arguments, Scanner& scanner,
std::vector<Interpreter::Type_Code>& code, bool invert)
{
ExprParser parser (getErrorHandler(), getContext(), mLocals, mLiterals, true);
StringParser stringParser (getErrorHandler(), getContext(), mLiterals);
std::stack<std::vector<Interpreter::Type_Code> > stack;
for (std::string::const_iterator iter (arguments.begin()); iter!=arguments.end();
++iter)
{
if (*iter=='S' || *iter=='c')
{
stringParser.reset();
if (*iter=='c') stringParser.smashCase();
scanner.scan (stringParser);
if (invert)
{
std::vector<Interpreter::Type_Code> tmp;
stringParser.append (tmp);
stack.push (tmp);
}
else
stringParser.append (code);
}
else
{
parser.reset();
scanner.scan (parser);
std::vector<Interpreter::Type_Code> tmp;
char type = parser.append (tmp);
if (type!=*iter)
Generator::convert (tmp, type, *iter);
if (invert)
stack.push (tmp);
else
std::copy (tmp.begin(), tmp.end(), std::back_inserter (code));
}
}
while (!stack.empty())
{
std::vector<Interpreter::Type_Code>& tmp = stack.top();
std::copy (tmp.begin(), tmp.end(), std::back_inserter (code));
stack.pop();
}
}
示例5: SafeReadFont
FontPtr ResourceConfig::SafeReadFont(StringParser &theVal)
{
std::string aFace;
theVal.ReadString(aFace); EnsureComma(theVal);
int aStyle = SafeReadFontStyle(theVal); EnsureComma(theVal);
int aSize;
if(!theVal.ReadValue(aSize) || aSize<=0)
throw ConfigObjectException("Invalid font size.");
return Window::GetDefaultWindow()->GetFont(FontDescriptor(aFace,aStyle,aSize));
}
示例6: backupIncremental
ErrorCode _CCONV FSBase::backupIncremental(const char * path, unsigned * amountChanged)
{
if (path == nullptr)
return INVALIDARG;
StringParser otherParser;
if (!otherParser.initialize(path))
otherParser.setServer(path);
if (otherParser.getServer().empty())
return INVALIDARG;
if (!createDir(otherParser.getServer()))
return FAILEDTOGETWINDIR;
fstream file;
string data;
ErrorCode retVal = getLogFileData(otherParser.getServer(), file, data);
if (failed(retVal))
return retVal;
PathTimeLog log(parser.getServer(), data);
if (log.isCorrupted())
return LOG_CORRUPTED;
unsigned amountBackup = 0;
retVal = backupAux(parser.getServer(), otherParser.getServer(), &log.getLastBackupTime(), amountBackup);
if (failed(retVal))
return retVal;
replaceRecordInData(parser.getServer(), log.getNowTime(), data);
retVal = setLogFileData(otherParser.getServer(), file, data);
if (amountChanged != nullptr)
*amountChanged = amountBackup;
return retVal;
}
示例7: HandleKeyVal
bool LobbyConfig::HandleKeyVal(ConfigParser &theParser, const std::string &theKey, StringParser &theVal)
{
if(theKey=="LOBBYDEFINE")
{
std::string aKey, aVal;
theVal.ReadString(aKey,true);
theVal.ReadString(aVal);
if(!aKey.empty())
mDefineMap[aKey] = aVal;
}
else
return ConfigObject::HandleKeyVal(theParser,theKey,theVal);
return true;
}
示例8: ResourceConfig_AddToMap
static bool ResourceConfig_AddToMap(const char *theName, StringParser &theVal, Map &theMap, int theParseCount, Type* &theType)
{
std::string aKey;
theVal.ReadValue(aKey,true);
if(aKey.empty())
throw ConfigObjectException("Invalid resource key.");
std::pair<Map::iterator,bool> aRet;
aRet = theMap.insert(Map::value_type(aKey,Map::referent_type(Type(),theParseCount)));
int &aParseCount = aRet.first->second.second;
if(aRet.second)
{
theType = &aRet.first->second.first;
return true;
}
else if(aParseCount==theParseCount)
{
char aBuf[512];
sprintf(aBuf,"%s resource already exists: %s",theName,aKey.c_str());
throw ConfigObjectException(aBuf);
}
return false;
}
示例9: connectToDb
SQLRETURN connectToDb(HENV henv, const StringParser & parser, HDBC & hdbc)
{
SQLRETURN retcode = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc);
check_rc(retcode, retcode);
//for massive copy
//retcode = SQLSetConnectAttr(hdbc, SQL_COPT_SS_BCP, (void *)SQL_BCP_ON, SQL_IS_INTEGER);
//check_rc(retcode, "SQLSetConnectAttr(hdbc1) Failed\n\n");
string szDSN = "Driver={SQL Server Native Client 11.0};Server=" + parser.getServer() + ";Database=" +
parser.getDbName() + ";UID=" + parser.getLogin() + ";PWD=" + parser.getPass();
retcode = connect(hdbc, (SQLCHAR*)szDSN.c_str());
if (!MYSQLSUCCESS(retcode))
{
SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
return retcode;
}
//retcode = SQLSetConnectAttr(hdbc, SQL_ATTR_AUTOCOMMIT, (SQLPOINTER)TRUE, 0);
return retcode;
}
示例10: SafeReadImage
ImagePtr ResourceConfig::SafeReadImage(StringParser &theVal)
{
std::string aPath;
theVal.ReadString(aPath);
ImagePtr anImage = WindowManager::GetDefaultWindowManager()->DecodeDelayImage(ComponentConfig::GetResourceFile(aPath).c_str());
if(anImage.get()==NULL)
throw ConfigObjectException("Failed to decode image: " + aPath);
return anImage;
}
示例11: ParseURI
//returns: StatusLineTooLong, SyntaxError, BadMethod
QTSS_Error RTSPRequest::ParseFirstLine(StringParser &parser)
{
//first get the method
StrPtrLen theParsedData;
parser.ConsumeWord(&theParsedData);
this->SetVal(qtssRTSPReqMethodStr, theParsedData.Ptr, theParsedData.Len);
//THIS WORKS UNDER THE ASSUMPTION THAT:
//valid HTTP/1.1 headers are: GET, HEAD, POST, PUT, OPTIONS, DELETE, TRACE
fMethod = RTSPProtocol::GetMethod(theParsedData);
if (fMethod == qtssIllegalMethod)
return QTSSModuleUtils::SendErrorResponse(this, qtssClientBadRequest, qtssMsgBadRTSPMethod, &theParsedData);
//no longer assume this is a space... instead, just consume whitespace
parser.ConsumeWhitespace();
//now parse the uri
QTSS_Error err = ParseURI(parser);
if (err != QTSS_NoErr)
return err;
//no longer assume this is a space... instead, just consume whitespace
parser.ConsumeWhitespace();
//if there is a version, consume the version string
StrPtrLen versionStr;
parser.ConsumeUntil(&versionStr, StringParser::sEOLMask);
//check the version
if (versionStr.Len > 0)
fVersion = RTSPProtocol::GetVersion(versionStr);
//go past the end of line
if (!parser.ExpectEOL())
return QTSSModuleUtils::SendErrorResponse(this, qtssClientBadRequest, qtssMsgNoRTSPVersion,&theParsedData);
return QTSS_NoErr;
}
示例12: HandleInt
bool ResourceConfig::HandleInt(StringParser &theVal)
{
int *anInt;
std::string aRefName;
if(ResourceConfig_AddToMap("Int",theVal,mIntMap,mParseCount,anInt))
{
ResourceConfig *aRef = CheckResourceReference(theVal,aRefName);
if(aRef!=NULL)
*anInt = aRef->SafeGetInt(aRefName);
else
{
if(!theVal.ReadValue(*anInt))
throw ConfigObjectException("Invalid integer value.");
}
}
return true;
}
示例13: HandleString
bool ResourceConfig::HandleString(StringParser &theVal)
{
GUIString *aString;
std::string aRefName;
if(ResourceConfig_AddToMap("String",theVal,mStringMap,mParseCount,aString))
{
ResourceConfig *aRef = CheckResourceReference(theVal,aRefName);
if(aRef!=NULL)
*aString = aRef->SafeGetString(aRefName);
else
{
std::wstring aVal;
theVal.ReadValue(aVal,false);
*aString = aVal;
}
}
return true;
}
示例14: SafeReadBackground
Background ResourceConfig::SafeReadBackground(StringParser &theVal)
{
std::string aType;
theVal.ReadString(aType);
if(stricmp(aType.c_str(),"COLOR")==0)
{
EnsureComma(theVal);
return SafeReadColor(theVal);
}
else if(stricmp(aType.c_str(),"IMAGE")==0)
{
EnsureComma(theVal);
return SafeReadImage(theVal).get();
}
else if(stricmp(aType.c_str(),"STRETCHIMAGE")==0)
{
EnsureComma(theVal);
Background aBackground(SafeReadImage(theVal));
aBackground.SetStretchImage(true);
return aBackground;
}
else if(stricmp(aType.c_str(),"WATERMARK")==0)
{
EnsureComma(theVal);
Background aBackground(SafeReadImage(theVal));
aBackground.SetUseOffsets(false);
return aBackground;
}
else if(stricmp(aType.c_str(),"NONE")==0)
return -1;
else if(stricmp(aType.c_str(),"TRANSPARENT")==0)
{
Background aBackground(-1);
aBackground.SetWantGrabBG(true);
return aBackground;
}
else
throw ConfigObjectException("Invalid background specification");
}
示例15: backupFull
ErrorCode _CCONV FSBase::backupFull(const char * path, unsigned * amountChanged)
{
if (path == nullptr)
return INVALIDARG;
StringParser otherParser;
if (!otherParser.initialize(path))
otherParser.setServer(path);
if (otherParser.getServer().empty())
return INVALIDARG;
if (!createDir(otherParser.getServer()))
return FAILEDTOGETWINDIR;
unsigned amountBackup = 0;
ErrorCode res = backupAux(parser.getServer(), otherParser.getServer(), NULL, amountBackup);
if (amountChanged != nullptr)
*amountChanged = amountBackup;
return res;
}