AstNodeWrapper.h

Go to the documentation of this file.
00001 /*
00002  *
00003  *
00004  * Distributed under the OpenDDS License.
00005  * See: http://www.opendds.org/license.html
00006  */
00007 #ifndef OPENDDS_DCPS_ASTNODEWRAPPER_H
00008 #define OPENDDS_DCPS_ASTNODEWRAPPER_H
00009 
00010 #include "dds/DCPS/Definitions.h"
00011 #include "dds/DCPS/PoolAllocator.h"
00012 
00013 #ifndef OPENDDS_NO_CONTENT_SUBSCRIPTION_PROFILE
00014 
00015 #include "yard/yard_parser.hpp"
00016 #include <sstream>
00017 #include <stdexcept>
00018 
00019 namespace OpenDDS {
00020 namespace DCPS {
00021 
00022 typedef yard::TreeBuildingParser<char>::Node AstNode;
00023 
00024 /// called after parsing has failed, throws std::exception with details
00025 inline void reportErrors(yard::SimpleTextParser& parser, const char* input)
00026 {
00027   AstNode* prev = 0;
00028   for (AstNode* iter = parser.GetAstRoot()->GetFirstChild(); iter;
00029       iter = iter->GetSibling()) {
00030     prev = iter;
00031   }
00032   ptrdiff_t pos = prev ? prev->GetLastToken() - parser.Begin() : 0;
00033   std::ostringstream oss;
00034   oss << pos;
00035   throw std::runtime_error("Invalid expression [" + OPENDDS_STRING(input)
00036     + "] at character " + oss.str());
00037 }
00038 
00039 
00040 inline OPENDDS_STRING toString(yard::TreeBuildingParser<char>::Node* iter)
00041 {
00042   return iter ? OPENDDS_STRING(iter->GetFirstToken(), iter->GetLastToken()) : "";
00043 }
00044 
00045 
00046 /// keeps the details of yard out of the FilterEvaluator header file
00047 struct FilterEvaluator::AstNodeWrapper {
00048   AstNodeWrapper(AstNode* ptr)
00049     : ptr_(ptr) {}
00050   operator AstNode*() const { return ptr_; }
00051   AstNode* operator->() const { return ptr_; }
00052   AstNode* ptr_;
00053 };
00054 
00055 }
00056 }
00057 
00058 #endif
00059 #endif

Generated on Fri Feb 12 20:05:18 2016 for OpenDDS by  doxygen 1.4.7