本文整理汇总了C++中symbol_table::add方法的典型用法代码示例。如果您正苦于以下问题:C++ symbol_table::add方法的具体用法?C++ symbol_table::add怎么用?C++ symbol_table::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类symbol_table
的用法示例。
在下文中一共展示了symbol_table::add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: emu_fatalerror
cheat_parameter::cheat_parameter(cheat_manager &manager, symbol_table &symbols, const char *filename, xml_data_node ¶mnode)
: m_value(0)
{
// read the core attributes
m_minval = number_and_format(xml_get_attribute_int(¶mnode, "min", 0), xml_get_attribute_int_format(¶mnode, "min"));
m_maxval = number_and_format(xml_get_attribute_int(¶mnode, "max", 0), xml_get_attribute_int_format(¶mnode, "max"));
m_stepval = number_and_format(xml_get_attribute_int(¶mnode, "step", 1), xml_get_attribute_int_format(¶mnode, "step"));
// iterate over items
for (xml_data_node *itemnode = xml_get_sibling(paramnode.child, "item"); itemnode != NULL; itemnode = xml_get_sibling(itemnode->next, "item"))
{
// check for NULL text
if (itemnode->value == NULL || itemnode->value[0] == 0)
throw emu_fatalerror("%s.xml(%d): item is missing text\n", filename, itemnode->line);
// check for non-existant value
if (xml_get_attribute(itemnode, "value") == NULL)
throw emu_fatalerror("%s.xml(%d): item is value\n", filename, itemnode->line);
// extract the parameters
UINT64 value = xml_get_attribute_int(itemnode, "value", 0);
int format = xml_get_attribute_int_format(itemnode, "value");
// allocate and append a new item
item &curitem = m_itemlist.append(*global_alloc(item(itemnode->value, value, format)));
// ensure the maximum expands to suit
m_maxval = MAX(m_maxval, curitem.value());
}
// add a variable to the symbol table for our value
symbols.add("param", symbol_table::READ_ONLY, &m_value);
}
示例2: emu_fatalerror
cheat_parameter::cheat_parameter(cheat_manager &manager, symbol_table &symbols, const char *filename, xml_data_node const ¶mnode)
: m_value(0)
{
// read the core attributes
m_minval = number_and_format(paramnode.get_attribute_int("min", 0), paramnode.get_attribute_int_format("min"));
m_maxval = number_and_format(paramnode.get_attribute_int("max", 0), paramnode.get_attribute_int_format("max"));
m_stepval = number_and_format(paramnode.get_attribute_int("step", 1), paramnode.get_attribute_int_format("step"));
// iterate over items
for (xml_data_node const *itemnode = paramnode.get_child("item"); itemnode != nullptr; itemnode = itemnode->get_next_sibling("item"))
{
// check for nullptr text
if (itemnode->get_value() == nullptr || itemnode->get_value()[0] == 0)
throw emu_fatalerror("%s.xml(%d): item is missing text\n", filename, itemnode->line);
// check for non-existant value
if (!itemnode->has_attribute("value"))
throw emu_fatalerror("%s.xml(%d): item is value\n", filename, itemnode->line);
// extract the parameters
uint64_t const value = itemnode->get_attribute_int("value", 0);
xml_data_node::int_format const format = itemnode->get_attribute_int_format("value");
// allocate and append a new item
auto curitem = std::make_unique<item>(itemnode->get_value(), value, format);
// ensure the maximum expands to suit
m_maxval = std::max(m_maxval, curitem->value());
m_itemlist.push_back(std::move(curitem));
}
// add a variable to the symbol table for our value
symbols.add("param", symbol_table::READ_ONLY, &m_value);
}