mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-20 05:13:58 +00:00
Format all C++ and Java code via clang-format
Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
@@ -3,26 +3,26 @@
|
||||
#include "std/target_os.hpp"
|
||||
|
||||
#if defined(OMIM_OS_WINDOWS_NATIVE)
|
||||
#define fseek64 _fseeki64
|
||||
#define ftell64 _ftelli64
|
||||
#define fseek64 _fseeki64
|
||||
#define ftell64 _ftelli64
|
||||
|
||||
#elif defined(OMIM_OS_WINDOWS_MINGW)
|
||||
#define fseek64 fseeko64
|
||||
#define ftell64 ftello64
|
||||
#define fseek64 fseeko64
|
||||
#define ftell64 ftello64
|
||||
|
||||
#else
|
||||
// POSIX standart.
|
||||
#include <sys/types.h>
|
||||
// POSIX standart.
|
||||
#include <sys/types.h>
|
||||
|
||||
// TODO: Always assert for 8 bytes after increasing min Android API to 24+.
|
||||
// See more details here: https://android.googlesource.com/platform/bionic/+/master/docs/32-bit-abi.md
|
||||
#if defined(OMIM_OS_ANDROID) && (defined(__arm__) || defined(__i386__))
|
||||
static_assert(sizeof(off_t) == 4, "32-bit Android NDK < API 24 has only 32-bit file operations support");
|
||||
#else
|
||||
static_assert(sizeof(off_t) == 8, "FileReader and FileWriter require 64-bit file operations");
|
||||
#endif
|
||||
#define fseek64 fseeko
|
||||
#define ftell64 ftello
|
||||
// TODO: Always assert for 8 bytes after increasing min Android API to 24+.
|
||||
// See more details here: https://android.googlesource.com/platform/bionic/+/master/docs/32-bit-abi.md
|
||||
#if defined(OMIM_OS_ANDROID) && (defined(__arm__) || defined(__i386__))
|
||||
static_assert(sizeof(off_t) == 4, "32-bit Android NDK < API 24 has only 32-bit file operations support");
|
||||
#else
|
||||
static_assert(sizeof(off_t) == 8, "FileReader and FileWriter require 64-bit file operations");
|
||||
#endif
|
||||
#define fseek64 fseeko
|
||||
#define ftell64 ftello
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
#include "coding/constants.hpp"
|
||||
#include "coding/internal/file64_api.hpp"
|
||||
#include "coding/reader.hpp" // For Reader exceptions.
|
||||
#include "coding/writer.hpp" // For Writer exceptions.
|
||||
#include "coding/reader.hpp" // For Reader exceptions.
|
||||
#include "coding/writer.hpp" // For Writer exceptions.
|
||||
|
||||
#include "base/exception.hpp"
|
||||
#include "base/logging.hpp"
|
||||
@@ -40,10 +40,9 @@ std::ostream & operator<<(std::ostream & stream, FileData::Op op)
|
||||
return stream;
|
||||
}
|
||||
|
||||
FileData::FileData(string const & fileName, Op op)
|
||||
: m_FileName(fileName), m_Op(op)
|
||||
FileData::FileData(string const & fileName, Op op) : m_FileName(fileName), m_Op(op)
|
||||
{
|
||||
char const * const modes [] = {"rb", "wb", "r+b", "ab"};
|
||||
char const * const modes[] = {"rb", "wb", "r+b", "ab"};
|
||||
|
||||
m_File = fopen(fileName.c_str(), modes[static_cast<int>(op)]);
|
||||
if (m_File)
|
||||
@@ -190,9 +189,7 @@ bool CheckFileOperationResult(int res, string const & fName)
|
||||
// additional check if file really was removed correctly
|
||||
uint64_t dummy;
|
||||
if (GetFileSize(fName, dummy))
|
||||
{
|
||||
LOG(LERROR, ("File exists but can't be deleted. Sharing violation?", fName));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -226,18 +223,16 @@ bool MoveFileX(string const & fOld, string const & fNew)
|
||||
// Otherwise perform the full move.
|
||||
if (!CopyFileX(fOld, fNew))
|
||||
{
|
||||
(void) DeleteFileX(fNew);
|
||||
(void)DeleteFileX(fNew);
|
||||
return false;
|
||||
}
|
||||
(void) DeleteFileX(fOld);
|
||||
(void)DeleteFileX(fOld);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WriteToTempAndRenameToFile(string const & dest, function<bool(string const &)> const & write,
|
||||
string const & tmp)
|
||||
bool WriteToTempAndRenameToFile(string const & dest, function<bool(string const &)> const & write, string const & tmp)
|
||||
{
|
||||
string const tmpFileName =
|
||||
tmp.empty() ? dest + ".tmp" + strings::to_string(this_thread::get_id()) : tmp;
|
||||
string const tmpFileName = tmp.empty() ? dest + ".tmp" + strings::to_string(this_thread::get_id()) : tmp;
|
||||
if (!write(tmpFileName))
|
||||
{
|
||||
LOG(LERROR, ("Can't write to", tmpFileName));
|
||||
@@ -298,7 +293,7 @@ bool CopyFileX(string const & fOld, string const & fNew)
|
||||
}
|
||||
|
||||
// Don't care about possible error here ..
|
||||
(void) DeleteFileX(fNew);
|
||||
(void)DeleteFileX(fNew);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,13 @@ class FileData
|
||||
{
|
||||
public:
|
||||
/// @note Do not change order (@see FileData::FileData).
|
||||
enum class Op { READ = 0, WRITE_TRUNCATE, WRITE_EXISTING, APPEND };
|
||||
enum class Op
|
||||
{
|
||||
READ = 0,
|
||||
WRITE_TRUNCATE,
|
||||
WRITE_EXISTING,
|
||||
APPEND
|
||||
};
|
||||
|
||||
FileData(std::string const & fileName, Op op);
|
||||
~FileData();
|
||||
@@ -33,8 +39,8 @@ public:
|
||||
|
||||
private:
|
||||
FILE * m_File;
|
||||
const std::string m_FileName;
|
||||
const Op m_Op;
|
||||
std::string const m_FileName;
|
||||
Op const m_Op;
|
||||
|
||||
std::string GetErrorProlog() const;
|
||||
|
||||
@@ -47,8 +53,7 @@ bool RenameFileX(std::string const & fOld, std::string const & fNew);
|
||||
|
||||
/// Write to temp file and rename it to dest. Delete temp on failure.
|
||||
/// @param write function that writes to file with a given name, returns true on success.
|
||||
bool WriteToTempAndRenameToFile(std::string const & dest,
|
||||
std::function<bool(std::string const &)> const & write,
|
||||
bool WriteToTempAndRenameToFile(std::string const & dest, std::function<bool(std::string const &)> const & write,
|
||||
std::string const & tmp = "");
|
||||
|
||||
void AppendFileToFile(std::string const & fromFilename, std::string const & toFilename);
|
||||
|
||||
@@ -36,15 +36,14 @@ public:
|
||||
, m_restrictDepth(static_cast<size_t>(-1))
|
||||
, m_dispatcher(dispatcher)
|
||||
, m_enableCharHandler(enableCharHandler)
|
||||
, m_parser(std::unique_ptr<XML_ParserStruct, decltype(&XML_ParserFree)>(
|
||||
XML_ParserCreate(nullptr /* encoding */), &XML_ParserFree))
|
||||
, m_parser(std::unique_ptr<XML_ParserStruct, decltype(&XML_ParserFree)>(XML_ParserCreate(nullptr /* encoding */),
|
||||
&XML_ParserFree))
|
||||
{
|
||||
CHECK(m_parser, ());
|
||||
OnPostCreate();
|
||||
}
|
||||
|
||||
static void StartElementHandler(void * userData, XML_Char const * name,
|
||||
XML_Char const ** attrs)
|
||||
static void StartElementHandler(void * userData, XML_Char const * name, XML_Char const ** attrs)
|
||||
{
|
||||
CHECK(userData, (name));
|
||||
auto * xmlParser = static_cast<XmlParser *>(userData);
|
||||
@@ -138,8 +137,8 @@ public:
|
||||
return {};
|
||||
|
||||
std::stringstream s;
|
||||
s << "XML parse error at line " << XML_GetCurrentLineNumber(m_parser.get())
|
||||
<< " and byte " << XML_GetCurrentByteIndex(m_parser.get());
|
||||
s << "XML parse error at line " << XML_GetCurrentLineNumber(m_parser.get()) << " and byte "
|
||||
<< XML_GetCurrentByteIndex(m_parser.get());
|
||||
return s.str();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user