#include <cstring>
#if defined(__MINGW32__) || defined(__MINGW64__) || defined(__CYGWIN__) || \
defined(__QNXNTO__)
#define _POSIX_C_SOURCE …
#define _XOPEN_SOURCE …
#endif
#if defined(_WIN32) || defined(__MINGW32__) || defined(__MINGW64__) || defined(__CYGWIN__)
# ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
# endif
# ifndef NOMINMAX
#define NOMINMAX
# endif
# ifdef _MSC_VER
# include <crtdbg.h>
# endif
# include <windows.h>
# ifndef __CYGWIN__
# include <direct.h>
# endif
# include <winbase.h>
# undef interface
#endif
#include "flatbuffers/util.h"
#include <sys/stat.h>
#include <clocale>
#include <cstdlib>
#include <fstream>
#include <functional>
#include "flatbuffers/base.h"
namespace flatbuffers {
namespace {
static bool FileExistsRaw(const char *name) { … }
static bool LoadFileRaw(const char *name, bool binary, std::string *buf) { … }
LoadFileFunction g_load_file_function = …;
FileExistsFunction g_file_exists_function = …;
static std::string ToCamelCase(const std::string &input, bool is_upper) { … }
static std::string ToSnakeCase(const std::string &input, bool screaming) { … }
std::string ToAll(const std::string &input,
std::function<char(const char)> transform) { … }
std::string CamelToSnake(const std::string &input) { … }
std::string DasherToSnake(const std::string &input) { … }
std::string ToDasher(const std::string &input) { … }
std::string SnakeToSnake2(const std::string &s) { … }
}
bool LoadFile(const char *name, bool binary, std::string *buf) { … }
bool FileExists(const char *name) { … }
bool DirExists(const char *name) { … }
LoadFileFunction SetLoadFileFunction(LoadFileFunction load_file_function) { … }
FileExistsFunction SetFileExistsFunction(
FileExistsFunction file_exists_function) { … }
bool SaveFile(const char *name, const char *buf, size_t len, bool binary) { … }
static const char kPathSeparatorWindows = …;
static const char *PathSeparatorSet = …;
std::string StripExtension(const std::string &filepath) { … }
std::string GetExtension(const std::string &filepath) { … }
std::string StripPath(const std::string &filepath) { … }
std::string StripFileName(const std::string &filepath) { … }
std::string StripPrefix(const std::string &filepath,
const std::string &prefix_to_remove) { … }
std::string ConCatPathFileName(const std::string &path,
const std::string &filename) { … }
std::string PosixPath(const char *path) { … }
std::string PosixPath(const std::string &path) { … }
void EnsureDirExists(const std::string &filepath) { … }
std::string FilePath(const std::string& project, const std::string& filePath, bool absolute) { … }
std::string AbsolutePath(const std::string &filepath) { … }
std::string RelativeToRootPath(const std::string &project,
const std::string &filepath) { … }
#if defined(FLATBUFFERS_LOCALE_INDEPENDENT) && \
(FLATBUFFERS_LOCALE_INDEPENDENT > 0)
ClassicLocale ClassicLocale::instance_;
#ifdef _MSC_VER
ClassicLocale::ClassicLocale()
: locale_(_create_locale(LC_ALL, "C")) {}
ClassicLocale::~ClassicLocale() { _free_locale(locale_); }
#else
ClassicLocale::ClassicLocale()
: locale_(newlocale(LC_ALL, "C", nullptr)) {}
ClassicLocale::~ClassicLocale() { freelocale(locale_); }
#endif
#endif
std::string RemoveStringQuotes(const std::string &s) { … }
bool SetGlobalTestLocale(const char *locale_name, std::string *_value) { … }
bool ReadEnvironmentVariable(const char *var_name, std::string *_value) { … }
std::string ConvertCase(const std::string &input, Case output_case,
Case input_case) { … }
}