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


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

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


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

示例1: if

 Handle<Value> Statement::GetFieldValueByIndex(const Arguments& args)
 {
	 Statement* pStatement = ObjectWrap::Unwrap<Statement>(args.This());
	 HandleScope scope;
	 int index = args[0]->Int32Value();
	 Sqlite3_XX::VARIANT var = pStatement->pRecord->GetFieldValue(index);
	 if (var.vt == Sqlite3_XX::VT_BSTR)
	 {
		 TSTRING value = var.bstrVal;
#ifdef OS_WIN32
		 return scope.Close(String::New(encodeConv::CodingConv::Unicode2Utf8(value.c_str()).c_str()));

#elif defined OS_LINUX
		  return scope.Close(String::New(value.c_str()));
#endif

	 }
	 else if (var.vt == Sqlite3_XX::VT_I4)
	 {
		 return scope.Close(Integer::New(var.intVal));
	 }
	 else if (var.vt == Sqlite3_XX::VT_R8)
	 {
		  return scope.Close(Number::New(var.dblVal));
	 }
	return Undefined();
	
 }
开发者ID:Rudeman,项目名称:achat,代码行数:28,代码来源:Statement.cpp

示例2: ReadDir

void cUnixFSServices::ReadDir(const TSTRING& strFilename, std::vector<TSTRING>& v, bool bFullPaths) const
{
#else
void cUnixFSServices::ReadDir(const TSTRING& strFilenameC, std::vector<TSTRING>& v, bool bFullPaths) const
{
    TSTRING strFilename = cDevicePath::AsNative(strFilenameC);
#endif

    //Get all the filenames
    DIR* dp = 0;

#if defined(O_DIRECTORY) && defined(O_NOATIME)
    //dfd will be autoclosed by closedir(), should not be explicitly closed.
    int dfd = open(strFilename.c_str(), O_RDONLY | O_DIRECTORY | O_NOATIME);
    if (dfd > 0)
        dp = fdopendir(dfd);
#else
    dp = opendir(strFilename.c_str());
#endif

    if (dp == NULL)
    {
        throw eFSServicesGeneric(strFilename, iFSServices::GetInstance()->GetErrString());
        return;
    }

    struct dirent* d;

    while ((d = readdir(dp)) != NULL)
    {
        if ((strcmp(d->d_name, _T(".")) != 0) && (strcmp(d->d_name, _T("..")) != 0))
        {
            if (bFullPaths)
            {
                //Create the full pathname
                TSTRING strNewName = strFilename;

                // get full path of dir entry
                util_TrailingSep(strNewName, true);
                strNewName += d->d_name;

                // save full path name
                v.push_back(strNewName);
            }
            else
                v.push_back(d->d_name);
        }
    }

    //Close the directory
    closedir(dp);
}
开发者ID:Tripwire,项目名称:tripwire-open-source,代码行数:52,代码来源:unixfsservices.cpp

示例3: _GetNumberFormat

TSTRING OverwriteDlg::_GetNumberFormat(UINT64 ui64Num) {

  TSTRING r;

  sprintf(r, _T("%I64d"), ui64Num);

  int iAlloc = GetNumberFormat(LOCALE_SYSTEM_DEFAULT,
                               0UL,
                               r.c_str(),
                               NULL,
                               NULL,
                               0);

  if (0 < iAlloc) {

    TCHAR *szBuf = new TCHAR[iAlloc];

    if (NULL != szBuf) {

      RtlZeroMemory(szBuf, iAlloc * sizeof(TCHAR));

      NUMBERFMT nf          = {0};
      TSTRING tsDecSep  = _GetLocaleInfoString(LOCALE_SMONDECIMALSEP);
      TSTRING tsThouSep = _GetLocaleInfoString(LOCALE_STHOUSAND);

      nf.LeadingZero   = _GetLocaleInfoNumeric(LOCALE_ILZERO);
      nf.Grouping      = _GetLocaleInfoNumeric(LOCALE_SGROUPING);
      nf.lpDecimalSep  = const_cast<TCHAR *>(tsDecSep.c_str());
      nf.lpThousandSep = const_cast<TCHAR *>(tsThouSep.c_str());
      nf.NegativeOrder = _GetLocaleInfoNumeric(LOCALE_INEGNUMBER);
      nf.NumDigits     = 0U;

      if (0 != GetNumberFormat(LOCALE_SYSTEM_DEFAULT,
                               0UL,
                               r.c_str(),
                               &nf,
                               szBuf,
                               iAlloc))
      {

        r = szBuf;

      }

      delete szBuf;
    }

  }

  return r;
}
开发者ID:ryanlederman,项目名称:extfilecopy,代码行数:51,代码来源:OverwriteDlg.cpp

示例4: NewItem

bool CHelpDB::NewItem(CTSTRING& _sAlias, CTSTRING& sText, CTSTRING& sCreator)
{
    MSXML::IXMLDOMElementPtr El;
    bool r = false;
    if(m_doc == 0) return false;
    TSTRING sAlias;

    {
        TCHAR* tsz = _tcsdup(_sAlias.c_str());
        _tcsupr(tsz);
        sAlias = tsz;
        SAFE_FREE(tsz);
    }

    // Just determine if it exists.
    if(GetItemElement(sAlias, El, false))
    {
        // it already exists; fail.
        sprintf(m_err, _T("%s already exists.  If you want to change the existing entry, use !msgchange."), sAlias.c_str());
        g_pLog->msg(_T("%s"), m_err.c_str());
    }
    else
    {
        // doesn't already exist... we're golden like the shower.  This time
        // just call GetItemElement() with bCreate set to true.
        if(!GetItemElement(sAlias, El, true))
        {
            sprintf(m_err, _T("%s could not be added."), sAlias.c_str());
            g_pLog->msg(_T("%s"), m_err.c_str());
        }
        else
        {
            El->setAttribute(TAG_ALIAS, sAlias.c_str());
            El->setAttribute(TAG_CREATOR, sCreator.c_str());
            El->setAttribute(TAG_TEXT, sText.c_str());
            El->setAttribute(TAG_USAGE, _T("0"));
            SYSTEMTIME st;
            TSTRING sTime;
            GetLocalTime(&st);
            Bin2Str(sTime, (BYTE*)&st, sizeof(st));
            El->setAttribute(TAG_TIME, sTime.c_str());

            g_pLog->msg(_T("New db item: %s = %s"), _sAlias.c_str(), sText.c_str());

            r = true;
        }
    }

    return r;
}
开发者ID:thenfour,项目名称:_tWinMain,代码行数:50,代码来源:oldhelp.cpp

示例5: LoadSound

void CSoundManager::LoadSound( TSTRING szFilename, TSTRING szReference, bool isMusic )
{
	CSGD_XAudio2* pXA = CSGD_XAudio2::GetInstance();
	int newID;
	if( isMusic )
		newID = pXA->MusicLoadSong(szFilename.c_str());
	else
		newID = pXA->SFXLoadSound(szFilename.c_str());

	SoundID newSoundID;
	newSoundID.first = szReference;
	newSoundID.second = newID;

	m_vSoundIDs.push_back(newSoundID);
}
开发者ID:Jon-Stumpfel,项目名称:league-of-champion-craft,代码行数:15,代码来源:SoundManager.cpp

示例6: _SetStaticText

bool OverwriteDlg::_SetStaticText(Window &Wnd, CTSTRING &tsFileName) {

  bool r = false;
  FILESIZE fs;

  if (FileGetSize(tsFileName, fs)) {

    FILETIMES ft;

    if (FileGetTime(tsFileName, ft)) {

     /*
      * Set the text of the static control as follows:
      *
      * [size in bytes] [formatted size]
      * [created date]
      * [modified date]
      */
      TSTRING tsTemp;
      TSTRING tsFormatBytes = _GetNumberFormat(fs.ui64Bytes);                    

      sprintf(tsTemp, _T("%s Bytes (%s)\nCreated: %s\nModified: %s"),
              tsFormatBytes.c_str(), fs.tsStrFmt.c_str(),
              ft.tsLongCreated.c_str(), ft.tsLongModified.c_str());

      Wnd.SetWindowText(tsTemp);
      r = true;

    }

  }

  return r;
}
开发者ID:ryanlederman,项目名称:extfilecopy,代码行数:34,代码来源:OverwriteDlg.cpp

示例7: LookupArgInfo

///////////////////////////////////////////////////////////////////////////////
// LookupArgInfo
///////////////////////////////////////////////////////////////////////////////
bool cCmdLineParser::LookupArgInfo(int argId, TSTRING& arg, TSTRING& alias) const
{
    arg     = _T("");
    alias   = _T("");

    cHashTableIter<TSTRING, cArgInfo> iter(mArgTable);
    for(iter.SeekBegin(); ! iter.Done(); iter.Next())
    {
        if(iter.Val().mId == argId)
        {
            TSTRING str = iter.Key();
            if((str.length() > 0) && (str[0] == _T('-')))
            {
                // this is the alias!
                alias = (str.c_str() + 1);
            }
            else
            {
                // this is the arg...
                arg = str;
            }
        }
    }
    return ((! arg.empty()) || (! alias.empty()));
}
开发者ID:brc0x1,项目名称:tripwire-open-source,代码行数:28,代码来源:cmdlineparser.cpp

示例8: _DoZeroAccumulator

void CameraControlsDlg::_DoZeroAccumulator(void) {

  TSTRING tsMsg;

  sprintf(tsMsg, _T("Are you sure you want")
          _T(" to zero the step accumulator and")
          _T(" global frame count?\n\n")
          _T("Frame count is currently: %d\n"),
          *m_pdwFrameCount);

  if (IDYES == MessageBox(m_hWnd, tsMsg.c_str(),
                          _T("FURR - Confirm Accumulator Reset"),
                          MB_YESNO | MB_ICONQUESTION))
  {

    if (!m_AMSComm.Camera_ResetAccumulator()) {

      _ThrowAMSError();

    } else {

      *m_pdwFrameCount = 0UL;
      m_pParent->Output(FURR_OT_INFORMATION, _T("CameraControls:")
                        _T("Set step accumulator and frame count to zero"));

    }

  }

}
开发者ID:ryanlederman,项目名称:furr,代码行数:30,代码来源:cameracontrolsdlg.cpp

示例9: getDateTimeString

	/// <summary>
	/// <para name='Name'>SLog::getDateTimeString</para>
	/// <para name='Purpose'>Return a formatted date time string</para>
	/// </summary>
	/// <param name='logFormat'>indicate whether to return the date time string in log format or decoration format</param>
	/// <returns>a formatted date/time string</returns>
	/// <remarks>
	/// <para name='Notes'></para>
	/// <para name='Author'>Kenn Guilstorf</para>
	/// <para name='LastModified'>2015-10-26</para>
	/// </remarks>
	TSTRING SLog::getDateTimeString(bool logFormat)
	{
		TSTRING retValue;
		TSTRING strFormat;
		TCHAR* chBuffer = new TCHAR[50];
		SYSTEMTIME st;

		if (logFormat)
		{
			strFormat = TSTRING(_T("%04d-%02d-%02d %02d:%02d:%02d.%03d | "));
		}
		else
		{
			strFormat = TSTRING(_T(".%04d%02d%02d.%02d%02d%02d%03d"));
		}

		GetLocalTime(&st);

		SPRINTF(chBuffer,
			50,
			strFormat.c_str(),
			(int)st.wYear, 
			(int)st.wMonth, 
			(int)st.wDay, 
			(int)st.wHour, 
			(int)st.wMinute, 
			(int)st.wSecond, 
			(int)st.wMilliseconds);
		
		retValue = TSTRING(chBuffer);

		return retValue;
	}
开发者ID:KennGuilstorf,项目名称:SPerfTest,代码行数:44,代码来源:SLog.cpp

示例10: Rename

////////////////////////////////////////////////////////////////////////
// Function name    : cUnixFSServices::Rename
// Description      : Rename a file.  Overwrites newname if it exists.and overwrite is true
//
// Returns          : false if failure, true on success
bool cUnixFSServices::Rename(const TSTRING& strOldName, const TSTRING& strNewName, bool overwrite) const
{
#ifdef _UNICODE
#    error UNICODE Rename not implemented
#endif

    // delete new file if overwriting
    if (overwrite)
        if (access(strNewName.c_str(), F_OK) == 0 && remove(strNewName.c_str()) != 0)
            return false;

    if (rename(strOldName.c_str(), strNewName.c_str()) == 0)
        return true;

    // Note: errno will be set
    return false;
}
开发者ID:Tripwire,项目名称:tripwire-open-source,代码行数:22,代码来源:unixfsservices.cpp

示例11: GetItemElement

bool CHelpDB::GetItemElement(CTSTRING& _sAlias, MSXML::IXMLDOMElementPtr& Out, bool bCreate)
{
    bool r = false;
    TSTRING sXPath;
    MSXML::IXMLDOMNodePtr Node;
    TSTRING sAlias;

    {
        TCHAR* tsz = _tcsdup(_sAlias.c_str());
        _tcsupr(tsz);
        sAlias = tsz;
        SAFE_FREE(tsz);
    }

    // this will look something like MSG[@ALIAS="hithere"]
    sprintf(sXPath, TAG_MSG _T("[@") TAG_ALIAS _T("=\"%s\"]"), sAlias.c_str());

    try
    {
        Node = m_root->selectSingleNode(_bstr_t(sXPath.c_str()));

        if((Node == NULL) && (bCreate == true))
        {
            MSXML::IXMLDOMElementPtr NewEl;
            MSXML::IXMLDOMNodePtr NewNode;

            NewEl = m_doc->createElement("MSG");
            NewEl.QueryInterface(__uuidof(MSXML::IXMLDOMNode), &NewNode);
            Node = m_root->appendChild(NewNode);
        }

        if(Node != NULL)
        {
            Node.QueryInterface(__uuidof(MSXML::IXMLDOMElement), &Out);
            r = true;
        }
    }
    catch(_com_error& e)
    {
        sprintf(m_err, _T("COM Error: %08x"), e.Error());
        g_pLog->msg(_T("CHelpDB::GetItemElement(%s)"), _sAlias.c_str());
    }

    return r;
}
开发者ID:thenfour,项目名称:_tWinMain,代码行数:45,代码来源:oldhelp.cpp

示例12: util_FileExists

bool util_FileExists(const TSTRING& fileName)
{
#if IS_UNIX
    // for unix we may be able to use the same logic as above, but
    // it is too close to 2.2.1 release to make that change w/o testing.
    // I know the above works for windows.
    return _taccess(fileName.c_str(), F_OK) == 0;
#endif
}
开发者ID:jiangzhw,项目名称:tripwire-open-source,代码行数:9,代码来源:siggencmdline.cpp

示例13: Undefined

Handle<Value> Statement::GetFieldName(const Arguments& args)
 {
	 int index = args[0]->Int32Value();
	 HandleScope scope;
	 Statement* pStatement = ObjectWrap::Unwrap<Statement>(args.This());
	 TSTRING name = pStatement->pRecord->GetFieldName(index);

#ifdef OS_WIN32
	 return scope.Close(String::New(encodeConv::CodingConv::Unicode2Utf8(name.c_str()).c_str()));

	 
#elif defined OS_LINUX
	  return scope.Close(String::New(name.c_str()));

#endif
	  return Undefined();

 }
开发者ID:Rudeman,项目名称:achat,代码行数:18,代码来源:Statement.cpp

示例14: PrintIter

static void PrintIter(const iFCOIter* pIter, cDebug& d)
{
    TSTRING str;
    for(; ! pIter->Done(); pIter->Next())
    {
        str += pIter->FCO()->GetName().AsString().c_str();
        str += _T(" ");
    }
    d.TraceDebug(_T("%s\n"), str.c_str());
}
开发者ID:brc0x1,项目名称:tripwire-open-source,代码行数:10,代码来源:fcosetimpl_t.cpp

示例15: SendString

void cPipedMailMessage::SendString(const TSTRING& s)
{
    if (_ftprintf(mpFile, "%s", s.c_str()) < 0)
    {
        TOSTRINGSTREAM estr;
        estr << TSS_GetString(cTripwire, tripwire::STR_ERR2_MAIL_MESSAGE_COMMAND) << mstrSendMailExePath;

        throw eMailPipedOpen(estr.str());
    }
}
开发者ID:Tripwire,项目名称:tripwire-open-source,代码行数:10,代码来源:pipedmailmessage.cpp


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