MPMA Framework 0.4
MiscStuff.h
Go to the documentation of this file.
00001 
00002 //Luke Lenhart, 1999-2007
00003 //See /docs/License.txt for details on how this code may be used.
00004 
00005 #pragma once
00006 
00007 #include <string>
00008 #include <vector>
00009 #include <stdlib.h> //for rand()
00010 #include "File.h"
00011 #include "Types.h"
00012 
00014 namespace MISC
00015 {
00016     // -- assorted misc functions --
00017 
00019     std::string ReadFile(const MPMA::Filename &fname);
00021     bool LoadStringList(std::vector<std::string> &outList, const MPMA::Filename &file);
00023     std::string MakeLower(const std::string &str);
00025     std::string StripFirstLine(const std::string &str);
00027     std::string StripPadding(const std::string &str);
00029     nuint CountBits(nuint data);
00031     int GetHighestBit(nuint data);
00033     void ExplodeString(const std::string &inData, std::vector<std::string> &outData, const std::string &inDeliminators=" \t\n");
00035     nuint ParseHexString(const std::string &s);
00037     bool StartsWith(const std::string &haystack, const std::string &needle);
00039     bool EndsWith(const std::string &haystack, const std::string &needle);
00041     bool Contains(const std::string &haystack, const std::string &needle);
00043     int IndexOf(const std::string &haystack, const std::string &needle, int startIndex=0);
00044 }
00045 
00046 // -- other misc stuff
00047 
00048 //leftover habits from QBasic...
00049 inline double rndd() { return ((double)rand()/(double)RAND_MAX); }
00050 inline float rndf() { return ((float)rand()/(float)RAND_MAX); }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends