当前位置: 首页>>代码示例>>C++>>正文


C++ Tokens::size方法代码示例

本文整理汇总了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;
    }
}
开发者ID:bombapiter,项目名称:mangos,代码行数:29,代码来源:InstanceSaveMgr.cpp

示例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;
    }
}
开发者ID:michael-popov,项目名称:clockworkdb,代码行数:9,代码来源:cmd_dataspaces.cpp

示例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;
}
开发者ID:Jojo2323,项目名称:mangos3,代码行数:54,代码来源:Archaeology.cpp

示例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;
}
开发者ID:nos4r2zod,项目名称:mangos,代码行数:33,代码来源:Util.cpp

示例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
  }
开发者ID:151706061,项目名称:OrthancMirror,代码行数:34,代码来源:HttpContentNegociation.cpp

示例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;
 }
开发者ID:michael-popov,项目名称:clockworkdb,代码行数:7,代码来源:function_factory.cpp

示例7: return

uint32 GetUInt32ValueFromArray(Tokens const& data, uint16 index)
{
    if (index >= data.size())
        return 0;

    return (uint32)atoi(data[index].c_str());
}
开发者ID:520lly,项目名称:mangos-classic,代码行数:7,代码来源:Util.cpp

示例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;		
	}				
}
开发者ID:3ka5-cat,项目名称:PacketGenerator,代码行数:34,代码来源:FileWorker.cpp

示例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;
}
开发者ID:starius,项目名称:bacteria-core,代码行数:27,代码来源:Bytecode.cpp

示例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();
}
开发者ID:Lykurg,项目名称:qt-creator,代码行数:9,代码来源:cppautocompleter.cpp

示例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 );
}
开发者ID:michael-popov,项目名称:clockworkdb,代码行数:12,代码来源:parser.cpp

示例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;
}
开发者ID:michael-popov,项目名称:clockworkdb,代码行数:12,代码来源:cmd_metrics.cpp

示例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;
}
开发者ID:f110,项目名称:p5-Compiler-Lexer,代码行数:13,代码来源:Compiler_manager.cpp

示例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 );
}
开发者ID:michael-popov,项目名称:clockworkdb,代码行数:14,代码来源:parser.cpp

示例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 );
}
开发者ID:michael-popov,项目名称:clockworkdb,代码行数:17,代码来源:parser.cpp


注:本文中的Tokens::size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。