HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_WorkArgs.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_WorkArgs.h ( UT Library, C++)
7  *
8  * COMMENTS: Class to implement a dynamic argv array to support unlimited
9  * arguments. This class is used to replace something like:
10  * char *argv[MAX_SIZE];
11  */
12 
13 #ifndef __UT_WorkArgs__
14 #define __UT_WorkArgs__
15 
16 #include "UT_API.h"
17 #include "UT_Assert.h"
18 #include <SYS/SYS_Types.h>
19 
20 #include <stdlib.h>
21 
22 
23 #define UT_INITIAL_ARGV_SIZE 256
24 
26 public:
27  UT_WorkArgs();
28  ~UT_WorkArgs();
29 
30  void appendArg(const char *text) { setArg(myArgc, text); }
31  void setArg(int idx, const char *text);
32 
33  int entries() const { return myArgc; }
34  int getArgc() const { return myArgc; }
35  const char *getArg(int idx) const { return myArgv[idx]; }
36  const char *const* getArgv() const { return myArgv; }
37 
38  const char *operator[](int i) const
39  { return (i < myArgc) ? myArgv[i]:0; }
40  const char *operator()(int i) const
41  { UT_ASSERT_P(i <= myArgc); return myArgv[i]; }
42 
43  UT_WorkArgs( const UT_WorkArgs &copy );
44  UT_WorkArgs &operator=( const UT_WorkArgs &copy );
45 
46  int64 getMemoryUsage(bool inclusive) const;
47 
48  typedef const char *const* iterator;
49  iterator begin() const { return myArgv; }
50  iterator end() const { return myArgv+myArgc; }
51 
52 private:
53  void reserve( int num_elems );
54 private:
55  const char **myArgv;
56  int myArgc, myAlloc;
57  const char *myStackArgv[UT_INITIAL_ARGV_SIZE];
58 };
59 
60 #endif
#define UT_INITIAL_ARGV_SIZE
Definition: UT_WorkArgs.h:23
const char *const * iterator
Definition: UT_WorkArgs.h:48
#define UT_API
Definition: UT_API.h:13
png_uint_32 i
Definition: png.h:2877
long long int64
Definition: SYS_Types.h:107
#define UT_ASSERT_P(ZZ)
Definition: UT_Assert.h:125
const char * getArg(int idx) const
Definition: UT_WorkArgs.h:35
int getArgc() const
Definition: UT_WorkArgs.h:34
void appendArg(const char *text)
Definition: UT_WorkArgs.h:30
int entries() const
Definition: UT_WorkArgs.h:33
const char * operator[](int i) const
Definition: UT_WorkArgs.h:38
iterator end() const
Definition: UT_WorkArgs.h:50
const char * operator()(int i) const
Definition: UT_WorkArgs.h:40
iterator begin() const
Definition: UT_WorkArgs.h:49
const char *const * getArgv() const
Definition: UT_WorkArgs.h:36