Ejemplo n.º 1
0
void CILuaState::getMultiMetaTable(const char *value)
{
    if (!value)
    {
        return;
    }
    
    string metaTableNames(value);
    string::size_type index;
    int count = 0;
    
    // do while to get each metaTableName.
    // if metaTableName is existed, getMetaTable with name.
    while (index != string::npos)
    {
        index = metaTableNames.find('_');
        
        if (index != string::npos)
        {
            string name = metaTableNames.substr(0, index);
            getMetaTable(name.c_str());
            count++;
            metaTableNames = metaTableNames.substr(index + 1);
        }
        else
        {
            // if not found, only have a key or the last key
            getMetaTable(metaTableNames.c_str());
            count++;
        }
        
    }

    // ex:if we need 4 metaTables, we should setMetaTable 4 times.
    // @note that, there is a counter above statements.
    for (int i=0; i<count; i++)
    {
        setMetaTable(-2);
    }

}
Ejemplo n.º 2
0
//
// Overload for raw key strings.
//
void MetaTable::setMetaTable(const char *key, MetaTable *newValue)
{
   setMetaTable(MetaKey(key).index, newValue);
}