Example #1
0
void Builder::unserialize(const char* file)
{
    NodeManager* mgr = NodeManager::getSingleton();
    vector<Node*> nodes;
    const char* last = file;
    int width;
    while( file ) {
        if( (width = Config::hasDelimiter( file )) > 0 ) {
            nodes.push_back( mgr->unserialize( file, file - last ) );
            last = file;
            file += width;
        }
        file ++;
    }
    Node* node;
    for( int i = 0 ; i < nodes.size() ; i ++ ) {
        node = nodes.at(i);
        if( node ) {
            node->addLeft( nodes.at(2*i) );
            node->addRight( nodes.at(2*i+1) );
        }
    }
    root = nodes.at(0);
}