Another LF property change.

This commit is contained in:
wrenczes@gmail.com
2011-01-28 06:07:14 +00:00
parent f2cbd883a6
commit f4f1fdcd3d

View File

@@ -1,121 +1,121 @@
#ifndef _UTILS_H_ #ifndef _UTILS_H_
#define _UTILS_H_ #define _UTILS_H_
#include <JGE.h> #include <JGE.h>
#if defined (WIN32) || defined (LINUX) || defined (IOS) #if defined (WIN32) || defined (LINUX) || defined (IOS)
#else #else
#include <pspkernel.h> #include <pspkernel.h>
#include <pspdisplay.h> #include <pspdisplay.h>
#include <pspctrl.h> #include <pspctrl.h>
#include <pspiofilemgr.h> #include <pspiofilemgr.h>
#include <pspdebug.h> #include <pspdebug.h>
#include <psputility.h> #include <psputility.h>
#include <pspgu.h> #include <pspgu.h>
#include <psprtc.h> #include <psprtc.h>
#include <psptypes.h> #include <psptypes.h>
#include <malloc.h> #include <malloc.h>
#endif #endif
#include <math.h> #include <math.h>
#include <stdio.h> #include <stdio.h>
#include <string> #include <string>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <algorithm> #include <algorithm>
#include <stdlib.h> #include <stdlib.h>
#if defined( WIN32 ) || defined (LINUX) #if defined( WIN32 ) || defined (LINUX)
// enable this define to collect statistics on how many times an ifstream is created for a given file. // enable this define to collect statistics on how many times an ifstream is created for a given file.
//#define TRACK_FILE_USAGE_STATS //#define TRACK_FILE_USAGE_STATS
#endif #endif
namespace wagic namespace wagic
{ {
#ifdef TRACK_FILE_USAGE_STATS #ifdef TRACK_FILE_USAGE_STATS
class ifstream : public std::ifstream class ifstream : public std::ifstream
{ {
public: public:
explicit ifstream(const char *inFilename, ios_base::openmode inMode = ios_base::in) : explicit ifstream(const char *inFilename, ios_base::openmode inMode = ios_base::in) :
std::ifstream(inFilename, inMode) std::ifstream(inFilename, inMode)
{ {
sFileMap[std::string(inFilename)] += 1; sFileMap[std::string(inFilename)] += 1;
} }
static void Dump() static void Dump()
{ {
DebugTrace("-------------------"); DebugTrace("-------------------");
DebugTrace("File Usage Statistics" << std::endl); DebugTrace("File Usage Statistics" << std::endl);
std::map<std::string, int>::const_iterator iter = sFileMap.begin(); std::map<std::string, int>::const_iterator iter = sFileMap.begin();
for (; iter != sFileMap.end(); ++iter) for (; iter != sFileMap.end(); ++iter)
{ {
DebugTrace(iter->first << " -- " << iter->second); DebugTrace(iter->first << " -- " << iter->second);
} }
DebugTrace("End File Usage Statistics"); DebugTrace("End File Usage Statistics");
DebugTrace("-------------------"); DebugTrace("-------------------");
} }
private: private:
static std::map<std::string, int> sFileMap; static std::map<std::string, int> sFileMap;
}; };
#else #else
typedef std::ifstream ifstream; typedef std::ifstream ifstream;
#endif #endif
} //namespace wagic } //namespace wagic
using std::string; using std::string;
//string manipulation methods //string manipulation methods
string& trim(string& str); string& trim(string& str);
string& ltrim(string& str); string& ltrim(string& str);
string& rtrim(string& str); string& rtrim(string& str);
std::string join(vector<string>& v, string delim = " "); std::string join(vector<string>& v, string delim = " ");
std::vector<std::string>& split(const std::string& s, char delim, std::vector<std::string>& elems); std::vector<std::string>& split(const std::string& s, char delim, std::vector<std::string>& elems);
std::vector<std::string> split(const std::string& s, char delim); //splits a string with "delim" and returns a vector of strings. std::vector<std::string> split(const std::string& s, char delim); //splits a string with "delim" and returns a vector of strings.
std::string wordWrap(const std::string& s, float width, int fontId); std::string wordWrap(const std::string& s, float width, int fontId);
int loadRandValues(string s); int loadRandValues(string s);
int filesize(const char * filename); int filesize(const char * filename);
int fileExists(const char * filename); int fileExists(const char * filename);
int WRand(); int WRand();
#ifdef LINUX #ifdef LINUX
void dumpStack(); void dumpStack();
#endif #endif
/* RAM simple check functions header */ /* RAM simple check functions header */
// *** DEFINES *** // *** DEFINES ***
#if defined (WIN32) || defined (LINUX) || defined (IOS) #if defined (WIN32) || defined (LINUX) || defined (IOS)
#define RAM_BLOCK (100 * 1024 * 1024) #define RAM_BLOCK (100 * 1024 * 1024)
#else #else
#define RAM_BLOCK (1024 * 1024) #define RAM_BLOCK (1024 * 1024)
#endif #endif
// *** FUNCTIONS DECLARATIONS *** // *** FUNCTIONS DECLARATIONS ***
u32 ramAvailableLineareMax(void); u32 ramAvailableLineareMax(void);
u32 ramAvailable(void); u32 ramAvailable(void);
#ifdef WIN32 #ifdef WIN32
#include <direct.h> #include <direct.h>
#define MAKEDIR(name) mkdir(name) #define MAKEDIR(name) mkdir(name)
#else #else
#include <sys/stat.h> #include <sys/stat.h>
#define MAKEDIR(name) mkdir(name, 0777) #define MAKEDIR(name) mkdir(name, 0777)
#endif #endif
#endif #endif