Gaudi Framework, version v23r2

Home   Generated: Thu Jun 28 2012

Node.h

Go to the documentation of this file.
00001 // $Id:$
00002 #ifndef JOBOPTIONSVC_NODE_H_
00003 #define JOBOPTIONSVC_NODE_H_
00004 // ============================================================================
00005 // Includes:
00006 // ============================================================================
00007 // STD & STL:
00008 // ============================================================================
00009 #include <iostream>
00010 #include <string>
00011 #include <vector>
00012 // ============================================================================
00013 // BOOST:
00014 // ============================================================================
00015 
00016 #include <boost/fusion/include/adapt_struct.hpp>
00017 #include <boost/fusion/include/unused.hpp>
00018 #include <boost/range/iterator_range.hpp>
00019 // ============================================================================
00020 #include "Position.h"
00021 #include "Iterator.h"
00022 // ============================================================================
00023 namespace Gaudi { namespace Parsers {
00024 // ============================================================================
00025 class Node {
00026 public:
00027  enum NodeType {kRoot,kInclude, kIdentifier, kProperty, kOperation,
00028   kValue, kAssign, kEqual, kPlusEqual, kMinusEqual, kVector, kMap, kPair,
00029   kSimple, kString, kReal, kBool, kUnits, kUnit, kCondition, kIfdef, kIfndef,
00030   kElse, kPrintOptions, kPrintOn, kPrintOff, kShell, kPrintTree, kDumpFile,
00031   kPropertyRef};
00032   NodeType type;
00033   std::string value;
00034   std::vector<Node> children;
00035   Position position;
00036 
00037   Node(): type(kRoot){}
00038   std::string name() const;
00039   std::string ToString() const;
00040   std::string ToString(int indent) const;
00041 };
00042 // ============================================================================
00043 class NodeOperations {
00044 public:
00045   struct value {};
00046   template<typename A, typename B = boost::fusion::unused_type,
00047     typename C = boost::fusion::unused_type,
00048     typename D = boost::fusion::unused_type>
00049   struct result {
00050     typedef void type;
00051   };
00052   //---------------------------------------------------------------------------
00053   void operator()(Node& node, Node::NodeType type) const {
00054     node.type = type;
00055   }
00056 
00057   void operator()(Node& node, Node& child) const {
00058     node.children.push_back(child);
00059   }
00060 
00061   void operator()(Node& node, const std::string& val) const {
00062     node.value = val;
00063   }
00064 
00065   void operator()(Node& node, boost::iterator_range<Iterator> range) const {
00066     node.value = boost::copy_range<std::string>(range);
00067   }
00068 
00069   void operator()(Node& node, bool val) const {
00070     node.value = val?"1":"0";
00071   }
00072 
00073   void operator()(Node& node, const Iterator& iter) const {
00074     const IteratorPosition& pos = iter.get_position();
00075     node.position = Position(pos.file, pos.line, pos.column);
00076   }
00077 
00078   //---------------------------------------------------------------------------
00079 };
00080 // ============================================================================
00081 }  /* Gaudi */ }  /* Parsers */
00082 // ============================================================================
00083 BOOST_FUSION_ADAPT_STRUCT(
00084         Gaudi::Parsers::Node,
00085         (Gaudi::Parsers::Node::NodeType, type)
00086         (std::string, value)
00087         (std::vector<Gaudi::Parsers::Node>, children)
00088 )
00089 // ============================================================================
00090 #endif  // JOBOPTIONSVC_NODE_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Thu Jun 28 2012 23:27:18 for Gaudi Framework, version v23r2 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004