本文整理汇总了C++中Tokens::size方法的典型用法代码示例。如果您正苦于以下问题:C++ Tokens::size方法的具体用法?C++ Tokens::size怎么用?C++ Tokens::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tokens
的用法示例。
在下文中一共展示了Tokens::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _DelHelper
void InstanceSaveManager::_DelHelper(DatabaseType &db, const char *fields, const char *table, const char *queryTail,...)
{
Tokens fieldTokens = StrSplit(fields, ", ");
ASSERT(fieldTokens.size() != 0);
va_list ap;
char szQueryTail [MAX_QUERY_LEN];
va_start(ap, queryTail);
vsnprintf( szQueryTail, MAX_QUERY_LEN, queryTail, ap );
va_end(ap);
QueryResult *result = db.PQuery("SELECT %s FROM %s %s", fields, table, szQueryTail);
if(result)
{
do
{
Field *fields = result->Fetch();
std::ostringstream ss;
for(size_t i = 0; i < fieldTokens.size(); i++)
{
std::string fieldValue = fields[i].GetCppString();
db.escape_string(fieldValue);
ss << (i != 0 ? " AND " : "") << fieldTokens[i] << " = '" << fieldValue << "'";
}
db.DirectPExecute("DELETE FROM %s WHERE %s", table, ss.str().c_str());
} while (result->NextRow());
delete result;
}
}
示例2: parse
void ListDataspacesCommand::parse(Tokens& tokens)
{
if (tokens.size() > 2) {
if ((tokens.size() != 4) ||
!checkString(tokens[2], "filter") ||
(tokens[3].m_angen != ANGEN_TITLE)) THROW("Invalid format of LIST DATASPACES command");
m_pattern = tokens[3].m_val.m_str;
}
}
示例3: _LoadArchaeology
void Player::_LoadArchaeology(QueryResult* result)
{
for (uint8 i = 0; i < MAX_RESEARCH_SITES; ++i)
_digSites[i].count = 0;
if (!sWorld.getConfig(CONFIG_BOOL_ARCHAEOLOGY_ENABLED))
{
delete result;
return;
}
if (!result)
{
GenerateResearchSites();
GenerateResearchProjects();
return;
}
Field* fields = result->Fetch();
// Loading current zones
Tokens tokens = Tokens(fields[0].GetCppString(), ' ');
if (tokens.size() != 0 && tokens.size() <= MAX_RESEARCH_SITES)
{
_researchSites.clear();
for (uint8 i = 0; i < tokens.size(); ++i)
_researchSites.insert(uint32(atoi(tokens[i])));
}
else
GenerateResearchSites();
// Loading current zone info
tokens = Tokens(fields[1].GetCppString(), ' ');
if (tokens.size() == MAX_RESEARCH_SITES)
{
for (uint8 i = 0; i < MAX_RESEARCH_SITES; ++i)
_digSites[i].count = uint32(atoi(tokens[i]));
}
// Loading current projects
tokens = Tokens(fields[2].GetCppString(), ' ');
if (tokens.size() == MAX_RESEARCH_PROJECTS)
{
for (uint8 i = 0; i < MAX_RESEARCH_PROJECTS; ++i)
if (ResearchProjectEntry const* entry = sResearchProjectStore.LookupEntry(atoi(tokens[i])))
if (entry->IsVaid())
ReplaceResearchProject(0, entry->ID);
}
else
GenerateResearchProjects();
delete result;
}
示例4: IsIPAddress
/// Check if the string is a valid ip address representation
bool IsIPAddress(char const* ipaddress)
{
if(!ipaddress)
return false;
// FG: support IP ranges to be valid IP addresses, e.g. 192.168.0.%, 127.%.%.%, 1.2.3.4
Tokens tok = StrSplit(ipaddress, ".");
if(tok.size() != 4)
return false;
for(Tokens::iterator it = tok.begin(); it != tok.end(); it++)
{
// must not be empty and not more then 3 chars per part
if(it->empty() || it->size() > 3)
return false;
// must contain digits only or % (mysql wildcard)
for(uint32 pos = 0; pos < it->size(); ++pos)
if( !(isdigit((*it)[pos]) ||(*it)[pos] == '%') )
return false;
// if its a number, it must be < 255 to be valid ip part
if(atoi(it->c_str()) >= 255)
return false;
}
return true;
// -end-
// Let the big boys do it.
// Drawback: all valid ip address formats are recognized e.g.: 12.23,121234,0xABCD)
//return ACE_OS::inet_addr(ipaddress) != INADDR_NONE;
}
示例5: GetQuality
float HttpContentNegociation::GetQuality(const Tokens& parameters)
{
for (size_t i = 1; i < parameters.size(); i++)
{
std::string key, value;
if (SplitPair(key, value, parameters[i], '=') &&
key == "q")
{
float quality;
bool ok = false;
try
{
quality = boost::lexical_cast<float>(value);
ok = (quality >= 0.0f && quality <= 1.0f);
}
catch (boost::bad_lexical_cast&)
{
}
if (ok)
{
return quality;
}
else
{
LOG(ERROR) << "Quality parameter out of range in a HTTP request (must be between 0 and 1): " << value;
throw OrthancException(ErrorCode_BadRequest);
}
}
}
return 1.0f; // Default quality
}
示例6: init
virtual void init(Tokens& params) {
if (params.size() == 0) return;
if (params.size() != 1) THROW("Function MEAN() expects only one argument");
if (params[0].m_angen != ANGEN_LONG) THROW("Function MEAN() expects one integer argument");
if (params[0].m_val.m_long <= 0) THROW("Invalid argument for function MEAN()");
m_maxSize = (size_t) params[0].m_val.m_long;
}
示例7: return
uint32 GetUInt32ValueFromArray(Tokens const& data, uint16 index)
{
if (index >= data.size())
return 0;
return (uint32)atoi(data[index].c_str());
}
示例8: savePacket
bool FileWorker::savePacket(const Token& name, const Tokens& formats, const Token& fileName)
{
xml_document doc;
xml_parse_result result = doc.load_file(fileName.c_str());
if (result || result.status == pugi::status_file_not_found) {
xml_node packetNode = doc.append_child("packet");
packetNode.append_attribute("name") = name.c_str();
for (size_t i = 0; i < formats.size(); ++i) {
if (Utilities::startsWith(formats[i], ETH2PROTO))
packetNode.append_attribute(ETH2PROTO.c_str()) = formats[i].c_str();
else if (Utilities::startsWith(formats[i], IPV4PROTO))
packetNode.append_attribute(IPV4PROTO.c_str()) = formats[i].c_str();
else if (Utilities::startsWith(formats[i], UDPPROTO))
packetNode.append_attribute(UDPPROTO.c_str()) = formats[i].c_str();
else if (Utilities::startsWith(formats[i], TCPPROTO))
packetNode.append_attribute(TCPPROTO.c_str()) = formats[i].c_str();
else if (Utilities::startsWith(formats[i], ICMPPROTO))
packetNode.append_attribute(ICMPPROTO.c_str()) = formats[i].c_str();
//else
//return false;
}
return doc.save_file(fileName.c_str());
}
else {
setGlobalError(string("Packets file: error while open XML").append(result.description()));
DbgMsg(__FILE__, __LINE__,
"Device::loadPacket() load_file() ERROR:\n");
DbgMsg(__FILE__, __LINE__,
"Description: %s\n", result.description());
DbgMsg(__FILE__, __LINE__,
"Error offset: %s\n", result.offset);
return false;
}
}
示例9: parser
Instructions Bytecode::parser(const Tokens& tokens) const {
Tokens tokens_group;
// Abstract syntax tree.
Instructions ast;
int funcs = 0, params = 0, specs = 0;
for (int i = 0; i < tokens.size(); i++) {
if (tokens[i].type == DELIMITER) {
checkFunctions(tokens_group[0], funcs);
checkById(tokens_group[0].function_id, params, specs);
Instruction inst =
makeInstruction(params, specs, tokens_group);
ast.push_back(inst);
funcs = 0, params = 0, specs = 0;
tokens_group.clear();
} else {
if (tokens[i].type == FUNCTION) {
funcs++;
} else if (tokens[i].type == PARAMETER) {
params++;
} else {
specs++;
}
tokens_group.push_back(tokens[i]);
}
}
return ast;
}
示例10: Token
static const Token tokenAtPosition(const Tokens &tokens, const unsigned pos)
{
for (int i = tokens.size() - 1; i >= 0; --i) {
const Token tk = tokens.at(i);
if (pos >= tk.utf16charsBegin() && pos < tk.utf16charsEnd())
return tk;
}
return Token();
}
示例11: parseDump
//static
void Command::parseDump( Tokens& tokens, bool helpMode, Command*& result )
{
if (tokens.size() < 3 && !helpMode) THROW( CWDB_ERR_PARSER, "Bad syntax: missing options in \"dump\" command" );
switch( checkAngen( tokens, 1) ) {
case ANGEN_COLLECTION: result = new DumpCollectionCommand; break;
default: THROW( CWDB_ERR_PARSER, "Bad syntax: unrecognized option in \"dump\" command" );
}
if (result != 0 && !helpMode) result->parse( tokens );
}
示例12: parse
void RenameMetricCommand::parse(Tokens& tokens)
{
if (tokens.size() != 5) THROW("Invalid RENAME METRIC command");
if (tokens[2].m_angen != ANGEN_IDENT) THROW("Expected existing metric name");
m_oldName = tokens[2].m_val.m_str;
if (!checkString(tokens[3], "to")) THROW("Expected key word TO");
if (tokens[4].m_angen != ANGEN_IDENT) THROW("Expected new metric name");
m_newName = tokens[4].m_val.m_str;
}
示例13:
Token *TokenManager::getTokenByBase(Token *base, int offset)
{
Tokens *tks = this->tokens;
size_t size = tks->size();
int wanted_idx = -1;
for (size_t i = 0; i < size; i++) {
if (tks->at(i) == base) {
wanted_idx = i + offset;
}
}
return (0 <= wanted_idx && (size_t)wanted_idx < size) ?
tks->at(wanted_idx) : NULL;
}
示例14: parseDrop
//static
void Command::parseDrop( Tokens& tokens, bool helpMode, Command*& result )
{
if (tokens.size() < 3 && !helpMode) THROW( CWDB_ERR_PARSER, "Bad syntax: missing options in \"drop\" command" );
switch( checkAngen( tokens, 1) ) {
case ANGEN_DATASPACE: result = new DropDataspaceCommand; break;
case ANGEN_COLLECTION: result = new DropCollectionCommand; break;
case ANGEN_METRIC: result = new DropMetricCommand; break;
default: THROW( CWDB_ERR_PARSER, "Bad syntax: unrecongized option in \"drop\" command" );
}
if (result != 0 && !helpMode) result->parse( tokens );
}
示例15: parseDescr
//static
void Command::parseDescr( Tokens& tokens, bool helpMode, Command*& result )
{
if (tokens.size() == 1) {
result = new DescrCommand();
return;
}
switch( checkAngen( tokens, 1) ) {
case ANGEN_DATASPACE: result = new DescrDataspaceCommand; break;
case ANGEN_COLLECTION: result = new DescrCollectionCommand; break;
case ANGEN_METRIC: result = new DescrMetricCommand; break;
default: THROW( CWDB_ERR_PARSER, "Bad syntax: unrecognized option in \"descr\" command" );
}
if (result != 0 && !helpMode) result->parse( tokens );
}