HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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_StringMap.h>
20 
21 class OP_Node;
22 class OP_BundleFilter;
23 class UT_Regex;
24 
26 public:
27  static OP_BundlePattern *allocPattern(const char *str);
28  static void freePattern(OP_BundlePattern *pattern);
29 
30  int argc() const { return myPatterns.entries(); }
31  const char *argv(int i) const
32  {
33  return myPatterns(i).org_str;
34  }
35 
36  bool isAllPattern() const { return myAllPattern; }
37  bool isNullPattern() const { return myNullPattern; }
38 
39  bool hasPattern(const char *str) const;
40 
41  bool match(const OP_Node *node, const char *relativepath,
42  bool assume_kids_included) const;
43 
44  //
45  // Raw, single match function. This can be used in filter traversal.
46  bool matchNode(const OP_Node *node,
47  const char *relativetopath,
48  bool result_if_no_match,
49  int *excluded) const;
50 
51 protected:
52  OP_BundlePattern(const char *str);
54 
55 private:
56  struct Pattern
57  {
58  bool is_pattern; // false if just a plain string
59  bool is_negated; // negated pattern (starts with a ^)
60  bool is_relative; // Relative pattern (starts with './')
61  const char *org_str; // The original string
62  const char *str; // Adjusted string (for carat)
63  const char *rel_str; // Relative string (incl carat)
64  UT_SharedPtr<UT_Regex> pattern;
65  UT_SharedPtr<UT_Regex> rel_pattern;
66  };
67 
68  const char *myPatternToken;
69 
70  // A copy of the original string. Just used as a storage for the tokenized
71  // parts.
72  UT_String myPattern;
73 
74  // The list of sub-patterns.
75  UT_Array<Pattern> myPatterns;
76 
77  // Here we store a map into the pattern array of strings that are
78  // "plain" and contain no glob/regex characters.
79  typedef UT_StringMap<exint> PlainPatternMap;
80 
81  PlainPatternMap myPlainPatterns;
82  PlainPatternMap myRelPatterns;
83 
84  int myRefCount;
85  bool myAllPattern;
86  bool myNullPattern;
87 };
88 #endif
89 
const char * argv(int i) const
png_uint_32 i
Definition: png.h:2877
int argc() const
bool isNullPattern() const
#define OP_API
Definition: OP_API.h:10
bool isAllPattern() const