forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcppFile.cxx
More file actions
175 lines (155 loc) · 3.76 KB
/
cppFile.cxx
File metadata and controls
175 lines (155 loc) · 3.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file cppFile.cxx
* @author drose
* @date 1999-11-11
*/
#include "cppFile.h"
#include <ctype.h>
using std::string;
/**
*
*/
CPPFile::
CPPFile(const Filename &filename, const Filename &filename_as_referenced,
Source source) :
_filename(filename), _filename_as_referenced(filename_as_referenced),
_source(source),
_pragma_once(false)
{
_filename.set_text();
_filename_as_referenced.set_text();
}
/**
*
*/
CPPFile::
CPPFile(const CPPFile ©) :
_filename(copy._filename),
_filename_as_referenced(copy._filename_as_referenced),
_source(copy._source),
_pragma_once(copy._pragma_once)
{
}
/**
*
*/
void CPPFile::
operator = (const CPPFile ©) {
_filename = copy._filename;
_filename_as_referenced = copy._filename_as_referenced;
_source = copy._source;
_pragma_once = copy._pragma_once;
}
/**
*
*/
CPPFile::
~CPPFile() {
}
/**
* Returns true if the file appears to be a C or C++ source code file based on
* its extension. That is, returns true if the filename ends in .c, .C, .cc,
* .cpp, or any of a series of likely extensions.
*/
bool CPPFile::
is_c_or_i_file() const {
return is_c_or_i_file(_filename);
}
/**
* Returns true if the file appears to be a C or C++ source code file based on
* its extension. That is, returns true if the filename ends in .c, .C, .cc,
* .cpp, or any of a series of likely extensions.
*/
bool CPPFile::
is_c_or_i_file(const Filename &filename) {
string extension = filename.get_extension();
// downcase the extension.
for (string::iterator ei = extension.begin();
ei != extension.end();
++ei) {
(*ei) = tolower(*ei);
}
return (extension == "c" || extension == "cc" ||
extension == "cpp" || extension == "c++" || extension == "cxx" ||
extension == "i" || extension == "t");
}
/**
* Returns true if the file appears to be a C or C++ source code file based on
* its extension. That is, returns true if the filename ends in .c, .C, .cc,
* .cpp, or any of a series of likely extensions.
*/
bool CPPFile::
is_c_file() const {
return is_c_file(_filename);
}
/**
* Returns true if the file appears to be a C or C++ source code file based on
* its extension. That is, returns true if the filename ends in .c, .C, .cc,
* .cpp, or any of a series of likely extensions.
*/
bool CPPFile::
is_c_file(const Filename &filename) {
string extension = filename.get_extension();
// downcase the extension.
for (string::iterator ei = extension.begin();
ei != extension.end();
++ei) {
(*ei) = tolower(*ei);
}
return (extension == "c" || extension == "cc" ||
extension == "cpp" || extension == "c++" || extension == "cxx");
}
/**
* If the other file is "nearer" than this file (in the sense that a file in
* the local directory is nearer than a file in the system directory, etc.),
* replaces this file's information with that of the other. Otherwise, does
* nothing.
*/
void CPPFile::
replace_nearer(const CPPFile &other) {
if ((int)_source > (int)other._source) {
(*this) = other;
}
}
/**
*
*/
bool CPPFile::
operator < (const CPPFile &other) const {
return _filename < other._filename;
}
/**
*
*/
bool CPPFile::
operator == (const CPPFile &other) const {
return _filename == other._filename;
}
/**
*
*/
bool CPPFile::
operator != (const CPPFile &other) const {
return _filename != other._filename;
}
/**
*
*/
const char *CPPFile::
c_str() const {
return _filename.c_str();
}
/**
*
*/
bool CPPFile::
empty() const {
return _filename.empty();
}