athena/include/Athena/Utility.hpp

73 lines
2.2 KiB
C++
Raw Normal View History

2014-04-20 09:14:15 +00:00
// This file is part of libAthena.
//
2014-04-20 09:14:15 +00:00
// libAthena is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
2014-04-20 09:14:15 +00:00
// libAthena is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
2014-04-20 09:14:15 +00:00
// along with libAthena. If not, see <http://www.gnu.org/licenses/>
2013-01-26 20:19:24 +00:00
#ifndef __UTILITY_H__
#define __UTILITY_H__
#include <string>
2013-09-09 03:36:54 +00:00
#include <vector>
#include <stdarg.h>
#include "Athena/Types.hpp"
2013-01-26 20:19:24 +00:00
2014-04-20 09:14:15 +00:00
namespace Athena
{
namespace utility
{
bool isEmpty(atInt8*, atUint32);
atUint16 swapU16(atUint16 val );
atInt16 swap16 (atInt16 val );
atUint32 swapU32(atUint32 val);
atInt32 swap32 (atInt32 val );
atUint64 swapU64(atUint64 val);
atInt64 swap64 (atInt64 val);
2013-07-21 03:57:20 +00:00
float swapFloat(float val);
double swapDouble(double val);
2014-09-09 10:19:19 +00:00
atInt16 LittleInt16(atInt16& val);
atUint16 LittleUint16(atUint16& val);
atInt16 BigInt16(atInt16& val);
atUint16 BigUint16(atUint16& val);
atInt32 LittleInt32(atInt32& val);
atUint32 LittleUint32(atUint32& val);
atInt32 BigInt32(atInt32& val);
atUint32 BigUint32(atUint32& val);
atInt64 LittleInt64(atInt64& val);
atUint64 LittleUint64(atUint64& val);
atInt64 BigInt64(atInt64& val);
atUint16 BigUint64(atUint16& val);
float LittleFloat(float& val);
float BigFloat(float& val);
double LittleDouble(double& val);
double BigDouble(double& val);
2013-01-26 20:19:24 +00:00
bool isSystemBigEndian();
2014-06-30 00:26:34 +00:00
void fillRandom(atUint8 * rndArea, atUint64 count);
2013-09-09 03:36:54 +00:00
std::vector<std::string> split(const std::string &s, char delim);
2014-01-19 04:01:31 +00:00
std::string join(const std::vector<std::string>& elems, const std::string& delims);
2013-09-09 03:36:54 +00:00
void tolower(std::string& str);
void toupper(std::string& str);
std::string vsprintf(const char* fmt, va_list list);
std::string sprintf(const char* fmt, ...);
2014-01-11 18:27:29 +00:00
bool parseBool(const std::string& boolean, bool* valid = NULL);
2013-09-09 03:36:54 +00:00
int countChar(const std::string& str, const char chr, int* lastOccur = NULL);
2013-09-09 03:36:54 +00:00
atUint64 fileSize(FILE* f);
} // utility
2014-04-20 09:14:15 +00:00
} // Athena
2013-01-26 20:19:24 +00:00
#endif