HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_SourceLocation.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_SourceLocation.h ( VEX Library, C++)
7  *
8  * COMMENTS:
9  * A structure to keep track of source locations.
10  */
11 
12 #ifndef __UT_SourceLocation__
13 #define __UT_SourceLocation__
14 
15 #include "UT_API.h"
16 #include "UT_String.h"
17 
19 {
20 public:
21  UT_SourceLocation(const char *source = NULL, int line = 0,
22  int column_start = 0, int column_end = 0) :
23  mySource(source), myLine(line),
24  myColumnStart(column_start), myColumnEnd(column_end)
25  {
26  }
27 
29  mySource(src.mySource), myLine(src.myLine),
30  myColumnStart(src.myColumnStart), myColumnEnd(src.myColumnEnd)
31  {
32  if (src.mySource.isHard())
33  mySource.harden();
34  }
35 
36  int64 getMemoryUsage(bool inclusive) const
37  {
38  int64 mem = inclusive ? sizeof(*this) : 0;
39  mem += mySource.getMemoryUsage(false);
40  return mem;
41  }
42 
43  void harden() { mySource.harden(); }
44  const UT_String &source() const { return mySource; }
45  int line() const { return myLine; }
46  int columnStart() const { return myColumnStart; }
47  int &columnStart() { return myColumnStart; }
48  int columnEnd() const { return myColumnEnd; }
49  int &columnEnd() { return myColumnEnd; }
50 
52  {
53  mySource = src.mySource;
54  if (src.mySource.isHard())
55  mySource.harden();
56  myLine = src.myLine;
57  myColumnStart = src.myColumnStart;
58  myColumnEnd = src.myColumnEnd;
59  return *this;
60  }
61 
62 private:
63  UT_String mySource;
64  int myLine;
65  int myColumnStart, myColumnEnd;
66 };
67 
68 UT_API std::ostream &
69 operator<<(std::ostream &os, const UT_SourceLocation &loc);
70 
71 
72 #endif // __UT_SourceLocation__
UT_API std::ostream & operator<<(std::ostream &os, const UT_SourceLocation &loc)
int columnStart() const
bool isHard() const
Returns whether this string is hardened already.
Definition: UT_String.h:242
const UT_String & source() const
#define UT_API
Definition: UT_API.h:13
UT_SourceLocation & operator=(const UT_SourceLocation &src)
UT_SourceLocation(const char *source=NULL, int line=0, int column_start=0, int column_end=0)
long long int64
Definition: SYS_Types.h:107
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:802
void harden()
Take shallow copy and make it deep.
Definition: UT_String.h:213
int columnEnd() const
UT_SourceLocation(const UT_SourceLocation &src)
int64 getMemoryUsage(bool inclusive) const
GLenum src
Definition: glcorearb.h:1792