Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class 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 #include "IndexTypes.hpp"
00026 
00027 namespace indri {
00028   namespace lang {
00029     class RawExtentNode;
00030     class ScoredExtentNode;
00031     class DocumentStructureNode;
00032 
00033     class Unpacker {
00034     private:
00035       indri::xml::XMLNode* _root;
00036       std::map<std::string, class Node*> _nodes;
00037       indri::xml::XMLNode* _current;
00038 
00039       Node* _unpack( indri::xml::XMLNode* child );
00040 
00041     public:
00042       Unpacker( indri::xml::XMLNode* root );
00043       ~Unpacker( );
00044       std::vector<Node*> unpack();
00045       std::string getString( const char* stringName ) ;
00046       UINT64 getInteger( const char* name );
00047       double getDouble( const char* name );
00048       RawExtentNode* getRawExtentNode( const char* name );
00049       std::vector<RawExtentNode*> getRawExtentVector( const char* name );
00050       std::vector<ScoredExtentNode*> getScoredExtentVector( const char* name );
00051       std::vector<std::string> getStringVector( const char* name );
00052       std::vector<int> getIntVector( const char* name );
00053       std::vector<lemur::api::DOCID_T> getDocIdVector( const char* name );
00054       
00055       std::vector<double> getDoubleVector( const char* name ) ;
00056       ScoredExtentNode* getScoredExtentNode( const char* name );
00057       bool getBoolean( const char* name );
00058       DocumentStructureNode* getDocumentStructureNode( const char* name );
00059 
00060       template<class T>
00061       std::vector<T*> getNodeVector( const char* name ) {
00062         std::vector<T*> result;
00063         const indri::xml::XMLNode* vector = _current->getChild(name);
00064 
00065         for( size_t i=0; i<vector->getChildren().size(); i++ ) {
00066           indri::xml::XMLNode* ref = vector->getChildren()[i];
00067           T* node = dynamic_cast<T*>(_nodes[ref->getValue()]);
00068           result.push_back(node);
00069         }
00070 
00071         return result;
00072       }
00073     };
00074   }
00075 }
00076 #endif // INDRI_UNPACKER_HPP

Generated on Tue Jun 15 11:02:56 2010 for Lemur by doxygen 1.3.4