Setting code formatting standard to allman.

This commit is contained in:
emb
2015-01-01 14:08:42 -06:00
parent 174ea4f4f9
commit 6410139f87
76 changed files with 5352 additions and 5314 deletions

View File

@@ -1,5 +1,5 @@
/* This file is subject to the terms and conditions defined in
* file 'LICENSE.txt', which is part of this source code package.
/* This file is subject to the terms and conditions defined in
* file 'LICENSE.txt', which is part of this source code package.
*/
#include "Log.h"
#include <iostream>
@@ -12,53 +12,53 @@ std::streambuf *Logger::CoutStream = NULL;
bool Logger::Initialize(std::string file)
{
WriteFileStream.open(file.c_str());
WriteFileStream.open(file.c_str());
CerrStream = std::cerr.rdbuf(WriteFileStream.rdbuf());
CoutStream = std::cout.rdbuf(WriteFileStream.rdbuf());
CerrStream = std::cerr.rdbuf(WriteFileStream.rdbuf());
CoutStream = std::cout.rdbuf(WriteFileStream.rdbuf());
return WriteFileStream.is_open();
return WriteFileStream.is_open();
}
void Logger::DeInitialize()
{
if(WriteFileStream.is_open())
{
WriteFileStream.close();
if(WriteFileStream.is_open())
{
WriteFileStream.close();
}
}
std::cerr.rdbuf(CerrStream);
std::cout.rdbuf(CoutStream);
std::cerr.rdbuf(CerrStream);
std::cout.rdbuf(CoutStream);
}
void Logger::Write(Zone zone, std::string component, std::string message)
{
std::string zoneStr;
std::string zoneStr;
switch(zone)
{
case ZONE_INFO:
zoneStr = "INFO";
break;
case ZONE_DEBUG:
zoneStr = "DEBUG";
break;
case ZONE_WARNING:
zoneStr = "WARNING";
break;
case ZONE_ERROR:
zoneStr = "ERROR";
break;
}
std::time_t rawtime = std::time(NULL);
struct tm* timeinfo = std::localtime(&rawtime);
switch(zone)
{
case ZONE_INFO:
zoneStr = "INFO";
break;
case ZONE_DEBUG:
zoneStr = "DEBUG";
break;
case ZONE_WARNING:
zoneStr = "WARNING";
break;
case ZONE_ERROR:
zoneStr = "ERROR";
break;
}
std::time_t rawtime = std::time(NULL);
struct tm* timeinfo = std::localtime(&rawtime);
static char timeStr[60];
std::strftime(timeStr, sizeof(timeStr), "%Y-%m-%d %H:%M:%S", timeinfo);
static char timeStr[60];
std::strftime(timeStr, sizeof(timeStr), "%Y-%m-%d %H:%M:%S", timeinfo);
std::stringstream ss;
ss << "[" << timeStr << "] [" << zoneStr << "] [" << component << "] " << message << std::endl;
std::cout << ss.str();
std::stringstream ss;
ss << "[" << timeStr << "] [" << zoneStr << "] [" << component << "] " << message << std::endl;
std::cout << ss.str();
}

View File

@@ -1,5 +1,5 @@
/* This file is subject to the terms and conditions defined in
* file 'LICENSE.txt', which is part of this source code package.
/* This file is subject to the terms and conditions defined in
* file 'LICENSE.txt', which is part of this source code package.
*/
#pragma once
@@ -12,20 +12,20 @@
class Logger
{
public:
enum Zone
{
ZONE_DEBUG,
ZONE_INFO,
ZONE_WARNING,
ZONE_ERROR
enum Zone
{
ZONE_DEBUG,
ZONE_INFO,
ZONE_WARNING,
ZONE_ERROR
};
static bool Initialize(std::string file);
static void Write(Zone zone, std::string component, std::string message);
static void DeInitialize();
};
static bool Initialize(std::string file);
static void Write(Zone zone, std::string component, std::string message);
static void DeInitialize();
private:
static std::streambuf *CerrStream;
static std::streambuf *CoutStream;
static std::ofstream WriteFileStream;
static std::streambuf *CerrStream;
static std::streambuf *CoutStream;
static std::ofstream WriteFileStream;
};

View File

@@ -20,112 +20,112 @@ Utils::~Utils()
bool Utils::FindMatchingFile(std::string prefix, std::vector<std::string> &extensions, std::string &file)
{
for(unsigned int i = 0; i < extensions.size(); ++i)
{
std::string temp = prefix + "." + extensions[i];
temp = Configuration::ConvertToAbsolutePath(Configuration::GetAbsolutePath(), temp);
for(unsigned int i = 0; i < extensions.size(); ++i)
{
std::string temp = prefix + "." + extensions[i];
temp = Configuration::ConvertToAbsolutePath(Configuration::GetAbsolutePath(), temp);
std::ifstream f(temp.c_str());
std::ifstream f(temp.c_str());
if (f.good())
{
file = temp;
return true;
}
}
if (f.good())
{
file = temp;
return true;
}
}
return false;
return false;
}
std::string Utils::Replace(
std::string subject,
const std::string& search,
const std::string& replace)
std::string subject,
const std::string& search,
const std::string& replace)
{
size_t pos = 0;
while ((pos = subject.find(search, pos)) != std::string::npos)
{
subject.replace(pos, search.length(), replace);
pos += replace.length();
}
return subject;
size_t pos = 0;
while ((pos = subject.find(search, pos)) != std::string::npos)
{
subject.replace(pos, search.length(), replace);
pos += replace.length();
}
return subject;
}
float Utils::ConvertFloat(std::string content)
{
float retVal = 0;
std::stringstream ss;
ss << content;
ss >> retVal;
float retVal = 0;
std::stringstream ss;
ss << content;
ss >> retVal;
return retVal;
return retVal;
}
int Utils::ConvertInt(std::string content)
{
int retVal = 0;
std::stringstream ss;
ss << content;
ss >> retVal;
int retVal = 0;
std::stringstream ss;
ss << content;
ss >> retVal;
return retVal;
return retVal;
}
void Utils::NormalizeBackSlashes(std::string& content)
{
std::replace(content.begin(), content.end(), '\\', '/');
std::replace(content.begin(), content.end(), '\\', '/');
}
std::string Utils::GetDirectory(std::string filePath)
{
NormalizeBackSlashes(filePath);
std::string directory = filePath;
NormalizeBackSlashes(filePath);
std::string directory = filePath;
const size_t last_slash_idx = filePath.rfind('/');
if (std::string::npos != last_slash_idx)
{
directory = filePath.substr(0, last_slash_idx);
}
const size_t last_slash_idx = filePath.rfind('/');
if (std::string::npos != last_slash_idx)
{
directory = filePath.substr(0, last_slash_idx);
}
return directory;
return directory;
}
std::string Utils::GetParentDirectory(std::string directory)
{
NormalizeBackSlashes(directory);
NormalizeBackSlashes(directory);
size_t last_slash_idx = directory.find_last_of('/');
if(directory.length() - 1 == last_slash_idx)
{
directory = directory.erase(last_slash_idx, directory.length()-1);
last_slash_idx = directory.find_last_of('/');
}
size_t last_slash_idx = directory.find_last_of('/');
if(directory.length() - 1 == last_slash_idx)
{
directory = directory.erase(last_slash_idx, directory.length()-1);
last_slash_idx = directory.find_last_of('/');
}
if (std::string::npos != last_slash_idx)
{
directory = directory.erase(last_slash_idx, directory.length());
}
if (std::string::npos != last_slash_idx)
{
directory = directory.erase(last_slash_idx, directory.length());
}
return directory;
return directory;
}
std::string Utils::GetFileName(std::string filePath)
{
NormalizeBackSlashes(filePath);
std::string filename = filePath;
NormalizeBackSlashes(filePath);
std::string filename = filePath;
const size_t last_slash_idx = filePath.rfind('/');
if (std::string::npos != last_slash_idx)
{
filename = filePath.erase(0, last_slash_idx+1);
}
const size_t last_slash_idx = filePath.rfind('/');
if (std::string::npos != last_slash_idx)
{
filename = filePath.erase(0, last_slash_idx+1);
}
return filename;
return filename;
}

View File

@@ -9,18 +9,18 @@
class Utils
{
public:
static std::string Replace(std::string subject, const std::string& search,
const std::string& replace);
static std::string Replace(std::string subject, const std::string& search,
const std::string& replace);
static float ConvertFloat(std::string content);
static int ConvertInt(std::string content);
static void NormalizeBackSlashes(std::string &content);
static std::string GetDirectory(std::string filePath);
static std::string GetParentDirectory(std::string filePath);
static std::string GetFileName(std::string filePath);
static bool FindMatchingFile(std::string prefix, std::vector<std::string> &extensions, std::string &file);
static float ConvertFloat(std::string content);
static int ConvertInt(std::string content);
static void NormalizeBackSlashes(std::string &content);
static std::string GetDirectory(std::string filePath);
static std::string GetParentDirectory(std::string filePath);
static std::string GetFileName(std::string filePath);
static bool FindMatchingFile(std::string prefix, std::vector<std::string> &extensions, std::string &file);
private:
Utils();
virtual ~Utils();
Utils();
virtual ~Utils();
};