本文整理汇总了C++中gd::String::Raw方法的典型用法代码示例。如果您正苦于以下问题:C++ String::Raw方法的具体用法?C++ String::Raw怎么用?C++ String::Raw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gd::String
的用法示例。
在下文中一共展示了String::Raw方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadStringFromFile
void GD_API ReadStringFromFile( const gd::String & filename, const gd::String & group, RuntimeScene & scene, gd::Variable & variable )
{
std::shared_ptr<XmlFile> file = XmlFilesManager::GetFile(filename, false);
TiXmlHandle hdl( &file->GetTinyXmlDocument() );
//D�coupage des groupes
istringstream groupsStr( group.Raw() );
std::string str;
vector < gd::String > groups;
while ( std::getline( groupsStr, str, '/' ) )
{
groups.push_back(gd::String::FromUTF8(str));
}
groups.erase(std::remove_if(groups.begin(), groups.end(), StringEmpty()), groups.end());
//On avance petit � petit dans le fichier
for (std::size_t i =0;i<groups.size();i++)
{
if ( !hdl.FirstChildElement(groups.at(i).c_str()).ToElement())
{
return;
}
hdl = hdl.FirstChildElement(groups.at(i).c_str());
}
//On stocke la valeur
if ( hdl.ToElement()->Attribute("texte") == NULL ) return;
//Update variable texte
variable.SetString(hdl.ToElement()->Attribute("texte"));
return;
}
示例2: GroupExists
bool GD_API GroupExists( const gd::String & filename, const gd::String & group )
{
std::shared_ptr<XmlFile> file = XmlFilesManager::GetFile(filename);
TiXmlHandle hdl( &file->GetTinyXmlDocument() );
//D�coupage des groupes
istringstream groupsStr( group.Raw() );
std::string str;
vector < gd::String > groups;
while ( std::getline( groupsStr, str, '/' ) )
groups.push_back(gd::String::FromUTF8(str));
groups.erase(std::remove_if(groups.begin(), groups.end(), StringEmpty()), groups.end());
//On avance petit � petit dans le fichier
for (std::size_t i =0;i<groups.size();i++)
{
if ( !hdl.FirstChildElement(groups.at(i).c_str()).ToElement())
return false;
hdl = hdl.FirstChildElement(groups.at(i).c_str());
}
return true;
}
示例3: WriteValueInFile
void GD_API WriteValueInFile( const gd::String & filename, const gd::String & group, double value )
{
std::shared_ptr<XmlFile> file = XmlFilesManager::GetFile(filename);
TiXmlHandle hdl( &file->GetTinyXmlDocument() );
//D�coupage des groupes
istringstream groupsStr( group.Raw() );
std::string str;
vector < gd::String > groups;
while ( std::getline( groupsStr, str, '/' ) )
{
groups.push_back(gd::String::FromUTF8(str));
}
groups.erase(std::remove_if(groups.begin(), groups.end(), StringEmpty()), groups.end());
if ( groups.empty() )
return;
//Insertion de la d�claration
TiXmlDeclaration decl( "1.0", "UTF-8", "" );
if ( hdl.FirstChildElement().Element() != NULL )
{
//Il y a d�j� un noeud, on v�rifie que c'est pas une d�claration
if ( hdl.FirstChild().ToNode()->ToDeclaration() == NULL )
file->GetTinyXmlDocument().InsertBeforeChild(hdl.FirstChildElement().Element(), decl);
}
else
file->GetTinyXmlDocument().InsertEndChild(decl); //Il n'y a rien, on peut ins�rer notre d�claration
//Cr�ation si besoin est de la racine
if ( hdl.FirstChildElement(groups.at(0).c_str()).Element() == NULL )
{
TiXmlElement root(groups.at(0).c_str());
file->GetTinyXmlDocument().InsertEndChild(root);
}
//A chaque fois, on v�rifie si le groupe voulu existe, si non on le cr��,
//et on se d�place dedans.
for (std::size_t i =0;i<groups.size();i++)
{
if ( hdl.FirstChildElement(groups.at(i).c_str()).Element() == NULL )
{
TiXmlElement le_nouveau (groups.at(i).c_str());
hdl.Element()->InsertEndChild(le_nouveau);
}
hdl = hdl.FirstChildElement(groups.at(i).c_str());
}
//Ecriture dans le groupe
if ( hdl.Element() != NULL )
hdl.Element()->SetDoubleAttribute("value", value);
return;
}
示例4: ShowOpenFile
/**
* Display an "open file" dialog
*/
void GD_EXTENSION_API ShowOpenFile( RuntimeScene & scene, gd::Variable & variable, const gd::String & title, gd::String filters )
{
sf::Clock timeSpent;
gd::String result;
//Display the dialog
#if defined(WINDOWS)
//Process filters to match windows dialogs filters style.
filters.Raw() = filters.Raw()+'\0';
std::replace(filters.Raw().begin(), filters.Raw().end(), '|', '\0');
OPENFILENAMEW toGetFileName; //Struct for the dialog
wchar_t filePath[MAX_PATH];
_wgetcwd(filePath, MAX_PATH);
ZeroMemory(&toGetFileName, sizeof(OPENFILENAMEW));
toGetFileName.lStructSize = sizeof(OPENFILENAMEW);
toGetFileName.hwndOwner = NULL;
toGetFileName.lpstrFile = filePath;
toGetFileName.nMaxFile = MAX_PATH;
toGetFileName.lpstrFilter = filters == "\0" ? NULL : filters.ToWide().c_str();
toGetFileName.nFilterIndex = 1;
toGetFileName.Flags = OFN_PATHMUSTEXIST | OFN_NOCHANGEDIR;;
if(GetOpenFileNameW(&toGetFileName) == TRUE)
result = gd::String::FromWide(filePath);
#endif
#if defined(LINUX) || defined(MACOS)
std::string strResult;
nw::OpenFile * dialog = new nw::OpenFile(title.ToLocale(), true, strResult);
dialog->wait_until_closed();
result = gd::String::FromLocale(strResult);
#endif
scene.GetTimeManager().NotifyPauseWasMade(timeSpent.getElapsedTime().asMicroseconds());//Don't take the time spent in this function in account.
//Update the variable
variable.SetString(result);
}
示例5: DeleteGroupFromFile
void GD_API DeleteGroupFromFile( const gd::String & filename, const gd::String & group )
{
std::shared_ptr<XmlFile> file = XmlFilesManager::GetFile(filename);
TiXmlHandle hdl( &file->GetTinyXmlDocument() );
//D�coupage des groupes
istringstream groupsStr( group.Raw() );
std::string str;
vector < gd::String > groups;
while ( std::getline( groupsStr, str, '/' ) )
{
groups.push_back(gd::String::FromUTF8(str));
}
groups.erase(std::remove_if(groups.begin(), groups.end(), StringEmpty()), groups.end());
if ( groups.empty() )
return;
groups.push_back("");
//A chaque fois, on v�rifie si le groupe voulu existe
for (std::size_t i =0;i<groups.size();i++)
{
if ( hdl.FirstChildElement(groups.at(i).c_str()).Element() == NULL )
return;
//Si on arrive au groupe parent du groupe
//� supprimer
if ( i >= (groups.size()-1)-1 )
{
hdl.ToNode()->RemoveChild(hdl.FirstChildElement(groups.at(i).c_str()).ToNode());
return;
}
hdl = hdl.FirstChildElement(groups.at(i).c_str());
}
return;
}