xoreos
0.0.5
|
Utility templates and functions. More...
Go to the source code of this file.
Macros | |
#define | ARRAYSIZE(x) (sizeof(x) / sizeof(x[0])) |
Macro which determines the number of entries in a fixed size array. More... | |
Functions | |
template<typename T > | |
T | ABS (T x) |
template<typename T > | |
T | MIN (T a, T b) |
template<typename T > | |
T | MAX (T a, T b) |
template<typename T > | |
T | CLIP (T v, T amin, T amax) |
template<typename T > | |
void | SWAP (T &a, T &b) |
Template method which swaps the values of its two parameters. More... | |
template<typename T > | |
bool | ISPOWER2 (T x) |
Is this integer value a power of 2? More... | |
static uint32 | NEXTPOWER2 (uint32 x) |
Round up to the next power of 2. More... | |
static uint64 | NEXTPOWER2 (uint64 x) |
Round up to the next power of 2. More... | |
void | warning (const char *s,...) GCC_PRINTF(1 |
Print a warning message to both stderr and the global log file (if a global log file has been opened). More... | |
void void | status (const char *s,...) GCC_PRINTF(1 |
Print a status message to both stderr and the global log file (if a global log file has been opened). More... | |
void void void | info (const char *s,...) GCC_PRINTF(1 |
Print an info message to both stdout and the global log file (if a global log file has been opened). More... | |
void void void void NORETURN_PRE | error (const char *s,...) GCC_PRINTF(1 |
Print an error message to both stderr and the global log file (if a global log file has been opened). More... | |
float | convertIEEEFloat (uint32 data) |
Convert a uint32 holding the bit pattern of a 32-bit IEEE 754 single precision floating point value into a real, native float. More... | |
double | convertIEEEDouble (uint64 data) |
Convert a uint64 holding the bit pattern of a 64-bit IEEE 754 double precision floating point value into a real, native double. More... | |
uint32 | convertIEEEFloat (float value) |
Convert a native float into a uint32 holding the bit pattern a 32-bit IEEE 754 single precision floating point value. More... | |
uint64 | convertIEEEDouble (double value) |
Convert a native double into a uint64 holding the bit pattern a 64-bit IEEE 754 double precision floating point value. More... | |
double | readNintendoFixedPoint (uint32 value, bool sign, uint8 iBits, uint8 fBits) |
Read a fixed-point value, in a format used by the Nintendo DS. More... | |
float | readIEEEFloat16 (uint16 value) |
Read a half-precision 16-bit IEEE float, converting it into a 32-bit iEEE float. More... | |
Variables | |
void void void void NORETURN_PRE | NORETURN_POST |
Utility templates and functions.
Definition in file util.h.
#define ARRAYSIZE | ( | x | ) | (sizeof(x) / sizeof(x[0])) |
Macro which determines the number of entries in a fixed size array.
Definition at line 131 of file util.h.
Referenced by Graphics::Aurora::TextureManager::activeTexture(), Aurora::FileTypeManager::buildExtensionLookup(), Aurora::FileTypeManager::buildHashLookup(), Aurora::FileTypeManager::buildTypeLookup(), Engines::KotOR::CharacterGenerationMenu::CharacterGenerationMenu(), convertShortToLongOption(), Graphics::Aurora::Texture::create(), Engines::DragonAge::Creature::createModelPrefix(), Graphics::CubeMapCombiner::CubeMapCombiner(), Engines::NWN::NWNEngine::declareBogusTextures(), Engines::Jade::JadeEngine::declareLanguages(), Engines::KotOR2::KotOR2Engine::declareLanguages(), Engines::Sonic::SonicEngine::declareLanguages(), Engines::NWN2::NWN2Engine::declareLanguages(), Engines::DragonAge::DragonAgeEngine::declareLanguages(), Engines::DragonAge2::DragonAge2Engine::declareLanguages(), Engines::Witcher::WitcherEngine::declareLanguages(), Engines::KotOR::KotOREngine::declareLanguages(), Engines::NWN::NWNEngine::declareLanguages(), Engines::Sonic::SonicEngine::declareResources(), Sound::WMACodec::decodeExpHuffman(), Sound::Ima_ADPCMStream::decodeIMA(), Aurora::findGDAHeader(), Aurora::ERFFile::findNWNPremiumKey(), Engines::NWN::getCreatureAnimationName(), Engines::NWN::getCreatureTalkAnimationName(), Engines::NWN::getDoorAnimationName(), Common::FilePath::getHumanReadableSize(), Engines::NWN::getPlaceableAnimationName(), Sound::WMACodec::initExponents(), Sound::WMACodec::initNoise(), Engines::NWN::OptionsResolutionMenu::initResolutionsBox(), Engines::NWN::Game::isPremiumModule(), Engines::Sonic::Placeable::load(), Graphics::Aurora::Texture::loadImage(), Graphics::outputGLDebug(), Graphics::TXI::parseBlending(), Aurora::LanguageManager::parseLanguage(), Graphics::Aurora::Model_NWN::populateDefaultAnimations(), Engines::DragonAge2::ScriptContainer::readScript(), Engines::DragonAge::ScriptContainer::readScript(), Engines::Jade::ScriptContainer::readScripts(), Engines::KotOR::ScriptContainer::readScripts(), Engines::KotOR2::ScriptContainer::readScripts(), Engines::NWN::ScriptContainer::readScripts(), Engines::Witcher::ScriptContainer::readScripts(), Engines::NWN2::ScriptContainer::readScripts(), Engines::DragonAge2::Functions::registerFunctions(), Engines::DragonAge::Functions::registerFunctions(), Engines::NWN::Functions::registerFunctions(), Engines::Witcher::Functions::registerFunctions(), Engines::NWN2::Functions::registerFunctions(), Engines::KotOR2::Functions::registerFunctions(), Engines::Jade::Functions::registerFunctions(), Engines::KotOR::Functions::registerFunctions(), Engines::NWN::Module::removePCTokens(), Engines::NWN::Module::setPCTokens(), Aurora::NWScript::NCSFile::setupOpcodes(), Engines::KotOR::HUD::update(), Engines::KotOR::GUIBackground::update(), Engines::Jade::GUIBackground::update(), and Engines::NWN::Console::updateCampaigns().
|
inline |
Definition at line 69 of file util.h.
Referenced by Engines::DragonAge::Functions::abs(), Engines::DragonAge2::Functions::abs(), Engines::KotOR2::Functions::abs(), Engines::NWN::Functions::abs(), Engines::NWN2::Functions::abs(), Engines::Witcher::Functions::abs(), Engines::KotOR::Functions::abs(), Engines::Jade::Functions::abs(), Graphics::Aurora::CubeSide::calculateDistance(), Graphics::Aurora::Model::calculateDistance(), Common::composeString(), Engines::DragonAge::Functions::fabs(), Engines::DragonAge2::Functions::fabs(), Engines::NWN2::Functions::fabs(), Engines::KotOR2::Functions::fabs(), Engines::NWN::Functions::fabs(), Engines::Witcher::Functions::fabs(), Engines::KotOR::Functions::fabs(), Engines::Jade::Functions::fabs(), Common::BoundingBox::getDepth(), Engines::Sonic::ObjectDistanceSort::getDistance(), Engines::Jade::ObjectDistanceSort::getDistance(), Engines::KotOR2::ObjectDistanceSort::getDistance(), Engines::NWN2::ObjectDistanceSort::getDistance(), Engines::Witcher::ObjectDistanceSort::getDistance(), Engines::KotOR::ObjectDistanceSort::getDistance(), Engines::NWN::ObjectDistanceSort::getDistance(), Engines::DragonAge::ObjectDistanceSort::getDistance(), Engines::DragonAge2::ObjectDistanceSort::getDistance(), Common::BoundingBox::getHeight(), Graphics::Aurora::GUIQuad::getHeight(), Common::BoundingBox::getWidth(), Graphics::Aurora::GUIQuad::getWidth(), Engines::DragonAge2::Functions::isVectorEmpty(), Engines::DragonAge::Functions::isVectorEmpty(), Graphics::Aurora::TextureFont::load(), Common::MDCT::MDCT(), Engines::NWN::QuadWidget::QuadWidget(), and Engines::ConsoleWindow::updateHighlight().
|
inline |
Definition at line 72 of file util.h.
Referenced by Engines::NWN::OptionsVideoMenu::callbackActive(), Engines::NWN::WidgetSlider::changedValue(), Video::dequant(), Engines::ConsoleWindow::highlightClip(), Video::XMVWMV2Codec::IDCTPut(), Graphics::Aurora::Cursor::load(), Sound::MS_ADPCMStream::readBuffer(), Engines::KotOR::OptionsSoundAdvancedMenu::readConfig(), Engines::KotOR::OptionsGraphicsAdvancedMenu::readConfig(), Engines::KotOR::OptionsGameplayMenu::readConfig(), Engines::NWN::PartyLeader::setHealth(), Engines::NWN::WidgetScrollbar::setLength(), Graphics::ImageDecoder::MipMap::setPixel(), Graphics::CameraManager::setPosition(), Engines::NWN::WidgetSlider::setState(), Engines::NWN::WidgetScrollbar::setState(), Engines::NWN::OptionsFeedbackMenu::show(), Engines::NWN::OptionsVideoMenu::show(), Engines::NWN::OptionsGameMenu::show(), Engines::ConsoleWindow::updateScrollbarLength(), and Engines::ConsoleWindow::updateScrollbarPosition().
double convertIEEEDouble | ( | uint64 | data | ) |
Convert a uint64 holding the bit pattern of a 64-bit IEEE 754 double precision floating point value into a real, native double.
NOTE: Currently, this function assumes native doubles are 64-bit IEEE 754 double precision floating point values!
Definition at line 143 of file util.cpp.
References doubleConvert::dDouble, and doubleConvert::dInt.
Referenced by Common::FoxPro::getDouble(), Common::ReadStream::readIEEEDoubleBE(), Common::ReadStream::readIEEEDoubleLE(), Common::FoxPro::setDouble(), Common::WriteStream::writeIEEEDoubleBE(), and Common::WriteStream::writeIEEEDoubleLE().
uint64 convertIEEEDouble | ( | double | value | ) |
Convert a native double into a uint64 holding the bit pattern a 64-bit IEEE 754 double precision floating point value.
NOTE: Currently, this function assumes native doubles are 64-bit IEEE 754 double precision floating point values!
Definition at line 151 of file util.cpp.
References doubleConvert::dDouble, and doubleConvert::dInt.
float convertIEEEFloat | ( | uint32 | data | ) |
Convert a uint32 holding the bit pattern of a 32-bit IEEE 754 single precision floating point value into a real, native float.
NOTE: Currently, this function assumes native floats are 32-bit IEEE 754 single precision floating point values!
Definition at line 116 of file util.cpp.
References floatConvert::dFloat, and floatConvert::dInt.
Referenced by Common::FoxPro::getDouble(), Aurora::GFF3Struct::getDouble(), readIEEEFloat16(), Common::ReadStream::readIEEEFloatBE(), Common::ReadStream::readIEEEFloatLE(), Common::FoxPro::setDouble(), Common::WriteStream::writeIEEEFloatBE(), and Common::WriteStream::writeIEEEFloatLE().
uint32 convertIEEEFloat | ( | float | value | ) |
Convert a native float into a uint32 holding the bit pattern a 32-bit IEEE 754 single precision floating point value.
NOTE: Currently, this function assumes native floats are 32-bit IEEE 754 single precision floating point values!
Definition at line 125 of file util.cpp.
References floatConvert::dFloat, and floatConvert::dInt.
void void void void NORETURN_PRE error | ( | const char * | s, |
... | |||
) |
Print an error message to both stderr and the global log file (if a global log file has been opened).
See Common::DebugManager for details.
Automatically prepends the text "ERROR: " and appends an exclamation mark and a newline.
Additionally, the program will immediately quit with return code 1.
void void void info | ( | const char * | s, |
... | |||
) |
Print an info message to both stdout and the global log file (if a global log file has been opened).
See Common::DebugManager for details.
Automatically appends a newline.
|
inline |
|
inline |
Definition at line 71 of file util.h.
Referenced by Common::BoundingBox::add(), Graphics::NCGR::calculateGrid(), Engines::KotORJadeWidget::createText(), Engines::NWN::DialogBox::finishReplies(), Sound::WwRIFFVorbisStream::generateHeaderSetup(), Common::BoundingBox::getCoordMax(), Common::BoundingBox::getMax(), Aurora::SSFFile::getMaxSoundFileLen(), Engines::NWN::Tooltip::getSize(), Common::Huffman::init(), Engines::NWN::WidgetLabel::initCaption(), Engines::NWN::OptionsVideoAdvancedMenu::initWidget(), listDebug(), Engines::WidgetListBox::mouseWheel(), Engines::Console::printFullHelp(), Graphics::Aurora::Model_Sonic::readPolygonCommands(), Graphics::Aurora::FadeQuad::render(), Engines::NWN::Scrollbar::setLength(), Engines::NWN::WidgetScrollbar::setLength(), Engines::NWN::OptionsVideoAdvancedMenu::show(), Graphics::Font::split(), Common::UString::split(), Common::ReadLine::tabComplete(), Engines::NWN2::Console::updateMusic(), Engines::KotOR2::Console::updateMusic(), Engines::KotOR::Console::updateMusic(), Engines::Witcher::Console::updateMusic(), Engines::NWN::Console::updateMusic(), Engines::NWN::Tooltip::updatePosition(), Engines::Console::updateSounds(), Engines::Console::updateVideos(), and Common::MemoryWriteStreamDynamic::write().
|
inline |
Definition at line 70 of file util.h.
Referenced by Common::BoundingBox::add(), Engines::NWN::Scrollbar::createH(), Engines::NWN::Scrollbar::createV(), Engines::KotOR2::CharacterGeneration::decStep(), Engines::KotOR::CharacterGenerationMenu::decStep(), Common::ReadLine::findCommonSubstring(), Sound::WMACodec::getBlockSizeCount(), Common::BoundingBox::getCoordMin(), Common::BoundingBox::getMin(), Graphics::Aurora::GUIQuad::getPosition(), Engines::WidgetListBox::mouseWheel(), Video::Bink::BinkAudioTrack::readAudioCoeffs(), Graphics::Aurora::ModelNode_Jade::readChunkedIndices(), Graphics::Aurora::FadeQuad::render(), Engines::ConsoleWindow::scrollDown(), Engines::KotOR::Object::setCurrentHitPoints(), and Engines::ConsoleWindow::updateHighlight().
Round up to the next power of 2.
Definition at line 84 of file util.h.
Referenced by Graphics::Aurora::NFTRFont::drawGlyphs(), Video::VideoDecoder::initVideo(), and Graphics::SBM::readData().
float readIEEEFloat16 | ( | uint16 | value | ) |
Read a half-precision 16-bit IEEE float, converting it into a 32-bit iEEE float.
Definition at line 198 of file util.cpp.
References convertIEEEFloat().
Referenced by Graphics::Aurora::ModelNode_DragonAge::read2Float32(), Graphics::Aurora::ModelNode_DragonAge::read3Float32(), and Graphics::Aurora::ModelNode_DragonAge::read4Float32().
Read a fixed-point value, in a format used by the Nintendo DS.
value | The integer representing the fixed-point value. |
sign | Is this a signed fixed-point value? |
iBits | Number of bits in the integer part. |
fBits | Number of bits in the fractional part. |
Definition at line 159 of file util.cpp.
References UINT64_C.
Referenced by Graphics::Aurora::Model_Sonic::createPrimitives(), Aurora::GFF4Struct::getDouble(), Aurora::GFF4Struct::getFloat(), Graphics::Aurora::Model_Sonic::readBone(), Aurora::GFXFile::readMatrix(), and Graphics::Aurora::Model_Sonic::readModel().
void void status | ( | const char * | s, |
... | |||
) |
Print a status message to both stderr and the global log file (if a global log file has been opened).
See Common::DebugManager for details.
Automatically appends a newline.
|
inline |
Template method which swaps the values of its two parameters.
Definition at line 78 of file util.h.
Referenced by Common::blowfishDec(), Common::blowfishEnc(), Engines::ConsoleWindow::getHighlight(), Common::FFT::permute(), Video::Bink::BinkVideoTrack::readHuffman(), Aurora::LocString::swap(), Graphics::ImageDecoder::MipMap::swap(), Common::ScopedPtrBase< Engines::NWN2::Creature, DeallocatorDefault >::swap(), and Common::UString::swap().
void warning | ( | const char * | s, |
... | |||
) |
Print a warning message to both stderr and the global log file (if a global log file has been opened).
See Common::DebugManager for details.
Automatically prepends the text "WARNING: " and appends an exclamation mark and a newline.
void void void void NORETURN_PRE NORETURN_POST |