16
16
#include < string>
17
17
18
18
#ifdef _WIN32
19
- static const bool OS_WINDOWS = true ;
19
+ constexpr bool OSWindows = true ;
20
20
#else
21
- static const bool OS_WINDOWS = false ;
21
+ constexpr bool OSWindows = false ;
22
22
#endif
23
23
24
24
// / Type alias for source location information for variable mappings with
@@ -39,72 +39,72 @@ struct ident_t {
39
39
// / Struct to hold source individual location information.
40
40
class SourceInfo {
41
41
// / Underlying string copy of the original source information.
42
- const std::string sourceStr ;
42
+ const std::string SourceStr ;
43
43
44
44
// / Location fields extracted from the source information string.
45
- const std::string name ;
46
- const std::string filename ;
47
- const int32_t line ;
48
- const int32_t column ;
45
+ const std::string Name ;
46
+ const std::string Filename ;
47
+ const int32_t Line ;
48
+ const int32_t Column ;
49
49
50
- std::string initStr (const void *name ) {
51
- if (!name )
50
+ std::string initStr (const void *Name ) {
51
+ if (!Name )
52
52
return " ;unknown;unknown;0;0;;" ;
53
53
else
54
- return std::string (reinterpret_cast <const char *>(name ));
54
+ return std::string (reinterpret_cast <const char *>(Name ));
55
55
}
56
56
57
- std::string initStr (const ident_t *loc ) {
58
- if (!loc )
57
+ std::string initStr (const ident_t *Loc ) {
58
+ if (!Loc )
59
59
return " ;unknown;unknown;0;0;;" ;
60
60
else
61
- return std::string (reinterpret_cast <const char *>(loc ->psource ));
61
+ return std::string (reinterpret_cast <const char *>(Loc ->psource ));
62
62
}
63
63
64
64
// / Get n-th substring in an expression separated by ;.
65
- std::string getSubstring (const int n ) const {
66
- std::size_t begin = sourceStr .find (' ;' );
67
- std::size_t end = sourceStr .find (' ;' , begin + 1 );
68
- for (int i = 0 ; i < n; i ++) {
69
- begin = end ;
70
- end = sourceStr .find (' ;' , begin + 1 );
65
+ std::string getSubstring (const unsigned N ) const {
66
+ std::size_t Begin = SourceStr .find (' ;' );
67
+ std::size_t End = SourceStr .find (' ;' , Begin + 1 );
68
+ for (unsigned I = 0 ; I < N; I ++) {
69
+ Begin = End ;
70
+ End = SourceStr .find (' ;' , Begin + 1 );
71
71
}
72
- return sourceStr .substr (begin + 1 , end - begin - 1 );
72
+ return SourceStr .substr (Begin + 1 , End - Begin - 1 );
73
73
};
74
74
75
75
// / Get the filename from a full path.
76
- std::string removePath (const std::string &path ) const {
77
- std::size_t pos = (OS_WINDOWS ) ? path .rfind (' \\ ' ) : path .rfind (' /' );
78
- return path .substr (pos + 1 );
76
+ std::string removePath (const std::string &Path ) const {
77
+ std::size_t Pos = (OSWindows ) ? Path .rfind (' \\ ' ) : Path .rfind (' /' );
78
+ return Path .substr (Pos + 1 );
79
79
};
80
80
81
81
public:
82
- SourceInfo (const ident_t *loc )
83
- : sourceStr (initStr(loc )), name (getSubstring(1 )),
84
- filename (removePath(getSubstring(0 ))), line (std::stoi(getSubstring(2 ))),
85
- column (std::stoi(getSubstring(3 ))) {}
86
-
87
- SourceInfo (const map_var_info_t name )
88
- : sourceStr (initStr(name )), name (getSubstring(0 )),
89
- filename (removePath(getSubstring(1 ))), line (std::stoi(getSubstring(2 ))),
90
- column (std::stoi(getSubstring(3 ))) {}
91
-
92
- const char *getName () const { return name .c_str (); }
93
- const char *getFilename () const { return filename .c_str (); }
94
- int32_t getLine () const { return line ; }
95
- int32_t getColumn () const { return column ; }
96
- bool isAvailible () const { return (line || column ); }
82
+ SourceInfo (const ident_t *Loc )
83
+ : SourceStr (initStr(Loc )), Name (getSubstring(1 )),
84
+ Filename (removePath(getSubstring(0 ))), Line (std::stoi(getSubstring(2 ))),
85
+ Column (std::stoi(getSubstring(3 ))) {}
86
+
87
+ SourceInfo (const map_var_info_t Name )
88
+ : SourceStr (initStr(Name )), Name (getSubstring(0 )),
89
+ Filename (removePath(getSubstring(1 ))), Line (std::stoi(getSubstring(2 ))),
90
+ Column (std::stoi(getSubstring(3 ))) {}
91
+
92
+ const char *getName () const { return Name .c_str (); }
93
+ const char *getFilename () const { return Filename .c_str (); }
94
+ int32_t getLine () const { return Line ; }
95
+ int32_t getColumn () const { return Column ; }
96
+ bool isAvailible () const { return (Line || Column ); }
97
97
};
98
98
99
99
// / Standalone function for getting the variable name of a mapping.
100
- static inline std::string getNameFromMapping (const map_var_info_t name ) {
101
- if (!name )
100
+ static inline std::string getNameFromMapping (const map_var_info_t Name ) {
101
+ if (!Name )
102
102
return " unknown" ;
103
103
104
- const std::string name_str (reinterpret_cast <const char *>(name ));
105
- std::size_t begin = name_str .find (' ;' );
106
- std::size_t end = name_str .find (' ;' , begin + 1 );
107
- return name_str .substr (begin + 1 , end - begin - 1 );
104
+ const std::string NameStr (reinterpret_cast <const char *>(Name ));
105
+ std::size_t Begin = NameStr .find (' ;' );
106
+ std::size_t End = NameStr .find (' ;' , Begin + 1 );
107
+ return NameStr .substr (Begin + 1 , End - Begin - 1 );
108
108
}
109
109
110
110
#endif
0 commit comments