本文整理汇总了C++中UString类的典型用法代码示例。如果您正苦于以下问题:C++ UString类的具体用法?C++ UString怎么用?C++ UString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddNewLineString
static void AddNewLineString(UString &s, const UString &m)
{
s += m;
s.Add_LF();
}
示例2: InitName
bool InitName(const UString &name, bool newStyle)
{
_first = true;
_newStyle = newStyle;
int dotPos = name.ReverseFind('.');
UString basePart = name;
if (dotPos >= 0)
{
UString ext = name.Mid(dotPos + 1);
if (ext.CompareNoCase(L"rar") == 0)
{
_afterPart = name.Mid(dotPos);
basePart = name.Left(dotPos);
}
else if (ext.CompareNoCase(L"exe") == 0)
{
_afterPart = L".rar";
basePart = name.Left(dotPos);
}
else if (!_newStyle)
{
if (ext.CompareNoCase(L"000") == 0 ||
ext.CompareNoCase(L"001") == 0 ||
ext.CompareNoCase(L"r00") == 0 ||
ext.CompareNoCase(L"r01") == 0)
{
_afterPart.Empty();
_first = false;
_changedPart = ext;
_unchangedPart = name.Left(dotPos + 1);
return true;
}
}
}
if (!_newStyle)
{
_afterPart.Empty();
_unchangedPart = basePart + UString(L".");
_changedPart = L"r00";
return true;
}
int numLetters = 1;
if (basePart.Right(numLetters) == L"1" || basePart.Right(numLetters) == L"0")
{
while (numLetters < basePart.Length())
{
if (basePart[basePart.Length() - numLetters - 1] != '0')
break;
numLetters++;
}
}
else
return false;
_unchangedPart = basePart.Left(basePart.Length() - numLetters);
_changedPart = basePart.Right(numLetters);
return true;
}
示例3: msg_Dbg
CtrlGeneric *TopWindow::findHitControl( int xPos, int yPos )
{
if( m_pActiveLayout == NULL )
{
return NULL;
}
// Get the controls in the active layout
const list<LayeredControl> &ctrlList = m_pActiveLayout->getControlList();
list<LayeredControl>::const_reverse_iterator iter;
// New control hit by the mouse
CtrlGeneric *pNewHitControl = NULL;
// Loop on the control list to find the uppest hit control
for( iter = ctrlList.rbegin(); iter != ctrlList.rend(); ++iter )
{
// Get the position of the control in the layout
const Position *pos = (*iter).m_pControl->getPosition();
if( pos != NULL )
{
// Compute the coordinates of the mouse relative to the control
int xRel = xPos - pos->getLeft();
int yRel = yPos - pos->getTop();
CtrlGeneric *pCtrl = (*iter).m_pControl;
// Control hit ?
if( pCtrl->isVisible() && pCtrl->mouseOver( xRel, yRel ) )
{
pNewHitControl = (*iter).m_pControl;
break;
}
}
else
{
msg_Dbg( getIntf(), "control at NULL position" );
}
}
// If the hit control has just been entered, send it an enter event
if( pNewHitControl && (pNewHitControl != m_pLastHitControl) )
{
// Don't send the event if another control captured the mouse
if( !m_pCapturingControl || (m_pCapturingControl == pNewHitControl ) )
{
EvtEnter evt( getIntf() );
pNewHitControl->handleEvent( evt );
if( !m_pCapturingControl )
{
// Show the tooltip
m_rWindowManager.hideTooltip();
UString tipText = pNewHitControl->getTooltipText();
if( tipText.length() > 0 )
{
// Set the tooltip text variable
VarManager *pVarManager = VarManager::instance( getIntf() );
pVarManager->getTooltipText().set( tipText );
m_rWindowManager.showTooltip();
}
}
}
}
return pNewHitControl;
}
示例4: isDirectory
bool FilePath::isDirectory(const UString &p) {
return (exists(p.c_str()) && is_directory(p.c_str()));
}
示例5: getExtension
UString FilePath::getExtension(const UString &p) {
path file(p.c_str());
return file.extension();
}
示例6: escapeStringLiteral
UString FilePath::escapeStringLiteral(const UString &str) {
const boost::regex esc("[\\^\\.\\$\\|\\(\\)\\[\\]\\*\\+\\?\\/\\\\]");
const std::string rep("\\\\\\1&");
return boost::regex_replace(std::string(str.c_str()), esc, rep, boost::match_default | boost::format_sed);
}
示例7: LangString
HRESULT CPanel::CopyTo(CCopyToOptions &options, const CRecordVector<UInt32> &indices,
UStringVector *messages,
bool &usePassword, UString &password)
{
CMyComPtr<IFolderOperations> folderOperations;
if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
{
UString errorMessage = LangString(IDS_OPERATION_IS_NOT_SUPPORTED);
if (options.showErrorMessages)
MessageBox(errorMessage);
else if (messages != 0)
messages->Add(errorMessage);
return E_FAIL;
}
HRESULT res;
{
CPanelCopyThread extracter;
extracter.ExtractCallbackSpec = new CExtractCallbackImp;
extracter.ExtractCallback = extracter.ExtractCallbackSpec;
extracter.options = &options;
extracter.ExtractCallbackSpec->ProgressDialog = &extracter.ProgressDialog;
extracter.ProgressDialog.CompressingMode = false;
extracter.ExtractCallbackSpec->StreamMode = options.streamMode;
#ifdef EXTERNAL_CODECS
CExternalCodecs __externalCodecs;
#else
CMyComPtr<IUnknown> compressCodecsInfo;
#endif
if (indices.Size() == 1)
extracter.FirstFilePath = GetItemRelPath(indices[0]);
if (options.VirtFileSystem)
{
extracter.ExtractCallbackSpec->VirtFileSystem = options.VirtFileSystem;
extracter.ExtractCallbackSpec->VirtFileSystemSpec = options.VirtFileSystemSpec;
}
extracter.ExtractCallbackSpec->ProcessAltStreams = options.includeAltStreams;
if (!options.hashMethods.IsEmpty())
{
{
CCodecs *codecs = new CCodecs;
ThrowException_if_Error(codecs->Load());
#ifdef EXTERNAL_CODECS
__externalCodecs.GetCodecs = codecs;
__externalCodecs.GetHashers = codecs;
ThrowException_if_Error(__externalCodecs.LoadCodecs());
#else
compressCodecsInfo = codecs;
#endif
}
extracter.Hash.SetMethods(EXTERNAL_CODECS_VARS options.hashMethods);
extracter.ExtractCallbackSpec->SetHashMethods(&extracter.Hash);
}
else if (options.testMode)
{
extracter.ExtractCallbackSpec->SetHashCalc(&extracter.Hash);
}
extracter.Hash.Init();
UString title;
{
UInt32 titleID = IDS_COPYING;
if (options.moveMode)
titleID = IDS_MOVING;
else if (!options.hashMethods.IsEmpty() && options.streamMode)
{
titleID = IDS_CHECKSUM_CALCULATING;
if (options.hashMethods.Size() == 1)
{
const UString &s = options.hashMethods[0];
if (s != L"*")
title = s;
}
}
else if (options.testMode)
titleID = IDS_PROGRESS_TESTING;
if (title.IsEmpty())
title = LangString(titleID);
}
UString progressWindowTitle = L"7-Zip"; // LangString(IDS_APP_TITLE);
extracter.ProgressDialog.MainWindow = GetParent();
extracter.ProgressDialog.MainTitle = progressWindowTitle;
extracter.ProgressDialog.MainAddTitle = title + L' ';
extracter.ExtractCallbackSpec->OverwriteMode = NExtract::NOverwriteMode::kAsk;
extracter.ExtractCallbackSpec->Init();
extracter.Indices = indices;
//.........这里部分代码省略.........
示例8: str
//------------------------------------------------------------------------
void AGainSimple::setDefaultMessageText (String128 text)
{
UString str (defaultMessageText, 128);
str.assign (text, -1);
}
示例9: AmendString
UString HawkSqlite::AmendString(const UString& sValue)
{
AString sRet = AmendString((Char*)sValue.c_str());
return (Utf8*)sRet.c_str();
}
示例10: while
OtpAuthToken::OtpAuthToken(CryptEngine* eng_, const UString& buf)
{
U_TRACE_REGISTER_OBJECT(5, OtpAuthToken, "%p,%.*S", eng_, U_STRING_TO_TRACE(buf))
eng = eng_;
U_STR_RESERVE(buffer, 1000);
long pos;
unsigned char ptr[1000];
#ifdef U_PROXY_UNIT
Base64engine eng1;
pos = eng1.decode((unsigned char*)buf.data(), (long)buf.size(), ptr);
pos = eng->decrypt(ptr, pos, (unsigned char*)buffer.data());
#else
pos = u_base64_decode(U_STRING_TO_PARAM(buf), ptr);
# ifdef USE_LIBSSL
pos = u_des3_decode(ptr, pos, (unsigned char*)buffer.data());
# endif
#endif
U_STR_SIZE_ADJUST_FORCE(buffer, pos);
migrate = false;
valid = (memcmp(buffer.data(), U_CONSTANT_TO_PARAM("TID=")) == 0);
timestamp = 0;
if (valid)
{
unsigned n = U_VEC_SPLIT(vec, buffer, "=; \r\n"), i = 10;
if (n < i)
{
valid = false;
return;
}
U_INTERNAL_ASSERT(vec[0] == U_STRING_FROM_CONSTANT("TID"))
tid = vec[1];
U_INTERNAL_ASSERT(vec[2] == U_STRING_FROM_CONSTANT("UID"))
uid = vec[3];
U_INTERNAL_ASSERT(vec[4] == U_STRING_FROM_CONSTANT("SID"))
sid = vec[5];
U_INTERNAL_ASSERT(vec[6] == U_STRING_FROM_CONSTANT("TS"))
ts = vec[7];
U_INTERNAL_ASSERT(vec[8] == U_STRING_FROM_CONSTANT("CF"))
cf = vec[9];
while (i < n)
{
if (vec[i] == U_STRING_FROM_CONSTANT("MIGRATE"))
{
migrate = true;
++i;
}
else
{
hp.push_back(vec[i]);
++i;
if (i >= n)
{
valid = false;
return;
}
hp.push_back(vec[i]);
++i;
}
}
# ifdef U_STD_STRING
char* _ptr = (char*) ts.c_str();
# else
char* _ptr = ts.data();
# endif
static struct tm tm;
(void) strptime(_ptr, "%Y%m%d%H%M%S", &tm);
timestamp = mktime(&tm);
}
}
示例11: UnicodeStringToMultiByte2
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);
}
}
}
示例12:
String::String(const UString& str)
{
if (str.isNull())
return;
m_impl = StringImpl::create(str);
}
示例13: LoadFullPathAndShow
HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool selectFocused,
const UStringVector &selectedNames)
{
_dontShowMode = false;
LoadFullPathAndShow();
// OutputDebugStringA("=======\n");
// OutputDebugStringA("s1 \n");
CDisableTimerProcessing timerProcessing(*this);
CDisableNotify disableNotify(*this);
if (focusedPos < 0)
focusedPos = 0;
_listView.SetRedraw(false);
// m_RedrawEnabled = false;
LVITEMW item;
ZeroMemory(&item, sizeof(item));
// DWORD tickCount0 = GetTickCount();
_enableItemChangeNotify = false;
_listView.DeleteAllItems();
_enableItemChangeNotify = true;
int listViewItemCount = 0;
_selectedStatusVector.Clear();
// _realIndices.Clear();
_startGroupSelect = 0;
_selectionIsDefined = false;
// m_Files.Clear();
if (!_folder)
{
// throw 1;
SetToRootFolder();
}
_headerToolBar.EnableButton(kParentFolderID, !IsRootFolder());
{
CMyComPtr<IFolderSetFlatMode> folderSetFlatMode;
_folder.QueryInterface(IID_IFolderSetFlatMode, &folderSetFlatMode);
if (folderSetFlatMode)
folderSetFlatMode->SetFlatMode(BoolToInt(_flatMode));
}
/*
{
CMyComPtr<IFolderSetShowNtfsStreamsMode> setShow;
_folder.QueryInterface(IID_IFolderSetShowNtfsStreamsMode, &setShow);
if (setShow)
setShow->SetShowNtfsStreamsMode(BoolToInt(_showNtfsStrems_Mode));
}
*/
// DWORD tickCount1 = GetTickCount();
RINOK(_folder->LoadItems());
// DWORD tickCount2 = GetTickCount();
RINOK(InitColumns());
// OutputDebugString(TEXT("Start Dir\n"));
UInt32 numItems;
_folder->GetNumberOfItems(&numItems);
bool showDots = _showDots && !IsRootFolder();
_listView.SetItemCount(numItems + (showDots ? 1 : 0));
_selectedStatusVector.ClearAndReserve(numItems);
int cursorIndex = -1;
CMyComPtr<IFolderGetSystemIconIndex> folderGetSystemIconIndex;
if (!Is_Slow_Icon_Folder() || _showRealFileIcons)
_folder.QueryInterface(IID_IFolderGetSystemIconIndex, &folderGetSystemIconIndex);
if (!IsFSFolder())
{
CMyComPtr<IGetFolderArcProps> getFolderArcProps;
_folder.QueryInterface(IID_IGetFolderArcProps, &getFolderArcProps);
_thereAreDeletedItems = false;
if (getFolderArcProps)
{
CMyComPtr<IFolderArcProps> arcProps;
getFolderArcProps->GetFolderArcProps(&arcProps);
if (arcProps)
{
UInt32 numLevels;
if (arcProps->GetArcNumLevels(&numLevels) != S_OK)
numLevels = 0;
NCOM::CPropVariant prop;
if (arcProps->GetArcProp(numLevels - 1, kpidIsDeleted, &prop) == S_OK)
if (prop.vt == VT_BOOL && VARIANT_BOOLToBool(prop.boolVal))
_thereAreDeletedItems = true;
}
}
}
//.........这里部分代码省略.........
示例14: disableTimerProcessing1
void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
{
int destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex);
CPanel &srcPanel = Panels[srcPanelIndex];
CPanel &destPanel = Panels[destPanelIndex];
CPanel::CDisableTimerProcessing disableTimerProcessing1(destPanel);
CPanel::CDisableTimerProcessing disableTimerProcessing2(srcPanel);
if (!srcPanel.DoesItSupportOperations())
{
srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
return;
}
CRecordVector<UInt32> indices;
UString destPath;
bool useDestPanel = false;
{
if (copyToSame)
{
int focusedItem = srcPanel._listView.GetFocusedItem();
if (focusedItem < 0)
return;
int realIndex = srcPanel.GetRealItemIndex(focusedItem);
if (realIndex == kParentIndex)
return;
indices.Add(realIndex);
destPath = srcPanel.GetItemName(realIndex);
}
else
{
srcPanel.GetOperatedItemIndices(indices);
if (indices.Size() == 0)
return;
destPath = destPanel._currentFolderPrefix;
if (NumPanels == 1)
ReducePathToRealFileSystemPath(destPath);
}
CCopyDialog copyDialog;
UStringVector copyFolders;
ReadCopyHistory(copyFolders);
copyDialog.Strings = copyFolders;
copyDialog.Value = destPath;
copyDialog.Title = move ?
LangString(IDS_MOVE, 0x03020202):
LangString(IDS_COPY, 0x03020201);
copyDialog.Static = move ?
LangString(IDS_MOVE_TO, 0x03020204):
LangString(IDS_COPY_TO, 0x03020203);
if (copyDialog.Create(srcPanel.GetParent()) == IDCANCEL)
return;
destPath = copyDialog.Value;
if (!IsPathAbsolute(destPath))
{
if (!srcPanel.IsFSFolder())
{
srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
return;
}
destPath = srcPanel._currentFolderPrefix + destPath;
}
if (indices.Size() > 1 || (destPath.Length() > 0 && destPath.ReverseFind('\\') == destPath.Length() - 1) ||
IsThereFolderOfPath(destPath))
{
NDirectory::CreateComplexDirectory(destPath);
NName::NormalizeDirPathPrefix(destPath);
if (!CheckFolderPath(destPath))
{
if (NumPanels < 2 || destPath != destPanel._currentFolderPrefix || !destPanel.DoesItSupportOperations())
{
srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
return;
}
useDestPanel = true;
}
}
else
{
int pos = destPath.ReverseFind('\\');
if (pos >= 0)
{
UString prefix = destPath.Left(pos + 1);
NDirectory::CreateComplexDirectory(prefix);
if (!CheckFolderPath(prefix))
{
srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
return;
}
}
}
//.........这里部分代码省略.........
示例15: update
void TextView::update(const UString& _text, IFont* _font, int _height, Align _align, VertexColourType _format, int _maxWidth)
{
mFontHeight = _height;
// массив для быстрой конвертации цветов
static const char convert_colour[64] =
{
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0,
0, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
mViewSize.clear();
RollBackPoint roll_back;
IntSize result;
float width = 0.0f;
size_t count = 0;
mLength = 0;
mLineInfo.clear();
LineInfo line_info;
int font_height = _font->getDefaultHeight();
UString::const_iterator end = _text.end();
UString::const_iterator index = _text.begin();
/*if (index == end)
return;*/
result.height += _height;
for (; index != end; ++index)
{
Char character = *index;
// новая строка
if (character == FontCodeType::CR
|| character == FontCodeType::NEL
|| character == FontCodeType::LF)
{
if (character == FontCodeType::CR)
{
UString::const_iterator peeki = index;
++peeki;
if ((peeki != end) && (*peeki == FontCodeType::LF))
index = peeki; // skip both as one newline
}
line_info.width = (int)ceil(width);
line_info.count = count;
mLength += line_info.count + 1;
result.height += _height;
setMax(result.width, line_info.width);
width = 0;
count = 0;
mLineInfo.push_back(line_info);
line_info.clear();
// отменяем откат
roll_back.clear();
continue;
}
// тег
else if (character == L'#')
{
// берем следующий символ
++ index;
if (index == end)
{
--index; // это защита
continue;
}
character = *index;
// если два подряд, то рисуем один шарп, если нет то меняем цвет
if (character != L'#')
{
// парсим первый символ
uint32 colour = convert_colour[(character - 48) & 0x3F];
// и еще пять символов после шарпа
for (char i = 0; i < 5; i++)
{
++ index;
if (index == end)
{
--index; // это защита
continue;
}
colour <<= 4;
colour += convert_colour[ ((*index) - 48) & 0x3F ];
}
// если нужно, то меняем красный и синий компоненты
texture_utility::convertColour(colour, _format);
//.........这里部分代码省略.........