本文整理汇总了C++中ogre::String::substr方法的典型用法代码示例。如果您正苦于以下问题:C++ String::substr方法的具体用法?C++ String::substr怎么用?C++ String::substr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::String
的用法示例。
在下文中一共展示了String::substr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: splitBaseFilename
//-----------------------------------------------------------------------
void StringUtil::splitBaseFilename(const Ogre::String& fullName,
Ogre::String& outBasename, Ogre::String& outExtention)
{
size_t i = fullName.find_last_of(".");
if (i == Ogre::String::npos)
{
outExtention.clear();
outBasename = fullName;
}
else
{
outExtention = fullName.substr(i+1);
outBasename = fullName.substr(0, i);
}
}
示例2: parseDate
/// __DATE__ sieht ca. so aus : Nov 08 2005
long parseDate(char* date)
{
Ogre::String dateStr = Ogre::String(date);
Ogre::String monthStr = dateStr.substr(0,3);
int day = Ogre::StringConverter::parseInt( dateStr.substr(4,2) );
int year = Ogre::StringConverter::parseInt( dateStr.substr(7,4) );
int month = 0;
while( month < 12 && monthStr.compare(sMonths[month]) != 0 )
month++;
return /* Jahr */ year * 100000 +
/* Monat */ (month+1) * 1000 +
/* Tag */ day * 10 +
/* Sub-Version */ 0;
}
示例3: _parseAnimSound
/** 解析animation sound */
void VEffectManager::_parseAnimSound(Ogre::DataStreamPtr &stream, VSkill *skill)
{
assert(skill != VNULL);
VAnimationSound *sound = skill->addAnimationSound();
assert(sound != VNULL);
Ogre::String line;
while (!stream->eof())
{
line = stream->getLine();
++mParsingLineNumber;
if (!(line.empty() || line.substr(0, 2) == "//"))
{
if (line == "}")
{
break;
}
else
{
_parseAnimSoundAttrib(line, sound);
}
}
}
}
示例4: ValidAttr
//-----------------------------------------------------------------------------
void Ogitors::COFSSceneSerializer::_upgradeOgsceneFileFrom2To3(TiXmlNode* ogsceneRootNode)
{
TiXmlElement* element = ogsceneRootNode->FirstChildElement();
unsigned int obj_count = 0;
Ogre::String objecttype;
OgitorsPropertyValueMap params;
OgitorsPropertyValue tmpPropVal;
Ogre::String objAttValue;
size_t offset = 0;
do
{
objAttValue = ValidAttr(element->Attribute("typename"), "");
if(objAttValue != "")
{
if((offset = objAttValue.find(" Object")) != Ogre::String::npos)
{
objAttValue = objAttValue.substr(0, offset);
element->SetAttribute("typename", objAttValue.c_str());
}
}
else
continue;
} while(element = element->NextSiblingElement());
}
示例5: _parseElement
/** 解析特效元素 */
void VEffectManager::_parseElement(const VString &type, Ogre::DataStreamPtr &stream, VEffect *effect)
{
VEffectElement *element = createElement(type);
assert(element != VNULL);
effect->addElement(element);
Ogre::String line;
while (!stream->eof())
{
line = stream->getLine();
++mParsingLineNumber;
if (!(line.empty() || line.substr(0, 2) == "//"))
{
// 跳过空行和注释行
if (line == "}")
{
break;
}
else
{
_parseElementAttrib(line, element);
}
}
}
}
示例6: while
Version::Version(const Ogre::String& version)
{
size_t length = version.length();
size_t offset = 0;
size_t foundAt;
Ogre::String component;
int index = 0;
while (index < MAX_COMPONENTS && offset < length)
{
//Extract the current component
foundAt = version.find('.', offset);
component = version.substr(offset);
this->components[index++] = Ogre::StringConverter::parseInt(component);
//Break out if there is no next '.'
if (foundAt == Ogre::String::npos)
break;
//Move past the next '.'
offset = foundAt + 1;
}
for (; index < MAX_COMPONENTS; index++)
this->components[index] = 0;
}
示例7: splitResourceName
VBOOL splitResourceName(const Ogre::String& name,Ogre::String& resourceName,Ogre::String& groupName)
{
Ogre::String::size_type pos = name.find_first_of(':');
if (pos ==Ogre::String::npos)
{
if (groupName.empty())
groupName = DEFAULT_RESOURCE_GROUP_NAME;
resourceName = name;
return VFALSE;
}
else
{
groupName = name.substr(0, pos);
resourceName = name.substr(pos+1,Ogre::String::npos);
return VTRUE;
}
}
示例8: parseWindowGeometry
void OgreSetup::parseWindowGeometry(Ogre::ConfigOptionMap& config, unsigned int& width, unsigned int& height, bool& fullscreen) {
auto opt = config.find("Video Mode");
if (opt != config.end()) {
Ogre::String val = opt->second.currentValue;
Ogre::String::size_type pos = val.find('x');
if (pos != Ogre::String::npos) {
width = Ogre::StringConverter::parseUnsignedInt(val.substr(0, pos));
height = Ogre::StringConverter::parseUnsignedInt(val.substr(pos + 1));
}
}
//now on to whether we should use fullscreen
opt = config.find("Full Screen");
if (opt != config.end()) {
fullscreen = (opt->second.currentValue == "Yes");
}
}
示例9: parseScript
void SaveGameManager::parseScript(Ogre::DataStreamPtr &stream, const Ogre::String &groupName)
{
Ogre::String name = stream->getName();
name = name.substr(0, name.length()-5); //delete ".save" at the and of the name
int pointpos = name.find_last_of(".");
name = name.substr(0, pointpos);
if(Ogre::StringConverter::isNumber(name))
{
mHighestSaveGameNumber = std::max(mHighestSaveGameNumber, Ogre::StringConverter::parseInt(name));
SaveGameFile* file = new SaveGameFile("", Ogre::StringConverter::parseInt(name));
LOG_MESSAGE(Logger::RULES, "Parsing header of save game: " + name + ".save");
SaveGameFileReader reader;
reader.parseSaveGameFileHeader(stream, groupName, file);
if(file->getProperty(SaveGameFile::PROPERTY_MODULEID) != "") // broken save game
mSaveGames[Ogre::StringConverter::parseInt(name)] = file;
}
}
示例10: parseScript
void AudioScriptLoader::parseScript(Ogre::DataStreamPtr& dataStream, const Ogre::String& groupName)
{
Ogre::String line;
bool nextIsOpenBrace = false;
mScriptContext.mSection = ASS_NONE;
mScriptContext.mSection= ASS_NONE;
mScriptContext.mSound.setNull();
mScriptContext.mLineNo = 0;
mScriptContext.mFileName=dataStream->getName();
mScriptContext.mGroupName=groupName;
Logger::getInstance()->log("About to start parsing sound script "+dataStream->getName());
while(!dataStream->eof())
{
line = dataStream->getLine();
mScriptContext.mLineNo++;
// DEBUG LINE
//Logger::getInstance()->log("About to attempt line(#" +
// Ogre::StringConverter::toString(mScriptContext.mLineNo) + "): " + line);
// Ignore comments & blanks
if (!(line.length() == 0 || line.substr(0,2) == "//"))
{
if (nextIsOpenBrace)
{
// NB, parser will have changed context already
if (line != "{")
{
logParseError("Expecting '{' but got " +
line + " instead.", mScriptContext);
}
nextIsOpenBrace = false;
}
else
{
nextIsOpenBrace = parseLine(line);
}
}
}
// Check all braces were closed
if (mScriptContext.mSection != ASS_NONE)
{
logParseError("Unexpected end of file.", mScriptContext);
}
// Make sure we invalidate our context shared pointer (don't wanna hold on)
mScriptContext.mSound.setNull();
}
示例11: fnmatch
bool fnmatch (Ogre::String pattern, Ogre::String name, int dummy)
{
if (pattern == "*")
{
return true;
}
if (pattern.substr(0,2) == "*.")
{
Ogre::StringUtil::toLowerCase(pattern);
Ogre::StringUtil::toLowerCase(name);
Ogre::String extToFind = pattern.substr(2, pattern.size() - 2);
if ((name.size() > extToFind.size()) &&(extToFind == name.substr(name.size() - extToFind.size(), extToFind.size())))
{
return 0; // match
}
else
{
return 1; // don't match
}
}
return false;
}
示例12: onClickSave
//-------------------------------------------------------------------------------
void MaterialViewer::onClickSave(MyGUI::WidgetPtr)
{
Ogre::String name = mMaterialSettings["diffuse_tex"];
Ogre::String source = createMaterialSource("Brushes/" + name);
//Remove extension!
Ogre::String filename = name.substr(0, name.find_last_of('.')) + ".material";
std::ofstream out((USER_PREFIX "Content/" + filename).c_str());
out << source;
out.close();
MyGUI::Message::createMessageBox("Message", "File '" + filename + "' saved!",
"Your material file has been saved as 'Content/" + filename + "' in the user directory!",
MyGUI::MessageBoxStyle::IconInfo);
}
示例13:
float
ParseKeyFrameTime( const float length, const Ogre::String& string )
{
float res = 0;
if( string.at( string.size() - 1 ) == '%' )
{
res = length * Ogre::StringConverter::parseReal( string.substr( 0, string.size() - 1 ) ) / 100;
}
else
{
res = Ogre::StringConverter::parseReal( string );
}
return res;
}
示例14: locateSkeleton
bool MilkshapePlugin::locateSkeleton(Ogre::MeshPtr& mesh)
{
//
// choose filename
//
OPENFILENAME ofn;
memset (&ofn, 0, sizeof (OPENFILENAME));
char szFile[MS_MAX_PATH];
char szFileTitle[MS_MAX_PATH];
char szDefExt[32] = "skeleton";
char szFilter[128] = "OGRE .skeleton Files (*.skeleton)\0*.skeleton\0All Files (*.*)\0*.*\0\0";
szFile[0] = '\0';
szFileTitle[0] = '\0';
ofn.lStructSize = sizeof (OPENFILENAME);
ofn.lpstrDefExt = szDefExt;
ofn.lpstrFilter = szFilter;
ofn.lpstrFile = szFile;
ofn.nMaxFile = MS_MAX_PATH;
ofn.lpstrFileTitle = szFileTitle;
ofn.nMaxFileTitle = MS_MAX_PATH;
ofn.Flags = OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
ofn.lpstrTitle = "Locate OGRE Skeleton (since you're not exporting it)";
if (!::GetOpenFileName (&ofn))
return false;
// Strip off the path
Ogre::String skelName = szFile;
size_t lastSlash = skelName.find_last_of("\\");
skelName = skelName.substr(lastSlash+1);
Ogre::String msg = "Linking mesh to skeleton file '" + skelName + "'";
Ogre::LogManager::getSingleton().logMessage(msg);
// Create a dummy skeleton for Mesh to link to (saves it trying to load it)
Ogre::SkeletonPtr pSkel = Ogre::SkeletonManager::getSingleton().create(skelName,
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
Ogre::LogManager::getSingleton().logMessage("Dummy Skeleton object created for link.");
mesh->_notifySkeleton(pSkel);
return true;
}
示例15: OnSelectItemCallback
void wxObjectFolderTree::OnSelectItemCallback()
{
ClearObjectPreview();
if (mCurrentItem->IsRoot()) return;
mCurrentPath = Ogre::String(GetRelativePath(mCurrentItem->GetId()).GetPath().c_str()) + PATH_SEPERATOR;
if (mCurrentItem->IsFile())
{
Ogre::String Path = "Data/Editor/Objects/" + Ogre::String(GetRelativePath(mCurrentItem->GetId()).GetPath().c_str()) + PATH_SEPERATOR;
Ogre::String File = mCurrentItem->GetName().c_str();
mCurrentPath += File;
Ogre::String extension = File.substr(File.find(".")+1, File.length());
wxEdit::Instance().GetOgrePane()->OnSelectResource();
if (extension == "ocs" && wxEdit::Instance().GetWorldExplorer()->GetSelection() == 1)
{
CreateObjectPreview(Path + File);
((wxEditGOResource*)(wxEdit::Instance().GetpropertyWindow()->SetPage("EditGOCRes")))->SetResource(Path + File);
}
}
}