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  // Reset myArgc to 0, keep the allocated pointers
53  void reset();
54 
55  // set the argument capacity.
56  void reserve( int num_elems );
57 private:
58  const char **myArgv;
59  int myArgc, myAlloc;
60  const char *myStackArgv[UT_INITIAL_ARGV_SIZE];
61 };
62 
63 #endif
#define UT_INITIAL_ARGV_SIZE
Definition: UT_WorkArgs.h:23
OIIO_UTIL_API bool copy(string_view from, string_view to, std::string &err)
const char *const * iterator
Definition: UT_WorkArgs.h:48
#define UT_API
Definition: UT_API.h:14
GLboolean reset
Definition: glad.h:5138
#define UT_ASSERT_P(ZZ)
Definition: UT_Assert.h:155
const char * getArg(int idx) const
Definition: UT_WorkArgs.h:35
long long int64
Definition: SYS_Types.h:116
int getArgc() const
Definition: UT_WorkArgs.h:34
auto reserve(std::back_insert_iterator< Container > it, size_t n) -> checked_ptr< typename Container::value_type >
Definition: format.h:357
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