#include <stdlib.h>
#include <cstdlib>
#include <cmath>
#include <string.h>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <list>
#include <map>
#include <stack>
#include <stdexcept>
#include <SDL/SDL.h>
Include dependency graph for utils.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Namespaces | |
| namespace | hoa_utils |
Classes | |
| class | hoa_utils::Singleton< T > |
| Used for transforming a standard class into a singleton class. More... | |
| class | hoa_utils::ustring |
| Implements unicode strings with uint16 as the character type. More... | |
Typedefs | |
Allacrost Integer Types | |
These are the integer types used throughout the Allacrost source code. These types are created by redefining the SDL types (we do not like SDL's type-naming conventions). Use of the standard int, long, etc. is forbidden in Allacrost source code! Don't attempt to use any 64-bit types either, since a large population of PCs in our target audience are not a 64-bit architecture. | |
| typedef Sint16 | int16 |
| typedef Sint32 | int32 |
| typedef Sint8 | int8 |
| typedef Uint16 | uint16 |
| typedef Uint32 | uint32 |
| typedef Uint8 | uint8 |
Functions | |
| template<class T> | |
| void | hoa_utils::DataToString (std::string &s, const T &data) |
| Converts data to string. | |
| float | hoa_utils::FloorToFloatMultiple (const float value, const float multiple) |
| Rounds down a float to a multiple of another float. | |
| bool | hoa_utils::IsFloatInRange (float value, float lower, float upper) |
| Determines if a floating point number is within a range of two numbers. | |
| bool | hoa_utils::IsOddNumber (uint32 x) |
| Determines if an integer is an odd number or not. | |
| bool | hoa_utils::IsPowerOfTwo (uint32 x) |
| Determines if an unsigned integer is a power of two or not. | |
| template<typename T, size_t N> | |
| size_t | hoa_utils::NumberElementsArray (T(&)[N]) |
| A template function that returns the number of elements in an array. | |
| uint32 | hoa_utils::RoundUpPow2 (uint32 x) |
| Rounds an unsigned integer up to the nearest power of two. | |
Directory and File Manipulation Functions | |
| bool | hoa_utils::CleanDirectory (const std::string &dir_name) |
| Removes all files present in a directory. | |
| bool | hoa_utils::DoesFileExist (const std::string &file_name) |
| Checks if a file exists on the system or not. | |
| bool | hoa_utils::MakeDirectory (const std::string &dir_name) |
| Creates a directory relative to the path of the running application. | |
| bool | hoa_utils::MoveFile (const std::string &source_name, const std::string &destination_name) |
| Moves a file from one location to another. | |
| bool | hoa_utils::RemoveDirectory (const std::string &dir_name) |
| Deletes a directory, as well as any files the directory may contain. | |
Random Variable Genreator Fucntions | |
| int32 | hoa_utils::GaussianRandomValue (int32 mean, float std_dev=10.0f, bool positive_value=true) |
| Returns a Gaussian random value with specified mean and standard deviation. | |
| bool | hoa_utils::Probability (uint32 chance) |
| Returns true/false depending on the chance. | |
| int32 | hoa_utils::RandomBoundedInteger (int32 lower_bound, int32 upper_bound) |
| Returns a random interger value uniformally distributed between two inclusive bounds. | |
| float | hoa_utils::RandomFloat () |
| Creates a uniformly distributed random floating point number. | |
Version Checking Functions | |
| string | hoa_utils::GetLatestVersion () |
| Gets newest version. | |
| bool | hoa_utils::IsLatestVersion () |
| Checks version against a remote server. | |
Sorting Functions | |
| template<typename T> | |
| void | hoa_utils::InsertionSort (std::vector< T > &swap_vec) |
| Performs an insertion sort on a vector of elements. | |
String Utility Functions | |
| bool | hoa_utils::IsStringNumeric (const std::string &text) |
| Determines if a string is a valid numeric string. | |
| string | hoa_utils::MakeStandardString (const hoa_utils::ustring &text) |
| Creates an starndard string from a ustring. | |
| hoa_utils::ustring | hoa_utils::MakeUnicodeString (const std::string &text) |
| Creates a ustring from a standard string. | |
| template<typename T> | |
| std::string | hoa_utils::NumberToString (const T t) |
| Converts an integer type into a standard string. | |
Variables | |
| bool | hoa_utils::UTILS_DEBUG |
| Determines whether the code in the hoa_utils namespace should print debug statements or not. | |
Multiples of Pi constants | |
PI and multiples of PI. Used in various math calculations such as interpolations.
These constants are mostly used in the video engine. | |
| const float | hoa_utils::UTILS_2PI = 6.283185307f |
| const float | hoa_utils::UTILS_HALF_PI = 1.570796326f |
| const float | hoa_utils::UTILS_PI = 3.141592653f |
| const float | hoa_utils::UTILS_QUARTER_PI = 0.785398163f |
***************************************************************************(
This code includes various utility functions that are used across different parts of the code base. This file is included in every header file in the Allacrost source tree.
Use the following macros for compiler-dependent code.
Use the following statements to determine system endianess.
Use the following integer types throughout the entire Allacrost code.
Use the following string types througout the entire Allacrost code.
Definition in file utils.h.
1.5.1