00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
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