本文整理汇总了C++中raknet::RakString::SetChar方法的典型用法代码示例。如果您正苦于以下问题:C++ RakString::SetChar方法的具体用法?C++ RakString::SetChar怎么用?C++ RakString::SetChar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类raknet::RakString
的用法示例。
在下文中一共展示了RakString::SetChar方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PQprepare
PGresult * PostgreSQLInterface::QueryVariadic( const char * input, ... )
{
RakNet::RakString query;
PGresult *result;
DataStructures::List<VariadicSQLParser::IndexAndType> indices;
if ( input==0 || input[0]==0 )
return 0;
// Lookup this query in the stored query table. If it doesn't exist, prepare it.
RakNet::RakString inputStr;
inputStr=input;
unsigned int preparedQueryIndex;
for (preparedQueryIndex=0; preparedQueryIndex < preparedQueries.Size(); preparedQueryIndex++)
{
if (preparedQueries[preparedQueryIndex].StrICmp(inputStr)==0)
break;
}
// Find out how many params there are
// Find out the type of each param (%f, %s)
indices.Clear(false, _FILE_AND_LINE_);
GetTypeMappingIndices( input, indices );
if (preparedQueryIndex==preparedQueries.Size())
{
// if (indices.Size()>0)
// query += " (";
RakNet::RakString formatCopy;
RakNet::RakString insertion;
formatCopy=input;
unsigned int i;
unsigned int indexOffset=0;
for (i=0; i < indices.Size(); i++)
{
// if (i!=0)
// query += ",";
// query+=typeMappings[indices[i].typeMappingIndex].type;
formatCopy.SetChar(indices[i].strIndex+indexOffset, '$');
// if (i < 9)
// formatCopy.SetChar(indices[i].strIndex+1, i+1+'0');
// else
insertion=RakNet::RakString("%i::%s", i+1, VariadicSQLParser::GetTypeMappingAtIndex(indices[i].typeMappingIndex));
formatCopy.SetChar(indices[i].strIndex+1+indexOffset, insertion);
indexOffset+=(unsigned int) insertion.GetLength()-1;
}
// if (indices.Size()>0)
// query += ")";
// query += " AS ";
query += formatCopy;
// query += ";\n";
formatCopy+= ";\n";
result = PQprepare(pgConn, RakNet::RakString("PGSQL_ExecuteVariadic_%i", preparedQueries.Size()), formatCopy.C_String(), indices.Size(), NULL);
if (IsResultSuccessful(result, false))
{
PQclear(result);
preparedQueries.Insert(inputStr, _FILE_AND_LINE_);
}
else
{
printf(formatCopy.C_String());
printf("\n");
printf(lastError);
RakAssert(0);
PQclear(result);
return 0;
}
}
// char *paramData[512];
// int paramLength[512];
// int paramFormat[512];
va_list argptr;
va_start(argptr, input);
char **paramData;
int *paramLength;
int *paramFormat;
ExtractArguments(argptr, indices, ¶mData, ¶mLength);
paramFormat=RakNet::OP_NEW_ARRAY<int>(indices.Size(),_FILE_AND_LINE_);
for (unsigned int i=0; i < indices.Size(); i++)
paramFormat[i]=PQEXECPARAM_FORMAT_BINARY;
result = PQexecPrepared(pgConn, RakNet::RakString("PGSQL_ExecuteVariadic_%i", preparedQueryIndex), indices.Size(), paramData, paramLength, paramFormat, PQEXECPARAM_FORMAT_BINARY );
VariadicSQLParser::FreeArguments(indices, paramData, paramLength);
RakNet::OP_DELETE_ARRAY(paramFormat,_FILE_AND_LINE_);
va_end(argptr);
if (IsResultSuccessful(result, false)==false)
{
printf(lastError);
PQclear(result);
return 0;
}
return result;
}