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


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

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


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

示例1: makeRelativePath

LString makeRelativePath(const LString &aAbs, const LString &aBase)
{
  fs::path abspath(aAbs.c_str());
  fs::path basepath(aBase.c_str());
  if (!abspath.is_complete() || !basepath.is_complete())
    return aAbs; // aAbs or aBase is not absolute path

  if (abspath.root_path()!=basepath.root_path())
    return aAbs; // root names are different; cannot make relative path

  fs::path::const_iterator iter1 = abspath.begin();
  fs::path::const_iterator iter1_end = abspath.end();
  fs::path::const_iterator iter2 = basepath.begin();
  fs::path::const_iterator iter2_end = basepath.end();

  for (; iter1!=iter1_end && iter2!=iter2_end ; ++iter1, ++iter2) {
    if (*iter1!=*iter2) break;
  }

  fs::path relpath;
  //if (iter1!=iter1_end && iter2!=iter2_end) {
    for (; iter2!=iter2_end; ++iter2)
      relpath /= "..";
    for (; iter1!=iter1_end; ++iter1)
      relpath /= *iter1;
  //}

  // string() will canonicalize the path separator to "/"
  //return relpath.file_string();
  return relpath.string();
}
开发者ID:CueMol,项目名称:cuemol2,代码行数:31,代码来源:Utils.cpp

示例2: read

void SceneXMLReader::read()
{
  // If getPath() points to a relative path,
  // convert it to the absolute path name using the fs::current_path() (i.e. pwd)
  fs::path curpath = fs::current_path();
#if (BOOST_FILESYSTEM_VERSION==2)
  LString localfile = qlib::makeAbsolutePath(getPath(), curpath.file_string());
#else
  LString localfile = qlib::makeAbsolutePath(getPath(), curpath.string());
#endif


  // Enter the loading scene's context
  AutoStyleCtxt style_ctxt(m_pClient->getUID());
  
  // show start msg
  LOG_DPRINTLN("SceneXML> Start loading: %s ...", localfile.c_str());

  //
  // Setup streams
  //
  qlib::FileInStream fis;
  fis.open(localfile);
  qlib::LDom2InStream ois(fis);

  //
  // Construct data structure
  //   from the XML part in the target scene file.
  //
  qlib::LDom2Tree tree;
  ois.read(tree);
  LDom2Node *pNode = tree.top();

  m_pClient->setSource(localfile);
  m_pClient->setSourceType(getName());

  // perform deserialization to the client scene (m_pClient)
  tree.deserialize(&m_pClient);

  // load data source / collect chunk-load requests
  procDataSrcLoad(ois, pNode);

  // perform chunk loading
  procDataChunks(ois, pNode);

  ois.close();
  m_pClient->setUpdateFlag();
  m_errmsg = pNode->getErrorMsgs();

  LOG_DPRINTLN("SceneXML> File loaded: %s.", localfile.c_str());

  //////////
  // fire the scene-loaded event
  {
    SceneEvent ev;
    ev.setTarget(m_pClient->getUID());
    ev.setType(SceneEvent::SCE_SCENE_ONLOADED);
    m_pClient->fireSceneEvent(ev);
  }
}
开发者ID:biochem-fan,项目名称:cuemol2,代码行数:60,代码来源:SceneXMLReader.cpp

示例3:

LSerializable *LDOMObjInStream::readObjImpl()
{
  LString clsname = m_data.current()->type_name;
//  const int ncs = m_pCurNode->children.size();
//  const int nelems = LDomTree::getElemCount(*m_pCurNode);
//  const int nattrs = ncs-nelems;

  ClassRegistry *pMgr = ClassRegistry::getInstance();
  LClass *pClass = pMgr->getClassObj(clsname);
  if (pClass==NULL) {
    LOG_DPRINTLN("ERROR class \"%s\" is not defined", clsname.c_str());
    return NULL;
  }
  
  // createScrObj() creates SmartPtr object, if the class supports it.
  LDynamic *pNewObj = pClass->createScrObj();
  if (pNewObj==NULL) {
    LOG_DPRINTLN("ERROR cannot instantiate class \"%s\"", clsname.c_str());
    return NULL;
  }
  LSerializable *pS = dynamic_cast<LSerializable *>(pNewObj);
  if (pS==NULL) {
    LOG_DPRINTLN("ERROR cannot instantiate class \"%s\"", clsname.c_str());
    return NULL;
  }

  pS->readFrom(*this);

  return pS;
}
开发者ID:biochem-fan,项目名称:cuemol2,代码行数:30,代码来源:LDOMObjStream.cpp

示例4: Load

bool clLibrary::Load( const LString& LibName )
{
#if defined( OS_WINDOWS )
	FLibHandle = ::LoadLibrary( LibName.c_str() );

	if ( !FLibHandle )
	{
		LString DLL = FindLibrary( LibName );

		FLibHandle = ::LoadLibrary( DLL.c_str() );
	}

#else
	const char* ErrStr;

	FLibHandle = dlopen( LibName.c_str(), RTLD_LAZY );

	if ( ( ErrStr = dlerror() ) != NULL )
	{
		FLibHandle = NULL;
	}

#endif

	CHECK_RET( !FLibHandle, false, "Unable to load library " + LibName );

	return true;
}
开发者ID:berezhkovskaya,项目名称:Carousel3D,代码行数:28,代码来源:Library.cpp

示例5: addLinkByName

/** register new linkage between two residues */
bool TopoDB::addLinkByName(const LString &prev_res, char prev_ch,
			     const LString &next_res, char next_ch,
			     const LString &link_name)
{
  //MB_DPRINT("addLinkByName search %s\n",plusname.c_str());
  ResiPatch *pPatch = patchPrefixGet('+', link_name);
  if (pPatch==NULL)
    return false;

  // process the case in that prev and next is inverted
  if (pPatch->getPrevPrefix()!=prev_ch ||
      pPatch->getNextPrefix()!=next_ch) {

    pPatch = patchPrefixGet('-', link_name);

    if (pPatch->getPrevPrefix()!=prev_ch ||
        pPatch->getNextPrefix()!=next_ch)
      return false;
  }

  Linkage link;
  link.prev = prev_ch;
  link.next = next_ch;
  link.patch_name = pPatch->getName();

  LString key(prev_res.c_str());
  key.append(':');
  key.append(next_res.c_str());

  //MB_DPRINT("linkage LINK register %s\n",key.c_str());
  return m_linkDict.set(key, link);
  //return true;
}
开发者ID:biochem-fan,项目名称:cuemol2,代码行数:34,代码来源:TopoDB.cpp

示例6: procDataChunks

void SceneXMLReader::procDataChunks(qlib::LDom2InStream &ois, LDom2Node *pNode)
{
  for (;;) {
    try {
      LString chunkid = ois.getNextDataChunkID();
      if (chunkid.isEmpty())
        return;
      MB_DPRINTLN("SceneXMLReader> load datachunk: %s", chunkid.c_str());

      //LDataSrcContainer *pCnt = findChunkObj(chunkid);
      LDataSrcContainer *pCnt = ois.findChunkObj(chunkid);
      if (pCnt==NULL) {
        LOG_DPRINTLN("SceneXMLReader> data container for chunk %s not found.", chunkid.c_str());
        return;
      }

      qlib::InStream *pin = ois.getNextChunkStream();
      pCnt->readFromStream(*pin);
      ois.closeChunkStream(pin);
      
    }
    catch (qlib::LException &e) {
      pNode->appendErrMsg("SceneXML> Load object error (ignored).");
      pNode->appendErrMsg("SceneXML> Reason: %s", e.getMsg().c_str());
    }
    catch (...) {
      pNode->appendErrMsg("SceneXML> Load object error (ignored).");
      pNode->appendErrMsg("SceneXML> Reason: unknown");
    }
  }
}
开发者ID:biochem-fan,项目名称:cuemol2,代码行数:31,代码来源:SceneXMLReader.cpp

示例7: setProp

bool XmlRpcMgr::setProp(qlib::uid_t uid, const LString &propnm, const xmlrpc_c::value *pVal)
{
  qlib::LScriptable *pObj = getObj(uid);
  if (pObj==NULL) {
    // TO DO: report error
    MB_DPRINTLN("SetProp error, object %d not found", uid);
    return false;
  }
  
  ReoSetProp evt;
  evt.m_pObj = pObj;
  evt.m_propname = propnm;

  //////////
  // convert to LVariant

  // variant (lvar) doesn't have ownership of its content
  qlib::LVariant &lvar = evt.m_value;
  bool ok = false;
  LString errmsg;
  try {
    convXrval2Lvar(pVal, lvar);
    ok = true;
  }
  catch (const qlib::LException &e) {
    errmsg = 
      LString::format("SetProp(%s) cannot converting PyObj to LVariant: %s",
		      propnm.c_str(), e.getMsg().c_str());
    MB_DPRINTLN("Err: %s", errmsg.c_str());
  }
  catch (...) {
    errmsg = 
      LString::format("SetProp(%s): Cannot converting PyObj to LVariant.", propnm.c_str());
    MB_DPRINTLN("Err: %s", errmsg.c_str());
  }

  if (!ok) {
    // TO DO: report error
    return false;
  }

  MB_DPRINTLN("XMLRPC> svrthr SetProp conv OK ");

  //////////
  // perform setProperty

  m_pQue->putWait(&evt);
  if (!evt.m_bOK) {
    throw ( xmlrpc_c::fault(evt.m_errmsg.c_str(), xmlrpc_c::fault::CODE_UNSPECIFIED) );
    return qlib::invalid_uid;
  }
  
  MB_DPRINTLN("XMLRPC> svrthr setProp() putWait OK");

  // OK
  return true;
}
开发者ID:CueMol,项目名称:cuemol2,代码行数:57,代码来源:XmlRpcMgr.cpp

示例8: SetViewportTitle

void clViewport::SetViewportTitle( const LString& Title )
{
#ifdef OS_WINDOWS
    SetWindowText( FWindowHandle, Title.c_str() );
#endif

#if defined(OS_LINUX) && !defined(OS_ANDROID)
    XSetStandardProperties( FDeviceHandle, *FWindowHandle, Title.c_str(), Title.c_str(), None, NULL, 0, NULL );
#endif
}
开发者ID:mildrock,项目名称:Carousel3D,代码行数:10,代码来源:Viewport.cpp

示例9: makeAbsolutePath

LString makeAbsolutePath(const LString &aRel, const LString &aBase)
{
  MB_DPRINTLN("makeAbsPath rel=%s, base=%s", aRel.c_str(), aBase.c_str());

  fs::path relpath(aRel.c_str());
  fs::path basepath(aBase.c_str());
  if (relpath.is_complete())
    return aRel; // aRel is already in abs form

  // convert to the absolute representation

  fs::path::const_iterator iter1 = relpath.begin();
  fs::path::const_iterator iter1_end = relpath.end();

  int nup = 0;
  for (; iter1!=iter1_end; ++iter1) {
    if (*iter1=="..")
      ++nup;
    else
      break;
  }

  if (nup==0) {
    // There's no up-dir ('..') string --> just concat to make abs path.
#if (BOOST_FILESYSTEM_VERSION==2)
    relpath = fs::complete(relpath, basepath);
    return relpath.file_string();
#else
    relpath = fs::absolute(relpath, basepath);
    return relpath.string();
#endif
  }

  for (; nup>0; --nup) {
    MB_ASSERT(basepath.has_parent_path());
    basepath = basepath.parent_path();
  }
  
  for (; iter1!=iter1_end; ++iter1) {
    basepath /= *iter1;
  }

#if (BOOST_FILESYSTEM_VERSION==2)
  return basepath.file_string();
#else
  return basepath.string();
#endif
}
开发者ID:CueMol,项目名称:cuemol2,代码行数:48,代码来源:Utils.cpp

示例10: print

void PrintStream::print(const LString &n)
{
  int len = n.length();
  int res = write(n.c_str(), 0, len);
  if (res!=len)
    MB_THROW(IOException, LString::format("OutStream.write() failed. (%d:%d)", res, len));
}
开发者ID:CueMol,项目名称:cuemol2,代码行数:7,代码来源:PrintStream.cpp

示例11: ASE_ReadTVertexList

void clASELoader::ASE_ReadTVertexList( iIStream* FStream, clVAMender* Mender )
{
	guard();

#ifdef ASE_HEAVY_DEBUG
	Env->Logger->Log( L_DEBUG, "Reading Tvertex list..." );
#endif

	char Keyword[32];

	while ( !FStream->Eof() )
	{
		LString Line = FStream->ReadLineTrimLeadSpaces();

		if ( LStr::ContainsSubStr( Line, "}" ) )
		{
			break;
		}
		else if ( LStr::StartsWith( Line, ASE_MeshTVertex ) )
		{
			int Index;
			float U, V, W;

			sscanf( Line.c_str(), "%s %d %f %f %f", Keyword, &Index, &U, &V, &W );

			Mender->EmitTextureVertex( Index, LVector3( U, 1.0f - V, W ) );
		}
		else
		{
			FATAL_MSG( "Unexpected token in " + ASE_MeshTVertexList + " : " + Line );
		}
	}

	unguard();
}
开发者ID:berezhkovskaya,项目名称:Carousel3D,代码行数:35,代码来源:ASE.cpp

示例12: InitOpenAL

void clAudioThread::InitOpenAL()
{
#if L_AUDIO_USE_OPENAL
	guard();

//	Env->Logger->Log( L_LOG, "Initializing OpenAL..." );

	LString DeviceName = Env->Console->GetVarValueStr( "Audio.AudioDeviceName", "" );

	FDevice = alcOpenDevice( DeviceName.empty() ? NULL : DeviceName.c_str() );

	FATAL( !FDevice, "Unable to open OpenAL device" );

	FContext = alcCreateContext( FDevice, NULL );

	FATAL( !FContext, "Unable to create OpenAL context" );

	FATAL( !alcMakeContextCurrent( FContext ), "Unable to select OpenAL context" );

	Env->Logger->LogP( L_LOG, "OpenAL (%s, %s, %s), extensions : %s", alGetString( AL_VERSION ), alGetString( AL_VENDOR ), alGetString( AL_RENDERER ), alGetString( AL_EXTENSIONS ) );
//	Env->Logger->Log( L_LOG, "OpenAL vendor    : " + LString(  ) );
//	Env->Logger->Log( L_LOG, "OpenAL renderer  : " + LString( alGetString( AL_RENDERER ) ) );
//	Env->Logger->Log( L_LOG, "OpenAL extensions: " );
	/*
	   {
	      LString Extensions;
	      Extensions.assign( alGetString( AL_EXTENSIONS ) );
	      LStr::ReplaceAll( &Extensions, ' ', '\n' );
	      Env->Logger->Log( L_LOG, '\n' + Extensions );
	   }
	*/
	unguard();
#endif
}
开发者ID:berezhkovskaya,项目名称:Carousel3D,代码行数:34,代码来源:Audio_OpenAL.cpp

示例13: ReCacheC

void clResourcesManager::ReCacheC( const LString& Param )
{
	guard( "%s", Param.c_str() );

	if ( Param.empty() )
	{
		Env->Console->DisplayInfoTip( "Usage: RECACHE <file name>" );
		return;
	}

	iResource* Resource = Env->Resources->FindResourceInGraph( FResourcesGraph, Param );

	if ( !Resource )
	{
		Env->Console->DisplayError( "Unable to find resource: " + Param );
		return;
	}

	Env->Console->DisplayInfoTip( Resource->GetFileName() );
	Env->Console->Display( "Recaching " + Resource->ClassName() );

	Resource->ReloadResource( true );

	unguard();
}
开发者ID:berezhkovskaya,项目名称:Carousel3D,代码行数:25,代码来源:ResourcesManager.cpp

示例14: is_keyword

static bool is_keyword(const LString &name) {
    const char *str = name.c_str();
    int i = 0;
    while ((i <= 8) && str[i])
	i++;
    if (i > 8)
	return false;
    int start = len_start[i];
    int end = len_start[i+1];
    while ((start < end) && (str[0] > keywords[start][0]))
	start ++;
    if ((start >= end) || (str[0] != keywords[start][0]))
	return false;
    while ((start < end) && (str[0] == keywords[start][0])){
	const char *str1 = str + 1;
	const char *key1 = keywords[start] + 1;
	while ((*key1 == *str1) && *str1) {
	    key1++;
	    str1++;
	    }
	if (*str1 == *key1)
	    return true;
	start ++;
	}
    return false;
    }
开发者ID:jrk,项目名称:suif2,代码行数:26,代码来源:symbol_walkers.cpp

示例15: LoadAnimStates

void clMesh::LoadAnimStates( const LString& FileName )
{
	guard( "%s", FileName.c_str() );

	FAnimations = Env->Resources->LoadAnimation( FileName );

	unguard();
}
开发者ID:berezhkovskaya,项目名称:Carousel3D,代码行数:8,代码来源:Mesh.cpp


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