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


C++ WideString::c_str方法代码示例

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


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

示例1:

PyObject *
PyIMEngine::py_get_surrounding_text (PyIMEngineObject *self, PyObject *args)
{
	PyObject *tuple;

	int maxlen_before = -1;
	int maxlen_after = -1;

	if (!PyArg_ParseTuple (args, "|ii:get_surrounding_text", &maxlen_before, &maxlen_after))
		return NULL;

	WideString text;
	int cursor;
	int provided = self->engine.get_surrounding_text(text, cursor, maxlen_before, maxlen_after);
	
	tuple = PyTuple_New (2);

	if (!provided) {
		text = L"";
		cursor = 0;
	}

#if Py_UNICODE_SIZE == 4
	PyTuple_SET_ITEM (tuple, 0, PyUnicode_FromUnicode ((Py_UNICODE *)text.c_str(), text.length()));
#else
	gunichar2 *utf16_str = g_ucs4_to_utf16 (text.c_str(), -1, NULL, NULL, NULL);
	PyTuple_SET_ITEM (tuple, 0, PyUnicode_FromUnicode ((Py_UNICODE *)utf16_str, text.length()));
#endif
	PyTuple_SET_ITEM (tuple, 1, PyInt_FromLong ((long) cursor));
	
	return tuple;
}
开发者ID:Alwnikrotikz,项目名称:scim-python,代码行数:32,代码来源:scim-python-engine.cpp

示例2: indexOf

int StringUtil::indexOf(const WideString &str, const WideString &toFind, size_t startFrom) {
	const char *index = strstr(str.c_str(), toFind.c_str());
	if (index == nullptr) {
		return -1;
	} else {
		return index - str.c_str();
	}
}
开发者ID:,项目名称:,代码行数:8,代码来源:

示例3: defaultValue

void CJX_Field::defaultValue(CFXJSE_Value* pValue,
                             bool bSetting,
                             XFA_Attribute eAttribute) {
  CXFA_Node* xfaNode = GetXFANode();
  if (!xfaNode->IsWidgetReady())
    return;

  if (bSetting) {
    if (pValue) {
      xfaNode->SetPreNull(xfaNode->IsNull());
      xfaNode->SetIsNull(pValue->IsNull());
    }

    WideString wsNewText;
    if (pValue && !(pValue->IsNull() || pValue->IsUndefined()))
      wsNewText = pValue->ToWideString();
    if (xfaNode->GetUIChildNode()->GetElementType() == XFA_Element::NumericEdit)
      wsNewText = xfaNode->NumericLimit(wsNewText);

    CXFA_Node* pContainerNode = xfaNode->GetContainerNode();
    WideString wsFormatText(wsNewText);
    if (pContainerNode)
      wsFormatText = pContainerNode->GetFormatDataValue(wsNewText);

    SetContent(wsNewText, wsFormatText, true, true, true);
    return;
  }

  WideString content = GetContent(true);
  if (content.IsEmpty()) {
    pValue->SetNull();
    return;
  }

  CXFA_Node* formValue = xfaNode->GetFormValueIfExists();
  CXFA_Node* pNode = formValue ? formValue->GetFirstChild() : nullptr;
  if (pNode && pNode->GetElementType() == XFA_Element::Decimal) {
    if (xfaNode->GetUIChildNode()->GetElementType() ==
            XFA_Element::NumericEdit &&
        (pNode->JSObject()->GetInteger(XFA_Attribute::FracDigits) == -1)) {
      pValue->SetString(content.ToUTF8().AsStringView());
    } else {
      CFX_Decimal decimal(content.AsStringView());
      pValue->SetFloat((float)(double)decimal);
    }
  } else if (pNode && pNode->GetElementType() == XFA_Element::Integer) {
    pValue->SetInteger(FXSYS_wtoi(content.c_str()));
  } else if (pNode && pNode->GetElementType() == XFA_Element::Boolean) {
    pValue->SetBoolean(FXSYS_wtoi(content.c_str()) == 0 ? false : true);
  } else if (pNode && pNode->GetElementType() == XFA_Element::Float) {
    CFX_Decimal decimal(content.AsStringView());
    pValue->SetFloat((float)(double)decimal);
  } else {
    pValue->SetString(content.ToUTF8().AsStringView());
  }
}
开发者ID:,项目名称:,代码行数:56,代码来源:

示例4: Exception

	String StringUtils::wideString2utf8String( const WideString& wideString )
	{
		size_t widesize = wideString.length();
		String returnString;

		if ( sizeof( wchar_t ) == 2 )
		{
			size_t utf8size = MAX_UTF8_CHAR_LENGTH * widesize + 1;
			returnString.resize( utf8size, '\0' );
			const UTF16* sourcestart = reinterpret_cast<const UTF16*>( wideString.c_str() );
			const UTF16* sourceend = sourcestart + widesize;
			UTF8* targetstart = reinterpret_cast<UTF8*>( &((returnString)[ 0 ]) );
			UTF8* thisFirstWChar = targetstart;
			UTF8* targetend = targetstart + utf8size;
			ConversionResult res = ConvertUTF16toUTF8( &sourcestart, sourceend, &targetstart, targetend, strictConversion );

			if ( res != conversionOK )
			{
				throw Exception(Exception::ERROR_WIDE_2_UTF8, String("Could not convert from wide string to UTF8."));
			}

			returnString.resize(targetstart - thisFirstWChar);
		}

		else if ( sizeof( wchar_t ) == 4 )
		{
			size_t utf8size = MAX_UTF8_CHAR_LENGTH * widesize + 1;
			returnString.resize( utf8size, '\0' );
			const UTF32* sourcestart = reinterpret_cast<const UTF32*>( wideString.c_str() );
			const UTF32* sourceend = sourcestart + widesize;
			UTF8* targetstart = reinterpret_cast<UTF8*>( &((returnString)[ 0 ]) );
			UTF8* thisFirstWChar = targetstart;
			UTF8* targetend = targetstart + utf8size;
			ConversionResult res = ConvertUTF32toUTF8( &sourcestart, sourceend, &targetstart, targetend, strictConversion );

			if ( res != conversionOK )
			{
				throw Exception(Exception::ERROR_WIDE_2_UTF8, String("Could not convert from wide string to UTF8."));
			}

			returnString.resize(targetstart - thisFirstWChar);
		}

		else
		{
			throw Exception(Exception::ERROR_WIDE_2_UTF8, String("Could not convert from wide string to UTF8."));
		}
		return returnString;
	}
开发者ID:fire-archive,项目名称:OgreCollada,代码行数:49,代码来源:COLLADABUStringUtils.cpp

示例5: CreateFile

Win32Stream::Win32Stream(const WideString& path, IO::Access access)
    : m_path(path)
{
    DWORD wac = 0;
    if (access & IO::AccessRead)
        wac |= GENERIC_READ;
    if (access & IO::AccessWrite)
        wac |= GENERIC_WRITE;

    m_hFile = CreateFile(path.c_str(), wac, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
    if (m_hFile == INVALID_HANDLE_VALUE)
        Win32ThrowLastError("Win32Stream::Win32Stream '%S'", path.c_str());

    Stats::IncrementCount(Stats::FileHandles);
}
开发者ID:kona4kona,项目名称:HiME,代码行数:15,代码来源:hime-vfs-win32.cpp

示例6: SendEmail

bool MailSender::SendEmail(const WideString& email, const WideString& subject, const WideString& messageText)
{
	// Don't try to send email if recipient is not set
	if (email.empty() || email == L"")
		return false;
	WideString mailtoText = L"";
	
	// Create mailto text
	mailtoText = Format(L"mailto:?to=%s&subject=%s&body=%s", email.c_str(), subject.c_str(), messageText.c_str());
	// Call default mail client
	int result = (int)ShellExecute(NULL, L"open", mailtoText.c_str(), NULL, NULL, SW_SHOWNORMAL);
	
	// If the function succeeds, it returns a value greater than 32.
	// If the function fails, it returns an error value that indicates the cause of the failure. 
	return (result > 32);
}
开发者ID:droidenko,项目名称:dava.framework,代码行数:16,代码来源:MailSender.cpp

示例7: addString

int ComboFrame::addString(WideString text, int data)
{
  int id = SendMessage(hWnd, CB_ADDSTRING, 0, (uint32) text.c_str());
  if (id != CB_ERR)
    SendMessage(hWnd, CB_SETITEMDATA, id, data);
  return id;
}
开发者ID:NateChambers,项目名称:mule-view,代码行数:7,代码来源:controlframes.cpp

示例8: directoryExists

	//--------------------------------
	bool Utils::directoryExists( const WideString &pathString )
	{
		bool pathExists = false;

#ifdef COLLADABU_OS_WIN
		SystemType type = getSystemType();
		if( type != WINDOWS )
			return false;

		const wchar_t* currentPath = _wgetcwd( 0, 0);
		const wchar_t* testPath = pathString.c_str();

		pathExists = _wchdir( testPath ) == 0;
		_wchdir( currentPath );
		return pathExists;
#else
		SystemType type = getSystemType();
		if( type != POSIX )
			return false;

		//...
#endif

		return pathExists;
	}
开发者ID:A-Bronco,项目名称:OpenCOLLADA,代码行数:26,代码来源:COLLADABUUtils.cpp

示例9: Render

void CRespawn::Render()
{
    position2d<s32> pos;
    for ( int i = 0; i < points.size(); i++ )
    {
      WideString wstr = "(S) ";
      wstr += points[i]->getActorName().c_str();
      pos = IRR.smgr->getSceneCollisionManager()->getScreenCoordinatesFrom3DPosition( points[i]->getPosition(), IRR.smgr->getActiveCamera() );
      IRR.gui->getBuiltInFont()->draw( wstr.c_str(), core::rect<s32>( pos.X, pos.Y, pos.X + 100, pos.Y + 50 ), irr::video::SColor( 255, 15, 85, 10 ), false, true );
    }

    // draw 3d stuff
    IRR.video->setTransform( ETS_WORLD, matrix4() );

    SMaterial m; 
    m.Lighting = false; 
    m.BackfaceCulling = false;
    IRR.video->setMaterial( m );
    vector3df vP;
    for ( int i = 0; i < points.size(); i++ )
    {
      vP = points[i]->getPosition();
      IRR.video->draw3DBox( aabbox3df( vP - vector3df( points[i]->radius, points[i]->radius, points[i]->radius ), vP + vector3df( points[i]->radius, points[i]->radius, points[i]->radius ) ), SColor( 255, 105, 22, 90 ) );
    }
}
开发者ID:master4523,项目名称:crimsonglory,代码行数:25,代码来源:respawn.cpp

示例10: nameTree

TEST(cpdf_nametree, GetUnicodeNameWithBOM) {
  // Set up the root dictionary with a Names array.
  auto pRootDict = pdfium::MakeUnique<CPDF_Dictionary>();
  CPDF_Array* pNames = pRootDict->SetNewFor<CPDF_Array>("Names");

  // Add the key "1" (with BOM) and value 100 into the array.
  std::ostringstream buf;
  constexpr char kData[] = "\xFE\xFF\x00\x31";
  for (size_t i = 0; i < sizeof(kData); ++i)
    buf.put(kData[i]);
  pNames->AddNew<CPDF_String>(ByteString(buf), true);
  pNames->AddNew<CPDF_Number>(100);

  // Check that the key is as expected.
  CPDF_NameTree nameTree(pRootDict.get());
  WideString storedName;
  nameTree.LookupValueAndName(0, &storedName);
  EXPECT_STREQ(L"1", storedName.c_str());

  // Check that the correct value object can be obtained by looking up "1".
  WideString matchName = L"1";
  CPDF_Object* pObj = nameTree.LookupValue(matchName);
  ASSERT_TRUE(pObj->IsNumber());
  EXPECT_EQ(100, pObj->AsNumber()->GetInteger());
}
开发者ID:,项目名称:,代码行数:25,代码来源:

示例11:

TEST_F(CFGAS_FormatStringTest, DateTimeFormat) {
  struct {
    const wchar_t* locale;
    const wchar_t* input;
    const wchar_t* pattern;
    const wchar_t* output;
  } tests[] = {
      {L"en", L"1999-07-16T10:30Z",
       L"'At' time{HH:MM Z} 'on' date{MMM DD, YYYY}",
       L"At 10:30 GMT on Jul 16, 1999"},
      {L"en", L"1999-07-16T10:30", L"'At' time{HH:MM} 'on' date{MMM DD, YYYY}",
       L"At 10:30 on Jul 16, 1999"},
      {L"en", L"1999-07-16T10:30Z",
       L"time{'At' HH:MM Z} date{'on' MMM DD, YYYY}",
       L"At 10:30 GMT on Jul 16, 1999"},
      {L"en", L"1999-07-16T10:30Z",
       L"time{'At 'HH:MM Z}date{' on 'MMM DD, YYYY}",
       L"At 10:30 GMT on Jul 16, 1999"}};

  for (size_t i = 0; i < FX_ArraySize(tests); ++i) {
    WideString result;
    EXPECT_TRUE(fmt(tests[i].locale)
                    ->FormatDateTime(tests[i].input, tests[i].pattern,
                                     FX_DATETIMETYPE_TimeDate, &result));
    EXPECT_STREQ(tests[i].output, result.c_str()) << " TEST: " << i;
  }
}
开发者ID:,项目名称:,代码行数:27,代码来源:

示例12: WideString2QStrint

QString WideString2QStrint(const WideString& str)
{
#ifdef __DAVAENGINE_MACOS__
	return QString::fromStdWString(str);
#else
	return QString((const QChar*)str.c_str(), str.length());
#endif
}
开发者ID:,项目名称:,代码行数:8,代码来源:

示例13: toString

//=====================================================================================
String IC_StrConv::toString( const WideString str )
{
    int len = str.size() + 1;
    c8* buf = new c8[len];
    ::wcstombs( buf, str.c_str(), len );
    String wstr = buf;
    delete[] buf;
    return wstr;
}
开发者ID:master4523,项目名称:crimsonglory,代码行数:10,代码来源:console_utils.cpp

示例14: WideCharToMultiByte

String UTF8Utils::EncodeToUTF8(const WideString& wstring)
{
	int32 bufSize = WideCharToMultiByte(CP_UTF8, 0, wstring.c_str(), -1, 0, 0, NULL, NULL);
	if (!bufSize)
	{
		return "";
	}

	String resStr = "";

	char* buf = new char[bufSize];
	int32 res = WideCharToMultiByte(CP_UTF8, 0, wstring.c_str(), -1, buf, bufSize, NULL, NULL);
	if (res)
	{
		resStr = String(buf);
	}

	delete[] buf;
	return resStr;
};
开发者ID:,项目名称:,代码行数:20,代码来源:

示例15: CreateGlobalText

HGLOBAL CreateGlobalText(WideString text)
{
  HGLOBAL data = GlobalAlloc(GMEM_MOVEABLE, (text.length() + 1) * 2);
  wchar_t* ptr = (wchar_t*) GlobalLock(data);
  if (ptr)
  {
    wcscpy(ptr, text.c_str());
    GlobalUnlock(data);
  }
  return data;
}
开发者ID:NateChambers,项目名称:mule-view,代码行数:11,代码来源:dragdrop.cpp


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