本文整理汇总了C++中UnicodeString::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ UnicodeString::c_str方法的具体用法?C++ UnicodeString::c_str怎么用?C++ UnicodeString::c_str使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnicodeString
的用法示例。
在下文中一共展示了UnicodeString::c_str方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PatternLen
//---------------------------------------------------------------------------
intptr_t TInteractiveCustomCommand::PatternLen(const UnicodeString & Command, intptr_t Index)
{
intptr_t Len = 0;
switch (Command[Index + 1])
{
case L'?':
{
const wchar_t * Ptr = Command.c_str() + Index - 1;
const wchar_t * PatternEnd = wcschr(Ptr + 1, L'!');
if (PatternEnd == nullptr)
{
throw Exception(FMTLOAD(CUSTOM_COMMAND_UNTERMINATED, Command[Index + 1], Index));
}
Len = PatternEnd - Ptr + 1;
}
break;
case L'`':
{
const wchar_t * Ptr = Command.c_str() + Index - 1;
const wchar_t * PatternEnd = wcschr(Ptr + 2, L'`');
if (PatternEnd == nullptr)
{
throw Exception(FMTLOAD(CUSTOM_COMMAND_UNTERMINATED, Command[Index + 1], Index));
}
Len = PatternEnd - Ptr + 1;
}
break;
default:
Len = FChildCustomCommand->PatternLen(Command, Index);
break;
}
return Len;
}
示例2: TReplaceFlags
BOOST_FIXTURE_TEST_CASE(test14, base_fixture_t)
{
{
UnicodeString str = ::StringReplace(L"AA", L"A", L"B", TReplaceFlags() << rfReplaceAll);
BOOST_CHECK_EQUAL(W2MB(str.c_str()).c_str(), "BB");
}
{
UnicodeString str = ::AnsiReplaceStr(L"AA", L"A", L"B");
BOOST_CHECK_EQUAL(W2MB(str.c_str()).c_str(), "BB");
}
{
UnicodeString str = L"ABC";
BOOST_CHECK_EQUAL(::Pos(str, L"DEF"), 0);
BOOST_CHECK_EQUAL(::Pos(str, L"AB"), 1);
BOOST_CHECK_EQUAL(::Pos(str, L"BC"), 2);
BOOST_CHECK_EQUAL(::AnsiPos(str, 'D'), 0);
BOOST_CHECK_EQUAL(::AnsiPos(str, 'A'), 1);
BOOST_CHECK_EQUAL(::AnsiPos(str, 'B'), 2);
}
{
UnicodeString str = ::LowerCase(L"AA");
BOOST_CHECK_EQUAL(W2MB(str.c_str()).c_str(), "aa");
}
{
UnicodeString str = ::UpperCase(L"aa");
BOOST_CHECK_EQUAL(W2MB(str.c_str()).c_str(), "AA");
}
{
UnicodeString str = ::Trim(L" aa ");
BOOST_CHECK_EQUAL(W2MB(str.c_str()).c_str(), "aa");
}
}
示例3: 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;
}
示例4: 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++; }
}
}
}
}
示例5: OpenKey
bool TRegistry::OpenKey(const UnicodeString & Key, bool CanCreate)
{
bool Result = false;
UnicodeString S = Key;
bool Relative = Classes::IsRelative(S);
// if (!Relative) S.erase(0, 1); // Delete(S, 1, 1);
HKEY TempKey = 0;
if (!CanCreate || S.IsEmpty())
{
Result = RegOpenKeyEx(GetBaseKey(Relative), S.c_str(), 0,
FAccess, &TempKey) == ERROR_SUCCESS;
}
else
{
Result = RegCreateKeyEx(GetBaseKey(Relative), S.c_str(), 0, nullptr,
REG_OPTION_NON_VOLATILE, FAccess, nullptr, &TempKey, nullptr) == ERROR_SUCCESS;
}
if (Result)
{
if ((GetCurrentKey() != 0) && Relative)
{
S = FCurrentPath + L'\\' + S;
}
ChangeKey(TempKey, S);
}
return Result;
}
示例6: 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();
}
示例7: rand
BOOST_FIXTURE_TEST_CASE(test21, base_fixture_t)
{
BOOST_TEST_MESSAGE("RAND_MAX = " << RAND_MAX);
for (int i = 0; i < 10; i++)
{
BOOST_TEST_MESSAGE("rand() = " << rand());
BOOST_TEST_MESSAGE("random(256) = " << random(256));
}
UnicodeString enc = ::EncryptPassword(L"1234ABC", L"234556");
BOOST_TEST_MESSAGE("enc = " << W2MB(enc.c_str()).c_str());
UnicodeString dec = ::DecryptPassword(enc, L"234556");
BOOST_TEST_MESSAGE("dec = " << W2MB(dec.c_str()).c_str());
BOOST_CHECK(dec == L"1234ABC");
}
示例8: ItemsFormatString
UnicodeString ItemsFormatString(const UnicodeString & SingleItemFormat,
const UnicodeString & MultiItemsFormat, intptr_t Count, const UnicodeString & FirstItem)
{
UnicodeString Result;
if (Count == 1)
{
Result = FORMAT(SingleItemFormat.c_str(), FirstItem.c_str());
}
else
{
Result = FORMAT(MultiItemsFormat.c_str(), Count);
}
return Result;
}
示例9: ExpandFileName
UnicodeString ExpandFileName(const UnicodeString & FileName)
{
UnicodeString Result;
UnicodeString Buf(MAX_PATH, 0);
intptr_t Size = GetFullPathNameW(FileName.c_str(), static_cast<DWORD>(Buf.Length() - 1),
reinterpret_cast<LPWSTR>(const_cast<wchar_t *>(Buf.c_str())), nullptr);
if (Size > Buf.Length())
{
Buf.SetLength(Size);
Size = ::GetFullPathNameW(FileName.c_str(), static_cast<DWORD>(Buf.Length() - 1),
reinterpret_cast<LPWSTR>(const_cast<wchar_t *>(Buf.c_str())), nullptr);
}
return UnicodeString(Buf.c_str(), Size);
}
示例10: GridSetEditText
//---------------------------------------------------------------------------
void __fastcall TMediaDlgBox::GridSetEditText(TObject *Sender, int ACol,
int ARow, const UnicodeString Value)
{
double d;
if( Grid->EditorMode == TRUE ) return;
if( ARow ){
ARow--;
switch(ACol){
case 1: // DIE(導)
if( Calc(d, AnsiString(Value).c_str()) == TRUE){
lenv.rel[ARow] = d;
GridNewLine(ARow);
}
break;
case 2: // COND(誘電)
if( Calc(d, AnsiString(Value).c_str()) == TRUE){
lenv.cond[ARow] = d/1000.0;
GridNewLine(ARow);
}
break;
case 3: // XorR(m)
if( *Value.c_str() ){
if( Calc(d, AnsiString(Value).c_str()) == TRUE){
lenv.intval[ARow] = d;
GridNewLine(ARow);
}
}
else if( ARow >= (lenv.mmax - 1) ){
lenv.intval[ARow] = NULLV;
GridNewLine(ARow);
}
break;
case 4: // H(m)
if( *Value.c_str() ){
if( Calc(d, AnsiString(Value).c_str()) == TRUE){
lenv.height[ARow] = d;
GridNewLine(ARow);
}
}
else if( ARow >= (lenv.mmax - 1) ){
lenv.height[ARow] = NULLV;
GridNewLine(ARow);
}
break;
}
}
}
示例11: tokenize
static void tokenize(const UnicodeString & str, rde::vector<UnicodeString> & tokens,
const UnicodeString & delimiters = L" ", const bool trimEmpty = false)
{
intptr_t lastPos = 0;
while (true)
{
intptr_t pos = str.FindFirstOf(delimiters.c_str(), lastPos);
if (pos == NPOS)
{
pos = str.Length();
if (pos != lastPos || !trimEmpty)
{
tokens.push_back(
UnicodeString(str.data() + lastPos, pos - lastPos));
}
break;
}
else
{
if (pos != lastPos || !trimEmpty)
{
tokens.push_back(
UnicodeString(str.data() + lastPos, pos - lastPos));
}
}
lastPos = pos + 1;
}
}
示例12:
BOOST_FIXTURE_TEST_CASE(test19, base_fixture_t)
{
UnicodeString ProgramsFolder;
::SpecialFolderLocation(CSIDL_PROGRAM_FILES, ProgramsFolder);
BOOST_TEST_MESSAGE("ProgramsFolder = " << W2MB(ProgramsFolder.c_str()).c_str());
BOOST_CHECK(ProgramsFolder.Length() > 0);
}
示例13: QueryValue
bool __fastcall TVersionInfo::QueryValue(const UnicodeString& SubBlock, LPVOID& Buffer,
unsigned int& BufferLength) const
{
assert(FFileVersionInfoData != NULL);
return VerQueryValue(FFileVersionInfoData, SubBlock.c_str(), &Buffer, &BufferLength);
}
示例14: ValidateName
//---------------------------------------------------------------------
void TCopyParamList::ValidateName(const UnicodeString & Name)
{
if (Name.LastDelimiter(FInvalidChars) > 0)
{
throw Exception(FMTLOAD(ITEM_NAME_INVALID, Name.c_str(), FInvalidChars.c_str()));
}
}
示例15: UpperCase
UnicodeString UpperCase(const UnicodeString & Str)
{
std::wstring Result(Str.c_str(), Str.Length());
// Result.SetLength(Str.Length());
std::transform(Result.begin(), Result.end(), Result.begin(), ::toupper);
return Result;
}