本文整理汇总了C++中StringVec::size方法的典型用法代码示例。如果您正苦于以下问题:C++ StringVec::size方法的具体用法?C++ StringVec::size怎么用?C++ StringVec::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringVec
的用法示例。
在下文中一共展示了StringVec::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: showPosition
void Commands::showPosition(Player* player, const std::string& cmd, const std::string& param)
{
if (!param.empty() && player->isAccessPlayer()) {
StringVec exploded = explodeString(param, ", ", 2);
if (!exploded.size() || exploded.size() < 3) {
player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, "Not enough params.");
return;
}
uint16_t x = atoi(exploded[0].c_str());
uint16_t y = atoi(exploded[1].c_str());
uint8_t z = atoi(exploded[2].c_str());
Position oldPosition = player->getPosition();
if (g_game.internalTeleport(player, Position(x, y, z)) == RET_NOERROR) {
g_game.addMagicEffect(oldPosition, NM_ME_POFF, player->isInGhostMode());
g_game.addMagicEffect(player->getPosition(), NM_ME_TELEPORT, player->isInGhostMode());
return;
}
}
const Position& pos = player->getPosition();
std::ostringstream ss;
ss << "Your current position is [X: " << pos.x << " | Y: " << pos.y << " | Z: " << pos.getZ() << "].";
player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, ss.str());
}
示例2: add_alias
void Grammar::add_alias( const string& alias, const StringVec& pairs )
{
assert( pairs.size() % 2 == 0 ); // pairs must be even.
if( alias == "field" ) {
for( size_t i = 0 ; i < pairs.size() ; i += 2 ) {
m_field_alias[pairs[i]] = pairs[i+1];
}
} else if ( alias == "pseudo" ) {
for ( size_t i = 0; i < pairs.size(); i += 2 ) {
m_num_pseudo_alias[pairs[i + 1]] = pairs[i];
}
} else if( alias == "unit" ) {
for( size_t i = 0 ; i < pairs.size() ; i += 2 ) {
m_unit_alias[pairs[i]] = pairs[i+1];
string name = pairs[i+1];
Unit unit = unit_null;
if( name == "year" ) {
unit = unit_year;
} else if( name == "month" ) {
unit = unit_month;
} else if( name == "week" ) {
unit = unit_week;
} else if( name == "day" ) {
unit = unit_day;
} else {
continue;
}
string key = make_key( pairs[i] );
m_unit_type_alias[key] = unit;
}
}
}
示例3: Location
Argument::Argument(const std::string& str,
SymbolTable symbol_table,
bool isRel,
Log log)
{
StrVarMap v_map;
if(str[0] != '(')
{
if(str[0] == '?')
{
t = Argument::Var;
val = str;
return;
}
Symbol* sym;
size_t id = symbol_table.CheckEntry(str, 0, isRel, sym);
if(sym == NULL) id = symbol_table.AddEntry(str, Location(), 0, isRel);
if(isRel)
t = Argument::Relation;
else t = Argument::Function;
value = id;
return;
}
std::string cmd;
StringVec args;
if(!SeparateCommand(str, cmd, args, log))
{
log.Fatal << "Unable to construct argument from " << str << std::endl;
return;
}
Symbol* sym;
size_t id = symbol_table.CheckEntry(cmd, args.size(), isRel, sym);
if(sym == NULL)
id = symbol_table.AddEntry(cmd, Location(), args.size(), isRel);
if(isRel)
t = Argument::Relation;
else t = Argument::Function;
value = id;
for(size_t i = 0;i < args.size();i++)
{
Argument *arg;
if(id == SymbolTable::NotID || id == SymbolTable::OrID)
arg = ConstructArgument(args[i], v_map, symbol_table, true, log);
else
arg = ConstructArgument(args[i], v_map, symbol_table, false, log);
if(arg != NULL) this->args.push_back(arg);
}
}
示例4: loadFrameworkBlockListFromFile
void SBFrameworksBuildPhase::loadFrameworkBlockListFromFile(const String& fileName)
{
// Get the path to the file which has the block list.
const BuildSettings bs(NULL);
String templateDir = bs.getValue("VSIMPORTER_TEMPLATES_DIR");
// If we have reached this far the folder is guaranteed to exist as we must have already called checkWinObjCSDK().
assert(!sb_realpath(templateDir).empty());
String blockListFilePath = joinPaths(templateDir, fileName);
ifstream file(blockListFilePath);
if (file.is_open())
{
String line;
while (getline(file, line))
{
StringVec tokens;
tokenize(line, tokens, "-> ");
if (tokens.size() == 0)
{
// empty line
continue;
}
// We do not expect more than 2 tokens per line.
// First is the blocked library name and possibly a second token which is the replacement library name.
sbValidate(tokens.size() <= 2,
"Invalid Block List: Only one blocked library and an optional replacement library separated by '->' are allowed per line");
String blockedLibrary = tokens[0];
// We may or may not have the replacement library specified.
String replaceWithLibrary = "";
if (tokens.size() > 1)
{
replaceWithLibrary = tokens[1];
// Check if the library replacements form a cycle.
auto it = s_blockedLibraries.find(replaceWithLibrary);
while (it != s_blockedLibraries.end())
{
replaceWithLibrary = it->second;
sbValidate(blockedLibrary != replaceWithLibrary,
blockedLibrary + " is trying to cyclically replace itself with another blocked library.");
it = s_blockedLibraries.find(replaceWithLibrary);
}
}
s_blockedLibraries.insert(pair<String, String>(blockedLibrary, replaceWithLibrary));
}
file.close();
}
}
示例5: parseCoomand
bool ProtocolSpectator::parseCoomand(std::string text)
{
if (text[0] == '/') {
StringVec t = explodeString(text.substr(1, text.length()), " ", 1);
if (t.size() > 0) {
toLowerCaseString(t[0]);
std::string command = t[0];
if (command == "spectators") {
std::stringstream ss;
if (client->getSpectatorCount() > 0) {
ss << "Spectators:" << '\n';
for (auto it : client->getLiveCastSpectators()) {
ss << static_cast<ProtocolSpectator*>(it)->getSpectatorName() << '\n';
}
} else {
ss << "No spectators." << '\n';
}
sendChannelMessage("", ss.str().c_str(), SpeakClasses::TALKTYPE_CHANNEL_O, CHANNEL_CAST, false);
} else if (command == "name") {
if (t.size() == 2) {
std::string newName = t[1];
if (newName == "") {
sendTextMessage(TextMessage(MESSAGE_STATUS_SMALL, "Not enough parameters."), false);
return true;
}
if (newName.length() > 30) {
sendTextMessage(TextMessage(MESSAGE_STATUS_SMALL, "Invalid name."), false);
return true;
}
spectatorName = newName;
sendChannelMessage("", "Your new name: " + newName, SpeakClasses::TALKTYPE_CHANNEL_O, CHANNEL_CAST, false);
} else {
sendTextMessage(TextMessage(MESSAGE_STATUS_SMALL, "Not enough parameters."), false);
}
}
}
return true;
}
return false;
}
示例6:
const std::string & index2str(long index)
{
if (index < 0 || index >= (long) m_vec.size()) {
return m_invalid;
}
return *(m_vec[index]);
}
示例7: lua_WordWrap
int D_Typeface::lua_WordWrap(lua_State *L) {
D_Typeface::Ref self = lua::SharedPtr::Get<D_Typeface>(L, "D_Typeface", 1, true);
bool kern = (lua_gettop(L) < 4) || (lua_toboolean(L, 4) ? true : false);
float kernScale = (lua_gettop(L) < 5) ? 1.f : (float)luaL_checknumber(L, 5);
self->typeface->font->SetPixelSize(
self->typeface->width,
self->typeface->height
);
StringVec strings = self->typeface->font->WordWrapString(
luaL_checkstring(L, 2),
(float)luaL_checknumber(L, 3),
kern,
kernScale
);
if (strings.empty())
return 0;
int ofs = 1;
lua_createtable(L, (int)strings.size(), 0);
for (StringVec::const_iterator it = strings.begin(); it != strings.end(); ++it) {
lua_pushinteger(L, ofs++);
lua_pushstring(L, (*it).c_str);
lua_settable(L, -3);
}
return 1;
}
示例8: t_args
Array c_DebuggerClientCmdUser::t_args() {
TRACE(5, "c_DebuggerClientCmdUser::t_args\n");
StringVec *args = m_client->args();
Array ret(Array::Create());
for (unsigned int i = 1; i < args->size(); i++) {
ret.append(String(args->at(i)));
}
return ret;
}
示例9: t_args
Array c_DebuggerClientCmdUser::t_args() {
INSTANCE_METHOD_INJECTION_BUILTIN(DebuggerClientCmdUser, DebuggerClientCmdUser::args);
StringVec *args = m_client->args();
Array ret(Array::Create());
for (unsigned int i = 1; i < args->size(); i++) {
ret.append(String(args->at(i)));
}
return ret;
}
示例10: matchWildcardList
bool matchWildcardList(const String& str, const StringVec& wildcardList)
{
for (unsigned i = 0; i < wildcardList.size(); i++) {
if (WildcardMatch(str.c_str(), wildcardList[i].c_str())) {
return true;
}
}
return false;
}
示例11: UpdateProfilesCombo
void ProfileDlg::UpdateProfilesCombo()
{
m_profiles.ResetContent();
StringVec vec = GetExistingProfiles();
for(int i=0; i<vec.size(); ++i)
{
m_profiles.InsertString(0,vec[i]);
}
}
示例12: FilesExist
/** check whether a file exists */
bool Parameter::FilesExist(const string ¶mName, int fieldNo, std::vector<std::string> const& extensions)
{
typedef std::vector<std::string> StringVec;
StringVec::const_iterator iter;
PARAM_MAP::const_iterator iterParam = m_setting.find(paramName);
if (iterParam == m_setting.end()) {
// no param. therefore nothing to check
return true;
}
const StringVec &pathVec = (*iterParam).second;
for (iter = pathVec.begin() ; iter != pathVec.end() ; ++iter) {
StringVec vec = Tokenize(*iter);
size_t tokenizeIndex;
if (fieldNo == -1)
tokenizeIndex = vec.size() - 1;
else
tokenizeIndex = static_cast<size_t>(fieldNo);
if (tokenizeIndex >= vec.size()) {
stringstream errorMsg("");
errorMsg << "Expected at least " << (tokenizeIndex+1) << " tokens per entry in '"
<< paramName << "', but only found "
<< vec.size();
UserMessage::Add(errorMsg.str());
return false;
}
const string &pathStr = vec[tokenizeIndex];
bool fileFound=0;
for(size_t i=0; i<extensions.size() && !fileFound; ++i) {
fileFound|=FileExists(pathStr + extensions[i]);
}
if(!fileFound) {
stringstream errorMsg("");
errorMsg << "File " << pathStr << " does not exist";
UserMessage::Add(errorMsg.str());
return false;
}
}
return true;
}
示例13: handleArgs
MojErr BusClient::handleArgs(const StringVec& args)
{
MojErr err = Base::handleArgs(args);
MojErrCheck(err);
if (args.size() && args[0] == "service")
m_launchedAsService = true;
return MojErrNone;
}
示例14: split
int split(StringVec &result, const String &src, const String& delm)
{
String _src(src);
char *p = strtok((char*)_src.c_str(), delm.c_str());
while (p != NULL)
{
result.push_back(p);
p = strtok(NULL, delm.c_str());
}
return int(result.size());
}
示例15: setStringVecValue
inline void setStringVecValue( StringVec& sv, const std::string& value, size_t index = 0 )
{
size_t size = sv.size();
if( size <= index )
{
while( size < index )
{
sv.push_back( "" );
++size;
}
sv.push_back( value );
}
else
sv[index] = value;
}