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


C++ nlmisc::CSString类代码示例

本文整理汇总了C++中nlmisc::CSString的典型用法代码示例。如果您正苦于以下问题:C++ CSString类的具体用法?C++ CSString怎么用?C++ CSString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CSString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: endState

bool CStateManager::endState(const NLMISC::CSString& stateName)
{
	uint32 i;

	// make sure the state is already active
	for (i=0;i<_States.size();++i)
	{
		if (_States[i]==stateName)
		{
			break;
		}
	}
	if (i==_States.size())
	{
		nlwarning("Cannot end state as it is not already active: %s",stateName.c_str());
		return false;
	}

	// set the state as inactive
	_States.erase(_States.begin()+i);

	// write the states to a file
	NLMISC::CSString stateTxt;
	stateTxt.join(_States,"\n");
	stateTxt.writeToFile(StateFileName);

	// execute the end_state script
	CScriptManager::getInstance()->runScript("end_"+stateName);

	return true;
}
开发者ID:Kiddinglife,项目名称:ryzom,代码行数:31,代码来源:ss_state_manager.cpp

示例2: parseFile

bool CCharScanScriptFile::parseFile(const std::string& fileName, CCharScanScript* container)
{
	_FileName= fileName;

	// read the content of the input file
	bool result;
	NLMISC::CSString fileContent;
	result=fileContent.readFromFile(fileName);
	if (result==false)
	{
		nlwarning("Failed to read script file: %s",fileName.c_str());
		return false;
	}

	// split the file into lines and execute them one by one
	NLMISC::CVectorSString lines;
	fileContent.splitLines(lines);
	for (uint32 i=0;i<lines.size();++i)
	{
		// strip comments and leading and trailing blanks
		CSString theLine= lines[i].replace("//","\xff").splitTo('\xff').strip();
		if (theLine.empty())
			continue;

		CCharScanScriptCommandRegistry::getInstance()->execute(*this,theLine,container);
	}
	return true;
}
开发者ID:mixxit,项目名称:solinia,代码行数:28,代码来源:char_scan_script.cpp

示例3: applyFirstPatch

bool applyFirstPatch(const NLMISC::CSString& patchFile,const NLMISC::CSString& destFile)
{
	nlinfo("APPLY FIRST PATCH: %s => %s",patchFile.c_str(),destFile.c_str());
	NLMISC::CSString cmd= "xdelta patch "+patchFile+" /dev/null "+destFile;
	bool ok= system(cmd.c_str())==0;
	return ok;
}
开发者ID:mixxit,项目名称:solinia,代码行数:7,代码来源:spa_server_patch_applier.cpp

示例4: applyPatch

bool applyPatch(const NLMISC::CSString& patchFile,const NLMISC::CSString& srcFile,const NLMISC::CSString& destFile)
{
	nlinfo("APPLY PATCH: %s to file %s => %s",patchFile.c_str(),srcFile.c_str(),destFile.c_str());
	NLMISC::CSString cmd= "xdelta patch "+patchFile+" "+srcFile+" "+destFile;
	bool ok= system(cmd.c_str())==0;
	return ok;
}
开发者ID:mixxit,项目名称:solinia,代码行数:7,代码来源:spa_server_patch_applier.cpp

示例5: getFileVersion

uint32 getFileVersion(const NLMISC::CSString& fileName)
{
	// start at the back of the file name and scan forwards until we find a '/' or '\\' or ':' or a digit
	uint32 i= fileName.size();
	while (i--)
	{
		char c= fileName[i];

		// if we've hit a directory name separator then we haven't found a version number so drop out
		if (c=='/' || c=='\\' || c==':')
			return ~0u;

		// if we've found a digit then construct the rest of the version number and return
		if (isdigit(c))
		{
			uint32 firstDigit= i;
			while (firstDigit!=0 && isdigit(fileName[firstDigit-1]))
			{
				--firstDigit;
			}
			return fileName.leftCrop(firstDigit).left(i-firstDigit+1).atoui();
		}
	}

	// default to our 'invalid' value
	return ~0u;
}
开发者ID:,项目名称:,代码行数:27,代码来源:

示例6: untarIfNeeded

bool untarIfNeeded(const NLMISC::CSString& destFile)
{
	if (destFile.right(4)==".tgz" || destFile.right(7)==".tar.gz")
	{
		return untar(destFile);
	}
	return true;
}
开发者ID:mixxit,项目名称:solinia,代码行数:8,代码来源:spa_server_patch_applier.cpp

示例7: addValidState

void CStateManager::addValidState(const NLMISC::CSString& stateName)
{
	if (stateName.countWords()!=1)
	{
		nlwarning("Invalid state name: %s",stateName.c_str());
		return;
	}
	_ValidStates.insert(stateName.strip());
}
开发者ID:Kiddinglife,项目名称:ryzom,代码行数:9,代码来源:ss_state_manager.cpp

示例8: getAccountIdFromFileName

// The following routine returns the account id for a given file name
// returns 0 for files that do not contain a recognisable account id.
// The account id is assumed to be the first integer found between 2 '_' characters. eg for file 'account_123_4_pdr.bin' the value would be 123
static uint32 getAccountIdFromFileName(NLMISC::CSString filename)
{
	uint32 accountId;
	do
	{
		DROP_IF(filename.empty(),"No account number found in file: "+filename,return 0);
		accountId= filename.strtok("_.").atoui();
	}
	while (accountId==0);
	return accountId;
}
开发者ID:Kiddinglife,项目名称:ryzom,代码行数:14,代码来源:stat_user_file_list_builders.cpp

示例9: addToFdc

static void addToFdc(const NLMISC::CSString& filespec, CFileDescriptionContainer& result)
{
	if (filespec.left(1)=="@")
	{
		readFileList(filespec.leftCrop(1),result);
	}
	else
	{
		result.addFileSpec(filespec);
	}
}
开发者ID:Kiddinglife,项目名称:ryzom,代码行数:11,代码来源:handy_commands.cpp

示例10: setUserComponentToSave

bool CUserComponentValidator::setUserComponentToSave(const std::string& filename, const CUserComponentValidator::TValues& values, std::string& headerMD5, const std::string &body)
{
    _Filename = filename;
//	std::ostringstream out2;
//	out2.str(body);

//	_UserComponentBody =out2.str();

    _UserComponentBody = body;

    {
        NLMISC::CHashKeyMD5 md5Id = NLMISC::getMD5((uint8*)_UserComponentBody.data(), (uint32)_UserComponentBody.size());
        _BodyMd5 = md5Id.toString().c_str();
    }

//	out2.str("");
//	out2 << NLMISC::toString("-- BodyMD5 = '%s'\n", _BodyMd5.c_str() );
//	TValues::const_iterator first(values.begin()), last(values.end());
//	for (; first != last; ++first)
//	{
    //>first->second.c_str()) "\n" => "\\n"
//		NLMISC::CSString tmp = first->second.c_str();
//		tmp = tmp.replace("\n", "\\n");

//		out2 << NLMISC::toString("-- %s = '%s'\n", first->first.c_str(), tmp.c_str());
//	}


//	_HeaderBody =out2.str();


    _HeaderBody = NLMISC::toString("-- BodyMD5 = '%s'\n", _BodyMd5.c_str() );

    TValues::const_iterator first(values.begin()), last(values.end());
    for (; first != last; ++first)
    {
        //>first->second.c_str()) "\n" => "\\n"
        NLMISC::CSString tmp = first->second.c_str();
        tmp = tmp.replace("\n", "\\n");

        _HeaderBody += NLMISC::toString("-- %s = '%s'\n", first->first.c_str(), tmp.c_str());
    }


    std::string headerBodyMd5;
    {
        NLMISC::CHashKeyMD5 md5Id = NLMISC::getMD5((uint8*)_HeaderBody.data(), (uint32)_HeaderBody.size());
        _HeaderMd5 = md5Id.toString().c_str();
        headerMD5 = _HeaderMd5;
    }

    return true;
}
开发者ID:mixxit,项目名称:solinia,代码行数:53,代码来源:scenario.cpp

示例11:

CStateManager::CStateManager() 
{
	// read the states from a file
	NLMISC::CSString stateTxt;
	if (NLMISC::CFile::fileExists(StateFileName))
	{
		stateTxt.readFromFile(StateFileName);
		stateTxt.splitLines(_States);
	}

	// display the loaded state list
	display();
}
开发者ID:Kiddinglife,项目名称:ryzom,代码行数:13,代码来源:ss_state_manager.cpp

示例12: init

bool CRepository::init(const NLMISC::CSString& name,const NLMISC::CSString& directory)
{
	_Name= name.unquoteIfQuoted();
	_TargetDirectory= NLMISC::CPath::standardizePath(directory.unquoteIfQuoted());

	nldebug("Repository %s: %s",_Name.c_str(),_TargetDirectory.c_str());

	// check whether the target directory exists
	if (!NLMISC::CFile::isDirectory(_TargetDirectory))
	{
		// the directory didn't exist so try to create it...
		NLMISC::CFile::createDirectoryTree(_TargetDirectory);
		DROP_IF(!NLMISC::CFile::isDirectory(_TargetDirectory),"Failed to create target directory: \""+_TargetDirectory+"\"",return false);
	}
开发者ID:,项目名称:,代码行数:14,代码来源:

示例13: buildTimestampFromDateStr

// The following routine builds a timestamp value from a date string in the format <dd>/<mm>/<yyyy>
// If the text doesn't match the expected format then ~0u is returned
static uint32 buildTimestampFromDateStr(const NLMISC::CSString& dateStr)
{
	// setup a new time structure, extracting the day, month and year values from the argument string
	struct tm tmstruct;
	NLMISC::CSString txt= dateStr.strip();
	tmstruct.tm_mday	= txt.splitTo('/',true,true).atoi();
	tmstruct.tm_mon		= txt.splitTo('/',true,true).atoi() -1;
	tmstruct.tm_year	= txt.atoi();
	if (tmstruct.tm_year<100)
		tmstruct.tm_year= ((tmstruct.tm_year+30)%100)+1970;

	// make sure the day month and year are valid
	DROP_IF(tmstruct.tm_year<1970 || tmstruct.tm_year>=2100,"FILE_LIST_BUILDER 'Since' invalid year: "+dateStr,return ~0u);
	DROP_IF(tmstruct.tm_mon<0 || tmstruct.tm_mon>=12,"FILE_LIST_BUILDER 'Since' invalid month: "+dateStr,return ~0u);
	DROP_IF(tmstruct.tm_mday<1 || tmstruct.tm_mday>31,"FILE_LIST_BUILDER 'Since' invalid day: "+dateStr,return ~0u);

	// complete initialisation of tm struct (and map year into range from 1970 up
	tmstruct.tm_year	-= 1900;
	tmstruct.tm_wday	= 0;
	tmstruct.tm_yday	= 0;
	tmstruct.tm_isdst	= 0;

	// build a time_t value for the start of the day
	tmstruct.tm_sec		= 0;
	tmstruct.tm_min		= 0;
	tmstruct.tm_hour	= 0;
	
	return (uint32)mktime( &tmstruct );
}
开发者ID:Kiddinglife,项目名称:ryzom,代码行数:31,代码来源:stat_user_file_list_builders.cpp

示例14: setScenarioToSave

bool CScenarioValidator::setScenarioToSave(const std::string& filename, CObject* scenario, const CScenarioValidator::TValues& values, std::string& headerMD5)
{
    _Filename = filename;
    //std::ostringstream out2;
    //out2.str("");
    std::string out2;

    if (!scenario)
    {
        return false;
    }

    //out2 <<"scenario = "<< *scenario ;
    out2 += "scenario = ";
    scenario->serialize(out2);

    _ScenarioBody = out2;
    {
        NLMISC::CHashKeyMD5 md5Id = NLMISC::getMD5((uint8*)_ScenarioBody.data(),(uint32) _ScenarioBody.size());
        _BodyMd5 = md5Id.toString().c_str();
    }


    out2.clear();
    //out2.str("");
    out2 += NLMISC::toString("-- BodyMD5 = '%s'\n", _BodyMd5.c_str() );
    TValues::const_iterator first(values.begin()), last(values.end());
    for (; first != last; ++first)
    {
        //>first->second.c_str()) "\n" => "\\n"
        NLMISC::CSString tmp = first->second.c_str();
        tmp = tmp.replace("\n", "\\n");

        out2 += NLMISC::toString("-- %s = '%s'\n", first->first.c_str(), tmp.c_str());
    }

    _HeaderBody =out2;
    std::string headerBodyMd5;
    {
        NLMISC::CHashKeyMD5 md5Id = NLMISC::getMD5((uint8*)_HeaderBody.data(), (uint32)_HeaderBody.size());
        _HeaderMd5 = md5Id.toString().c_str();
        headerMD5 = _HeaderMd5;
    }
    return true;
}
开发者ID:mixxit,项目名称:solinia,代码行数:45,代码来源:scenario.cpp

示例15: cbChatText

	void CFactionChannel::cbChatText(TChannelRank rank,const TCharacterId& id,GUS::TClientId clientId,const NLMISC::CSString& txt)
	{
		if (txt.leftStrip().left(1)=="/")
		{
			// execute a command
			CFactionChannelContext context(this,rank,id,clientId);
			CTxtCommandResult result= ECFCCommandSet->execute(context,txt.leftStrip().leftCrop(1));
			switch (result.getType())
			{
				case CTxtCommandResult::SUCCESS:
					getChannel().sendMessage(clientId,"*","Command executed: "+txt);
					break;

				case CTxtCommandResult::SYNTAX_ERROR:
					getChannel().sendMessage(clientId,"*","Error in command parameter syntax: "+txt);
					break;

				case CTxtCommandResult::BAD_PERMISSION:
					getChannel().sendMessage(clientId,"*","You don't have permission to execute this command: "+txt);
					break;

				case CTxtCommandResult::UNKNOWN_COMMAND:
					getChannel().sendMessage(clientId,"*","Unknown command - try '/help' to see the valid command list: "+txt.firstWordConst());
					break;

				case CTxtCommandResult::EXECUTION_ERROR:
				default:
					getChannel().sendMessage(clientId,"*","Error trying to execute command: "+txt);
					break;
			}
			if (result.getReason()!="" && !result.getReason().empty())
				getChannel().sendMessage(clientId,"*",result.getReason());
			return;
		}

		// make sure the use has the right to chat in the channel at the moment
		if (rank<_MinChatRank)
		{
			getChannel().sendMessage(clientId,"system","Players of your rank are currently not able to chat in this channel");
			return;
		}

		// broadcast the message back to the chat
		getChannel().broadcastMessage(id,txt);
	}
开发者ID:Kiddinglife,项目名称:ryzom,代码行数:45,代码来源:ec_faction_channel.cpp


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