本文整理汇总了C++中wstring::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ wstring::begin方法的具体用法?C++ wstring::begin怎么用?C++ wstring::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wstring
的用法示例。
在下文中一共展示了wstring::begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetCurrentDirectory
void CDirectory::SetCurrentDirectory ( const wstring& szDirectoryPath )
{
std::string szDirectoryPath_iso ( szDirectoryPath.begin ( ), szDirectoryPath.end ( ) );
szDirectoryPath_iso.assign ( szDirectoryPath.begin ( ), szDirectoryPath.end ( ) );
chdir ( szDirectoryPath_iso.c_str ( ) );
}
示例2: parse
void url::parse(const wstring& url_s)
{
const wstring prot_end(L"://");
wstring::const_iterator prot_i = search(url_s.begin(), url_s.end(), prot_end.begin(), prot_end.end());
protocol_.reserve(distance(url_s.begin(), prot_i));
transform(url_s.begin(), prot_i, back_inserter(protocol_), ptr_fun<int, int>(tolower)); // protocol is icase
if (prot_i == url_s.end())
return;
advance(prot_i, prot_end.length());
wstring::const_iterator path_i = find(prot_i, url_s.end(), '/');
host_.reserve(distance(prot_i, path_i));
std::copy(prot_i, path_i, back_inserter(host_));
auto found = host_.find_first_of(L'@');
if (found != std::string::npos)
{
auto creds = host_.substr(0, found);
auto found2 = creds.find_first_of(L':');
if (found2 != std::string::npos)
{
user_ = creds.substr(0, found2);
passw_ = creds.substr(found2+1);
}
host_ = host_.substr(found+1);
}
// host is icase
wstring::const_iterator query_i = find(path_i, url_s.end(), '?');
path_.assign(path_i, query_i);
if (query_i != url_s.end())
++query_i;
query_.assign(query_i, url_s.end());
}
示例3: insertReplacedString
// See https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/replace#Specifying_a_string_as_a_parameter
// Some tricky test cases:
// "abcdefghijklmn".replace(/(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)(m)(n)/, "$001"): "$001"
// "abcdefghijklmn".replace(/(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)(m)(n)/, "$01"): "a"
// "abcdefghijklmn".replace(/(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)(m)(n)/, "$10"): "j"
// "abcdefghijklmn".replace(/(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)(m)(n)/, "$15"): "a5"
// "abcdefghijklmn".replace(/(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)(m)(n)/, "$20"): "b0"
void insertReplacedString(wstring& builder, const wstring& base, const wstring& str, const RegExpMatch& match)
{
const vector<wstring>& substrings = match.substrings;
const wstring& mstr = substrings[0];
for (size_t i = 0; i < str.length(); i++)
{
if (str[i] == L'$' && str.length() > i + 1)
{
wchar_t ch = str[++i];
switch (ch)
{
case L'$': // insert a '$'
builder.push_back(ch);
break;
case L'&': // insert the matched string
builder.append(mstr);
break;
case L'`': // insert the portion preceding the matched string
builder.append(base.begin(), base.begin() + match.index);
break;
case L'\'': // insert the portion following the matched string
builder.append(base.begin() + match.index + mstr.length(), base.end());
break;
default:
if (ch >= L'0' && ch <= L'9')
{
int expidx = 0;
wchar_t ch2 = str.length() > i + 1 ? str[i + 1] : L'\0';
if (ch2 >= L'0' && ch2 <= L'9')
{
expidx = ch2 - L'0' + 10 * (ch - L'0');
// if expidx overflows, fall back to single-digit
if (expidx == 0 || expidx >= (int)substrings.size())
{
expidx = ch - L'0';
ch2 = 0;
}
}
else
{
ch2 = 0;
expidx = ch - L'0';
}
// substrings.size() is 1 bigger than actual sub matches
if (expidx < (int)substrings.size() && expidx > 0)
{
const wstring& submstr = substrings[expidx];
builder.append(submstr);
if (ch2) ++i;
break;
}
}
// $ escape fails, output as is
builder.push_back(L'$');
builder.push_back(ch);
}
}
else builder.push_back(str[i]);
}
}
示例4: ToLower
wstring ToLower(wstring in)
{
in = w_trim(in);
int (*pf)(int) = tolower;
transform(in.begin(), in.end(), in.begin(), pf);
return in;
}
示例5: val
/**
* Returns a multi-byte representation of a wide-character string.
* Flaws: no character set conversions, multiple copy operations.
*/
inline string
toS(const wstring& ws, const wstring& vdefault = L"") {
//sprintf(charptr,"%ls",wsdtring.c_str());
string val(ws.begin(), ws.end());
if (val.length() == 0)
val.append(vdefault.begin(), vdefault.end());
return val;
}
示例6: strFilename
KeyValueFileParser::KeyValueFileParser(const wstring& wstrFilename, bool bStopOnEmptyLine, const wstring& wstrToken, const std::wstring& wstrEndToken)
{
string strFilename(wstrFilename.begin(), wstrFilename.end());
string strToken(wstrToken.begin(), wstrToken.end());
string strEndToken(wstrEndToken.begin(), wstrEndToken.end());
m_bFileReadable = ParseFile(strFilename, bStopOnEmptyLine, strToken, strEndToken);
}
示例7: ToUpper
void ToUpper(wstring& str, bool use_locale) {
if (use_locale) {
std::transform(str.begin(), str.end(), str.begin(),
std::bind2nd(std::ptr_fun(&std::toupper<wchar_t>),
current_locale));
} else {
std::transform(str.begin(), str.end(), str.begin(), towupper);
}
}
示例8: trimleft
void StrUtils::trimleft(wstring& s )
{
wstring::iterator it;
for( it = s.begin(); it != s.end(); it++ )
if( !StrUtils::isspace(*it))
break;
s.erase( s.begin(), it );
}
示例9: trim
wstring trim(wstring str) {
wstring::iterator it = str.begin();
while (str.begin() != str.end() && *str.begin() == L' ')
str.erase(str.begin());
while (str.begin() != str.end()) {
it = str.end() - 1;
if (*it != L' ') break;
str.erase(it);
}
return str;
}
示例10: strToken
KeyValueFileParser::KeyValueFileParser(ifstream& fileData,
bool bStopOnEmptyLine,
const wstring& wstrToken,
const wstring& wstrEndToken)
{
string strToken(wstrToken.begin(), wstrToken.end());
string strEndToken(wstrEndToken.begin(), wstrEndToken.end());
m_bFileReadable = ParseFile(fileData, bStopOnEmptyLine,
strToken, strEndToken);
}
示例11: _getFirstLanguage
void IEAcceptLanguagesAction::_getFirstLanguage(wstring& regvalue)
{
if (m_languages.size() > 0)
{
regvalue = m_languages[0];
std::transform(regvalue.begin(), regvalue.end(), regvalue.begin(), ::tolower);
return;
}
regvalue.clear();
return;
}
示例12: strKey
KeyValPair::KeyValPair(const wstring& key, const wstring& value) :
strKey(key.begin(), key.end()),
wstrKey(key),
strValue(value.begin(), value.end()),
wstrValue(value)
{
vwstrValue = Tokenize(value);
for (size_t i = 0;i<vwstrValue.size();i++) {
vstrValue.push_back(string(vwstrValue[i].begin(), vwstrValue[i].end()));
}
FillDerivedData();
}
示例13: yk51_StringICompW
/**
* @brief 2つの文字列を小文字として比較する
*
* @param s1, s2 比較文字列
*
* @return s1とs2を辞書式の順序で比較した関係を示す
* @retval <0 s1はs2より小さい
* @retval =0 s1とs2は等しい
* @retval >0 s2はs1より小さい
*/
int yk51_StringICompW(const wstring &s1, const wstring &s2)
{
typedef pair<wstring::const_iterator, wstring::const_iterator> pairT;
pairT p = mismatch(s1.begin(), s1.end(),
s2.begin(),
not2(ptr_fun(yk51_CharCompareW)));
if(p.first == s1.end()){
if(p.second == s2.end()) return 0;
else return -1;
}
return yk51_CharCompareW(*p.first, *p.second);
}
示例14: EraseRight
void EraseRight(wstring& str1, const wstring& str2, bool case_insensitive) {
if (str1.length() < str2.length())
return;
if (case_insensitive) {
if (!std::equal(str2.begin(), str2.end(), str1.end() - str2.length(),
&IsCharsEqual))
return;
} else {
if (!std::equal(str2.begin(), str2.end(), str1.end() - str2.length()))
return;
}
str1.resize(str1.length() - str2.length());
}
示例15: calculateTextWidth
int SpriteManager::calculateTextWidth(wstring text, unsigned int fontId) {
float width = 0;
wchar_t previousLetter = *(text.begin());
for (std::wstring::iterator it = text.begin(); it != text.end(); ++it) {
Glyph g = renderer->getFontManager()->getGlyph(fontId, *it);
float kerning = 0;
if (it != text.begin() && g.kerning.find(previousLetter) != g.kerning.end()) {
kerning = (*(g.kerning.find(previousLetter))).second;
}
width += kerning;
width += g.advanceX;
previousLetter = *it;
}
return width;
}