NCBI C++ ToolKit
traversal_pattern_match_callback.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef TRAVERSALPATTERN__HPP
2 #define TRAVERSALPATTERN__HPP
3 
4 /* $Id: traversal_pattern_match_callback.hpp 51628 2011-10-19 14:23:17Z kornbluh $
5 * ===========================================================================
6 *
7 * PUBLIC DOMAIN NOTICE
8 * National Center for Biotechnology Information
9 *
10 * This software/database is a "United States Government Work" under the
11 * terms of the United States Copyright Act. It was written as part of
12 * the author's official duties as a United States Government employee and
13 * thus cannot be copyrighted. This software/database is freely available
14 * to the public for use. The National Library of Medicine and the U.S.
15 * Government have not placed any restriction on its use or reproduction.
16 *
17 * Although all reasonable efforts have been taken to ensure the accuracy
18 * and reliability of the software and data, the NLM and the U.S.
19 * Government do not and cannot warrant the performance or results that
20 * may be obtained by using this software or data. The NLM and the U.S.
21 * Government disclaim all warranties, express or implied, including
22 * warranties of performance, merchantability or fitness for any particular
23 * purpose.
24 *
25 * Please cite the author in any work or product based on this material.
26 *
27 * ===========================================================================
28 *
29 * Author: Michael Kornbluh
30 *
31 * File Description:
32 * Used to attach user functions to be called by the traversal.
33 */
34 
35 #include <vector>
36 
37 #include <corelib/ncbiobj.hpp>
38 
40 #include "traversal_node.hpp"
41 
43 
45 public:
47 
48  // This will attach the given user functions to any
49  // nodes they belong to, and add any nodes with functions
50  // to out_nodesWithFunctions
52  CTraversalSpecFileParser &spec_file_parser,
53  CTraversalNode::TNodeSet &out_nodesWithFunctions );
54 
55 private:
56 
57  // attach the given pattern to all relevant nodes
59 
60  // mark as deprecated any nodes we can
62  const CTraversalSpecFileParser::TPattern & deprec_pattern,
63  CTraversalNode::TNodeSet & nodes_to_destroy );
64 
65  typedef std::vector<std::string>::const_reverse_iterator TPatternIter;
66  // Check if the given node matches the given pattern
67  bool x_PatternMatches( CRef<CTraversalNode> node, TPatternIter pattern_start, TPatternIter pattern_end );
68 
69  // Check if at least one of any of the given patterns matches the given node
71 
72  // This actually does the pattern attachment. It can throw an exception if that's impossible, such
73  // as due to specifying an ancestor pattern that doesn't work (shouldn't usually happen, since
74  // such problems are usually caught earlier.
77  const CTraversalSpecFileParser::TPattern &main_pattern,
78  const CTraversalSpecFileParser::TPattern &extra_arg_pattern );
79 
80  // returns true if the node can't get a pattern attached to it
81  bool x_NodeIsUnmatchable( const CTraversalNode &node );
82 
83  // This assumes that the node has the same variable name regardless of
84  // which caller is used.
85  const string &x_GetNodeVarName( const CTraversalNode &node );
86 
87  enum ERefChoice {
91  };
92 
94  const CTraversalNode& parent_ref,
95  const CTraversalNode& child );
96 
97  // maps the given type or label or class to all the nodes that contain it as the last part
98  // e.g. "location" maps to any nodes that ar named "location" in their last part
101 };
102 
104 
105 #endif /* TRAVERSALPATTERN__HPP */
CRef –.
Definition: ncbiobj.hpp:618
std::set< CRef< CTraversalNode > > TNodeSet
bool x_AnyPatternMatches(CRef< CTraversalNode > node, const CTraversalSpecFileParser::TPatternVec &patterns)
bool x_PatternMatches(CRef< CTraversalNode > node, TPatternIter pattern_start, TPatternIter pattern_end)
const string & x_GetNodeVarName(const CTraversalNode &node)
map< std::string, CTraversalNode::TNodeVec > TLeafToNodeMap
CRef< CTraversalNode > x_TranslateArgToNode(CRef< CTraversalNode > node, const CTraversalSpecFileParser::TPattern &main_pattern, const CTraversalSpecFileParser::TPattern &extra_arg_pattern)
CTraversalPatternMatchCallback(CTraversalSpecFileParser &spec_file_parser, CTraversalNode::TNodeSet &out_nodesWithFunctions)
bool x_NodeIsUnmatchable(const CTraversalNode &node)
ERefChoice x_UseRefOrChild(const CTraversalNode &parent_ref, const CTraversalNode &child)
void x_TryToDeprecatePatternMatchers(const CTraversalSpecFileParser::TPattern &deprec_pattern, CTraversalNode::TNodeSet &nodes_to_destroy)
void x_TryToAttachPattern(CTraversalSpecFileParser::CDescFileNodeRef pattern)
void x_DoAttachment(CRef< CTraversalNode > node, CTraversalSpecFileParser::CDescFileNodeRef pattern)
std::vector< std::string >::const_reverse_iterator TPatternIter
std::vector< TPattern > TPatternVec
std::vector< std::string > TPattern
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
static patstr * patterns
Definition: pcregrep.c:259
Modified on Tue Feb 27 05:50:53 2024 by modify_doxy.py rev. 669887