Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Unpacker.hpp

Go to the documentation of this file.
00001 /*==========================================================================
00002  * Copyright (c) 2004 University of Massachusetts.  All Rights Reserved.
00003  *
00004  * Use of the Lemur Toolkit for Language Modeling and Information Retrieval
00005  * is subject to the terms of the software license set forth in the LICENSE
00006  * file included with this software, and also available at
00007  * http://www.lemurproject.org/license.html
00008  *
00009  *==========================================================================
00010 */
00011 
00012 
00013 //
00014 // Unpacker
00015 //
00016 // 17 March 2004 -- tds
00017 //
00018 
00019 #ifndef INDRI_UNPACKER_HPP
00020 #define INDRI_UNPACKER_HPP
00021 
00022 #include <string>
00023 #include <map>
00024 #include "indri/XMLNode.hpp"
00025 
00026 namespace indri {
00027   namespace lang {
00028     class RawExtentNode;
00029     class ScoredExtentNode;
00030 
00031     class Unpacker {
00032     private:
00033       XMLNode* _root;
00034       std::map<std::string, class Node*> _nodes;
00035       XMLNode* _current;
00036 
00037       Node* _unpack( XMLNode* child );
00038 
00039     public:
00040       Unpacker( XMLNode* root );
00041       std::vector<Node*> unpack();
00042       std::string getString( const char* stringName ) ;
00043       UINT64 getInteger( const char* name );
00044       double getDouble( const char* name );
00045       RawExtentNode* getRawExtentNode( const char* name );
00046       std::vector<RawExtentNode*> getRawExtentVector( const char* name );
00047       std::vector<ScoredExtentNode*> getScoredExtentVector( const char* name );
00048       std::vector<int> getIntVector( const char* name );
00049       std::vector<double> getDoubleVector( const char* name ) ;
00050       ScoredExtentNode* getScoredExtentNode( const char* name );
00051       bool getBoolean( const char* name );
00052 
00053       template<class T>
00054       std::vector<T*> getNodeVector( const char* name ) {
00055         std::vector<T*> result;
00056         const XMLNode* vector = _current->getChild(name);
00057 
00058         for( unsigned int i=0; i<vector->getChildren().size(); i++ ) {
00059           XMLNode* ref = vector->getChildren()[i];
00060           T* node = dynamic_cast<T*>(_nodes[ref->getValue()]);
00061           result.push_back(node);
00062         }
00063 
00064         return result;
00065       }
00066     };
00067   }
00068 }
00069 #endif // INDRI_UNPACKER_HPP

Generated on Wed Nov 3 12:59:07 2004 for Lemur Toolkit by doxygen1.2.18