Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

TreePrinterWalker.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 // TreePrinterWalker
00015 //
00016 // 9 March 2004 -- tds
00017 //
00018 
00019 #ifndef INDRI_TREEPRINTERWALKER_HPP
00020 #define INDRI_TREEPRINTERWALKER_HPP
00021 
00022 #include "indri/QuerySpec.hpp"
00023 namespace indri
00024 {
00025   namespace lang
00026   {
00027 
00028     class TreePrinterWalker : public indri::lang::Walker {
00029     private:
00030       unsigned int _tabs;
00031     public:
00032       TreePrinterWalker() : _tabs(0) {}
00033 
00034       void before( indri::lang::IndexTerm* node ) {
00035         for( unsigned int i=0; i<_tabs; i++ )
00036           std::cout << "\t";
00037 
00038         std::cout << "IndexTerm "
00039                   << node->getText().c_str()
00040                   << " "
00041                   << node->nodeName().c_str()
00042                   << std::endl;
00043 
00044         _tabs++;
00045       }
00046 
00047       void before( indri::lang::Field* node ) {
00048         for( unsigned int i=0; i<_tabs; i++ )
00049           std::cout << "\t";
00050 
00051         std::cout << "Field "
00052                   << node->getFieldName().c_str()
00053                   << " "
00054                   << node->nodeName().c_str()
00055                   << std::endl;
00056 
00057         _tabs++;
00058       }
00059 
00060       void defaultBefore( indri::lang::Node* node ) {
00061         for( unsigned int i=0; i<_tabs; i++ )
00062           std::cout << "\t";
00063 
00064         std::string type = node->typeName();
00065         std::string query = node->queryText();
00066 
00067         std::cout << type
00068                   << " "
00069                   << query
00070                   << std::endl;
00071 
00072         _tabs++;
00073       }
00074 
00075       void defaultAfter( indri::lang::Node* node ) {
00076         _tabs--;
00077       }
00078     };
00079   }
00080 }
00081 
00082 #endif // INDRI_TREEPRINTERWALKER_HPP
00083 
00084 

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