🎨 Reformatted code

This commit is contained in:
Edgar 2021-01-15 11:03:58 +01:00
parent 57b0d3a184
commit c3e01fc5c8
2 changed files with 21 additions and 16 deletions

View File

@ -41,18 +41,18 @@
#include <cstring> // this is for memset when compiling with gcc.
#include <deque>
#include <fstream>
#include <map>
#include <sstream>
#include <string>
#include <map>
//-------------------------------------------------------------
// Path-Seperators are different on other OS.
//-------------------------------------------------------------
#ifndef moPATHSEP
#ifndef MO_PATHSEP
#ifdef WIN32
#define moPATHSEP std::string("\\")
#define MO_PATHSEP std::string("\\")
#else
#define moPATHSEP std::string("/")
#define MO_PATHSEP std::string("/")
#endif
#endif
@ -485,20 +485,25 @@ class moFileReader
std::string original_str = original;
std::string translation_str = translation;
auto x = original_str.find(ContextSeparator);
auto ctxSeparator = original_str.find(ContextSeparator);
// Store it in the map.
if(x == std::string::npos){
if (ctxSeparator == std::string::npos)
{
m_lookup[original_str] = translation_str;
numStrings++;
}
else{
else
{
// try-catch for handling out_of_range exceptions
try {
m_lookup_context[original_str.substr(0, x)][original_str.substr(x + 1, original_str.length())] = translation_str;
try
{
m_lookup_context[original_str.substr(0, ctxSeparator)]
[original_str.substr(ctxSeparator + 1, original_str.length())] = translation_str;
numStrings++;
}
catch (...) {
catch (...)
{
m_error = "Stream bad during reading. The .mo-file seems to be invalid or has bad descriptions!";
return moFileReader::EC_ERROR;
}
@ -536,7 +541,7 @@ class moFileReader
if (m_lookup_context.empty()) return id;
auto iterator = m_lookup_context.find(context);
if(iterator == m_lookup_context.end()) return id;
if (iterator == m_lookup_context.end()) return id;
auto iterator2 = iterator->second.find(id);
return iterator2 == iterator->second.end() ? id : iterator2->second;
@ -582,7 +587,7 @@ class moFileReader
// Beautify Output
std::string fname;
unsigned int pos = infile.find_last_of(moPATHSEP);
unsigned int pos = infile.find_last_of(MO_PATHSEP);
if (pos != std::string::npos) { fname = infile.substr(pos + 1, infile.length()); }
else
{

View File

@ -97,7 +97,7 @@ void PrintLicense()
std::string GetAppName(const char *raw)
{
std::string r(raw);
int first = r.find_last_of(moPATHSEP) + 1;
int first = r.find_last_of(MO_PATHSEP) + 1;
r = r.substr(first, r.length() - first);
return r;
}