本文整理汇总了C++中synfig::String::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ String::c_str方法的具体用法?C++ String::c_str怎么用?C++ String::c_str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类synfig::String
的用法示例。
在下文中一共展示了String::c_str方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: file
bool
Settings::load_from_file(const synfig::String& filename)
{
std::ifstream file(filename.c_str());
if(!file)
return false;
while(file)
{
std::string line;
getline(file,line);
if(!line.empty() && ((line[0]>='a' && line[0]<='z')||(line[0]>='A' && line[0]<='Z')))
{
std::string::iterator equal(find(line.begin(),line.end(),'='));
if(equal==line.end())
continue;
std::string key(line.begin(),equal);
std::string value(equal+1,line.end());
//synfig::info("Settings::load_from_file(): Trying Key \"%s\" with a value of \"%s\".",key.c_str(),value.c_str());
try{
if(!set_value(key,value))
synfig::warning("Settings::load_from_file(): Key \"%s\" with a value of \"%s\" was rejected.",key.c_str(),value.c_str());
}
catch(...)
{
synfig::error("Settings::load_from_file(): Attempt to set key \"%s\" with a value of \"%s\" has thrown an exception.",key.c_str(),value.c_str());
throw;
}
}
}
return true;
}
示例2:
Distance::System // (static)
Distance::ident_system(const synfig::String& x)
{
synfig::String str;
// Make it all upper case, and remove white space
for(unsigned int i=0;i<x.size();i++)if(x[i]!=' ' && x[i]!='\t')str+=toupper(x[i]);
// If it is plural, make it singular
if(str[str.size()-1]=='S')
str=synfig::String(str.begin(),str.end()-1);
if(str.empty() || str=="U" || str=="UNIT")
return SYSTEM_UNITS;
if(str=="PX" || str=="PIXEL")
return SYSTEM_PIXELS;
if(str=="PT" || str=="POINT")
return SYSTEM_POINTS;
if(str=="IN" || str=="\"" || str=="INCHE" || str=="INCH")
return SYSTEM_INCHES;
if(str=="M" || str=="METER")
return SYSTEM_METERS;
if(str=="CM" || str=="CENTIMETER")
return SYSTEM_CENTIMETERS;
if(str=="MM" || str=="MILLIMETER")
return SYSTEM_MILLIMETERS;
synfig::warning("Distance::ident_system(): Unknown distance system \"%s\"",x.c_str());
return SYSTEM_UNITS;
}
示例3: tmp_filename
bool
Settings::save_to_file(const synfig::String& filename)const
{
synfig::String tmp_filename(filename+".TMP");
try
{
std::ofstream file(tmp_filename.c_str());
if(!file)return false;
KeyList key_list(get_key_list());
// Save the keys
{
KeyList::const_iterator iter;
for(iter=key_list.begin();iter!=key_list.end();++iter)
{
if(!file)return false;
String ret = get_value(*iter);
if (ret != String()) file<<*iter<<'='<<(ret == "none" ? "normal" : ret)<<endl;
}
}
if(!file)
return false;
}catch(...) { return false; }
#ifdef _WIN32
char old_file[80]="sif.XXXXXXXX";
mktemp(old_file);
rename(filename.c_str(),old_file);
if(rename(tmp_filename.c_str(),filename.c_str())!=0)
{
rename(old_file,tmp_filename.c_str());
return false;
}
remove(old_file);
#else
if(rename(tmp_filename.c_str(),filename.c_str())!=0)
return false;
#endif
return true;
}
示例4:
void
Toolbox::change_state(const synfig::String& statename)
{
etl::handle<studio::CanvasView> canvas_view(studio::App::get_selected_canvas_view());
if(canvas_view)
{
if(statename==canvas_view->get_smach().get_state_name())
{
return;
}
if(state_button_map.count(statename))
{
state_button_map[statename]->clicked();
}
else
{
synfig::error("Unknown state \"%s\"",statename.c_str());
}
}
}
示例5: screen_w
bool
DialogSettings::set_value(const synfig::String& key,const synfig::String& value)
{
int screen_w(Gdk::screen_width());
int screen_h(Gdk::screen_height());
if(value.empty())
return false;
if(key=="pos")
{
int x,y;
if(!strscanf(value,"%d %d",&x, &y))
return false;
if (x > screen_w) x = screen_w - 150; if (x < 0) x = 0;
if (y > screen_h) y = screen_h - 150; if (y < 0) y = 0;
window->move(x,y);
return true;
}
if(key=="size")
{
int x,y;
if(!strscanf(value,"%d %d",&x, &y))
return false;
if (x > screen_w) x = 150; if (x < 0) x = 0;
if (y > screen_h) y = 150; if (y < 0) y = 0;
window->set_default_size(x,y);
return true;
}
if(key=="x")
{
int x,y; window->get_position(x,y);
x=atoi(value.c_str());
window->move(x,y);
return true;
}
if(key=="y")
{
int x,y; window->get_position(x,y);
y=atoi(value.c_str());
window->move(x,y);
return true;
}
if(key=="w")
{
int x,y; window->get_size(x,y);
x=atoi(value.c_str());
window->set_default_size(x,y);
return true;
}
if(key=="h")
{
int x,y; window->get_size(x,y);
y=atoi(value.c_str());
window->set_default_size(x,y);
return true;
}
if(key=="visible")
{
if(value=="0")
window->hide();
else
window->present();
return true;
}
return synfigapp::Settings::set_value(key,value);
}