本文整理汇总了C++中AString函数的典型用法代码示例。如果您正苦于以下问题:C++ AString函数的具体用法?C++ AString怎么用?C++ AString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AString
void cPluginManager::FindPlugins(void)
{
AString PluginsPath = FILE_IO_PREFIX + AString( "Plugins/" );
// First get a clean list of only the currently running plugins, we don't want to mess those up
for (PluginMap::iterator itr = m_Plugins.begin(); itr != m_Plugins.end();)
{
if (itr->second == NULL)
{
PluginMap::iterator thiz = itr;
++thiz;
m_Plugins.erase( itr );
itr = thiz;
continue;
}
++itr;
}
AStringVector Files = cFile::GetFolderContents(PluginsPath.c_str());
for (AStringVector::const_iterator itr = Files.begin(); itr != Files.end(); ++itr)
{
if ((*itr == ".") || (*itr == "..") || (!cFile::IsFolder(PluginsPath + *itr)))
{
// We only want folders, and don't want "." or ".."
continue;
}
// Add plugin name/directory to the list
if (m_Plugins.find(*itr) == m_Plugins.end())
{
m_Plugins[*itr] = NULL;
}
}
}
示例2: UnicodeStringToMultiByte
AString UnicodeStringToMultiByte(const UString &srcString, UINT codePage)
{
if (!srcString.IsEmpty())
{
const wchar_t * wcs = &srcString[0];
char utf8[4096];
UniChar unipath[4096];
size_t n = wcslen(wcs);
for(size_t i = 0 ; i<= n ;i++) {
unipath[i] = wcs[i];
}
CFStringRef cfpath = CFStringCreateWithCharacters(NULL,unipath,n);
CFMutableStringRef cfpath2 = CFStringCreateMutableCopy(NULL,0,cfpath);
CFRelease(cfpath);
CFStringNormalize(cfpath2,kCFStringNormalizationFormD);
CFStringGetCString(cfpath2,(char *)utf8,4096,kCFStringEncodingUTF8);
CFRelease(cfpath2);
return AString(utf8);
}
AString resultString;
for (int i = 0; i < srcString.Len(); i++)
{
if (srcString[i] >= 256) resultString += '?';
else resultString += char(srcString[i]);
}
return resultString;
}
示例3: AString
AString cWebAdmin::GetDefaultPage(void)
{
AString Content;
Content += "<h4>Server Name:</h4>";
Content += "<p>" + AString( cRoot::Get()->GetServer()->GetServerID() ) + "</p>";
Content += "<h4>Plugins:</h4><ul>";
cPluginManager * PM = cPluginManager::Get();
const cPluginManager::PluginMap & List = PM->GetAllPlugins();
for (cPluginManager::PluginMap::const_iterator itr = List.begin(); itr != List.end(); ++itr)
{
if (itr->second == NULL)
{
continue;
}
AString VersionNum;
AppendPrintf(Content, "<li>%s V.%i</li>", itr->second->GetName().c_str(), itr->second->GetVersion());
}
Content += "</ul>";
Content += "<h4>Players:</h4><ul>";
cPlayerAccum PlayerAccum;
cWorld * World = cRoot::Get()->GetDefaultWorld(); // TODO - Create a list of worlds and players
if( World != NULL )
{
World->ForEachPlayer(PlayerAccum);
Content.append(PlayerAccum.m_Contents);
}
Content += "</ul><br>";
return Content;
}
示例4: AString
void ATextServer::__readcallback(ASocketServer *server, int socket, void *context)
{
ATextHandler *handler = (ATextHandler *)context;
if (handler) {
static uint8_t buffer[1024];
int n;
if ((n = server->ReadSocket(socket, buffer, sizeof(buffer))) > 0) {
AString data = AString((const char *)buffer, n).SearchAndReplace("\r", "");
handler->AddData(data);
}
else {
debug("Failed to read data from socket\n");
server->DeleteHandler(socket);
return;
}
handler->SendData();
}
else {
debug("Received data on an unregistered handler!\n");
server->DeleteHandler(socket);
}
}
示例5: TEST
TEST(StringTests, rshort)
{
LString short_text = "0123456789"_s;
EXPECT_EQ(&*short_text.begin(), &*RString(short_text).begin());
EXPECT_EQ(&*short_text.begin(), &*AString(short_text).begin());
RString r = VString<255>(short_text);
EXPECT_EQ(r.size(), 10);
AString a = VString<255>(short_text);
EXPECT_EQ(r, a);
AString r2 = r, r3;
RString a2 = a, a3;
XString r1 = r2;
XString a1 = a2;
r3 = r1;
a3 = a1;
EXPECT_EQ(r, r1);
EXPECT_EQ(a, a1);
EXPECT_EQ(r, r2);
EXPECT_EQ(a, a2);
EXPECT_EQ(r, r3);
EXPECT_EQ(a, a3);
EXPECT_EQ(&*r.begin(), &*r1.begin());
EXPECT_NE(&*a.begin(), &*a1.begin());
EXPECT_EQ(&*r.begin(), &*r2.begin());
EXPECT_NE(&*a.begin(), &*a2.begin());
EXPECT_EQ(&*r.begin(), &*r3.begin());
EXPECT_NE(&*a.begin(), &*a3.begin());
}
示例6: fun_add
static
int fun_add(dumb_ptr<env_t>, val_t *result, Slice<val_t> args)
{
if (ARG_TYPE(0) == TYPE::INT && ARG_TYPE(1) == TYPE::INT)
{
/* Integer addition */
RESULTINT = ARGINT(0) + ARGINT(1);
result->ty = TYPE::INT;
}
else if (ARG_MAY_BE_AREA(0) && ARG_MAY_BE_AREA(1))
{
/* Area union */
make_area(&args[0]);
make_area(&args[1]);
RESULTAREA = area_union(ARGAREA(0), ARGAREA(1));
ARGAREA(0) = nullptr;
ARGAREA(1) = nullptr;
result->ty = TYPE::AREA;
}
else
{
/* Anything else -> string concatenation */
stringify(&args[0], 1);
stringify(&args[1], 1);
/* Yes, we could speed this up. */
// ugh
MString m;
m += ARGSTR(0);
m += ARGSTR(1);
RESULTSTR = dumb_string::copys(AString(m));
result->ty = TYPE::STRING;
}
return 0;
}
示例7: find
void cHTTPFormParser::OnPartData(const char * a_Data, size_t a_Size)
{
if (m_CurrentPartName.empty())
{
// Prologue, epilogue or invalid part
return;
}
if (m_CurrentPartFileName.empty())
{
// This is a variable, store it in the map
iterator itr = find(m_CurrentPartName);
if (itr == end())
{
(*this)[m_CurrentPartName] = AString(a_Data, a_Size);
}
else
{
itr->second.append(a_Data, a_Size);
}
}
else
{
// This is a file, pass it on through the callbacks
if (!m_FileHasBeenAnnounced)
{
m_Callbacks.OnFileStart(*this, m_CurrentPartFileName);
m_FileHasBeenAnnounced = true;
}
m_Callbacks.OnFileData(*this, a_Data, a_Size);
}
}
示例8: main
int main(int argc, char *argv[])
{
ASocketServer server;
AStdSocket socket(server);
if (argc < 2) {
fprintf(stderr, "cmdsender " VER_STRING "\n");
fprintf(stderr, "Usage: cmdsender <host> [<port>]\n");
exit(1);
}
if (socket.open("0.0.0.0",
0,
ASocketServer::Type_Datagram)) {
uint_t port = 1722;
if (argc >= 3) port = (uint_t)AString(argv[2]);
if (socket.setdatagramdestination(argv[1], port)) {
AString line;
while (line.ReadLn(Stdin) >= 0) {
if (socket.printf("%s\n", line.str()) <= 0) break;
}
}
socket.close();
}
return 0;
}
示例9: const_access
AString _DataProxy::operator[](const std::string& field) const {
if (HasField(field)) {
return const_access(const_access(data->values, category), field);
}
else {
return AString("");
}
}
示例10: vdf_fopen
long _cdecl vdf_fopen(const char* filename, long flags)
{
IfsBase* res = VdfsBase.OpenFile(filename, flags);
if(res)
return (int)res;
VdfsBase.SetLastError(AString(filename) + " file not found");
return -1;
}
示例11: AString
bool AMySQLServer::convert(MYSQL_ROW row, int index, int& result)
{
const char *p = row[index];
result = 0;
if (p)
result = AString(p).toInt();
return true;
}
示例12: convert
bool AMySQLServer::convert(MYSQL_ROW row, int index, u2& result)
{
const char *p = row[index];
result = 0x0;
if (p)
result = (u2)AString(row[index]).toU4();
return true;
}
示例13: Hash
AString* StringHashTable::HashString( const AChar* str ){
if(str==NULL)
return NULL;
AString* p = NULL;
m_CS.Enter();
p = Hash(AString(str));
m_CS.Leave();
return p;
}
示例14: AString
AString cPrefabPiecePool::GetMetadata(const AString & a_ParamName) const
{
auto itr = m_Metadata.find(a_ParamName);
if (itr == m_Metadata.end())
{
return AString();
}
return itr->second;
}
示例15: AString
// static
status_t M3UParser::parseByteRange(
const AString &line, uint64_t curOffset,
uint64_t *length, uint64_t *offset) {
ssize_t colonPos = line.find(":");
if (colonPos < 0) {
return ERROR_MALFORMED;
}
ssize_t atPos = line.find("@", colonPos + 1);
AString lenStr;
if (atPos < 0) {
lenStr = AString(line, colonPos + 1, line.size() - colonPos - 1);
} else {
lenStr = AString(line, colonPos + 1, atPos - colonPos - 1);
}
lenStr.trim();
const char *s = lenStr.c_str();
char *end;
*length = strtoull(s, &end, 10);
if (s == end || *end != '\0') {
return ERROR_MALFORMED;
}
if (atPos >= 0) {
AString offStr = AString(line, atPos + 1, line.size() - atPos - 1);
offStr.trim();
const char *s = offStr.c_str();
*offset = strtoull(s, &end, 10);
if (s == end || *end != '\0') {
return ERROR_MALFORMED;
}
} else {
*offset = curOffset;
}
return OK;
}