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 
29  // Returns the number of expanded names
30  int entries() const
31  { return myExpandedTokens.entries(); }
32 
33  // Returns an expanded name
34  const char *operator()(unsigned int i) const
35  {
36  UT_ASSERT_P(i < myExpandedTokens.entries());
37  return myExpandedTokens[i];
38  }
39 
40  // Returns the number of parsed argument without expansion
41  int argEntries(unsigned int i) const
42  { return myTokens.entries(); }
43 
44  // Returns a parsed argument without expansion
45  const char *arg(unsigned int i) const
46  {
47  UT_ASSERT_P(i < myTokens.entries());
48  return myTokens[i];
49  }
50 
51  // Set a new pattern, clearing the workargs.
52  int setPattern(const char *pattern, int *dirty_flag=0);
53  int appendPattern(const char *pattern);
54 
55  const UT_String &getPattern() const
56  { return myPattern; }
57 
58  int64 getMemoryUsage(bool inclusive) const;
59 
60  // Extract the parsed tokens to a UT_StringArray with or without expansion
61  // Returns the number of extracted tokens.
62  const UT_StringArray& getTokens() const { return myTokens; }
63  const UT_StringArray& getExpandedTokens() const { return myExpandedTokens; }
64 
65  void clear();
66 private:
67  void setPattern(const char *pattern, int append);
68 
69  UT_String myPattern;
70  UT_StringArray myExpandedTokens; // Expanded
71  UT_StringArray myTokens; // Without expansion
72 };
73 
74 #endif
75 
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:155
const UT_StringArray & getExpandedTokens() const
long long int64
Definition: SYS_Types.h:116
GLushort pattern
Definition: glad.h:2583
int argEntries(unsigned int i) const
const UT_String & getPattern() const