本文整理汇总了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();
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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");
}
}
}
示例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;
}
示例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
}
示例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
}
示例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));
}
示例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();
}
示例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
}
示例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();
}
示例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;
}
示例15: LoadAnimStates
void clMesh::LoadAnimStates( const LString& FileName )
{
guard( "%s", FileName.c_str() );
FAnimations = Env->Resources->LoadAnimation( FileName );
unguard();
}