本文整理汇总了C++中AString::end方法的典型用法代码示例。如果您正苦于以下问题:C++ AString::end方法的具体用法?C++ AString::end怎么用?C++ AString::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AString
的用法示例。
在下文中一共展示了AString::end方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessLine
void InFtpAnalyzerStream::ProcessLine(const AString& line) {
FtpAnalyzer *fa = (FtpAnalyzer*)m_analyzer;
cmatch m;
if (regex_search((const char*)line.begin(), (const char*)line.end(), m, s_reFtpResponse)) {
int code = atoi(String(m[1]));
switch (code)
{
case 220:
{
ASCIIEncoding enc;
String s = enc.GetChars(line);
vector<String> vec = s.Split();
if (vec.size() >= 2 && vec[1].Find(".") != -1)
fa->ServerName = vec[1];
}
break;
case 227:
fa->PrepareEndpoint(ASCIIEncoding().GetChars(line));
break;
case 230:
if (fa->UserName!="anonymous" && !fa->m_user)
(fa->m_user=FtpUser::FindByServerLogin(fa->m_ci->DstEndPoint, fa->UserName))->SetPassword(fa->Password);
break;
}
}
}
示例2: ReloadRecipes
void cBrewingRecipes::ReloadRecipes(void)
{
ClearRecipes();
LOGD("Loading brewing recipes...");
std::ifstream f(BREWING_RECIPE_FILE, std::ios::in);
if (!f.good())
{
LOG("Could not open the brewing recipes file \"%s\". No brewing recipes are available.", BREWING_RECIPE_FILE);
return;
}
unsigned int LineNum = 0;
AString ParsingLine;
while (std::getline(f, ParsingLine))
{
LineNum++;
// Remove comments from the line:
size_t FirstCommentSymbol = ParsingLine.find('#');
if (FirstCommentSymbol != AString::npos)
{
ParsingLine.erase(ParsingLine.begin() += static_cast<long>(FirstCommentSymbol), ParsingLine.end());
}
if (ParsingLine.empty())
{
continue;
}
AddRecipeFromLine(ParsingLine, LineNum);
} // while (getline(ParsingLine))
LOG("Loaded " SIZE_T_FMT " brewing recipes", m_pState->Recipes.size());
}
示例3: Converted
void cWSSCompact::cPAKFile::UpdateChunk2To3()
{
int Offset = 0;
AString NewDataContents;
int ChunksConverted = 0;
for (sChunkHeaders::iterator itr = m_ChunkHeaders.begin(); itr != m_ChunkHeaders.end(); ++itr)
{
sChunkHeader * Header = *itr;
if( ChunksConverted % 32 == 0 )
{
LOGINFO("Updating \"%s\" version 2 to version 3: " SIZE_T_FMT " %%", m_FileName.c_str(), (ChunksConverted * 100) / m_ChunkHeaders.size() );
}
ChunksConverted++;
AString Data;
int UncompressedSize = Header->m_UncompressedSize;
Data.assign(m_DataContents, Offset, Header->m_CompressedSize);
Offset += Header->m_CompressedSize;
// Crude data integrity check:
const int ExpectedSize = (16*256*16)*2 + (16*256*16)/2; // For version 2
if (UncompressedSize < ExpectedSize)
{
LOGWARNING("Chunk [%d, %d] has too short decompressed data (%d bytes out of %d needed), erasing",
Header->m_ChunkX, Header->m_ChunkZ,
UncompressedSize, ExpectedSize
);
Offset += Header->m_CompressedSize;
continue;
}
// Decompress the data:
AString UncompressedData;
{
int errorcode = UncompressString(Data.data(), Data.size(), UncompressedData, UncompressedSize);
if (errorcode != Z_OK)
{
LOGERROR("Error %d decompressing data for chunk [%d, %d]",
errorcode,
Header->m_ChunkX, Header->m_ChunkZ
);
Offset += Header->m_CompressedSize;
continue;
}
}
if (UncompressedSize != (int)UncompressedData.size())
{
LOGWARNING("Uncompressed data size differs (exp %d bytes, got " SIZE_T_FMT ") for chunk [%d, %d]",
UncompressedSize, UncompressedData.size(),
Header->m_ChunkX, Header->m_ChunkZ
);
Offset += Header->m_CompressedSize;
continue;
}
char ConvertedData[ExpectedSize];
memset(ConvertedData, 0, ExpectedSize);
// Cannot use cChunk::MakeIndex because it might change again?????????
// For compatibility, use what we know is current
#define MAKE_3_INDEX( x, y, z ) ( x + (z * 16) + (y * 16 * 16) )
unsigned int InChunkOffset = 0;
for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) for( int y = 0; y < 256; ++y ) // YZX Loop order is important, in 1.1 Y was first then Z then X
{
ConvertedData[ MAKE_3_INDEX(x, y, z) ] = UncompressedData[InChunkOffset];
++InChunkOffset;
} // for y, z, x
unsigned int index2 = 0;
for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) for( int y = 0; y < 256; ++y )
{
ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4) ) & 0x0f ) << ((x&1)*4);
++index2;
}
InChunkOffset += index2 / 2;
index2 = 0;
for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) for( int y = 0; y < 256; ++y )
{
ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4) ) & 0x0f ) << ((x&1)*4);
++index2;
}
InChunkOffset += index2 / 2;
index2 = 0;
for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) for( int y = 0; y < 256; ++y )
{
ConvertedData[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4) ) & 0x0f ) << ((x&1)*4);
++index2;
}
InChunkOffset += index2 / 2;
AString Converted(ConvertedData, ExpectedSize);
// Add JSON data afterwards
if (UncompressedData.size() > InChunkOffset)
//.........这里部分代码省略.........
示例4: ReloadRecipes
void cFurnaceRecipe::ReloadRecipes(void)
{
ClearRecipes();
LOGD("Loading furnace recipes...");
std::ifstream f(FURNACE_RECIPE_FILE, std::ios::in);
if (!f.good())
{
LOG("Could not open the furnace recipes file \"%s\". No furnace recipes are available.", FURNACE_RECIPE_FILE);
return;
}
unsigned int LineNum = 0;
AString ParsingLine;
while (std::getline(f, ParsingLine))
{
LineNum++;
if (ParsingLine.empty())
{
continue;
}
// Remove comments from the line:
size_t FirstCommentSymbol = ParsingLine.find('#');
if ((FirstCommentSymbol != AString::npos) && (FirstCommentSymbol != 0))
{
ParsingLine.erase(ParsingLine.begin() + static_cast<const long>(FirstCommentSymbol), ParsingLine.end());
}
switch (ParsingLine[0])
{
case '#':
{
// Comment
break;
}
case '!':
{
AddFuelFromLine(ParsingLine, LineNum);
break;
}
default:
{
AddRecipeFromLine(ParsingLine, LineNum);
break;
}
} // switch (ParsingLine[0])
} // while (getline(ParsingLine))
LOG("Loaded " SIZE_T_FMT " furnace recipes and " SIZE_T_FMT " fuels", m_pState->Recipes.size(), m_pState->Fuel.size());
}
示例5: itemdb_readdb
bool itemdb_readdb(ZString filename)
{
bool rv = true;
int ln = 0, lines = 0;
{
io::ReadFile in(filename);
if (!in.is_open())
{
PRINTF("can't read %s\n"_fmt, filename);
return false;
}
lines = 0;
AString line;
while (in.getline(line))
{
lines++;
if (is_comment(line))
continue;
// a line is 17 normal fields followed by 2 {} fields
// the fields are separated by ", *", but there may be ,
// in the {}.
auto it = std::find(line.begin(), line.end(), '{');
XString main_part = line.xislice_h(it).rstrip();
// According to the code, tail_part may be empty. See later.
ZString tail_part = line.xislice_t(it);
XString unused_slot_count;
item_data idv {};
if (!extract(
main_part, record<','>(
&idv.nameid,
lstripping(&idv.name),
lstripping(&idv.jname),
lstripping(&idv.type),
lstripping(&idv.value_buy),
lstripping(&idv.value_sell),
lstripping(&idv.weight),
lstripping(&idv.atk),
lstripping(&idv.def),
lstripping(&idv.range),
lstripping(&idv.magic_bonus),
lstripping(&unused_slot_count),
lstripping(&idv.sex),
lstripping(&idv.equip),
lstripping(&idv.wlv),
lstripping(&idv.elv),
lstripping(&idv.look)
)
)
)
{
PRINTF("%s:%d: error: bad item line: %s\n"_fmt,
filename, lines, line);
rv = false;
continue;
}
ln++;
Borrowed<struct item_data> id = itemdb_search(idv.nameid);
*id = std::move(idv);
if (id->value_buy == 0 && id->value_sell == 0)
{
}
else if (id->value_buy == 0)
{
id->value_buy = id->value_sell * 2;
}
else if (id->value_sell == 0)
{
id->value_sell = id->value_buy / 2;
}
id->use_script = nullptr;
id->equip_script = nullptr;
if (!tail_part)
continue;
id->use_script = parse_script(tail_part, lines, true);
tail_part = tail_part.xislice_t(std::find(tail_part.begin() + 1, tail_part.end(), '{'));
if (!tail_part)
continue;
id->equip_script = parse_script(tail_part, lines, true);
}
PRINTF("read %s done (count=%d)\n"_fmt, filename, ln);
}
return rv;
}