本文整理汇总了C++中std::string::append方法的典型用法代码示例。如果您正苦于以下问题:C++ string::append方法的具体用法?C++ string::append怎么用?C++ string::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::string
的用法示例。
在下文中一共展示了string::append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_field
void on_field(boost::string_ref const& s, error_code&)
{
flush();
field_.append(s.data(), s.size());
}
示例2: GurlsOption
GurlsOptionsList::GurlsOptionsList(std::string ExpName, bool usedefopt): GurlsOption(OptListOption), name(ExpName)
{
table = new std::map<std::string, GurlsOption* >();
(*table)["Name"] = new OptString(ExpName);
if(usedefopt)
{
// opt.combineclasses = @mean; % How to combine performance measure per class (mean/median/min/max?)
(*table)["combineclasses"] = new OptFunction("mean");
(*table)["name"] = new OptString(ExpName);
(*table)["plotstr"] = new OptString(ExpName);
#ifdef USE_BINARY_ARCHIVES
(*table)["savefile"] = new OptString(ExpName.append(".bin"));
#else
(*table)["savefile"] = new OptString(ExpName.append(".txt"));
#endif
(*table)["todisk"] = new OptNumber(1);
// ================================================== Algorithm options
// opt.kernel.type = 'rbf';
(*table)["singlelambda"] = new OptFunction("median");
(*table)["predbagmethod"] = new OptString("vote");
// NOTE: lambda is searched between
// [min(eig_r, opt.smallnumber), eig_1],
// where r = rank, eig_1 = max eig val.
(*table)["smallnumber"] = new OptNumber(1e-8);
// ================================================== Directory options
(*table)["tmpdir"] = new OptString(ExpName);
// ===================================================== Output options
(*table)["savekernel"] = new OptNumber(1);
(*table)["saveanalysis"] = new OptNumber(1);
// opt.hoperf = @perf_precrec;
(*table)["ploteval"] = new OptString("acc");
// WARNING: this should be an array of strings...
(*table)["perfeval"] = new OptString("acc");
// ======================================================== Data option
(*table)["nholdouts"] = new OptNumber(1);
(*table)["hoproportion"] = new OptNumber(0.2);
(*table)["hoperf"] = new OptString("macroavg");
// (*table)["nlambda"] = new OptNumber(100);
(*table)["nsigma"] = new OptNumber(25);
(*table)["nlambda"] = new OptNumber(20);
// (*table)["nsigma"] = new OptNumber(10);
(*table)["eig_percentage"] = new OptNumber(5);
// ======================================================== Pegasos option
(*table)["subsize"] = new OptNumber(50);
(*table)["calibfile"] = new OptString("foo");
(*table)["epochs"] = new OptNumber(4);
// ============================================================== Quiet
// Currenty either 0 or 1; levels of verbosity may be implemented later;
(*table)["verbose"] = new OptNumber(1);
// ======================================================= Version info
(*table)["version"] = new OptString("2.0");
GurlsOptionsList * randfeats = new GurlsOptionsList("randfeats");
randfeats->table->insert(pair<std::string,GurlsOption*>("D", new OptNumber(500)));
randfeats->table->insert(pair<std::string,GurlsOption*>("samplesize", new OptNumber(100)));
(*table)["randfeats"] = randfeats;
}
}
示例3: setCommonResourcePath
void CResourcePathDirector::setCommonResourcePath(std::string strOriginResPath)
{
m_strCommonResourcePath = strOriginResPath.append("/");
}
示例4: apply
static void apply( const Input& in, std::string& s )
{
s.append( in.begin(), in.size() );
}
示例5: GetConfigIntDefault
int32 GetConfigIntDefault(std::string base, const char* name, int32 value)
{
base.append(name);
return sConfigMgr->GetIntDefault(base.c_str(), value);
}
示例6:
inline void append_double_precision_pragma<double>(viennacl::ocl::context const & ctx, std::string & source)
{
source.append("#pragma OPENCL EXTENSION " + ctx.current_device().double_support_extension() + " : enable\n\n");
}
示例7: sendImpl
virtual void sendImpl(const void *data, int size, int code, bool chunked) {
m_response.clear();
m_response.append((const char *)data, size);
m_code = code;
}
示例8: GetOsPrettyNameWithVersion
std::string CSysInfo::GetOsPrettyNameWithVersion(void)
{
static std::string osNameVer;
if (!osNameVer.empty())
return osNameVer;
#if defined (TARGET_WINDOWS)
OSVERSIONINFOEXW osvi = {};
osNameVer = "Windows ";
if (sysGetVersionExWByRef(osvi))
{
switch (GetWindowsVersion())
{
case WindowsVersionVista:
if (osvi.wProductType == VER_NT_WORKSTATION)
osNameVer.append("Vista");
else
osNameVer.append("Server 2008");
break;
case WindowsVersionWin7:
if (osvi.wProductType == VER_NT_WORKSTATION)
osNameVer.append("7");
else
osNameVer.append("Server 2008 R2");
break;
case WindowsVersionWin8:
if (osvi.wProductType == VER_NT_WORKSTATION)
osNameVer.append("8");
else
osNameVer.append("Server 2012");
break;
case WindowsVersionWin8_1:
if (osvi.wProductType == VER_NT_WORKSTATION)
osNameVer.append("8.1");
else
osNameVer.append("Server 2012 R2");
break;
case WindowsVersionFuture:
osNameVer.append("Unknown Future Version");
break;
default:
osNameVer.append("Unknown version");
break;
}
// Append Service Pack version if any
if (osvi.wServicePackMajor > 0 || osvi.wServicePackMinor > 0)
{
osNameVer.append(StringUtils::Format(" SP%d", osvi.wServicePackMajor));
if (osvi.wServicePackMinor > 0)
{
osNameVer.append(StringUtils::Format(".%d", osvi.wServicePackMinor));
}
}
}
else
osNameVer.append(" unknown");
#elif defined(TARGET_FREEBSD) || defined(TARGET_DARWIN_IOS) || defined(TARGET_DARWIN_OSX)
osNameVer = GetOsName() + " " + GetOsVersion();
#elif defined(TARGET_ANDROID)
osNameVer = GetOsName() + " " + GetOsVersion() + " API level " + StringUtils::Format("%d", CJNIBuild::SDK_INT);
#elif defined(TARGET_LINUX)
osNameVer = getValueFromOs_release("PRETTY_NAME");
if (osNameVer.empty())
{
osNameVer = getValueFromLsb_release(lsb_rel_description);
std::string osName(GetOsName(true));
if (!osName.empty() && osNameVer.find(osName) == std::string::npos)
osNameVer = osName + osNameVer;
if (osNameVer.empty())
osNameVer = "Unknown Linux Distribution";
}
if (osNameVer.find(GetOsVersion()) == std::string::npos)
osNameVer += " " + GetOsVersion();
#endif // defined(TARGET_LINUX)
if (osNameVer.empty())
osNameVer = "Unknown OS Unknown version";
return osNameVer;
}
示例9: format
void format(std::string& str, long value)
{
char buffer[64];
std::sprintf(buffer, "%ld", value);
str.append(buffer);
}
示例10: proc_buf
//proc char * buf
//if this buf ends a command~~ SEN_FLAG = TRUE
//string sentence
//string cmd_header
//iOfSen nOfSen just for examine
bool proc_buf(const char * buf, bool & SEN_FLAG, std::string & sentence, std::string & cmd_header, std::string & usr_name, int & nOfSen, int & iOfSen, bool & isINV)
{
int i_f_brac = 0;
int i_l_brac = -1;
std::vector<int> v_space;
//1st assumption: buf's content doesnt cross the border
//2nd assumption: the sentences in a command has the same cmd header
//3rd assumption: there're only 2 types of REQ ~~ single REQ | compound REQ
//4th assumption: compound REQ has a stereotype( has 2 digital page indexs ... username's upper limit is 20 )
//5th assumption: compound REQ must have a sentence behind it
//get i_f_brac and i_l_brac
for( int i = 0; i < DEFAULT_BUFFER_LENGTH; i++ )
{
if( buf[i] == ']' )
{
i_l_brac = i;
break;
}
}
if( (buf[0] != '[') || (i_l_brac == DEFAULT_BUFFER_LENGTH-1) )
{
return false;
}
//judge whether this cammand is a single REQ~
for( int i = i_f_brac; i < i_l_brac; i++ )
{
if( buf[i] == ' ' )
{
v_space.push_back(i);
}
}
if( v_space.size()==0 ) //is a single REQ
{
SEN_FLAG = true;
//make a replica of header~~
char * header = new char [ i_l_brac - i_f_brac ];
for(int i = 0; i < i_l_brac - i_f_brac - 1; i++)
{
header[i] = buf[ i_f_brac+1 + i ];
}
header[ i_l_brac-i_f_brac-1 ] = '\0';
cmd_header.append(header);
printf( "\n%s\n", cmd_header.c_str() );
delete [] header;
return true;
}
else if( v_space.size()==3 ) //is a compound REQ
{
//****seperate the buff****
int i_sep[6] = { i_f_brac, v_space.at(0), v_space.at(1), v_space.at(2), i_l_brac, strlen(buf) };
std::string g_cmd;
std::string g_iPage;
std::string g_nPage;
std::string g_user;
std::string g_sen;
//char * cmd_str = new char [ i_sep[1]-i_sep[0] ];
//char * iCUR_str = new char [ i_sep[2]-i_sep[1] ];
//char * iALL_str = new char [ i_sep[3]-i_sep[2] ];
//char * username_str = new char [ i_sep[4]-i_sep[3] ];
//char * sen_str = new char [ i_sep[5]-i_sep[4] ];
int iCUR = 0;
int iALL = 0;
//cmd_str
for( int i = 0; i < i_sep[1]-i_sep[0] - 1; i++ )
{
//cmd_str[i] = buf[ i_sep[0]+1 + i ];
g_cmd.push_back( buf[ i_sep[0]+1 + i ] );
}
//cmd_str[i_sep[1]-i_sep[0] - 1] = '\0';
//iCUR_str
for( int i = 0; i < i_sep[2]-i_sep[1] - 1; i++ )
{
//iCUR_str[i] = buf[ i_sep[1]+1 + i ];
g_iPage.push_back( buf[ i_sep[1]+1 + i ] );
}
//iCUR_str[i_sep[2]-i_sep[1] - 1] = '\0';
//iALL_str
for( int i = 0; i < i_sep[3]-i_sep[2] - 1; i++ )
{
//iALL_str[i] = buf[ i_sep[2]+1 + i ];
//.........这里部分代码省略.........
示例11: GetUserAgent
std::string CSysInfo::GetUserAgent()
{
static std::string result;
if (!result.empty())
return result;
result = "XBMC/" + g_infoManager.GetLabel(SYSTEM_BUILD_VERSION_SHORT) + " (";
#if defined(TARGET_WINDOWS)
result += GetKernelName() + " " + GetKernelVersion();
BOOL bIsWow = FALSE;
if (IsWow64Process(GetCurrentProcess(), &bIsWow) && bIsWow)
result.append("; WOW64");
else
{
SYSTEM_INFO si = {};
GetSystemInfo(&si);
if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
result.append("; Win64; x64");
else if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64)
result.append("; Win64; IA64");
else if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_ARM)
result.append("; ARM");
}
#elif defined(TARGET_DARWIN)
#if defined(TARGET_DARWIN_IOS)
std::string iDevStr(GetModelName()); // device model name with number of model version
size_t iDevStrDigit = iDevStr.find_first_of("0123456789");
std::string iDev(iDevStr, 0, iDevStrDigit); // device model name without number
if (iDevStrDigit == 0)
iDev = "unknown";
result += iDev + "; ";
std::string iOSVerison(GetOsVersion());
size_t lastDotPos = iOSVerison.rfind('.');
if (lastDotPos != std::string::npos && iOSVerison.find('.') != lastDotPos
&& iOSVerison.find_first_not_of('0', lastDotPos + 1) == std::string::npos)
iOSVerison.erase(lastDotPos);
StringUtils::Replace(iOSVerison, '.', '_');
if (iDev == "iPad" || iDev == "AppleTV")
result += "CPU OS ";
else
result += "CPU iPhone OS ";
result += iOSVerison + " like Mac OS X";
#else
result += "Macintosh; ";
std::string cpuFam(GetBuildTargetCpuFamily());
if (cpuFam == "x86")
result += "Intel ";
else if (cpuFam == "PowerPC")
result += "PPC ";
result += "Mac OS X ";
std::string OSXVersion(GetOsVersion());
StringUtils::Replace(OSXVersion, '.', '_');
result += OSXVersion;
#endif
#elif defined(TARGET_ANDROID)
result += "Linux; Android ";
std::string versionStr(GetOsVersion());
const size_t verLen = versionStr.length();
if (verLen >= 2 && versionStr.compare(verLen - 2, 2, ".0", 2) == 0)
versionStr.erase(verLen - 2); // remove last ".0" if any
result += versionStr;
std::string deviceInfo(GetModelName());
char buildId[PROP_VALUE_MAX];
int propLen = __system_property_get("ro.build.id", buildId);
if (propLen > 0 && propLen <= PROP_VALUE_MAX)
{
if (!deviceInfo.empty())
deviceInfo += " ";
deviceInfo += "Build/";
deviceInfo.append(buildId, propLen);
}
if (!deviceInfo.empty())
result += "; " + deviceInfo;
#elif defined(TARGET_POSIX)
result += "X11; ";
struct utsname un;
if (uname(&un) == 0)
{
std::string cpuStr(un.machine);
if (cpuStr == "x86_64" && GetXbmcBitness() == 32)
cpuStr = "i686 (x86_64)";
result += un.sysname;
result += " ";
result += cpuStr;
}
else
result += "Unknown";
#else
result += "Unknown";
#endif
result += ")";
// add fork ID here in form:
// result += " XBMC_FORK_" + "forkname" + "/" + "1.0"; // default fork number is '1.0'
#ifdef TARGET_RASPBERRY_PI
result += " XBMC_HW_RaspberryPi/1.0";
#elif defined (TARGET_DARWIN_IOS)
std::string iDevVer;
if (iDevStrDigit == std::string::npos)
//.........这里部分代码省略.........
示例12: elegirProtagonista
// Devuelve el jugador que va a usar el cliente
// Caso 1: Si el jugador NO está en uso se crea y se devuelve una copia del mismo
// Caso 2: Si el jugador SI está en uso y SI se encuentra "congelado", se cambia su condición y se devuelve una copia del mismo
// Caso 3: Si el jugador SI está en uso y NO se encuentra "congelado", se elige otro jugador que no se encuentre en uso, se crea y se devuelve una copia del mismo
ProxyModeloEntidad::stEntidad ModeloFactory::elegirProtagonista(ModeloNivel* modeloNivel,std::string& mote,std::string& nombreEntidadPersonaje,int& id){
std::list<ModeloJugador*> listaEntidades = modeloNivel->getJugadores();
std::list<std::string> listaJugadoresUsados;
ProxyModeloEntidad::stEntidad stEntidad;
ModeloJugador* pEntidad = NULL;
bool moteEncontrado = false;
for( std::list<ModeloJugador*>::iterator itEntidad = listaEntidades.begin() ; itEntidad != listaEntidades.end() ; itEntidad++ ){
// Obtengo el nombre de jugador y entidad
std::string moteJugador = (*itEntidad)->nombreJugador();
std::string entidadPersonaje = (*itEntidad)->modeloEntidad()->nombreEntidad();
// Guardo el nombre de la entidad usada
listaJugadoresUsados.push_back(entidadPersonaje);
// Comparo el nombre del jugador usado con el que me pide el usuario nuevo
if( moteJugador.compare(mote) == 0 ){
pEntidad = (*itEntidad);
moteEncontrado = true;
}
}
// NOTA: Observar que si encuentro al usuario, ya no me interesa el personaje que eligió el cliente, porque este ya se encuentra creado
if( moteEncontrado == true ){
// Me fijo si está congelado o no
if( pEntidad->estaDesconectado() == true){
// Si está congelado y es el mismo nombre de usuario, lo descongelo y obtengo sus datos
pEntidad->estaDesconectado(false);
// Cargo la entidad
stEntidad = pEntidad->stEntidad();
pEntidad->cargarMatriz(stEntidad);
// Como se está conectando de vuelta, le reasigno al socket de cliente el ID que tenia antes (stEntidad.id), para poder reconocerlo en el loop de juego
pSocket->renombrarIdCliente(id,stEntidad.id);
// Renombro el id pasado por referencia
id = stEntidad.id;
return stEntidad;
}else{
// Si no está congelado y es el mismo nombre de usuario, no lo puedo usar, así que busco otro personaje libre y lo creo
std::string nombrePersonajeObtenido = this->obtenerPersonajeLibre(listaJugadoresUsados,nombreEntidadPersonaje);
// Anexo el ID al mote para diferenciarlo del que ya está jugando
std::stringstream ss;
ss << id;
mote.append(ss.str());
nombreEntidadPersonaje = nombrePersonajeObtenido; // Actualizo el nombre que va a tener el personaje
this->crearJugador(modeloNivel,stEntidad,nombrePersonajeObtenido,mote,id);
return stEntidad;
}
}else{
// Si no encontré ese nombre entre los jugadores creo uno nuevo
std::string nombrePersonajeObtenido = this->obtenerPersonajeLibre(listaJugadoresUsados,nombreEntidadPersonaje);
nombreEntidadPersonaje = nombrePersonajeObtenido; // Actualizo el nombre que va a tener el personaje
this->crearJugador(modeloNivel,stEntidad,nombrePersonajeObtenido,mote,id);
return stEntidad;
}
return stEntidad;
}
示例13: prepare_newline
void htmlrenderer::prepare_newline(std::string& line, int indent_level) {
line = "";
line.append(indent_level*2, ' ');
}
示例14: on_value
void on_value(boost::string_ref const& s, error_code&)
{
value_.append(s.data(), s.size());
}
示例15: move
static std::vector<std::string> listFiles(std::string path)
{
std::vector<std::string> results;
#ifdef _WIN32
if (path.back() != '/')
path.append("/*");
else
path.append("*");
//convert to wide chars for windows
std::basic_string<TCHAR> wPath;
wPath.assign(path.begin(), path.end());
WIN32_FIND_DATA findData;
HANDLE hFind = FindFirstFile(wPath.c_str(), &findData);
if (hFind == INVALID_HANDLE_VALUE)
{
std::cout << "Failed to find file data, invalid file handle returned" << std::endl;
return results;
}
do
{
if ((findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) //not a directory
{
//convert from wide char
std::basic_string<TCHAR> wName(findData.cFileName);
std::string fileName;
fileName.assign(wName.begin(), wName.end());
results.push_back(fileName);
}
} while (FindNextFile(hFind, &findData) != 0);
FindClose(hFind);
return std::move(results);
#else
if (path.back() != '/')
path.append("/.");
else
path.append(".");
struct dirent* dp;
DIR* dir = opendir(path.c_str());
if (dir)
{
while ((dp = readdir(dir)) != nullptr)
{
std::string workingPath(path);
workingPath.append("/");
workingPath.append((dp->d_name));
struct stat buf;
if (!stat(workingPath.c_str(), &buf))
{
if (!S_ISDIR(buf.st_mode))
{
results.emplace_back(dp->d_name);
}
}
}
closedir(dir);
}
return std::move(results);
#endif //_WIN32
}