Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

util.hpp File Reference


Detailed Description

This is the header file for utility functions. Essentially, all functions that do not belong in a class go in this file.

Author:
John Gaughan
Version:
0.08
Date:
26 January 2005
Revisions:

Definition in file util.hpp.

Go to the source code of this file.

Namespaces

namespace  Doomwad

Functions

uint16 convertEndian (uint16 x)
 Convert an unsigned short int to this machine's endianness.
uint32 convertEndian (uint32 x)
 Convert an unsigned int to this machine's endianness.
EXPORT std::string exceptionString (const std::string &, const std::string &, size_t) throw ()
 Create an exception description.
bool isInvalidPointer (void *p, size_t size=1)
 Test if a pointer is invalid.
bool isNullPointer (void *p)
 Test if a pointer is null.
char * makeDoomString (char *buffer, const std::string &str) throw ()
 Convert a String to a DoomString.
std::string & makeStdString (std::string &str, const char *buffer) throw ()
 Convert a DoomString to a String.


Function Documentation

uint16 convertEndian uint16  x  )  [inline]
 

Convert an unsigned short int to this machine's endianness.

Parameters:
x unsigned short int to convert.
Returns:
unsigned short int in this machine's endian representation.

Definition at line 83 of file util.hpp.

uint32 convertEndian uint32  x  )  [inline]
 

Convert an unsigned int to this machine's endianness.

Parameters:
x unsigned int to convert.
Returns:
unsigned int in this machine's endian representation.

Definition at line 67 of file util.hpp.

std::string Doomwad::exceptionString const std::string &  description,
const std::string &  file,
size_t  line
throw ()
 

Create an exception description.

There are several options for creating consistent and meaningful exceptions. Rather than define new exceptions, this library uses the ones in <stdexcept> and relies on its internal string buffer to describe the error. To keep exception descriptions consistent, this function creates a string based on the file name, line number, and a custom description. The user of this function uses its return value to create an exception.

To use this function, type a string description as the first argument. Use the __FILE__ and __LINE__ macros for the other two.

Parameters:
description Description of what caused the exception.
file File name in which the exception occurred.
line Line number at which the exception occurred.
Returns:
std::string representation of the exception string on the stack.

Definition at line 62 of file util.cpp.

Referenced by Doomwad::Lump::append(), Doomwad::Lump::assign(), Doomwad::Lump::at(), Doomwad::Flat::at(), Doomwad::Lump::getByte(), Doomwad::Lump::getDString(), Doomwad::Lump::getDWord(), Doomwad::Lump::getInt16(), Doomwad::Lump::getInt32(), Doomwad::Lump::getInt64(), Doomwad::Lump::getInt8(), Doomwad::Lump::getQWord(), Doomwad::Lump::getString(), Doomwad::Lump::getUInt16(), Doomwad::Lump::getUInt32(), Doomwad::Lump::getUInt64(), Doomwad::Lump::getUInt8(), Doomwad::Lump::getWord(), Doomwad::Lump::grow(), Doomwad::Lump::Lump(), Doomwad::Lump::operator+(), Doomwad::Lump::operator+=(), Doomwad::Lump::setByte(), Doomwad::Lump::setDString(), Doomwad::Lump::setDWord(), Doomwad::Lump::setInt16(), Doomwad::Lump::setInt32(), Doomwad::Lump::setInt64(), Doomwad::Lump::setInt8(), Doomwad::Lump::setQWord(), Doomwad::Lump::setString(), Doomwad::Lump::setUInt16(), Doomwad::Lump::setUInt32(), Doomwad::Lump::setUInt64(), Doomwad::Lump::setUInt8(), Doomwad::Lump::setWord(), and Doomwad::Lump::shrink().

bool isInvalidPointer void *  p,
size_t  size = 1
[inline]
 

Test if a pointer is invalid.

Parameters:
p Pointer to test.
size Size of the buffer pointed to by the pointer.
Returns:
True if invalid, false if valid.

Definition at line 112 of file util.hpp.

bool isNullPointer void *  p  )  [inline]
 

Test if a pointer is null.

Parameters:
p Pointer to test.
Returns:
True if null, false if not null.

Definition at line 99 of file util.hpp.

char* makeDoomString char *  buffer,
const std::string &  str
throw () [inline]
 

Convert a String to a DoomString.

Takes a std::string input and converts it to the format used in wad files.

Parameters:
buffer Character output buffer, assumed to be 8 characters.
str String input.
Returns:
Pointer to the output buffer.

Definition at line 132 of file util.hpp.

std::string& makeStdString std::string &  str,
const char *  buffer
throw () [inline]
 

Convert a DoomString to a String.

Takes a character buffer in the Doom wad file string format and converts it to a std::string. Assumes the buffer is 8 characters and has no terminating null.

Parameters:
str String output.
buffer Character input buffer.
Returns:
Reference to the output string.

Definition at line 152 of file util.hpp.


Generated on Fri Jun 10 19:38:51 2005 for libdoomwad by  doxygen 1.4.0