HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OP_BundlePattern.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: OP_BundlePattern.h ( OP Library, C++)
7  *
8  * COMMENTS: Pattern tokens for a bundle. This breaks up the pattern string
9  * into managable tokens which can be processed easily
10  */
11 
12 #ifndef __OP_BundlePattern__
13 #define __OP_BundlePattern__
14 
15 #include "OP_API.h"
16 #include <UT/UT_Array.h>
17 #include <UT/UT_SharedPtr.h>
18 #include <UT/UT_String.h>
19 #include <UT/UT_StringArray.h>
20 #include <UT/UT_StringMap.h>
21 
22 class OP_Node;
23 class OP_BundleFilter;
24 class UT_Regex;
25 
27 public:
28  static OP_BundlePattern *allocPattern(const char *str);
29  static void freePattern(OP_BundlePattern *pattern);
30 
31  int argc() const { return myPatterns.entries(); }
32  const char *argv(int i) const
33  {
34  return myPatterns(i).org_str;
35  }
36 
37  bool isAllPattern() const { return myAllPattern; }
38  bool isNullPattern() const { return myNullPattern; }
39 
40  bool hasPattern(const char *str) const;
41 
42  bool match(const OP_Node *node, const char *relativepath,
43  bool assume_kids_included) const;
44 
45  //
46  // Raw, single match function. This can be used in filter traversal.
47  bool matchNode(const OP_Node *node,
48  const char *relativetopath,
49  bool result_if_no_match,
50  int *excluded) const;
51 
52 protected:
53  OP_BundlePattern(const char *str);
55 
56 private:
57  struct Pattern
58  {
59  bool is_pattern; // false if just a plain string
60  bool is_negated; // negated pattern (starts with a ^)
61  bool is_relative; // Relative pattern (starts with './')
62  const char *org_str; // The original string
63  const char *str; // Adjusted string (for carat)
64  const char *rel_str; // Relative string (incl carat)
66  UT_SharedPtr<UT_Regex> rel_pattern;
67  };
68 
69  const char *myPatternToken;
70 
71  // A copy of the original string. Just used as a storage for the tokenized
72  // parts.
73  UT_String myPattern;
74 
75  // Extra storage for modified strings
76  UT_StringArray myModifiedPatterns;
77 
78  // The list of sub-patterns.
79  UT_Array<Pattern> myPatterns;
80 
81  // Here we store a map into the pattern array of strings that are
82  // "plain" and contain no glob/regex characters.
83  typedef UT_StringMap<exint> PlainPatternMap;
84 
85  PlainPatternMap myPlainPatterns;
86  PlainPatternMap myRelPatterns;
87 
88  int myRefCount;
89  bool myAllPattern;
90  bool myNullPattern;
91 };
92 #endif
93 
const char * argv(int i) const
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
Definition: UT_SharedPtr.h:28
int argc() const
bool isNullPattern() const
#define OP_API
Definition: OP_API.h:10
bool isAllPattern() const
GLubyte * pattern
Definition: glew.h:5711