本文整理汇总了C++中UnicodeString::SetLength方法的典型用法代码示例。如果您正苦于以下问题:C++ UnicodeString::SetLength方法的具体用法?C++ UnicodeString::SetLength怎么用?C++ UnicodeString::SetLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnicodeString
的用法示例。
在下文中一共展示了UnicodeString::SetLength方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExtractName
UnicodeString TStrings::ExtractName(const UnicodeString & S) const
{
UnicodeString Result = S;
intptr_t P = ::AnsiPos(Result, L'=');
if (P > 0)
{
Result.SetLength(P - 1);
}
else
{
Result.SetLength(0);
}
return Result;
}
示例2: GetTextStr
UnicodeString TStrings::GetTextStr() const
{
UnicodeString Result;
intptr_t Count = GetCount();
intptr_t Size = 0;
UnicodeString LB = sLineBreak;
for (intptr_t I = 0; I < Count; I++)
{
Size += GetString(I).Length() + LB.Length();
}
Result.SetLength(Size);
wchar_t * P = const_cast<wchar_t *>(Result.c_str());
for (intptr_t I = 0; I < Count; I++)
{
UnicodeString S = GetString(I);
intptr_t L = S.Length() * sizeof(wchar_t);
if (L != 0)
{
memmove(P, S.c_str(), L);
P += S.Length();
}
L = LB.Length() * sizeof(wchar_t);
if (L != 0)
{
memmove(P, LB.c_str(), L);
P += LB.Length();
}
}
return Result;
}
示例3: SetTextStr
void TStrings::SetTextStr(const UnicodeString & Text)
{
BeginUpdate();
SCOPE_EXIT
{
EndUpdate();
};
{
Clear();
const wchar_t * P = Text.c_str();
if (P != nullptr)
{
while (*P != 0x00)
{
const wchar_t * Start = P;
while (!((*P == 0x00) || (*P == 0x0A) || (*P == 0x0D)))
{
P++;
}
UnicodeString S;
S.SetLength(P - Start);
memmove(const_cast<wchar_t *>(S.c_str()), Start, (P - Start) * sizeof(wchar_t));
Add(S);
if (*P == 0x0D) { P++; }
if (*P == 0x0A) { P++; }
}
}
}
}
示例4: MaskFileName
//---------------------------------------------------------------------------
UnicodeString MaskFileName(const UnicodeString & FileName, const UnicodeString & Mask)
{
UnicodeString Result = FileName;
if (IsEffectiveFileNameMask(Mask))
{
bool Masked;
intptr_t P = Mask.LastDelimiter(L".");
if (P > 0)
{
intptr_t P2 = Result.LastDelimiter(".");
// only dot at beginning of file name is not considered as
// name/ext separator
UnicodeString FileExt = P2 > 1 ?
Result.SubString(P2 + 1, Result.Length() - P2) : UnicodeString();
FileExt = MaskFilePart(FileExt, Mask.SubString(P + 1, Mask.Length() - P), Masked);
if (P2 > 1)
{
Result.SetLength(P2 - 1);
}
Result = MaskFilePart(Result, Mask.SubString(1, P - 1), Masked);
if (!FileExt.IsEmpty())
{
Result += L"." + FileExt;
}
}
else
{
Result = MaskFilePart(Result, Mask, Masked);
}
}
return Result;
}
示例5: MB2W
/**
* @brief Encoding multibyte to wide std::string
* @param $src source char *
* @param $cp code page
* @return UnicodeString
*/
UnicodeString MB2W(const char * src, const UINT cp)
{
// assert(src);
if (!src || !*src)
{
return UnicodeString(L"");
}
intptr_t reqLength = MultiByteToWideChar(cp, 0, src, -1, nullptr, 0);
UnicodeString Result;
if (reqLength)
{
Result.SetLength(reqLength);
MultiByteToWideChar(cp, 0, src, -1, const_cast<LPWSTR>(Result.c_str()), static_cast<int>(reqLength));
Result.SetLength(Result.Length() - 1); //remove NULL character
}
return Result; // .c_str();
}
示例6: GetPersonalFolder
UnicodeString GetPersonalFolder()
{
UnicodeString Result;
SpecialFolderLocation(CSIDL_PERSONAL, Result);
if (IsWine())
{
UnicodeString WineHostHome;
int Len = ::GetEnvironmentVariable(L"WINE_HOST_HOME", nullptr, 0);
if (Len > 0)
{
WineHostHome.SetLength(Len - 1);
::GetEnvironmentVariable(L"WINE_HOST_HOME", const_cast<LPWSTR>(WineHostHome.c_str()), Len);
}
if (!WineHostHome.IsEmpty())
{
UnicodeString WineHome = L"Z:" + core::ToUnixPath(WineHostHome);
if (::DirectoryExists(WineHome))
{
Result = WineHome;
}
}
else
{
// Should we use WinAPI GetUserName() instead?
UnicodeString UserName;
int Len = ::GetEnvironmentVariable(L"USERNAME", nullptr, 0);
if (Len > 0)
{
UserName.SetLength(Len - 1);
::GetEnvironmentVariable(L"USERNAME", const_cast<LPWSTR>(UserName.c_str()), Len);
}
if (!UserName.IsEmpty())
{
UnicodeString WineHome = L"Z:\\home\\" + UserName;
if (::DirectoryExists(WineHome))
{
Result = WineHome;
}
}
}
}
return Result;
}
示例7: ExcludeTrailingBackslash
UnicodeString ExcludeTrailingBackslash(const UnicodeString & Str)
{
UnicodeString Result = Str;
if ((Str.Length() > 0) && ((Str[Str.Length()] == L'/') ||
(Str[Str.Length()] == L'\\')))
{
Result.SetLength(Result.Length() - 1);
}
return Result;
}
示例8: TrimVersion
//---------------------------------------------------------------------------
UnicodeString TConfiguration::TrimVersion(const UnicodeString & Version) const
{
UnicodeString Result = Version;
while ((Result.Pos(L".") != Result.LastDelimiter(L".")) &&
(Result.SubString(Result.Length() - 1, 2) == L".0"))
{
Result.SetLength(Result.Length() - 2);
}
return Result;
}
示例9: StringOfChar
UnicodeString StringOfChar(const wchar_t Ch, intptr_t Len)
{
UnicodeString Result;
if (Len < 0) Len = 0;
Result.SetLength(Len);
for (intptr_t I = 1; I <= Len; I++)
{
Result[I] = Ch;
}
return Result;
}
示例10: Format
UnicodeString Format(const wchar_t * Format, va_list Args)
{
UnicodeString Result;
if (Format && *Format)
{
intptr_t Len = _vscwprintf(Format, Args);
Result.SetLength(Len + 1);
// vswprintf(Buf, Len + 1, Format, args);
vswprintf(const_cast<wchar_t *>(Result.c_str()), Len + 1, Format, Args);
}
return Result.c_str();
}
示例11: TrimRight
UnicodeString TrimRight(const UnicodeString & Str)
{
UnicodeString Result = Str;
intptr_t Len = Result.Length();
while (Len > 0 &&
((Result[Len] == L' ') || (Result[Len] == L'\n')))
{
Len--;
}
Result.SetLength(Len);
return Result;
}
示例12: ComposeMaskStr
//---------------------------------------------------------------------------
UnicodeString TFileMasks::ComposeMaskStr(
TStrings * MasksStr, bool Directory)
{
UnicodeString Result;
UnicodeString ResultNoDirMask;
for (intptr_t I = 0; I < MasksStr->GetCount(); ++I)
{
UnicodeString Str = MasksStr->GetString(I).Trim();
if (!Str.IsEmpty())
{
for (intptr_t P = 1; P <= Str.Length(); P++)
{
if (Str.IsDelimiter(AllFileMasksDelimiters, P))
{
Str.Insert(Str[P], P);
P++;
}
}
UnicodeString StrNoDirMask;
if (Directory)
{
StrNoDirMask = Str;
Str = MakeDirectoryMask(Str);
}
else
{
while (Str.IsDelimiter(DirectoryMaskDelimiters, Str.Length()))
{
Str.SetLength(Str.Length() - 1);
}
StrNoDirMask = Str;
}
AddToList(Result, Str, FileMasksDelimiterStr);
AddToList(ResultNoDirMask, StrNoDirMask, FileMasksDelimiterStr);
}
}
// For directories, the above will add slash ay the end of masks,
// breaking size and time masks and thus circumverting their validation.
// This performes as hoc validation to cover the scenario.
// For files this makes no difference, but no harm either
TFileMasks Temp(Directory ? 1 : 0);
Temp = ResultNoDirMask;
return Result;
}
示例13: GetKeyNames
void TRegistry::GetKeyNames(TStrings * Strings) const
{
Strings->Clear();
TRegKeyInfo Info;
UnicodeString S;
if (GetKeyInfo(Info))
{
S.SetLength(static_cast<intptr_t>(Info.MaxSubKeyLen) + 1);
for (DWORD I = 0; I < Info.NumSubKeys; I++)
{
DWORD Len = Info.MaxSubKeyLen + 1;
RegEnumKeyEx(GetCurrentKey(), static_cast<DWORD>(I), &S[1], &Len, nullptr, nullptr, nullptr, nullptr);
Strings->Add(S.c_str());
}
}
}
示例14: GetValueNames
void TRegistry::GetValueNames(TStrings * Strings) const
{
Strings->Clear();
TRegKeyInfo Info;
UnicodeString S;
if (GetKeyInfo(Info))
{
S.SetLength(Info.MaxValueLen + 1);
for (DWORD I = 0; I < Info.NumValues; I++)
{
DWORD Len = Info.MaxValueLen + 1;
RegEnumValue(GetCurrentKey(), I, &S[1], &Len, nullptr, nullptr, nullptr, nullptr);
Strings->Add(S.c_str());
}
}
}
示例15: GetDelimitedText
UnicodeString TStrings::GetDelimitedText() const
{
UnicodeString Result;
intptr_t Count = GetCount();
if ((Count == 1) && GetString(0).IsEmpty())
{
Result = GetQuoteChar() + GetQuoteChar();
}
else
{
for (intptr_t I = 0; I < GetCount(); I++)
{
UnicodeString line = GetString(I);
Result += GetQuoteChar() + line + GetQuoteChar() + GetDelimiter();
}
if (Result.Length() > 0)
Result.SetLength(Result.Length() - 1);
}
return Result;
}