本文整理汇总了C++中AString::Empty方法的典型用法代码示例。如果您正苦于以下问题:C++ AString::Empty方法的具体用法?C++ AString::Empty怎么用?C++ AString::Empty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AString
的用法示例。
在下文中一共展示了AString::Empty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Clear
void Clear()
{
CID.Empty();
parentCID.Empty();
createType.Empty();
Extents.Clear();
}
示例2: ReadDataString
static bool ReadDataString(LPCWSTR fileName, LPCSTR startID,
LPCSTR endID, AString &stringResult)
{
stringResult.Empty();
NFile::NIO::CInFile inFile;
if (!inFile.Open(fileName))
return false;
const int kBufferSize = (1 << 12);
Byte buffer[kBufferSize];
int signatureStartSize = lstrlenA(startID);
int signatureEndSize = lstrlenA(endID);
UInt32 numBytesPrev = 0;
bool writeMode = false;
UInt64 posTotal = 0;
for (;;)
{
if (posTotal > (1 << 20))
return (stringResult.IsEmpty());
UInt32 numReadBytes = kBufferSize - numBytesPrev;
UInt32 processedSize;
if (!inFile.Read(buffer + numBytesPrev, numReadBytes, processedSize))
return false;
if (processedSize == 0)
return true;
UInt32 numBytesInBuffer = numBytesPrev + processedSize;
UInt32 pos = 0;
for (;;)
{
if (writeMode)
{
if (pos > numBytesInBuffer - signatureEndSize)
break;
if (memcmp(buffer + pos, endID, signatureEndSize) == 0)
return true;
char b = buffer[pos];
if (b == 0)
return false;
stringResult += b;
pos++;
}
else
{
if (pos > numBytesInBuffer - signatureStartSize)
break;
if (memcmp(buffer + pos, startID, signatureStartSize) == 0)
{
writeMode = true;
pos += signatureStartSize;
}
else
pos++;
}
}
numBytesPrev = numBytesInBuffer - pos;
posTotal += pos;
memmove(buffer, buffer + pos, numBytesPrev);
}
}
示例3: wcstombs
static void UnicodeStringToMultiByte2(AString &dest, const UString &src, UINT /* codePage */, char defaultChar, bool &defaultCharWasUsed)
{
dest.Empty();
defaultCharWasUsed = false;
if (src.IsEmpty())
return;
size_t limit = ((size_t)src.Len() + 1) * 6;
char *d = dest.GetBuf((unsigned)limit);
size_t len = wcstombs(d, src, limit);
if (len != (size_t)-1)
{
dest.ReleaseBuf_SetEnd((unsigned)len);
return;
}
{
const wchar_t *s = (const wchar_t *)src;
unsigned i;
for (i = 0;;)
{
wchar_t c = s[i];
if (c == 0)
break;
if (c >= 0x100)
{
c = defaultChar;
defaultCharWasUsed = true;
}
d[i++] = (char)c;
}
d[i] = 0;
dest.ReleaseBuf_SetLen(i);
}
}
示例4: ReadToString
void CStdInStream::ReadToString(AString &resultString)
{
resultString.Empty();
int c;
while((c = GetChar()) != EOF)
resultString += char(c);
}
示例5: GetCpuName
static void GetCpuName(AString &s)
{
s.Empty();
#ifdef MY_CPU_X86_OR_AMD64
{
#ifdef _7ZIP_ASM
Cx86cpuid cpuid;
if (x86cpuid_CheckAndRead(&cpuid))
{
x86cpuid_to_String(cpuid, s);
return;
}
#endif
#ifdef MY_CPU_AMD64
s = "x64";
#else
s = "x86";
#endif
}
#else
#ifdef MY_CPU_LE
s = "LE";
#elif defined(MY_CPU_BE)
s = "BE";
#else
#error ENDIANNESS
#endif
#endif
}
示例6: ReadString
void CInArchive::ReadString(unsigned size, AString &s)
{
s.Empty();
if (size != 0)
{
ReadBytes((Byte *)s.GetBuf(size), size);
s.ReleaseBuf_CalcLen(size);
}
}
示例7: Parse
bool CExtentInfo::Parse(const char *s)
{
NumSectors = 0;
StartSector = 0;
Access.Empty();
Type.Empty();
FileName.Empty();
s = GetNextWord(s, Access);
s = GetNextNumber(s, NumSectors);
if (!s)
return false;
s = GetNextWord(s, Type);
if (Type.IsEmpty())
return false;
SKIP_SPACES(s);
if (IsType_ZERO())
return (*s == 0);
if (*s != '\"')
return false;
s++;
{
const char *s2 = strchr(s, '\"');
if (!s2)
return false;
FileName.SetFrom(s, (unsigned)(s2 - s));
s = s2 + 1;
}
SKIP_SPACES(s);
if (*s == 0)
return true;
s = GetNextNumber(s, StartSector);
if (!s)
return false;
return true;
// SKIP_SPACES(s);
// return (*s == 0);
}
示例8: ReadFileName
void CInArchive::ReadFileName(unsigned size, AString &s)
{
if (size == 0)
{
s.Empty();
return;
}
char *p = s.GetBuffer(size);
SafeReadBytes(p, size);
p[size] = 0;
s.ReleaseBuffer();
}
示例9: UpdatePattern
bool ADVBPatterns::UpdatePattern(const AString& user, const AString& pattern, const AString& newpattern)
{
const ADVBConfig& config = ADVBConfig::Get();
ADVBLock lock("patterns");
bool changed = false;
if (user.Empty() || !(changed = UpdatePatternInFile(config.GetUserPatternsPattern().SearchAndReplace("{#?}", user), pattern, newpattern))) {
changed = UpdatePatternInFile(config.GetPatternsFile(), pattern, newpattern);
}
return changed;
}
示例10: ExtractInfoZipUnicodePath
bool CExtraSubBlock::ExtractInfoZipUnicodePath(AString &name, AString &res) const
{
res.Empty();
if (ID != NFileHeader::NExtraID::kInfoZipUnicodePath ||
(UInt32)Data.Size() < 5 ||
*(const Byte *)Data < 1 ||
GetUi32((const Byte *)Data + 1) != CrcCalc(name, name.Len()))
return false;
int size = (int)Data.Size() - sizeof(short) * 2 - sizeof(Byte);
if (size > 0)
{
char *p = res.GetBuffer(size + 1);
memcpy(p, (const Byte *)Data + sizeof(short) * 2 + sizeof(Byte), size);
p[size] = '\0';
res.ReleaseBuffer();
}
return true;
}
示例11: ParseDepedencyExpression
static bool ParseDepedencyExpression(const Byte *p, UInt32 size, AString &res)
{
res.Empty();
for (UInt32 i = 0; i < size;)
{
unsigned command = p[i++];
if (command > ARRAY_SIZE(kExpressionCommands))
return false;
res += kExpressionCommands[command];
if (command < 3)
{
if (i + kGuidSize > size)
return false;
res.Add_Space();
AddGuid(res, p + i, false);
i += kGuidSize;
}
res += "; ";
}
return true;
}
示例12: MyCPUID
static void x86cpuid_to_String(const Cx86cpuid &c, AString &s)
{
s.Empty();
UInt32 maxFunc2 = 0;
UInt32 t[3];
MyCPUID(0x80000000, &maxFunc2, &t[0], &t[1], &t[2]);
bool fullNameIsAvail = (maxFunc2 >= 0x80000004);
if (!fullNameIsAvail)
{
for (int i = 0; i < 3; i++)
PrintCpuChars(s, c.vendor[i]);
}
else
{
for (int i = 0; i < 3; i++)
{
UInt32 c[4] = { 0 };
MyCPUID(0x80000002 + i, &c[0], &c[1], &c[2], &c[3]);
for (int j = 0; j < 4; j++)
PrintCpuChars(s, c[j]);
}
}
s.Add_Space_if_NotEmpty();
{
char temp[32];
ConvertUInt32ToHex(c.ver, temp);
s += '(';
s += temp;
s += ')';
}
}
示例13: SplitString
static void SplitString(const AString &srcString, AStringVector &destStrings)
{
destStrings.Clear();
AString string;
int len = srcString.Length();
if (len == 0)
return;
for (int i = 0; i < len; i++)
{
char c = srcString[i];
if (c == '\n')
{
if (!string.IsEmpty())
{
destStrings.Add(string);
string.Empty();
}
}
else
string += c;
}
if (!string.IsEmpty())
destStrings.Add(string);
}
示例14: Clear
void Clear() { _fields.Clear(); LinesString.Empty(); }
示例15: WideCharToMultiByte
static void UnicodeStringToMultiByte2(AString &dest, const UString &src, UINT codePage, char defaultChar, bool &defaultCharWasUsed)
{
dest.Empty();
defaultCharWasUsed = false;
if (src.IsEmpty())
return;
{
/*
unsigned numRequiredBytes = src.Len() * 2;
char *d = dest.GetBuf(numRequiredBytes);
const wchar_t *s = (const wchar_t *)src;
unsigned i;
for (i = 0;;)
{
wchar_t c = s[i];
if (c >= 0x80 || c == 0)
break;
d[i++] = (char)c;
}
if (i != src.Len())
{
BOOL defUsed = FALSE;
defaultChar = defaultChar;
bool isUtf = (codePage == CP_UTF8 || codePage == CP_UTF7);
unsigned len = WideCharToMultiByte(codePage, 0, s + i, src.Len() - i,
d + i, numRequiredBytes + 1 - i,
(isUtf ? NULL : &defaultChar),
(isUtf ? NULL : &defUsed));
defaultCharWasUsed = (defUsed != FALSE);
if (len == 0)
throw 282229;
i += len;
}
d[i] = 0;
dest.ReleaseBuf_SetLen(i);
*/
/*
if (codePage != CP_UTF7)
{
const wchar_t *s = (const wchar_t *)src;
unsigned i;
for (i = 0;; i++)
{
wchar_t c = s[i];
if (c >= 0x80 || c == 0)
break;
}
if (s[i] == 0)
{
char *d = dest.GetBuf(src.Len());
for (i = 0;;)
{
wchar_t c = s[i];
if (c == 0)
break;
d[i++] = (char)c;
}
d[i] = 0;
dest.ReleaseBuf_SetLen(i);
return;
}
}
*/
unsigned len = WideCharToMultiByte(codePage, 0, src, src.Len(), NULL, 0, NULL, NULL);
if (len == 0)
{
if (GetLastError() != 0)
throw 282228;
}
else
{
BOOL defUsed = FALSE;
bool isUtf = (codePage == CP_UTF8 || codePage == CP_UTF7);
// defaultChar = defaultChar;
len = WideCharToMultiByte(codePage, 0, src, src.Len(),
dest.GetBuf(len), len,
(isUtf ? NULL : &defaultChar),
(isUtf ? NULL : &defUsed)
);
if (!isUtf)
defaultCharWasUsed = (defUsed != FALSE);
if (len == 0)
throw 282228;
dest.ReleaseBuf_SetEnd(len);
}
}
}