本文整理汇总了C++中std::wstring::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ wstring::begin方法的具体用法?C++ wstring::begin怎么用?C++ wstring::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::wstring
的用法示例。
在下文中一共展示了wstring::begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: re_non_letter_symbols
std::vector<size_t> SentenceSplitter::split(const std::wstring& i_line_to_split)
{
std::vector<size_t> result;
boost::wregex re_non_letter_symbols(L"[[:punct:]]");
boost::wsregex_iterator m1(i_line_to_split.begin(), i_line_to_split.end(), re_non_letter_symbols);
boost::wsregex_iterator m2;
std::for_each(m1, m2,
[this, &i_line_to_split, &result](const boost::match_results<std::wstring::const_iterator>& entry) mutable
{
if(this->testEntryOnSentenceSplit_(entry.position(size_t(0)), i_line_to_split))
{
result.push_back(entry.position(size_t(0)));
}
});
return result;
}
示例2: ConsumeString
/**
Consumes any whitespace in the stream until data is encountered. It then
consumes data enclosed in double quotes returns.
\param[in] data Data to consume.
\throws PersistUnexpectedDataException if data is not the next data in the
stream.
In the stream, data between the double quote characters is expected to be
xml-encoded so that all special characters are encoded with \&...;
e.g. double quote character is encoded as \"e;
*/
void SCXFilePersistDataReader::ConsumeString(const std::wstring& data)
{
try {
wchar_t ch = GetUTF8CharSkipLeadingWS();
// Expect a '"' to start the string
if (ch != L'\"')
{
throw PersistUnexpectedDataException(L"\"",
m_Stream->tellg(), SCXSRCLOCATION);
}
// Read stream char-by-char and match it to the argument-string
for (std::wstring::const_iterator iter = data.begin();
iter != data.end();
++iter)
{
ch = GetUTF8Char();
if (L'&' == ch)
{
ch = ConsumeEncodedChar();
}
if (ch != *iter)
{
throw PersistUnexpectedDataException(data, m_Stream->tellg(), SCXSRCLOCATION);
}
}
// Expect a '"' to end the string
if (GetUTF8Char() != L'\"')
{
throw PersistUnexpectedDataException(L"\"",
m_Stream->tellg(), SCXSRCLOCATION);
}
} catch (SCXLineStreamContentException& e) {
// If an invalid UTF-8 sequnce is encountered, including bad
// file state or EOF.
throw PersistUnexpectedDataException(L"\".*\"",
m_Stream->tellg(), SCXSRCLOCATION);
}
}
示例3: catch
std::string toUTF8(const std::wstring& s)
{
std::string result;
result.reserve(s.length() * 3);
char buf[4];
for (std::wstring::const_iterator i = s.begin(); i != s.end(); ++i) {
char *end = buf;
try {
rapidxml::xml_document<>::insert_coded_character<0>(end, *i);
for (char *b = buf; b != end; ++b)
result += *b;
} catch (rapidxml::parse_error& e) {
LOG_ERROR("toUTF8(): " << e.what());
}
}
return result;
}
示例4: to_str
std::string CodeConv::to_str(std::wstring const& in, char oob)
{
// If your boost version is equal or greater than 1.34, you can use
// lexical_cast<string>(). But boost 1.33's lexical_cast has bug.
std::string str;
for (std::wstring::const_iterator i = in.begin(); i != in.end(); ++i) {
if (*i > std::numeric_limits<char>::max()) {
if (oob == 0)
throw Exception0(Exception::E_CONV_INV_SEQ);
str += oob;
}
else {
str += static_cast<char>(*i);
}
}
return str;
}
示例5: connect
void Socket::connect(const std::wstring &server) {
struct sockaddr_un remote;
socklen_t len;
if ((d->socket = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
return;
}
std::string name = "/tmp/" + std::string(server.begin(), server.end());
remote.sun_family = AF_UNIX;
strcpy(remote.sun_path, name.c_str());
len = SUN_LEN(&remote);
if (connectWrapper(d->socket, (struct sockaddr *)&remote, len) == -1) {
return;
}
TelldusCore::MutexLocker locker(&d->mutex);
d->connected = true;
}
示例6: create_sr
bool create_sr(int wkid, std::wstring wkt, ISpatialReference **ppSR)
{
CComPtr<ISpatialReferenceFactory3> ipSpatialRefFactory; ipSpatialRefFactory.CoCreateInstance(CLSID_SpatialReferenceEnvironment);
CComPtr<ISpatialReference> ipSR;
if (wkid > 0)
{
ipSpatialRefFactory->CreateSpatialReference(wkid, &ipSR);
}
else
{
if (!wkt.empty())
{
long dw;
struct eq
{
static bool op(const wchar_t &c) { return c == L'\''; }
};
std::replace_if(wkt.begin(), wkt.end(), eq::op, L'\"');
CComBSTR bstr(wkt.c_str());
HRESULT hr = ipSpatialRefFactory->CreateESRISpatialReference(bstr, &ipSR, &dw);
if (FAILED(hr))
{
CComPtr<ISpatialReferenceInfo> ipSRInfo;
if (FAILED(ipSpatialRefFactory->CreateESRISpatialReferenceInfoFromPRJ(bstr, &ipSRInfo)))
return false;
long fcode = 0;
ipSRInfo->get_FactoryCode(&fcode);
if (FAILED(ipSpatialRefFactory->CreateSpatialReference(fcode, &ipSR)))
return false;
}
}
}
if (ipSR == NULL)
ipSR.CoCreateInstance(CLSID_UnknownCoordinateSystem);
CComQIPtr<ISpatialReferenceResolution> ipSRR(ipSR);
if (ipSRR)
FIX_DEFAULT_SR(ipSRR);
*ppSR = ipSR.Detach();
return *ppSR != nullptr;
}
示例7: matchStrings
bool matchStrings(std::wstring nameControlPanel, std::string nameEDID) {
std::string nameCP;
nameCP.assign(nameControlPanel.begin(), nameControlPanel.end());
std::transform(nameCP.begin(), nameCP.end(), nameCP.begin(), toupper);
// Remove spaces at the end of nameEDID
if (nameEDID.length() > 0)
{
while (nameEDID[ nameEDID.length()-1] == ' ')
nameEDID.erase(nameEDID.length()-1,1);
}
std::transform(nameEDID.begin(), nameEDID.end(), nameEDID.begin(), toupper);
size_t found;
found=nameCP.find(nameEDID);
if (found!=std::string::npos)
return true;
else
return false;
}
示例8:
std::shared_ptr<MeshData> RE::FileSystem::LoadModel(const std::wstring &filePath)
{
const std::string sFilePaths{ filePath.begin(), filePath.end() };
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(sFilePaths,
aiProcess_CalcTangentSpace |
aiProcess_Triangulate |
aiProcess_JoinIdenticalVertices |
aiProcess_SortByPType |
aiProcess_ConvertToLeftHanded |
aiProcess_FixInfacingNormals
);
if (!scene)
{
Log::Get().Write(std::string("[FileSystem] Assimp importer could not read mesh file:") + importer.GetErrorString());
}
return std::make_shared<MeshData>(ProcessAssimpScene(scene->mRootNode, scene));
}
示例9: if
BINLINE int32_t BBuffer::getStringLengthUtf8(const ::std::wstring& str) {
int32_t p = 0;
for (wstring::const_iterator it = str.begin(); it != str.end(); it++) {
wchar_t c = (*it);
if (c <= 0x7F) {
p++;
}
else if (c >= 0x80 && c <= 0x07FF) {
p += 2;
}
else { // if (c >= 0x800 && c <= 0xFFFF) {
p += 3;
}
}
return p;
}
示例10: toString
std::string toString(std::wstring ws)
{
#ifdef TNZCORE_LIGHT
std::string s;
s.assign(ws.begin(), ws.end());
return s;
#else
QString qString = QString::fromStdWString(ws);
// Test if 'ws' is not unicode (UTF-8)
#if 0
if(qString.toAscii() == qString)
#else
if (qString.toLatin1() == qString)
#endif
return qString.toStdString();
QByteArray a = qString.toUtf8();
return std::string(a);
#endif
}
示例11: Load
/**
*
* Load SYSTEM hive to memory
* Returns TRUE or FALSE
*
*/
BOOL SystemKey::Load (std::wstring fname) {
UnLoad();
if (!bRestore) {
bRestore = SetPrivilege (L"SeRestorePrivilege", TRUE);
}
if (bRestore) {
dprintf("\nChecking %s", std::string(fname.begin(), fname.end()).c_str());
DWORD dwAttr = GetFileAttributes (fname.c_str());
if (dwAttr != INVALID_FILE_ATTRIBUTES) {
dwError = RegLoadKey (HKEY_LOCAL_MACHINE, L"$$_SYSTEM", fname.c_str());
if (dwError == ERROR_SUCCESS) {
regFile = L"$$_SYSTEM";
bLoaded = TRUE;
}
} else {
dwError = GetLastError ();
}
}
return dwError == ERROR_SUCCESS;
}
示例12: trunc_str
bool public_nbs::trunc_str( const std::wstring& source, std::string& dest )
{
bool res = true;
dest.resize( source.size(), ' ' );
std::string::iterator b = dest.begin();
std::wstring::const_iterator i = source.begin();
std::wstring::const_iterator e = source.end();
for( ; i != e; ++i, ++b )
{
if( *i < std::numeric_limits<std::string::value_type>::min() ||
*i > std::numeric_limits<std::string::value_type>::max() )
{
res = false;
}
else
{
*b = (std::string::value_type)*i;
}
}
return res;
}
示例13: find_and_replace
void BootStrap::find_and_replace( std::wstring &input, std::map<WCHAR, std::wstring> &replacements) const
{
std::wostringstream oss;
std::map<WCHAR, std::wstring>::iterator specialCharIt;
for( std::wstring::iterator stringIter = input.begin(); stringIter != input.end(); stringIter++ )
{
if( *stringIter < 0x20 )
{
oss << ' ';
continue;
}
specialCharIt = replacements.find( *stringIter );
if ( specialCharIt == replacements.end() )
oss << *stringIter;
else
oss << specialCharIt->second;
}
input = oss.str();
}
示例14: install
bool install() {
char winDir[MAX_PATH];
GetSystemDirectoryA(winDir,sizeof(winDir));
strcat(winDir,"\\msiexec.exe");
std::string tmp(m_msiFile.length(),'0');
std::copy(m_msiFile.begin(),m_msiFile.end(),tmp.begin());
std::string param(std::string("/I \"")
+ tmp + "\" REINSTALLMODE=vomus REINSTALL=ALL");
ProcessStarter msiexec(winDir,param);
return msiexec.Run(true);
/* MsiSetInternalUI(INSTALLUILEVEL_FULL,0);
UINT retCode = MsiReinstallProduct(prodCode,
REINSTALLMODE_FILEREPLACE |
REINSTALLMODE_MACHINEDATA|
REINSTALLMODE_USERDATA |
REINSTALLMODE_SHORTCUT |
REINSTALLMODE_PACKAGE);
if (retCode == ERROR_UNKNOWN_PRODUCT) {
const wchar_t *pack = m_msiFile.c_str();
retCode = MsiInstallProduct(pack,L"ACTION=INSTALL");
}*/
// return retCode == ERROR_SUCCESS;
}
示例15: assert
IntegralValue::IntegralValue(std::wstring s, int width, bool sign)
{
assert(s.size() > 0);
wchar_t base = '\0';
if(s.size() > 2 and s[0] == L'0' and !is_digit(s[1]))
{
base = s[1];
s.erase(0, 2);
}
std::string t = "";
std::transform(s.begin(), s.end(), std::back_inserter(t), digit_utf_to_ascii);
unsigned char radix = 10;
switch(base)
{
case L'\0': radix = 10; break;
case L'x': radix = 16; break;
case L'b': radix = 2; break;
case L'o': radix = 8; break;
default: assert(false && "Compilation error - unsupported radix character");
}
auto srt = llvm::StringRef(t);
value = llvm::APSInt(llvm::APInt(width, srt, radix), !sign);
}