HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_ExpandArray.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: UT_ExpandArray.h ( UT Library, C++)
7  *
8  * COMMENTS:
9  * This class is used to encapsulate the methods
10  * involved with expanding a string pattern.
11  */
12 
13 #ifndef __UT_ExpandArray__
14 #define __UT_ExpandArray__
15 
16 #include "UT_API.h"
17 #include "UT_Assert.h"
18 #include "UT_String.h"
19 #include "UT_StringArray.h"
20 #include "UT_WorkArgs.h"
21 
23 {
24 
25 public:
26 
27  explicit UT_ExpandArray(int start_size = 256);
28  ~UT_ExpandArray();
29 
30  // Returns the number of expanded names
31  int entries() const
32  { return myExpandedTokens.entries(); }
33 
34  // Returns an expanded name
35  const char *operator()(unsigned int i) const
36  {
37  UT_ASSERT_P(i < myExpandedTokens.entries());
38  return myExpandedTokens[i];
39  }
40 
41  // Returns the number of parsed argument without expansion
42  int argEntries(unsigned int i) const
43  { return myTokens.entries(); }
44 
45  // Returns a parsed argument without expansion
46  const char *arg(unsigned int i) const
47  {
48  UT_ASSERT_P(i < myTokens.entries());
49  return myTokens[i];
50  }
51 
52  // Set a new pattern, clearing the workargs.
53  int setPattern(const char *pattern, int *dirty_flag=0);
54  int appendPattern(const char *pattern);
55 
56  const UT_String &getPattern() const
57  { return myPattern; }
58 
59  int64 getMemoryUsage(bool inclusive) const;
60 
61  // Extract the parsed tokens to a UT_StringArray with or without expansion
62  // Returns the number of extracted tokens.
63  const UT_StringArray& getTokens() const { return myTokens; }
64  const UT_StringArray& getExpandedTokens() const { return myExpandedTokens; }
65 
66  void clear();
67 private:
68  void setPattern(const char *pattern, int append);
69 
70  UT_String myPattern;
71  UT_StringArray myExpandedTokens; // Expanded
72  UT_StringArray myTokens; // Without expansion
73 };
74 
75 #endif
76 
const char * operator()(unsigned int i) const
int entries() const
#define UT_API
Definition: UT_API.h:14
const UT_StringArray & getTokens() const
const char * arg(unsigned int i) const
#define UT_ASSERT_P(ZZ)
Definition: UT_Assert.h:170
const UT_StringArray & getExpandedTokens() const
long long int64
Definition: SYS_Types.h:116
GLubyte * pattern
Definition: glew.h:5741
int argEntries(unsigned int i) const
const UT_String & getPattern() const