LibNebular, Some useful stuff. More...
#include "config.h"
#include <stdexcept>
#include <iostream>
#include <string>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <csetjmp>
#include <boost/shared_ptr.hpp>
#include <loki/Functor.h>
Go to the source code of this file.
Classes | |
class | HexInteger< Integer > |
Analogue of Integer that uses redefined for hexadecimal output operator<<(std::ostream &, const HexInteger<Integer> &) . More... | |
struct | null_deleter |
Deleter which does nothing. More... | |
class | CArrayOfArrayDeleter |
Deleter for C-style array of C-style arrays. More... | |
class | CFileWrapper |
Wraps C-style FILE structure. More... | |
struct | CFileWrapper::CFileDeleter |
Deleter for C-style FILE structure. | |
Defines | |
#define | LOKI_ENABLE_FUNCTION |
#define | LOKI_FUNCTOR_IS_NOT_A_SMALLOBJECT |
#define | TODO_HERE(x) |
Doesn't do anything with x and writes to std::clog "TODO" with location info. | |
#define | TODO(x) |
Doesn't evaluate x and writes to std::clog "TODO" with location info and x in literal form. | |
#define | TRACE(x) std::clog << "\"" << #x << "\" = \"" << x << "\"" << std::endl |
Traces to std::clog: x in literal form and value of x evaluated. | |
#define | ARRAY_SIZE(a) ( (sizeof( (a) )/sizeof( (a)[0])) ) |
Array size of one-dimensional C-style array. | |
Functions | |
template<typename Integer > | |
std::ostream & | operator<< (std::ostream &aOstream, const HexInteger< Integer > &x) |
Output Integer with hexadecimal representation enabled. | |
template<typename Integer > | |
Integer | roundDiv (Integer a, Integer b) |
Division of positive a by positive b with rounding of result to nearest integer. | |
template<typename T > | |
std::istream & | readBin (std::istream &inStream, T &field) |
Reads field of arbitrary type T as binary data from std::istream . | |
template<typename T > | |
std::ostream & | writeBin (std::ostream &outStream, T &field) |
Writes field of arbitrary type T as binary data to std::istream . | |
template<typename Integer > | |
Integer | checkedDivByMultiple (Integer a, Integer b) |
Division of integer a to its multiple b which checks that b is really multiple. | |
template<typename Integer > | |
Integer | checkedBitsToIntBytes (Integer bits) |
Conversion from bit count to byte count which checks that number of bits is a multiple of bitsPerByte. | |
template<typename Out > | |
Out | getBytes (const char *whereFrom, int numBytes) |
Safely gets numBytes from memory region whereFrom . | |
template<typename In > | |
void | setBytes (char *whereTo, int numBytes, In newValue) |
Safely sets numBytes from memory region whereTo to newValue . | |
template<typename In > | |
std::string | lexicalCastToStdString (In a) |
Does "lexical cast" to std::string . | |
Variables | |
const char | bitsPerByte = 8 |
LibNebular, Some useful stuff.
Copyright (C) 2011 Leonid Sadikov ⟨ leonius@inbox.ru ⟩
This file is part of LibNebular.
LibNebular is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3 as published by the Free Software Foundation.
See "COPYING.LESSER" and "COPYING" in distribution or ⟨http://www.gnu.org/licenses/⟩ for full license text.
Definition in file utils.hpp.
#define ARRAY_SIZE | ( | a | ) | ( (sizeof( (a) )/sizeof( (a)[0])) ) |
#define TODO | ( | x | ) |
{ \ std::clog << std::string("TODO: ") + \ "in function \"" + __PRETTY_FUNCTION__ + \ "\", file \"" + __FILE__ + \ "\" at line " + lexicalCastToStdString(__LINE__) + \ ": \n" + #x << std::endl; } \ while(false)
Doesn't evaluate x
and writes to std::clog
"TODO" with location info and x
in literal form.
#define TODO_HERE | ( | x | ) |
{ \ std::clog << std::string("TODO: ") + \ "in function \"" + __PRETTY_FUNCTION__ + \ "\", file \"" + __FILE__ + \ "\" at line " + lexicalCastToStdString(__LINE__) << \ std::endl; } \ while(false)
Doesn't do anything with x
and writes to std::clog
"TODO" with location info.
#define TRACE | ( | x | ) | std::clog << "\"" << #x << "\" = \"" << x << "\"" << std::endl |
Integer checkedBitsToIntBytes | ( | Integer | bits | ) | [inline] |
Conversion from bit count to byte count which checks that number of bits is a multiple of bitsPerByte.
Definition at line 223 of file utils.hpp.
Integer checkedDivByMultiple | ( | Integer | a, | |
Integer | b | |||
) | [inline] |
Out getBytes | ( | const char * | whereFrom, | |
int | numBytes | |||
) | [inline] |
std::string lexicalCastToStdString | ( | In | a | ) | [inline] |
std::ostream& operator<< | ( | std::ostream & | aOstream, | |
const HexInteger< Integer > & | x | |||
) | [inline] |
Output Integer
with hexadecimal representation enabled.
HexInteger
std::istream& readBin | ( | std::istream & | inStream, | |
T & | field | |||
) | [inline] |
Integer roundDiv | ( | Integer | a, | |
Integer | b | |||
) | [inline] |
void setBytes | ( | char * | whereTo, | |
int | numBytes, | |||
In | newValue | |||
) | [inline] |
Safely sets numBytes
from memory region whereTo
to newValue
.
About safety:
Definition at line 253 of file utils.hpp.
std::ostream& writeBin | ( | std::ostream & | outStream, | |
T & | field | |||
) | [inline] |
const char bitsPerByte = 8 |