本文整理汇总了C++中Attributes::find方法的典型用法代码示例。如果您正苦于以下问题:C++ Attributes::find方法的具体用法?C++ Attributes::find怎么用?C++ Attributes::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Attributes
的用法示例。
在下文中一共展示了Attributes::find方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
Variant* Node::attributeByAbsoluteNameFromVariant(Variant* variant, std::string name)
{
std::string subname;
std::string subabs;
size_t idx;
idx = name.find(".");
if (idx != std::string::npos)
{
subname = name.substr(0, idx);
subabs = name.substr(idx+1, name.size());
}
else
{
subname = name;
subabs = "";
}
if (!(variant))
return NULL;
if ((variant->type() == typeId::List) && (!subabs.empty()))
{
std::list<Variant*> lvariant = variant->value<std::list< Variant*> >();
std::list<Variant*>::iterator it = lvariant.begin();
Variant* res = NULL;
while (it != lvariant.end() && res == NULL)
res = this->attributeByAbsoluteNameFromVariant((*it), subabs);
return res;
}
else if (variant->type() == typeId::Map)
{
Attributes mvariant = variant->value<Attributes >();
Attributes::iterator it;
it = mvariant.find(subname);
if (it != mvariant.end())
{
if (!subabs.empty())
return this->attributeByAbsoluteNameFromVariant(it->second, subabs);
else
return new Variant(it->second);
}
else
return NULL;
}
else
return NULL;
}
示例2:
bool vesMaterial::vesInternal::addAttribute(
Attributes &attributes,
vesSharedPtr<vesMaterialAttribute> attribute)
{
if (!attribute) {
return false;
}
vesInternal::Attributes::iterator itr =
attributes.find(attribute->type());
if (itr == attributes.end() || ( (itr->second) != attribute )) {
attributes[attribute->type()] = attribute;
return true;
}
return false;
}
示例3: Load
void Layer::Load(std::ifstream& data, Resource_manager& resource_manager)
{
//Todo: Make sure loading works, on all platforms.
Attributes attributes;
std::string line;
while (seek_non_comment_line(data, line))
{
if ("</layer>" == line)
{
/* Used to only need to type attribute name once: prevents typos */
std::string attributeName;
attributeName = "tilemap";
if (attributes.end() != attributes.find(attributeName))
{
Show_attributes(std::cout, attributes);
//Todo: Tileset should be loaded with resource manager
Monday_out(VERBOSE_LEVEL2, std::cout, "Layer:Load()\n\tfile: \"%s\"\n", attributes[attributeName].c_str());
tileset.Set_Dimensions(tile_w, tile_h);
tileset.Load(attributes[attributeName], resource_manager);
attributes.erase(attributeName);
}
if (attributes.end() != attributes.find("width") && attributes.end() != attributes.find("height"))
{
Show_attributes(std::cout, attributes);
/* Read in [row x column] points if both height and width are
* specified.
*
* If one or the other is not defined, do nothing.
*/
attributeName = "width";
int width = String_to_type<int>(attributes[attributeName]);
attributes.erase(attributeName);
attributeName = "height";
int height = String_to_type<int>(attributes[attributeName]);
attributes.erase(attributeName);
tilemap.resize(width);
for (int y = 0; y < height; ++y)
{
/* Convert the current row into a number. Then find the
* "0 = ..." pair using that number/index.
*/
std::stringstream row;
row << y;
if (attributes.end() != attributes.find(row.str()))
{
// Pull in the entire string value to a stream
std::stringstream col(attributes[row.str()]);
for (Tilemap::iterator c = tilemap.begin(); c < tilemap.end(); ++c)
{
int index;
col >> index;
c->push_back(Tile(index));
}
}
}
}
示例4: if
Settings::Settings() {
std::fstream file;
file.open("Settings.ini",std::ios_base::in);
Attributes attr;
std::string line;
std::getline(file,line);
attr = Tools::unpackAttributes(line);
Attribute attribute;
attribute = attr.find("username");
if(attribute != attr.end()) {
username = attribute->second;
} else username = "username";
attribute = attr.find("server_address");
if(attribute != attr.end()) {
serverAddress = attribute->second;
} else serverAddress = "127.0.0.1";
attribute = attr.find("fpslimit");
if(attribute != attr.end()) {
fpsLimit = Tools::convert(attribute->second,int());
} else fpsLimit = 0;
// player piece color
int r = 0,g = 0,b = 0,a = 255;
attribute = attr.find("Player_Red");
if(attribute != attr.end() && attribute->second != "") {
r = Tools::convert(attribute->second,int());
}
attribute = attr.find("Player_Green");
if(attribute != attr.end() && attribute->second != "") {
g = Tools::convert(attribute->second,int());
}
attribute = attr.find("Player_Blue");
if(attribute != attr.end() && attribute->second != "") {
b = Tools::convert(attribute->second,int());
}
if(r < 0) r = 0;
else if(r > 255) r = 255;
if(g < 0) g = 0;
else if(g > 255) g = 255;
if(b < 0) b = 0;
else if(b > 255) b = 255;
playerColor = sf::Color(r,g,b,a);
attribute = attr.find("chat_font");
if(attribute != attr.end()) {
setChatFont(attribute->second);
} else setChatFont("fonts/arial.ttf");
attribute = attr.find("menu_font");
if(attribute != attr.end()) {
setMenuFont(attribute->second);
} else setMenuFont("fonts/arial.ttf");
defaultMenuButton.normal = sf::Color::Transparent;
defaultMenuButton.down = sf::Color(0,0,255,64);
defaultMenuButton.disable = sf::Color(0,0,0,64);
defaultMenuButton.over = sf::Color(255,255,255,64);
file.close();
}