HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 <stdlib.h>
18 #include <vector>
19 #include <string>
20 #include "UT_Assert.h"
21 #include <SYS/SYS_Types.h>
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  void toStringVector(std::vector < std::string >& tokens_out);
47 
48  int64 getMemoryUsage(bool inclusive) const;
49 
50  typedef const char *const* iterator;
51  iterator begin() const { return myArgv; }
52  iterator end() const { return myArgv+myArgc; }
53 
54 private:
55  void reserve( int num_elems );
56 private:
57  const char **myArgv;
58  int myArgc, myAlloc;
59  const char *myStackArgv[UT_INITIAL_ARGV_SIZE];
60 };
61 
62 #endif
#define UT_INITIAL_ARGV_SIZE
Definition: UT_WorkArgs.h:23
const char *const * iterator
Definition: UT_WorkArgs.h:50
#define UT_API
Definition: UT_API.h:12
png_uint_32 i
Definition: png.h:2877
#define UT_ASSERT_P(ZZ)
Definition: UT_Assert.h:101
long long int64
Definition: SYS_Types.h:106
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:52
const char * operator()(int i) const
Definition: UT_WorkArgs.h:40
iterator begin() const
Definition: UT_WorkArgs.h:51
const char *const * getArgv() const
Definition: UT_WorkArgs.h:36