当前位置: 首页>>代码示例>>C++>>正文


C++ wstring::size方法代码示例

本文整理汇总了C++中std::wstring::size方法的典型用法代码示例。如果您正苦于以下问题:C++ wstring::size方法的具体用法?C++ wstring::size怎么用?C++ wstring::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在std::wstring的用法示例。


在下文中一共展示了wstring::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: create

bool process::create(const std::wstring& command_line, const boost::filesystem::path& current_directory)
{
    if (statue_ == PROCESS_STATUE_READY)
    {
        if (command_line.empty())
        {
            if (!detail::create_process(
                        nullptr,
                        nullptr,
                        inherit_handle_,
                        NORMAL_PRIORITY_CLASS,
                        boost::filesystem::exists(current_directory) ? current_directory.c_str(): nullptr,
                        &si_, &pi_, inject_dll_
                    ))
            {
                return false;
            }
        }
        else
        {
            std::dynarray<wchar_t> command_line_buffer(command_line.size()+1);
            wcscpy_s(command_line_buffer.data(), command_line_buffer.size(), command_line.c_str());

            if (!detail::create_process(
                        nullptr,
                        command_line_buffer.data(),
                        inherit_handle_,
                        NORMAL_PRIORITY_CLASS,
                        boost::filesystem::exists(current_directory) ? current_directory.c_str(): nullptr,
                        &si_, &pi_, inject_dll_
                    ))
            {
                return false;
            }
        }

        statue_ = PROCESS_STATUE_RUNNING;
        return true;
    }

    return false;
}
开发者ID:BattleNWar,项目名称:YDWE,代码行数:42,代码来源:process.cpp

示例2: sizeof

uri::uri(const std::wstring &url)
    : raw_(url)
{
    URL_COMPONENTS components = { 0 };
    components.dwStructSize = sizeof(URL_COMPONENTS);
    components.dwSchemeLength = (DWORD)-1;
    components.dwHostNameLength = (DWORD)-1;
    components.dwUrlPathLength = (DWORD)-1;
    components.dwExtraInfoLength = (DWORD)-1;

    WinHttpCrackUrl(
        url.c_str(),
        (DWORD)url.size(),
        0,
        &components);

    hostName_ = std::wstring(components.lpszHostName, components.dwHostNameLength);
    port_ = components.nPort;
    urlPath_ = components.lpszUrlPath;
}
开发者ID:Awa128,项目名称:picotorrent,代码行数:20,代码来源:uri.cpp

示例3: DrawString

void CEquationEditorWindow::DrawString( const std::wstring& text, const CRect& textRect, bool isSelected )
{
	RECT rect;
	rect.bottom = textRect.Bottom();
	rect.top = textRect.Top();
	rect.left = textRect.Left();
	rect.right = textRect.Right();
	HFONT font = getFont( textRect.GetHeight() );
	HGDIOBJ oldObject = ::SelectObject( hdc, font );

	if( isSelected ) {
		::SetTextColor( hdc, symbolSelectedColorref );
		::SetBkColor( hdc, bkSelectedColorref );
	} else {
		::SetTextColor( hdc, symbolUnselectedColorref );
		::SetBkColor( hdc, bkUnselectedColorref );
	}
	::DrawText( hdc, text.c_str(), text.size(), &rect, DT_LEFT );
	::SelectObject( hdc, oldObject );
}
开发者ID:paulin-mipt,项目名称:EquationEditor,代码行数:20,代码来源:EquationEditorWindow.cpp

示例4: WriteString

	void WriteString(std::ofstream& fileStream, const std::wstring& str)
	{
		const char* tempPtr = nullptr;
		uint32_t size = 0;
		uint32_t sizeToWrite = 0;

		//size of name
		size		= (uint32_t)str.size();
		tempPtr		= reinterpret_cast<const char*>(&size);
		sizeToWrite = sizeof(uint32_t);
		fileStream.write(tempPtr, sizeToWrite);

		if(size != 0)
		{
			//Name
			tempPtr		= reinterpret_cast<const char*>(str.c_str());
			sizeToWrite	= sizeof(wchar_t) * size;
			fileStream.write(tempPtr, sizeToWrite);
		}
	}
开发者ID:dtbinh,项目名称:Arenal-Engine,代码行数:20,代码来源:GameContentDefs.cpp

示例5: SearchReplace

void SearchReplace(std::wstring& str, const std::wstring& toreplace, const std::wstring& replacewith)
{
    std::wstring result;
    std::wstring::size_type pos = 0;
    for (;;)    // while (true)
    {
        std::wstring::size_type next = str.find(toreplace, pos);
        result.append(str, pos, next-pos);
        if (next != std::string::npos)
        {
            result.append(replacewith);
            pos = next + toreplace.size();
        }
        else
        {
            break;  // exit loop
        }
    }
    str.swap(result);
}
开发者ID:dbremner,项目名称:sktoolslib,代码行数:20,代码来源:StringUtils.cpp

示例6: Trim

std::wstring Trim(const std::wstring& wstr)
{
	if (wstr.empty())
		return wstr;

	int i = 0, iSize = wstr.size();
	while (i < iSize && (wstr[i] == L' ' || wstr[i] == L'\t' ||
		wstr[i] == L'\n' || wstr[i] == L'\r')) i++;
	if (i >= iSize)
		return L"";

	int iMax = iSize - 1;
	while (iMax >= i && (wstr[iMax] == L' ' || wstr[iMax] == L'\t' ||
		wstr[iMax] == L'\n' || wstr[iMax] == L'\r')) iMax--;

	std::wstring wstrRet;
	for (; i <= iMax; ++i)
		wstrRet.push_back(wstr[i]);
	return wstrRet;
}
开发者ID:SkyeWatch,项目名称:SharedLibrary,代码行数:20,代码来源:StringTools.cpp

示例7: preInsert

std::wstring TextFile::preInsert(Coord &cursor, const std::wstring &value)
{
  if (value.size() != 1 || value[0] != '\n')
    return value;
  else
  {
    auto &line = (*this)[cursor.y];
    std::wstring spaces;
    int c = 0;
    for (auto ch: line)
      if (ch == L' ')
        ++c;
      else
        break;
    for (size_t x = cursor.x; x < line.size() && line[x] == ' '; ++x, --c);
    for (int i = 0; i < c; ++i)
      spaces += L' ';
    return L'\n' + spaces;
  }
}
开发者ID:antonte,项目名称:texteditor,代码行数:20,代码来源:text_file.cpp

示例8: render

 void render(sdl_surface& screen, int x, int y, const std::wstring& text) {
   SDL_Rect dest = {Sint16(x), Sint16(y)};
   for (unsigned i = 0; i != text.size(); ++i) {
     std::map<wchar_t, char_info>::iterator ci = m_chars.find(text[i]);
     if (ci != m_chars.end()) {
       char_info& c = ci->second;
       if (i != 0) {
         // Kerning
         auto ki = m_kern.find(std::make_pair(text[i], text[i - 1]));
         if (ki != m_kern.end()) {
           dest.x += ki->second;
         }
       }
       SDL_Rect glyph_dest = {Sint16(dest.x + c.xoffset),
                              Sint16(dest.y + c.yoffset)};
       SDL_BlitSurface(m_bmp, &c.src, screen, &glyph_dest);
       dest.x += c.xadvance;
     }
   }
 }
开发者ID:kalven,项目名称:arithmetix,代码行数:20,代码来源:font.hpp

示例9: checkLabel

std::wstring checkLabel(std::wstring& str, bool AllLocal)
{
	int pos = 0;

	while (pos < (int)str.size() && str[pos] != ' ' && str[pos] != 0)
	{
		if (str[pos] == ':')
		{
			std::wstring name = str.substr(0,pos);
			if (AllLocal == true && Global.symbolTable.isGlobalSymbol(name))
				name = L"@@" + name;
			
			addAssemblerLabel(name);
			return str.substr(pos+1);
		}
		pos++;
	}

	return str;
}
开发者ID:kabochi,项目名称:armips,代码行数:20,代码来源:Assembler.cpp

示例10: domain_error

/*------ マルチバイト文字列 --> ワイド文字文字列 ------*/
void igs::resource::mbs_to_wcs(const std::string &mbs, std::wstring &wcs,
                               const UINT code_page) {
  /* 第4引数で -1 指定により終端文字を含む大きさを返す */
  /*	int MultiByteToWideChar(
                  UINT CodePage
                  ,DWORD dwFlags
                  ,LPCSTR lpMultiByteStr
                  ,int cbMultiByte
                  ,LPWSTR lpWideCharStr
                  ,int cchWideChar
          );
  */
  int length = ::MultiByteToWideChar(code_page, 0, mbs.c_str(), -1, 0, 0);
  if (length <= 1) {
    return;
  } /* 終端以外の文字がないなら何もしない */

  /***	std::vector<wchar_t> buf(length);
  length = ::MultiByteToWideChar(
          code_page ,0 ,mbs.c_str() ,-1
          ,&buf.at(0) ,static_cast<int>(buf.size())
  );***/
  wcs.resize(length);
  length = ::MultiByteToWideChar(code_page, 0, mbs.c_str(), -1,
                                 const_cast<LPWSTR>(wcs.data()),
                                 static_cast<int>(wcs.size()));
  if (0 == length) {
    switch (::GetLastError()) {
    case ERROR_INSUFFICIENT_BUFFER:
      throw std::domain_error("MultiByteToWideChar():insufficient buffer");
    case ERROR_INVALID_FLAGS:
      throw std::domain_error("MultiByteToWideChar():invalid flags");
    case ERROR_INVALID_PARAMETER:
      throw std::domain_error("MultiByteToWideChar():invalid parameter");
    case ERROR_NO_UNICODE_TRANSLATION:
      throw std::domain_error("MultiByteToWideChar():no unicode translation");
    }
  }
  // wcs = std::wstring(buf.begin() ,buf.end()-1); /* 終端以外を */
  wcs.erase(wcs.end() - 1); /* 終端文字を消す。end()は終端より先位置 */
}
开发者ID:SaierMe,项目名称:opentoonz,代码行数:42,代码来源:igs_resource_msg_from_err_win.cpp

示例11: setlocale

std::string ws2s( const std::wstring& ws )
{
#ifdef WIN_PLATFORM
	std::string curLocale = setlocale(LC_ALL, NULL);        // curLocale = "C";
	setlocale(LC_ALL, "chs");
	const wchar_t* _Source = ws.c_str();
	size_t _Dsize = 2 * ws.size() + 1;
	char *_Dest = new char[_Dsize];
	memset(_Dest,0,_Dsize);
	wcstombs(_Dest,_Source,_Dsize);
	std::string result = _Dest;
	delete []_Dest;
	setlocale(LC_ALL, curLocale.c_str());
	return result;
#else


	std::string val = "";  
	if(!ws.c_str())  
	{  
		return val;  
	}  
	//size_t size= wcslen(pw)*sizeof(wchar_t);  
	size_t size= ws.length() * sizeof(wchar_t);  
	char *pc = NULL;  
	if ( !(pc = (char*)malloc(size)) )  
	{  
		return val;  
	}  
	size_t destlen = wcstombs(pc,ws.c_str(),size);  
	/*转换不为空时,返回值为-1。如果为空,返回值0*/  
	if ( destlen == (size_t)(0) )  
	{  
		return val;  
	}  
	val = pc;  
	free(pc);  
	return val; 
#endif
 
}
开发者ID:charlessoft,项目名称:extlib,代码行数:41,代码来源:StdString.cpp

示例12: ResolveFromCommandLine

    bool ResolveFromCommandLine(std::wstring &path)
    {
        if (path.empty())
        {
            return false;
        }
        path = Path::ExpandEnvStrings(path);

        if (path[0] == L'\"')
        {
            std::wstring unescaped;
            unescaped.reserve(path.size());
            std::wstring::iterator endOfUnescape = CmdLineToArgvWUnescape(path.begin(), path.end(), std::back_inserter(unescaped));
            if (boost::istarts_with(unescaped, GetRundll32Path()))
            {
                std::wstring::iterator startOfArgument = std::find(endOfUnescape, path.end(), L'\"');
                if (startOfArgument != path.end())
                {
                    unescaped.push_back(L' ');
                    CmdLineToArgvWUnescape(startOfArgument, path.end(), std::back_inserter(unescaped)); // Unescape the argument
                    RundllCheck(unescaped);
                }
            }

            path = unescaped;
            ExpandShortPath(path);
            Prettify(path.begin(), path.end());
            return SystemFacades::File::IsExclusiveFile(path);
        }
        else
        {
            NativePathToWin32Path(path);
            bool status = StripArgumentsFromPath(path);
            if (status)
            {
                ExpandShortPath(path);
                Prettify(path.begin(), path.end());
            }
            return status;
        }
    }
开发者ID:BillyONeal,项目名称:pevFind,代码行数:41,代码来源:Path.cpp

示例13: getAppInstallPath

std::wstring getAppInstallPath(std::wstring extra)
{
#ifdef NIX
	#if defined(USE_XDG_DIRS)
		std::string installPath = getenv("XDG_DATA_HOME");
		installPath.append("/desura");
	#elif defined(USE_SINGLE_HOME_DIR)
		std::string installPath = getenv("HOME");
		installPath.append("/.desura/games");
	#elif defined(USE_PORTABLE_DIR)
		std::string installPath = UTIL::STRING::toStr(getCurrentDir(L"games"));
	#endif
	
	if (extra.size() > 0)
		extra.insert(0, DIRS_WSTR);
	
	return UTIL::STRING::toWStr(installPath) + extra;
#else
	#error NOT IMPLEMENTED
#endif
}
开发者ID:harmy,项目名称:Desurium,代码行数:21,代码来源:UtilOs.cpp

示例14: WStrToUtf8

bool WStrToUtf8(const std::wstring& wstr, std::string& utf8str)
{
    try
    {
        std::string utf8str2;
        utf8str2.resize(wstr.size() * 4);                   // allocate for most long case

        auto end = utf8::utf16to8(wstr.cbegin(), wstr.cend(), utf8str2.begin());
        if (end != utf8str2.end())
            utf8str2.erase(end, utf8str2.end());

        utf8str = utf8str2;
    }
    catch (const std::exception&)
    {
        utf8str = "";
        return false;
    }

    return true;
}
开发者ID:lduguid,项目名称:mangos-tbc,代码行数:21,代码来源:Util.cpp

示例15: get_width

  int get_width(const std::wstring& text, unsigned chars = unsigned(-1)) {
    chars = std::min(static_cast<unsigned>(text.size()), chars);

    int width = 0;

    for (unsigned i = 0; i != chars; ++i) {
      std::map<wchar_t, char_info>::iterator ci = m_chars.find(text[i]);
      if (ci != m_chars.end()) {
        char_info& c = ci->second;
        if (i != 0) {
          std::map<kern_pair, int>::iterator ki =
              m_kern.find(std::make_pair(text[i], text[i - 1]));
          if (ki != m_kern.end()) width += ki->second;
        }

        width += c.xadvance;
      }
    }

    return width;
  }
开发者ID:kalven,项目名称:arithmetix,代码行数:21,代码来源:font.hpp


注:本文中的std::wstring::size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。