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_StringHolder.h"
17 
19 {
20 public:
23  int line = 0, int column_start = 0, int column_end = 0)
24  : mySource(source),
25  myLine(line),
26  myColumnStart(column_start),
27  myColumnEnd(column_end)
28  {
29  }
30 
31  int64 getMemoryUsage(bool inclusive) const
32  {
33  int64 mem = inclusive ? sizeof(*this) : 0;
34  mem += mySource.getMemoryUsage(false);
35  return mem;
36  }
37 
38  bool operator==(const UT_SourceLocation &other) const
39  {
40  return (mySource == other.mySource &&
41  myLine == other.myLine &&
42  myColumnStart == other.myColumnStart &&
43  myColumnEnd == other.myColumnEnd);
44  }
45  bool operator!=(const UT_SourceLocation &other) const
46  { return !(*this == other); }
47 
48  const UT_StringHolder&source() const
49  { return mySource; }
51  { mySource = source; }
52  int line() const
53  { return myLine; }
54  void setLine(int line)
55  { myLine = line; }
56  int columnStart() const
57  { return myColumnStart; }
58  void setColumnStart(int col)
59  { myColumnStart = col; }
60  int columnEnd() const
61  { return myColumnEnd; }
62  void setColumnEnd(int col)
63  { myColumnEnd = col; }
64 
65 private:
66  UT_StringHolder mySource;
67  int myLine;
68  int myColumnStart, myColumnEnd;
69 };
70 
71 UT_API std::ostream &
72 operator<<(std::ostream &os, const UT_SourceLocation &loc);
73 
74 #endif // __UT_SourceLocation__
bool operator==(const UT_SourceLocation &other) const
UT_API std::ostream & operator<<(std::ostream &os, const UT_SourceLocation &loc)
int columnStart() const
#define UT_API
Definition: UT_API.h:14
void setLine(int line)
void setColumnEnd(int col)
bool operator!=(const UT_SourceLocation &other) const
void setColumnStart(int col)
static const UT_StringHolder theEmptyString
void setSource(const UT_StringHolder &source)
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:803
long long int64
Definition: SYS_Types.h:116
const UT_StringHolder & source() const
int columnEnd() const
UT_SourceLocation(const UT_StringHolder &source=UT_StringHolder::theEmptyString, int line=0, int column_start=0, int column_end=0)
int64 getMemoryUsage(bool inclusive) const