39 case Type::Unspecified:
53 if (
type == Type::Unspecified) {
56 defaultSign = std::numeric_limits<char>::is_signed ?
's' :
'u';
153 bool Platform::set(
const std::string& platformstr, std::string& errstr,
const std::vector<std::string>& paths,
bool verbose)
155 if (platformstr ==
"win32A")
157 else if (platformstr ==
"win32W")
159 else if (platformstr ==
"win64")
161 else if (platformstr ==
"unix32")
163 else if (platformstr ==
"unix64")
165 else if (platformstr ==
"native")
167 else if (platformstr ==
"unspecified")
168 set(Type::Unspecified);
169 else if (paths.empty()) {
170 errstr =
"unrecognized platform: '" + platformstr +
"' (no lookup).";
175 for (
const std::string& path : paths) {
177 std::cout <<
"looking for platform '" + platformstr +
"' in '" + path +
"'" << std::endl;
184 errstr =
"unrecognized platform: '" + platformstr +
"'.";
196 std::vector<std::string> filenames{
199 "platforms/" + filename,
200 "platforms/" + filename +
".xml"
208 std::string filesdir = FILESDIR;
209 if (!filesdir.empty() && filesdir[filesdir.size()-1] !=
'/')
211 filenames.push_back(filesdir + (
"platforms/" + filename));
212 filenames.push_back(filesdir + (
"platforms/" + filename +
".xml"));
216 tinyxml2::XMLDocument doc;
217 bool success =
false;
218 for (
const std::string & f : filenames) {
220 std::cout <<
"try to load platform file '" << f <<
"' ... ";
221 if (doc.LoadFile(f.c_str()) == tinyxml2::XML_SUCCESS) {
223 std::cout <<
"Success" << std::endl;
228 std::cout << doc.ErrorStr() << std::endl;
236 static unsigned int xmlTextAsUInt(
const tinyxml2::XMLElement* node,
bool& error)
238 unsigned int retval = 0;
239 if (node->QueryUnsignedText(&retval) != tinyxml2::XML_SUCCESS)
246 const tinyxml2::XMLElement *
const rootnode = doc->FirstChildElement();
248 if (!rootnode || std::strcmp(rootnode->Name(),
"platform") != 0)
252 for (
const tinyxml2::XMLElement *node = rootnode->FirstChildElement(); node; node = node->NextSiblingElement()) {
253 if (std::strcmp(node->Name(),
"default-sign") == 0) {
254 const char* str = node->GetText();
259 }
else if (std::strcmp(node->Name(),
"char_bit") == 0)
261 else if (std::strcmp(node->Name(),
"sizeof") == 0) {
262 for (
const tinyxml2::XMLElement *sz = node->FirstChildElement(); sz; sz = sz->NextSiblingElement()) {
263 if (std::strcmp(sz->Name(),
"short") == 0)
265 else if (std::strcmp(sz->Name(),
"bool") == 0)
267 else if (std::strcmp(sz->Name(),
"int") == 0)
269 else if (std::strcmp(sz->Name(),
"long") == 0)
271 else if (std::strcmp(sz->Name(),
"long-long") == 0)
273 else if (std::strcmp(sz->Name(),
"float") == 0)
275 else if (std::strcmp(sz->Name(),
"double") == 0)
277 else if (std::strcmp(sz->Name(),
"long-double") == 0)
279 else if (std::strcmp(sz->Name(),
"pointer") == 0)
281 else if (std::strcmp(sz->Name(),
"size_t") == 0)
283 else if (std::strcmp(sz->Name(),
"wchar_t") == 0)
315 s += std::to_string(0);
static std::string fromNativeSeparators(std::string path)
Convert path to use internal path separators.
static std::string getPathFromFilename(const std::string &filename)
Lookup the path part from a filename (e.g., '/tmp/a.h' -> '/tmp/', 'a.h' -> '')
Information about a class type.
@ error
Programming error.
cppstd_t
C++ code standard.