/*
- Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2016-2021 Carl Hetherington <cth@carlh.net>
This file is part of libdcp.
files in the program, then also delete it here.
*/
+
+/** @file src/locale_convert.cc
+ * @brief Methods to convert to/from string using the current locale
+ */
+
+
#include "locale_convert.h"
#include <string>
#include <inttypes.h>
+
using std::string;
using std::wstring;
+
template<>
string
dcp::locale_convert (unsigned char x, int, bool)
return buffer;
}
+
template<>
string
dcp::locale_convert (unsigned short int x, int, bool)
return buffer;
}
+
template<>
string
dcp::locale_convert (int x, int, bool)
return buffer;
}
+
template<>
string
dcp::locale_convert (unsigned int x, int, bool)
return buffer;
}
+
template<>
string
dcp::locale_convert (long int x, int, bool)
return buffer;
}
+
template<>
string
dcp::locale_convert (unsigned long int x, int, bool)
return buffer;
}
+
template<>
string
dcp::locale_convert (long long int x, int, bool)
return buffer;
}
+
template<>
string
dcp::locale_convert (unsigned long long int x, int, bool)
return buffer;
}
+
template<>
string
dcp::locale_convert (float x, int precision, bool fixed)
return buffer;
}
+
template<>
string
dcp::locale_convert (double x, int precision, bool fixed)
return buffer;
}
+
template<>
string
dcp::locale_convert (string x, int, bool)
return x;
}
+
template<>
string
dcp::locale_convert (char* x, int, bool)
return x;
}
+
template<>
string
dcp::locale_convert (char const * x, int, bool)
return x;
}
+
template<>
string
dcp::locale_convert (wchar_t const * x, int, bool)
return string (s.begin(), s.end());
}
+
template<>
string
dcp::locale_convert (char x, int, bool)
return s;
}
+
template<>
string
dcp::locale_convert (boost::filesystem::path x, int, bool)
return x.string();
}
+
template<>
unsigned char
dcp::locale_convert (string x, int, bool)
return y;
}
+
template<>
unsigned short int
dcp::locale_convert (string x, int, bool)
return y;
}
+
template<>
unsigned int
dcp::locale_convert (string x, int, bool)
return y;
}
+
template<>
int
dcp::locale_convert (string x, int, bool)
return y;
}
+
template<>
long
dcp::locale_convert (string x, int, bool)
return y;
}
+
+template<>
+unsigned long
+dcp::locale_convert (string x, int, bool)
+{
+ unsigned long y = 0;
+#ifdef LIBDCP_WINDOWS
+ __mingw_sscanf (x.c_str(), "%lud", &y);
+#else
+ sscanf (x.c_str(), "%lud", &y);
+#endif
+ return y;
+}
+
+
template<>
long long
dcp::locale_convert (string x, int, bool)
return y;
}
+
+template<>
+unsigned long long
+dcp::locale_convert (string x, int, bool)
+{
+ unsigned long long y = 0;
+#ifdef LIBDCP_WINDOWS
+ __mingw_sscanf (x.c_str(), "%llud", &y);
+#else
+ sscanf (x.c_str(), "%llud", &y);
+#endif
+ return y;
+}
+
+
template<>
float
dcp::locale_convert (string x, int, bool)
return y;
}
+
template<>
double
dcp::locale_convert (string x, int, bool)