本文整理汇总了C++中std::wstring::at方法的典型用法代码示例。如果您正苦于以下问题:C++ wstring::at方法的具体用法?C++ wstring::at怎么用?C++ wstring::at使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::wstring
的用法示例。
在下文中一共展示了wstring::at方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findPattern
bool findPattern(
const std::vector<std::vector<wchar_t> >& matrix,
const std::wstring& pattern,
std::stack<LetterPoint>& path)
{
boost::unordered_map<wchar_t, std::vector<LetterPoint> > map;
for (size_t i = 0 ; i < matrix.size() ; ++i)
{
for (size_t j = 0 ; j < matrix.at(i).size() ; ++j)
{
map_type::value_type initList(matrix.at(i).at(j), std::vector<LetterPoint>());
map.insert(initList);
map_type::iterator iterator = map.find(matrix.at(i).at(j));
iterator->second.push_back(LetterPoint(i, j, matrix.at(i).at(j)));
}
}
if (map.count(pattern.at(0)) == 0)
{
return false;
}
for (size_t i = 0 ; i < map.find(pattern.at(0))->second.size() ; ++i)
{
if (findInMap(map, pattern.substr(1), map.find(pattern.at(0))->second.at(i), path))
{
return true;
}
}
return false;
}
示例2: CreateAllDirectory
/// 创建此路径上的所有目录
BOOL CreateAllDirectory(std::wstring strPath)
{
if(strPath.length()==0)
{
return FALSE;
}
for (size_t i=0;i<strPath.length();i++)
{
std::wstring::reference r=strPath.at(i);
if(r==L'/')
{
r=L'\\';
}
}
if(strPath.at(strPath.length()-1)!=L'\\')
{
strPath+=L"\\";
}
std::wstring::size_type nPos=0;
for(nPos = 0; nPos < strPath.length(); ++nPos)
{
nPos=strPath.find(L"\\",nPos);
if(nPos<0)
{
break;
}
std::wstring strDir=strPath.substr(0,nPos);
CreateDirectory(strDir.c_str(),NULL);
}
return TRUE;
}
示例3:
/* ComplexDMXMacro */
ComplexDMXMacro::ComplexDMXMacro(DMXController* controller, std::wstring address, DMXSource src, bool invert) {
_controller = controller;
_address = address;
_source = src;
_invert = invert;
if(address.length()<1) return;
if(address.at(0)==L'-') {
address = address.substr(1);
}
if(address.at(0)==L'm') {
address = address.substr(1);
}
// parse address
std::vector<std::wstring> parts = Explode<std::wstring>(address, std::wstring(L","));
std::vector<std::wstring>::iterator it = parts.begin();
while(it!=parts.end()) {
std::wstring nr = *it;
DMXSlot channel = DMXController::ParseChannelNumber(nr);
if(channel>-1 && channel < 514) {
_controller->_highestChannelUsed = Util::Max(_controller->_highestChannelUsed, channel);
_channels.push_back(channel);
}
++it;
}
}
示例4: GetString
bool CRealTextParser::GetString(std::wstring& p_rszLine, unsigned int& p_riPos, std::wstring& p_rszString, const std::wstring& p_crszEndChars)
{
while (p_rszLine.length() > p_riPos && p_crszEndChars.find(p_rszLine.at(p_riPos)) == std::wstring::npos) {
p_rszString += p_rszLine.at(p_riPos);
++p_riPos;
}
return p_rszLine.length() > p_riPos;
}
示例5: moveWordRight
void moveWordRight(bool modifySelection)
{
while (caretPos < text.length() && std::iswspace(text.at(caretPos)))
++caretPos;
while (caretPos < text.length() && !std::iswspace(text.at(caretPos)))
++caretPos;
if (modifySelection)
selectionStart = caretPos;
}
示例6: moveWordLeft
void moveWordLeft(bool modifySelection)
{
if (caretPos == text.length())
--caretPos;
while (caretPos > 0 && std::iswspace(text.at(caretPos - 1)))
--caretPos;
while (caretPos > 0 && !std::iswspace(text.at(caretPos - 1)))
--caretPos;
if (modifySelection)
selectionStart = caretPos;
}
示例7: ResourcesDirNormalize
void CSalsitaExtensionHelper::ResourcesDirNormalize(std::wstring &resourcesDir)
{
if (resourcesDir.size() && resourcesDir.at(resourcesDir.size()-1) != L'\\')
{
resourcesDir.append(L"\\");
}
}
示例8: replace
void replace(std::wstring &s, wchar_t before, wchar_t after)
{
const std::wstring::size_type size = s.size();
for (std::wstring::size_type i = 0; i < size; ++i)
if (s.at(i) == before)
s[i] = after;
}
示例9: EjectDrive
void EjectOSD::EjectDrive(std::wstring driveLetter) {
std::wstring name = L"\\\\.\\" + driveLetter + L":";
CLOG(L"Ejecting %s", name.c_str());
HANDLE dev = CreateFile(name.c_str(),
GENERIC_READ, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, NULL, NULL);
if (dev == INVALID_HANDLE_VALUE) {
CLOG(L"Failed to get device handle");
return;
}
DWORD bytesReturned = 0;
bool success = DeviceIoControl(dev, FSCTL_LOCK_VOLUME,
NULL, NULL, NULL, NULL, &bytesReturned, NULL)
&& DeviceIoControl(dev, FSCTL_DISMOUNT_VOLUME,
NULL, NULL, NULL, NULL, &bytesReturned, NULL)
&& DeviceIoControl(dev, IOCTL_STORAGE_EJECT_MEDIA,
NULL, NULL, NULL, NULL, &bytesReturned, NULL);
if (success) {
std::wstring rootPath = driveLetter + L":\\";
if (GetDriveType(rootPath.c_str()) != DRIVE_CDROM) {
int driveBit = (int) pow(2, (driveLetter.at(0) - 65));
_ignoreDrives |= driveBit;
CLOG(L"Added drive bit %d to ignore list", driveBit);
}
HideOthers(Eject);
_mWnd.Show();
}
CloseHandle(dev);
}
示例10: GetValue
bool CRegUtil::GetValue(const wchar_t* const name, std::wstring& strValue)
{
const int nSize = 1024;
std::vector<BYTE> buffer;
DWORD dwLength = 0;
DWORD dwType = REG_NONE;
buffer.resize(nSize);
void* pBuffer = &buffer[0];
LONG lResult = ::RegQueryValueEx(m_hKey, name, 0, &dwType, (LPBYTE)pBuffer, &dwLength);
if((lResult != ERROR_MORE_DATA && lResult != ERROR_SUCCESS)
|| (dwType != REG_SZ)
|| dwLength == 0)
{
return false;
}
if(lResult == ERROR_MORE_DATA)
{
buffer.resize(dwLength);
pBuffer = &buffer[0];
lResult = ::RegQueryValueEx(m_hKey, name, 0, &dwType, (LPBYTE)pBuffer, &dwLength);
}
if(lResult != ERROR_SUCCESS)
return false;
strValue.assign((const wchar_t*)pBuffer, dwLength / sizeof(wchar_t));
if(strValue.at(strValue.size() - 1) == 0)
strValue.resize(strValue.size() - 1);
return true;
}
示例11: getTemplateFilter
std::wstring getTemplateFilter(const std::wstring & templateContent)
{
size_t idx_template = templateContent.find(L"$TEMPLATE_FILEFILTER:");
std::wstring line;
if(idx_template != std::wstring::npos)
{
idx_template += wcslen(L"$TEMPLATE_FILEFILTER:");
size_t EOL = templateContent.find(L"\n", idx_template);
if(EOL == std::wstring::npos)
EOL = templateContent.size() - idx_template - 1;
if(templateContent.at(EOL - 1) == L'\r')
EOL--;
if(EOL < idx_template)
EOL = idx_template;
line = templateContent.substr(idx_template, EOL - idx_template);
}
else
{
line = LoadWideString(IDS_FILTER);
}
for(size_t i = 0; i < line.size(); i++)
if(line[i] == L'|')
line[i] = L'\0';
line.push_back(L'\0');
return line;
}
示例12: SkipSpaces
bool CRealTextParser::SkipSpaces(std::wstring& p_rszLine, unsigned int& p_riPos)
{
while (p_rszLine.length() > p_riPos && iswspace(p_rszLine.at(p_riPos))) {
++p_riPos;
}
return p_rszLine.length() > p_riPos;
}
示例13: StringToLower
std::wstring CRealTextParser::StringToLower(const std::wstring& p_crszString)
{
std::wstring szLowercaseString;
for (unsigned int i = 0; i < p_crszString.length(); ++i) {
szLowercaseString += towlower(p_crszString.at(i));
}
return szLowercaseString;
}
示例14: ReadHex
bool BaseConverter::ReadHex(const std::wstring& src, unsigned int defaultVal, unsigned int& val)
{
if(src.size()<=0||CheckHexString(src)==false)
{
val = defaultVal;
return false;
}
std::wstring src2 = src;
if (src.size() > 1 && src.at(0) == L'0' && (src.at(1) == L'X' || src.at(1) == L'x'))
{
std::wstring str2 = L"";
for (size_t i = 2; i < src.size(); ++i)
str2 += src[i];
src2 = str2;
}
// Convert to lower case
std::wstring src3 = L"";
for (size_t i = 0; i < src2.size(); ++i)
{
if(src2.at(i)==L'A')
src3 += L'a';
else if(src2.at(i)==L'B')
src3 += L'b';
else if(src2.at(i)==L'C')
src3 += L'c';
else if(src2.at(i)==L'D')
src3 += L'd';
else if(src2.at(i)==L'E')
src3 += L'e';
else if(src2.at(i)==L'F')
src3 += L'f';
else
src3 += src2.at(i);
}
std::wstringstream ss;
ss << std::setbase(16) << src3;
ss >> val;
return true;
}
示例15: toInt
// String to integer
int toInt(std::wstring s)
{
int val = 0;
for(unsigned int i = 0; i < s.length(); i++)
{
switch(s.at(i))
{
case L'0':
val = val * 10 + 0;
break;
case L'1':
val = val * 10 + 1;
break;
case L'2':
val = val * 10 + 2;
break;
case L'3':
val = val * 10 + 3;
break;
case L'4':
val = val * 10 + 4;
break;
case L'5':
val = val * 10 + 5;
break;
case L'6':
val = val * 10 + 6;
break;
case L'7':
val = val * 10 + 7;
break;
case L'8':
val = val * 10 + 8;
break;
case L'9':
val = val * 10 + 9;
break;
// Not an integer
default:
return -1;
}
}
return val;
};