Foundation module. More...
#include <cassert>
#include <string>
#include <vector>
#include <limits>
#include <cmath>
#include <tchar.h>
#include <wchar.h>
Go to the source code of this file.
Classes | |
class | common::Singleton< T > |
Wzorzec projektowy Singleton - klasa bazowa. More... | |
class | common::DeletePolicy |
Polityka zwalaniania inteligentnych wskaźników, która robi: delete p; . More... | |
class | common::DeleteArrayPolicy |
Polityka zwalaniania inteligentnych wskaźników, która robi: delete [] p; . More... | |
class | common::ReleasePolicy |
Polityka zwalaniania inteligentnych wskaźników, która robi: p->Release(); . More... | |
class | common::scoped_ptr< T, PolicyT > |
Inteligentny wskaźnik z wyłącznym prawem własności. More... | |
class | common::shared_ptr< T, PolicyT > |
Inteligentny wskaźnik ze zliczaniem referencji. More... | |
class | common::CloseHandlePolicy |
Polityka zwalniania uchwytu - robi: CloseHandle(p); . More... | |
class | common::DeleteObjectPolicy |
Polityka zwalniania uchwytu - robi: DeleteObject(p); . More... | |
class | common::scoped_handle< T, PolicyT > |
Inteligentny uchwyt - wyłączna własność. More... | |
class | common::shared_handle< T, PolicyT > |
Inteligentny uchwyt ze zliczaniem referencji. More... | |
class | common::RoundInterpolator< T > |
Interpoluje daną wielkość między wartościami kluczowymi dla parametru w zakresie 0..1 z zawinięciem. More... | |
struct | common::RoundInterpolator< T >::ITEM |
class | common::StringNaturalCompare |
Klasa do porównywania w porządku naturalnym. More... | |
class | common::StringNaturalLess |
Predykat do sortowania łańcuchów w porządku naturalnym. More... | |
class | common::StringNaturalGreater |
Predykat do sortowania łańcuchów w porządku naturalnym. More... | |
class | common::StrLessI |
Predykat do porównywania łańcuchów bez rozróżniania wielkości liter. More... | |
class | common::StrGreaterI |
Predykat do porównywania łańcuchów bez rozróżniania wielkości liter. More... | |
class | common::RandomGenerator |
Generator liczb pseudolosowych. More... | |
class | common::MersenneTwister |
Wolniejszy w inicjalizacji, generowaniu i większy, ale za to tużo lepszy generator liczb pseudolosowych. More... | |
class | common::UniqueGenerator |
Generator unikatowych identyfikatorów. More... | |
class | common::CmdLineParser |
Parser wiersza poleceń. More... | |
class | common::CommonGUID |
Reprezentuje 128-bitowy globalnie unikatowy identyfikator, zgodnie z RFC 4122. More... | |
struct | SthToStr_obj< T > |
struct | StrToSth_obj< T > |
class | common::Format_pimpl |
class | common::Format |
Klasa do wygodnego składania stringów z różnych informacji. More... | |
struct | SthToStr_obj< bool > |
struct | SthToStr_obj< tchar > |
struct | SthToStr_obj< int2 > |
struct | SthToStr_obj< int4 > |
struct | SthToStr_obj< long > |
struct | SthToStr_obj< int8 > |
struct | SthToStr_obj< uint1 > |
struct | SthToStr_obj< uint2 > |
struct | SthToStr_obj< uint4 > |
struct | SthToStr_obj< unsigned long > |
struct | SthToStr_obj< uint8 > |
struct | SthToStr_obj< float > |
struct | SthToStr_obj< double > |
struct | SthToStr_obj< tstring > |
struct | SthToStr_obj< std::vector< T > > |
struct | SthToStr_obj< char * > |
struct | SthToStr_obj< const tchar * > |
struct | SthToStr_obj< void * > |
struct | SthToStr_obj< const void * > |
struct | StrToSth_obj< bool > |
struct | StrToSth_obj< tchar > |
struct | StrToSth_obj< int2 > |
struct | StrToSth_obj< int4 > |
struct | StrToSth_obj< long > |
struct | StrToSth_obj< int8 > |
struct | StrToSth_obj< uint1 > |
struct | StrToSth_obj< uint2 > |
struct | StrToSth_obj< uint4 > |
struct | StrToSth_obj< unsigned long > |
struct | StrToSth_obj< uint8 > |
struct | StrToSth_obj< float > |
struct | StrToSth_obj< double > |
struct | StrToSth_obj< tstring > |
struct | StrToSth_obj< std::vector< T > > |
Namespaces | |
namespace | common |
Główna przestrzeń nazw biblioteki CommonLib. | |
Defines | |
#define | NOMINMAX |
To jest na wypadek włączania gdzieś niżej przez użytkownika <windows.h>. | |
#define | TCHAR_TO_INT(c) ( (int)(c) ) |
Konwertuje znak na liczbę naturalną. | |
#define | INT_TO_TCHAR(i) ( (wchar_t)(i) ) |
Konwertuje liczbę 0..255 na znak. | |
#define | __TFILE__ _T(__FILE__) |
Nazwa bieżącego pliku źródłowego jako łańcuch, zależnie od makra _UNICODE jest w Unikodzie. | |
#define | __TFUNCSIG__ _T(__FUNCSIG__) |
Pełna sygnatura bieżącej funkcji w kodzie, zależnie od makra _UNICODE jest w Unikodzie. | |
#define | __TFUNCTION__ _T(__FUNCTION__) |
Sama nazwa bieżącej funkcji w kodzie, zależnie od makra _UNICODE jest w Unikodzie. | |
#define | common_memzero(buf, bufSize) { ZeroMemory(buf,bufSize); } |
#define | common_sprintf(buf, bufSize, fmt,...) ( sprintf(buf,fmt,##__VA_ARGS__) ) |
#define | common_memcpy(dst, src, count) { memcpy(dst,src,count); } |
#define | common_memmove(dst, src, count) { memmove(dst,src,count); } |
#define | common_strcat(dst, dstSize, src) { strcat(dst,src); } |
#define | common_strncat(dst, dstSize, src, count) { strncat(dst,src,count); } |
#define | common_strchr(str, c) ( strchr(str,c) ) |
#define | common_strrchr(str, c) ( strrchr(str,c) ) |
#define | common_strcmp(s1, s2) ( strcmp(s1,s2) ) |
#define | common_strncmp(s1, s2, count) ( strncmp(s1,s2,count) ) |
#define | common_stricmp(s1, s2) ( stricmp(s1,s2) ) |
#define | common_strnicmp(s1, s2, count) ( strnicmp(s1,s2,count) ) |
#define | common_strcoll(s1, s2) ( strcoll(s) ) |
#define | common_strcpy(dst, dstSize, src) { strcpy(dst,src); } |
#define | common_strncpy(dst, dstSize, src, count) { strncpy(dst,src,count); } |
#define | common_strlen(str) ( strlen(str) ) |
#define | common_strspn(str, charset) ( strspn(str,charset) ) |
#define | common_strcspn(str, charset) ( strcspn(str,charset) ) |
#define | common_strpbrk(str, charset) ( strpbrk(str,charset) ) |
#define | common_strstr(str, strSearch) ( strstr(str,strSearch) ) |
#define | common_strxfrm(dst, str, count) ( strxfrm(dst,str,count) ) |
#define | SAFE_DELETE(x) { delete (x); (x) = 0; } |
Jeśli wskaźnik niezerowy, zwalnia go i zeruje. | |
#define | SAFE_DELARR(x) { delete [] (x); (x) = 0; } |
Jeśli wskaźnik niezerowy, zwalnia go jako tablicę i zeruje. | |
#define | SAFE_RELEASE(x) { if (x) { (x)->Release(); (x) = 0; } } |
Jeśli wskaźnik niezerowy, wywołuje mu Release() i zeruje. | |
#define | ASSERT_INT3(x) if ((x) == 0) { __asm { int 3 } } |
Asercja, która ZAWSZE przerywa program kiedy jest niespełniona (w debuggerze - robi breakpoint, bez debuggera - wywala program). | |
#define | ASSERT_INT3_DEBUG(x) { } |
Asercja, która w kompilacji Debug przerywa program kiedy jest niespełniona (w debuggerze - robi breakpoint, bez debuggera - wywala program). | |
#define | PACKED __attribute__((packed)) |
Do robienia alignacji co do jednego bajtu dla struktur, czyli bez wypełniaczy. | |
#define | DECLARE_NO_COPY_CLASS(ClassName) |
Makro do umieszczania w klasach, żeby klasa nie miała konstruktora kopiującego ani operatora przypisania. | |
#define | STATIC_ASSERT(x) { const char temp[ (((x) == 0) ? 0 : 1) ] = {'\0'}; } |
Asercja w czasie kompilacji. | |
#define | REF_COUNTED_FIELDS uint m_RefCount; |
#define | REF_COUNTED_METHODS |
#define | REF_COUNTED_CTOR { m_RefCount = 1; } |
#define | _countof(_Array) sizeof(*__countof_helper(_Array)) |
Makro do pobierania w czasie kompilacji liczby elementów statycznej tablicy. | |
#define | FLOAT_ALMOST_ZERO(F) ((absolute_cast<uint4>(F) & 0x7f800000L) == 0) |
Liczba zmiennoprzecinkowa bliska zeru. | |
Typedefs | |
typedef TCHAR | tchar |
Typ znakowy, zależnie od makra _UNICODE zdefiniowany jako char lub wchar_t. | |
typedef std::wstring | tstring |
Typ łańcuchowy, zależnie od makra _UNICODE zdefiniowany jako std::string lub std::wstring. | |
typedef unsigned __int32 | uint |
Liczba 32-bitowa bez znaku. | |
typedef __int8 | int1 |
Liczba 8-bitowa ze znakiem. | |
typedef unsigned __int8 | uint1 |
Liczba 8-bitowa bez znaku. | |
typedef __int16 | int2 |
Liczba 16-bitowa ze znakiem. | |
typedef unsigned __int16 | uint2 |
Liczba 16-bitowa bez znaku. | |
typedef __int32 | int4 |
Liczba 32-bitowa ze znakiem. | |
typedef unsigned __int32 | uint4 |
Liczba 32-bitowa bez znaku. | |
typedef __int64 | int8 |
Liczba 64-bitowa ze znakiem. | |
typedef unsigned __int64 | uint8 |
Liczba 64-bitowa bez znaku. | |
typedef std::vector< tstring > | STRING_VECTOR |
Wektor łańcuchów. | |
Enumerations | |
enum | common::ORIENTATION { common::O_NONE, common::O_VERT, common::O_HORIZ } |
Orientacja, czyli ułożenie - pionowa lub pozioma. More... | |
enum | common::EOLMODE { common::EOL_NONE, common::EOL_CRLF, common::EOL_LF, common::EOL_CR } |
Rodzaje znaków końca wiersza. More... | |
enum | common::CHARSET { common::CHARSET_NONE = 0, common::CHARSET_WINDOWS, common::CHARSET_ISO, common::CHARSET_IBM, common::CHARSET_UTF8 } |
Strona kodowa polskich znakow. More... | |
Functions | |
template<typename destT , typename srcT > | |
destT & | absolute_cast (srcT &v) |
Uniwersalny, brakujący w C++ operator dosłownego rzutowania (reintepretacji bitowej). | |
template<typename destT , typename srcT > | |
const destT & | absolute_cast (const srcT &v) |
template<typename _CountofType , size_t _SizeOfArray> | |
char(* | common::__countof_helper (_CountofType(&_Array)[_SizeOfArray]))[_SizeOfArray] |
template<typename T > | |
T ** | common::new_2d (size_t cx, size_t cy) |
Alokuje nową tablicę dynamiczną 2D. | |
template<typename T > | |
void | common::delete_2d (T **a, size_t cx) |
Zwalnia tablicę dynamiczną 2D. | |
void | common::strcpy0 (tchar *dest, const tstring &src) |
Kopiuje string do char* łącznie ze znakami '\0' (czego nie zapewnia strcpy). | |
template<class Iterator > | |
void | common::InsertionSort (Iterator b, Iterator e) |
Algorytm jak te z STL - sortowanie przez wstawianie. | |
template<class Iterator , typename Compare > | |
void | common::InsertionSort (Iterator b, Iterator e, Compare Comp) |
Algorytm jak te z STL - sortowanie przez wstawianie, z własnym komparatorem. | |
template<typename IterT , typename KeyT , typename CmpT > | |
IterT | common::FirstNotLessIndex (IterT beg, IterT end, const KeyT &key, CmpT cmp) |
template<typename IterT , typename KeyT , typename CmpT > | |
IterT | common::BinarySearch (IterT beg, IterT end, const KeyT &key, CmpT cmp) |
An STL-compatible algorithm that performs binary search in sorted container using random-access iterators and return iterator to found element. | |
void | common::SwapEndian16 (void *p) |
Swaps endianess of a 2-byte value. | |
void | common::SwapEndian32 (void *p) |
Swaps endianess of a 4-byte value. | |
void | common::SwapEndian64 (void *p) |
Swaps endianess of a 8-byte value. | |
void | common::SwapEndian16_Array (void *p, uint count) |
void | common::SwapEndian32_Array (void *p, uint count) |
void | common::SwapEndian64_Array (void *p, uint count) |
void | common::SwapEndian16_Data (void *p, uint count, int stepBytes) |
void | common::SwapEndian32_Data (void *p, uint count, int stepBytes) |
void | common::SwapEndian64_Data (void *p, uint count, int stepBytes) |
void | common::SwapEndian (bool &v) |
void | common::SwapEndian (uint1 &v) |
void | common::SwapEndian (int1 &v) |
void | common::SwapEndian (uint2 &v) |
void | common::SwapEndian (int2 &v) |
void | common::SwapEndian (uint4 &v) |
void | common::SwapEndian (int4 &v) |
void | common::SwapEndian (uint8 &v) |
void | common::SwapEndian (int8 &v) |
void | common::SwapEndian (float &v) |
void | common::SwapEndian (double &v) |
void | common::Wait (uint4 Miliseconds) |
Zatrzymuje bieżący wątek na podaną liczbę milisekund. | |
template<typename T > | |
int | common::UniversalCmp (const T &a, const T &b) |
template<typename T , typename PolicyT > | |
void | common::swap (scoped_ptr< T, PolicyT > &a, scoped_ptr< T, PolicyT > &b) |
template<typename T , typename PolicyT > | |
void | common::swap (shared_ptr< T, PolicyT > &a, shared_ptr< T, PolicyT > &b) |
template<typename T , typename PolicyT > | |
void | common::swap (scoped_handle< T, PolicyT > &a, scoped_handle< T, PolicyT > &b) |
template<typename T , typename PolicyT > | |
void | common::swap (shared_handle< T, PolicyT > &a, shared_handle< T, PolicyT > &b) |
bool | common::is_finite (float x) |
Zwraca true, jeśli liczba jest niezwyczajna (INF lub NaN). | |
bool | common::is_finite (double x) |
Zwraca true, jeśli liczba jest niezwyczajna (INF lub NaN). | |
bool | common::is_nan (float x) |
Zwraca true, jeśli liczba jest NaN. | |
bool | common::is_nan (double x) |
Zwraca true, jeśli liczba jest NaN. | |
template<typename T > | |
T | common::safe_add (T a, T b) |
Dodaje dwie liczby z ograniczeniem zakresu zamiast zawinięcia przy przepełnieniu. | |
template<typename T > | |
T | common::safe_sub (T a, T b) |
Odejmuje dwie liczby z ograniczeniem zakresu zamiast zawinięcia przy przepełnieniu. | |
template<typename T > | |
T | common::safe_mul (T a, T b) |
Mnoży dwie liczby z ograniczeniem zakresu zamiast zawinięcia przy przepełnieniu. | |
float | common::safe_acos (float x) |
Bezpieczny arcus cosinus, ogranicza zakres wejściowy do -1...+1 zwracając w razie przekrocznia skrajne wartości wyniku. | |
int | common::round (float x) |
Zaokrągla liczbę, zamiast ją obcinać. | |
int | common::round (double x) |
template<typename T > | |
T | common::ceil_div (T x, T y) |
Dzieli 2 liczby całkowite zaokrąglając wynik w górę. | |
template<typename T > | |
T | common::AlignUp (T val, T align) |
Aligns given value up to nearest multiply of align value. For example: AlignUp(11, 8) = 16. Use types like uint4, uint8 as T. | |
template<typename T > | |
T | common::AlignDown (T val, T align) |
Aligns given value down to nearest multiply of align value. For example: AlignUp(19, 8) = 16. Use types like uint4, uint8 as T. | |
template<typename T > | |
T | common::round_div (T x, T y) |
Dzielenie z zaokrągleniem matematycznie do najbliższej. | |
bool | common::around (float x, float epsilon) |
Zwraca true, jeśli liczba leży w epsilonowym otoczeniu zera. | |
bool | common::around (double x, double epsilon) |
bool | common::around (float x, float y, float epsilon) |
Zwraca true, jeśli liczba leży w epsilonowym otoczeniu drugiej liczby. | |
bool | common::around (double x, double y, double epsilon) |
bool | common::float_equal (float x, float y) |
Zwraca true, jeśli dwie liczby zmiennoprzecinkowe są praktycznie równe. | |
bool | common::double_equal (double x, double y) |
template<typename T > | |
T | common::sqr (T v) |
Liczy kwadrat liczby. | |
template<typename T > | |
T | common::sign (T v) |
Zwraca znak podanej liczby całkowitej, czyli -1 0 lub 1. | |
template<typename T > | |
T | common::MergeBits (T a, T b, T Mask) |
Łączy bity dwóch liczb wg maski, tzn. wybiera z A te bity, które w masce mają 0 i z B te bity, które w masce mają 1. | |
template<typename T > | |
uint | common::CountBitsSet (T v) |
Zwraca liczbę bitów, które są jedynką. | |
template<> | |
uint | common::CountBitsSet< uint > (unsigned v) |
uint | common::CalcParity (uint v) |
Oblicza bit parzystości liczby. | |
uint8 | common::CalcParity (uint8 v) |
Oblicza bit parzystości liczby. | |
template<typename T > | |
T | common::SwapBitSequences (T v, uint SrcBit, uint DstBit, uint NumBits) |
Zamienia miejscami ciąg bitów w liczbie. | |
template<typename T > | |
bool | common::IsPow2 (T x) |
Zwraca true, jeśli podana liczba jest potęgą dwójki. | |
uint4 | common::GetBitMask (uint4 n) |
Zwraca maskę bitową z ustawionymi na jedynkę n najmłodszymi bitami. | |
uint | common::log2u (uint v) |
Zwraca logarytm dwójkowy z podanej liczby całkowitej bez znaku, tzn numer najstarszego niezerowego bitu. | |
uint | common::log10u (uint v) |
Zwraca logarytm dziesiętny z podanej liczby całkowitej bez znaku, tzn numer najstarszej cyfry dziesiętnej. | |
uint | common::next_pow2 (uint v) |
Zwraca najmniejszą potęgę dwójki większą lub równą podanej liczbie. | |
uint | common::InterleaveBits (uint a, uint b) |
Przeplata młodsze 16 bitów a (do parzystych) i młodsze 16 bitów b (do nieparzystych) do liczby wynikowej. | |
uint | common::Extend10BitsBy2Zeros (uint n) |
uint | common::Extend16BitsBy1Zero (uint n) |
template<typename T > | |
T | common::powi (T a, uint4 b) |
Liczy potęge o całkowitym wykładniku (bardzo szybko!). | |
template<typename T , typename Predicate > | |
void | common::Sort2 (T &v1, T &v2, Predicate comp) |
template<typename T > | |
void | common::Sort2 (T &v1, T &v2) |
template<typename T , typename Predicate > | |
void | common::Sort3 (T &v1, T &v2, T &v3, Predicate comp) |
template<typename T > | |
void | common::Sort3 (T &v1, T &v2, T &v3) |
template<typename T > | |
T | common::max3 (const T &a, const T &b, const T &c) |
Zwraca największą z podanych 3 liczb. | |
template<typename T > | |
T | common::min3 (const T &a, const T &b, const T &c) |
Zwraca najmniejszą z podanych 3 liczb. | |
template<typename T > | |
T | common::minmax (const T &a, const T &x, const T &b) |
Zwraca liczbę x ograniczoną do podanego zakresu od a do b. | |
float | common::saturate (float x) |
double | common::saturate (double x) |
float | common::trunc (float x) |
Zwraca część całkowitą liczby wraz ze znakiem. | |
double | common::trunc (double x) |
float | common::frac (float x) |
Zwraca część ułamkową liczby wraz ze znakiem. | |
double | common::frac (double x) |
void | common::sincos (float angle, float *sine, float *cosine) |
Oblicza sinus i cosinus za jednym zamachem. Może być szybsze, niż liczenie osobno. | |
float | common::Lerp (float x, float y, float t) |
Interpolacja liniowa 1D (t = 0..1). | |
void | common::Lerp (float *out, float x, float y, float t) |
float | common::SafeLerp (float x, float y, float t) |
Interpolacja liniowa 1D (t jest ograniczane do 0..1). | |
float | common::Lerp2D (float x11, float x21, float x12, float x22, float tx, float ty) |
Interpolacja liniowa 2D. | |
float | common::NormalizeAngle (float angle) |
Normalizuje kąt do przedziału < 0..2PI ). | |
float | common::NormalizeAngle2 (float Angle) |
Normalizuje kąt do przedziału -PI..+PI. | |
float | common::DegToRad (float Angle) |
Przelicza kąt ze stopni na radiany. | |
float | common::RadToDeg (float Angle) |
Przelicza kąt z radianów na stopnie. | |
float | common::AngleDiff (float A, float B) |
Oblicza różnicę kątów A-B, gdzie A, B należą do: 0..2*PI. | |
float | common::EaseCurve (float x) |
Krzywa wygładzona 0..1 -> 0..1: e(x) = 3*x^2 - 2*x^3. | |
float | common::EaseCurve2 (float x) |
float | common::smoothstep (float min, float max, float x) |
Returns 0.0 if x <= min and 1.0 if x >= max and performs smooth Hermite interpolation between 0 and 1 when min < x < max. | |
void | common::SmoothCD (float *InOutPos, float Dest, float *InOutVel, float SmoothTime, float TimeDelta) |
Funkcja wygładzająca - Critically Damped Smoothing. | |
void | common::SmoothCD (float *InOutPos, float Dest, float *InOutVel, float SmoothTime, float TimeDelta, float MaxSpeed) |
float | common::Trapezoidal (float x, float a, float b, float c, float d) |
Zwraca liczbę z przedziału 0..1, zależnie od wartości x względem brzegów trapezu a, b, c, d. | |
float | common::Trapezoidal (float x, float a, float b, float c, float d, float min, float max) |
Jak Trapezoidal(), ale zamiast 0..1 zwraca liczbę z przedziału min..max. | |
int | common::QuadraticEquation (float a, float b, float c, float *Out_x1, float *Out_x2) |
Równanie kwadratowe a*x^2 + b*x + c = 0. | |
void | common::CalcMeanAndVariance (const float Numbers[], size_t NumberCount, float *OutMean, float *OutVariance=NULL, bool VarianceBiased=true) |
Oblicza średnią i opcjonalnie wariancję ze zbioru liczb typu float. | |
void | common::CalcMeanAndVariance (const void *NumberData, size_t NumberCount, int NumberStride, float *OutMean, float *OutVariance=NULL, bool VarianceBiased=true) |
uint | common::MurmurHash (const void *Data, uint DataLen, uint Seed) |
MurmurHash 2.0 - podobno bardzo dobra funkcja hashująca. Dowolne dane binarne. Niestety nie inkrementacyjna. | |
uint | common::SuperFastHash (const void *DataBytes, size_t DataLen) |
Bardzo szybka funkcja hashująca dane. | |
uint | common::WangMix (uint key) |
Hash of 32-bit integer number (uint to uint). | |
float | common::PerlinNoise1 (float x) |
float | common::PerlinNoise2 (float x, float y) |
float | common::PerlinNoise3 (float x, float y, float z) |
float | common::BrownianNoise1 (float x, uint i, float Persistence) |
float | common::BrownianNoise2 (float x, float y, uint i, float Persistence) |
float | common::BrownianNoise3 (float x, float y, float z, uint i, float Persistence) |
uint | common::MakeDEC3 (uint x, uint y, uint z) |
uint | common::MakeDEC3 (uint x, uint y, uint z, uint w) |
uint | common::GetXFromDEC3 (uint dec3) |
uint | common::GetYFromDEC3 (uint dec3) |
uint | common::GetZFromDEC3 (uint dec3) |
uint | common::GetWFromDEC3 (uint dec3) |
template<typename T > | |
bool | common::CalcLinearFactors (T &outA, T &outB, float x1, float x2, const T &y1, const T &y2) |
Calculates coefficients for linear equation y = A*x + B passing through given points (x1,y1), (x2,y2). | |
template<typename T > | |
bool | common::CalcQuadraticFactors (T &outA, T &outB, T &outC, float x1, float x2, float x3, const T &y1, const T &y2, const T &y3) |
Calculates coefficients for quadratic equation y = A*x^2 + B*x + C passing through given points (x1,y1), (x2,y2), (x3,y3). | |
bool | common::CharIsAlphaNumeric (tchar ch) |
Zwraca true, jesli znak jest alfanumeryczny (litera lub cyfra) wg ustawień systemu. | |
bool | common::CharIsAlpha (tchar ch) |
Zwraca true, jesli znak jest litera. | |
bool | common::CharIsDigit (tchar ch) |
Zwraca true, jesli znak jest cyfrą dziesietną. | |
bool | common::CharIsHexDigit (tchar ch) |
Zwraca true, jeśli znak jest cyfrą szesnastkową. | |
bool | common::CharIsLower (tchar ch) |
Zwraca true, jesli znak jest mala litera. | |
bool | common::CharIsUpper (tchar ch) |
Zwraca true, jesli znak jest duza litera. | |
bool | common::CharIsWhitespace (char ch) |
Zwraca true, jesli podany znak jest odstepem, czyli bialym znakiem wg systemu. | |
bool | common::CharIsWhitespace (wchar_t ch) |
bool | common::CharIsWhitespace_f (tchar ch) |
Zwraca true, jesli podany znak jest odstepem, czyli bialym znakiem. | |
size_t | common::StrStrI (const tstring &Str, const tstring &SubStr, size_t Count=0xffffffff) |
Szuka w łańcuchu Str podłańcucha SubStr, bez rozróżniania wielkości liter. | |
const tchar * | common::StrStrI (const tchar *Str, const tchar *SubStr, size_t Count=0xffffffff) |
void | common::ReverseString (tstring *s) |
Odwraca łańcuch w miejscu. | |
void | common::Trim (tstring *s) |
Obcina białe znaki z początku i końca łańcucha w miejscu. | |
void | common::Trim (tstring *Out, const tstring &s) |
Obcina białe znaki z początku i końca łańcucha. | |
tchar | common::CharToLower (tchar ch) |
Jeśli to litera, konwertuje na małą. | |
tchar | common::CharToUpper (tchar ch) |
Jeśli to litera, konwertuje na dużą. | |
void | common::LowerCase (tstring *s) |
Konwertuje łańcuch na małe litery. | |
void | common::LowerCase (tstring *Out, const tstring &s) |
void | common::UpperCase (tstring *s) |
Konwertuje łańcuch na duże. | |
void | common::UpperCase (tstring *Out, const tstring &s) |
bool | common::Charset_WindowsSpecialChar (char a_c, string *a_s) |
Zmienia znak specjalny kodowania Windows-1250 na odpowiednik normalny. | |
char | common::Charset_Convert_Char (char a_c, CHARSET a_Charset1, CHARSET a_Charset2) |
Zmienia znak z jednej strony kodowej na druga lub pozostawia bez zmian. | |
void | common::Charset_Convert (string *out, const string &s, CHARSET Charset1, CHARSET Charset2) |
Konwertuje lancuch na podana strone kodowa. | |
void | common::Rot13 (tstring *InOut) |
Szyforowanie/deszyfrowanie algorytmem ROT13. | |
void | common::Rot13 (tstring *Out, const tstring &In) |
void | common::EolModeToStr (tstring *Out, EOLMODE EolMode) |
Rodzaj znaku końca wiersza na odpowiadający mu znak (lub znaki). | |
void | common::Replace (tstring *result, const tstring &s, const tstring &s1, const tstring &s2) |
Zamienia w łańcuchu wszystkie wystąpienia jedego podłańcucha na drugi. | |
void | common::Replace (tstring *Out, const tstring &s, tchar Ch1, tchar Ch2) |
Zmienia w łańcuchu wszystkie wystąpienia znaku Ch1 na Ch2. | |
void | common::Replace (tstring *InOut, tchar Ch1, tchar Ch2) |
Zmienia w łańcuchu wszystkie wystąpienia znaku Ch1 na Ch2 w miejscu. | |
void | common::ReplaceEOL (tstring *result, const tstring &s, EOLMODE EOLMode) |
Zmienia wszelkiego rodzaju znaki końca wiersza w poddanym tekście na takie same - wg podanego trybu. | |
void | common::NormalizeWhitespace (tstring *result, const tstring &s) |
Zamienia wszystkie odstępy na pojedyncze spacje. | |
void | common::DuplicateString (tstring *Out, const tstring &s, size_t count) |
Zwraca łańcuch powtórzony podaną liczbę razy. | |
void | common::RightStr (tstring *Out, const tstring &s, size_t Length) |
Zwraca podłańcuch z prawej strony. | |
size_t | common::SubstringCount (const tstring &str, const tstring &substr) |
Zwraca liczbę wystąpień podłańcucha. | |
int | common::StrCmpI (const tstring &s1, const tstring &s2, size_t Count=0xffffffff) |
Porównuje dwa łańcuchy bez rozróżniania wielkości liter. | |
int | common::StrCmpI (const tchar *s1, const tchar *s2, size_t Count=0xffffffff) |
int | common::SubStrCmp (const tstring &s1, size_t off1, const tstring &s2, size_t off2, size_t length) |
Zwraca true, jeśli podfragmenty podanych łańcuchów są identyczne. | |
int | common::SubStrCmpI (const tstring &s1, size_t off1, const tstring &s2, size_t off2, size_t length) |
Zwraca true, jeśli podfragmenty podanych łańcuchów są identyczne nie rozróżniając wielkości liter. | |
bool | common::ContainsEOL (const tstring &s) |
Czy łańcuch zawiera znaki końca wiersza? | |
bool | common::StrBegins (const tstring &s, const tstring &sub, size_t Begin=0) |
Zwraca true, jesli podany lancuch zaczyna sie od podanego podlancucha. | |
bool | common::StrBeginsI (const tstring &s, const tstring &sub, size_t Begin=0) |
Zwraca true, jesli podany lancuch zaczyna sie od podanego podlancucha, bez rozrozniania wielkosci liter. | |
bool | common::StrEnds (const tstring &s, const tstring &Sub) |
Zwraca true, jeśli podany łańcuch kończy się podanym podłańcuchem. | |
bool | common::StrEndsI (const tstring &s, const tstring &Sub) |
Zwraca true, jeśli podany łańcuch kończy się podanym podłańcuchem, bez rozrozniania wielkosci liter. | |
bool | common::Split (const tstring &s, const tstring &delimiter, tstring *out, size_t *index) |
Kolejne wywołania rozdzielają łańcuch na kolejne elementy oddzielone w jego treści określonym podłańcuchem. | |
bool | common::SplitFirstOf (const tstring &s, const tstring &delimiters, tstring *out, size_t *index) |
Działa jak Split(), ale łańcuchem rozdzielającym jest każdy dowolny znak z delimiters. | |
void | common::Split (STRING_VECTOR *Out, const tstring &s, const tstring &Delimiter) |
Dzieli łańcuch na części i zwraca je jako wektor. | |
bool | common::SplitEOL (const tstring &s, tstring *out, size_t *index) |
Kolejne wywołania rozdzielają łańcuch na kolejne elementy oddzielone w jego treści którąś z sekwencji uznawaną za koniec wiersza (czyli na kolejne wiersze). | |
bool | common::SplitQuery (const tstring &s, tstring *out, size_t *index) |
Kolejne wywołania rozdzielają łańcuch na elementy oddzielone odstępami uwzględniając ciągi obięte w cudzysłowy "" jako całość. | |
bool | common::ValidateWildcard (const tstring &Mask, const tstring &S, bool CaseSensitive=true, size_t MaskOff=0, size_t SOff=0) |
Sprawdza, czy podany łancuch jest zgodny z podaną maską mogącą zawierać znaki wieloznaczne. | |
float | common::FineSearch (const tstring &SubStr, const tstring &Str) |
Zwraca zmiennoprzecinkową trafność wyszukiwania stringa SubStr w stringu Str. | |
size_t | common::LevenshteinDistance (const tstring &s1, const tstring &s2) |
Odległość edycyjna między dwoma łańcuchami. | |
size_t | common::LevenshteinDistanceI (const tstring &s1, const tstring &s2) |
Odległość edycyjna między dwoma łańcuchami bez uwzględniania wielkości liter. | |
bool | common::StrIsEmpty (const char *s) |
Zwraca true, jeśli podany łańcuch jest NULL lub zawiera 0 znaków (od razu ma kończące ''). | |
void | common::ClearStr (char *s) |
Czyści łańcuch wpisując samo kończące ''. | |
bool | common::StrIsEmpty (const wchar_t *s) |
void | common::ClearStr (wchar_t *s) |
const tchar * | common::strnistr (const tchar *str, const tchar *substr, size_t count=MAXUINT4) |
Szuka w łańcuchu str podłańcucha substr, bez rozróżniania wielkości liter. | |
bool | common::StrBegins (const tchar *str, const tchar *substr, bool caseSensitive) |
bool | common::StrEnds (const tchar *str, const tchar *substr, bool caseSensitive) |
Zwraca true, jeśli łańcuch str kończy się na łańcuch substr. | |
void | common::StrErase (tchar *str, size_t off, size_t count=MAXUINT4) |
Usuwa podany zakres znaków z łańcucha. Jest bezpieczny na przekroczenie zakresu. | |
void | common::StrInsert (tchar *str, size_t strCapacity, const tchar *newStr, size_t off, size_t count) |
Wstawia podany podłańcuch do łańcucha w podane miejsce. | |
void | common::StrInsert (tchar *str, size_t strCapacity, const tchar *newStr, size_t off) |
void | common::Trim (tchar *s) |
Obcina z początku i końca stringa białe znaki (w miejscu). | |
unsigned | common::StrReplace (tchar *str, tchar from, tchar to) |
Replaces in string src all "from" chars to "to" chars. Returns number of occurences. | |
bool | common::ConvertUnicodeToChars (string *Out, const wstring &S, unsigned CodePage) |
bool | common::ConvertUnicodeToChars (string *Out, const wchar_t *S, unsigned NumChars, unsigned CodePage) |
bool | common::ConvertCharsToUnicode (wstring *Out, const string &S, unsigned CodePage) |
bool | common::ConvertCharsToUnicode (wstring *Out, const char *S, unsigned NumChars, unsigned CodePage) |
bool | common::UnicodeToChars_CalcBufLen (size_t &outLen, const wchar_t *wcs, unsigned CodePage) |
Oblicza liczbę znaków (nie bajtów!) potrzebną przy konwersji między Unicode i ANSI. | |
bool | common::UnicodeToChars_CalcBufLen (size_t &outLen, const wchar_t *wcs, size_t wcsLen, unsigned CodePage) |
bool | common::CharsToUnicode_CalcBufLen (size_t &outLen, const char *str, unsigned CodePage) |
bool | common::CharsToUnicode_CalcBufLen (size_t &outLen, const char *str, size_t strLen, unsigned CodePage) |
bool | common::ConvertUnicodeToChars (char *outBuf, size_t bufLen, const wchar_t *wcs, unsigned CodePage) |
Konwertuje łańcuch między Unicode i ANSI. Nie dołącza kończącego zera. | |
bool | common::ConvertUnicodeToChars (char *outBuf, size_t bufLen, const wchar_t *wcs, size_t wcsLen, unsigned CodePage) |
bool | common::ConvertCharsToUnicode (wchar_t *outBuf, size_t bufLen, const char *str, unsigned CodePage) |
bool | common::ConvertCharsToUnicode (wchar_t *outBuf, size_t bufLen, const char *str, size_t strLen, unsigned CodePage) |
bool | common::TstringToString (string *Out, const tstring &S) |
bool | common::StringToTstring (tstring *Out, const string &S) |
bool | common::TstringToWstring (wstring *Out, const tstring &S) |
bool | common::WstringToTstring (tstring *Out, const wstring &S) |
string | common::TstringToStringR (const tstring &S) |
tstring | common::StringToTstringR (const string &S) |
wstring | common::TstringToWstring (const tstring &S) |
tstring | common::WstringToTstring (const wstring &S) |
bool | common::PathIsAbsolute (const tstring &s) |
Zwraca true, jeśli ścieżka jest bezwzględna. | |
void | common::IncludeTrailingPathDelimiter (tstring *InOutPath) |
Dodaje do sciezki konczacy '/' lub '\', jesli go nie ma - na miejscu. | |
void | common::IncludeTrailingPathDelimiter (tstring *OutPath, const tstring &InPath) |
Dodaje do sciezki konczacy '/' lub '\', jesli go nie ma - do nowego stringa. | |
void | common::ExcludeTrailingPathDelimiter (tstring *InOutPath) |
Pozbawia sciezke konczacego '/' lub '\', jesli go ma - na miejscu. | |
void | common::ExcludeTrailingPathDelimiter (tstring *OutPath, const tstring &InPath) |
Pozbawia sciezke konczacego '/' lub '\', jesli go ma - do nowego stringa. | |
void | common::ExtractPathPrefix (tstring *OutPrefix, const tstring &s) |
Zwraca początek ścieżki, w postaci takiej jak "C:\", "\\komputer\udział\" czy "/" albo "\". | |
void | common::ExtractFilePath (tstring *OutPath, const tstring &s) |
Zwraca ścieżkę do pliku bez nazwy pliku. | |
void | common::ExtractFileName (tstring *OutFileName, const tstring &s) |
Zwraca samą nazwę pliku bez ścieżki. | |
void | common::ExtractFileExt (tstring *OutExt, const tstring &s) |
Zwraca rozszerzenie pliku wraz z kropką. | |
void | common::ChangeFileExt (tstring *Out, const tstring &FileName, const tstring &Ext) |
Zmienia w nazwie pliku rozszerzenie na nowe. | |
void | common::NormalizePath (tstring *OutPath, const tstring &s) |
Pozbawia sciezke artefaktow typu ".\\" czy "..\\". | |
void | common::RelativeToAbsolutePath (tstring *Out, const tstring &Base, const tstring &Path) |
Przetwarza sciezke wzgledna na bezwzgledna wzgledem okreslonej sciezki. | |
void | common::AbsoluteToRelativePath (tstring *Out, const tstring &Base, const tstring &Target) |
Przetwarza sciezke bezwzgledna na wzgledna wzgledem okreslonej sciezki. | |
int | common::HexDigitToNumber (char Ch) |
Zwraca liczbowy odpowiednik cyfry szesnastkowej. | |
int | common::HexDigitToNumber (wchar_t Ch) |
template<typename T > | |
void | common::UintToStr (tstring *Out, T x, uint4 Base=10, bool UpperCase=true) |
Konwersja liczby całkowitej na łańcuch. | |
template<typename T > | |
void | common::IntToStr (tstring *Out, T x, uint4 Base=10, bool UpperCase=true) |
template<typename T > | |
bool | common::_CharToDigit (T *Digit, tchar ch) |
Konwertuje znak cyfry w dowolnym systemie ('0'..'9', 'A'..'Z', 'a'..'z') na liczbę, zwraca false jeśli błąd. | |
template<typename T > | |
int | common::StrToUint (T *Number, const tstring &str, unsigned Base=10) |
Konwersja łańcucha na liczbę całkowitą. | |
template<typename T > | |
int | common::StrToInt (T *Number, const tstring &str, unsigned Base=10) |
template<typename T > | |
tstring | common::IntToStrR (T x, int base=10, bool UpperCase=true) |
template<typename T > | |
tstring | common::UintToStrR (T x, int base=10, bool UpperCase=true) |
void | common::Size_tToStr (tstring *Out, size_t x, size_t Base=10, bool UpperCase=true) |
tstring | common::Size_tToStrR (size_t x, size_t Base=10, bool UpperCase=true) |
template<typename T > | |
void | common::UintToStr2 (tstring *Out, T x, unsigned Length, int base=10) |
Konwersja liczby na łańcuch o minimalnej podanej długości. | |
template<typename T > | |
void | common::IntToStr2 (tstring *Out, T x, unsigned Length, int base=10) |
template<typename T > | |
tstring | common::UintToStr2R (T x, unsigned Length, int Base=10) |
template<typename T > | |
tstring | common::IntToStr2R (T x, unsigned Length, int Base=10) |
void | common::CharToStr (tstring *Out, tchar ch) |
Konwertuje znak na łańcuch, jako że automatycznie to się niestety nie odbywa. | |
tstring | common::CharToStrR (tchar ch) |
void | common::DoubleToStr (tstring *Out, double x, char Mode= 'g', int Precision=6) |
Konwersja liczb zmiennoprzecinkowych na łańcuch. | |
void | common::FloatToStr (tstring *Out, float x, char Mode= 'g', int Precision=6) |
tstring | common::DoubleToStrR (double x, char Mode= 'g', int Precision=6) |
tstring | common::FloatToStrR (float x, char Mode= 'g', int Precision=6) |
int | common::StrToDouble (double *out, const tstring &s) |
Konwersja łańcucha na liczbę zmiennoprzecinkową. | |
int | common::StrToFloat (float *out, const tstring &s) |
void | common::BoolToStr (tstring *Out, bool x, char mode= 'f') |
Konwertuje wartość logiczną na łańcuch. | |
tstring | common::BoolToStrR (bool x, char mode= 'f') |
bool | common::StrToBool (bool *result, const tstring &s) |
Konwertuje łańcuch na wartość logiczną. | |
void | common::PtrToStr (tstring *Out, const void *p) |
Konwertuje wskaźnik na łańcuch 8 znaków zapisany szesnastkowo. | |
tstring | common::PtrToStrR (const void *p) |
template<typename T > | |
void | common::SizeToStr (tstring *str, T size, bool Space, int Precision) |
Liczba bajtów na łańcuch z rozmiarem np. "1 B", "10.5 kB". | |
template<typename T > | |
tstring | common::SizeToStrR (T Size, bool Space, int Precision) |
float | common::WaveformSine (float x, float Base, float Amplitude, float Frequency, float Phase) |
Standard sine wave which smoothly changes from low to high and back again. | |
float | common::WaveformSine (float x) |
float | common::WaveformTriangle (float x, float Base, float Amplitude, float Frequency, float Phase) |
An angular wave with a constant increase / decrease speed with pointed peaks. | |
float | common::WaveformTriangle (float x) |
float | common::WaveformSquare (float x, float Base, float Amplitude, float Frequency, float Phase) |
Half of the time is spent at the min, half at the max with instant transition between. | |
float | common::WaveformSquare (float x) |
float | common::WaveformSawtooth (float x, float Base, float Amplitude, float Frequency, float Phase) |
Gradual steady increase from min to max over the period with an instant return to min at the end. | |
float | common::WaveformSawtooth (float x) |
float | common::WaveformInvSawtooth (float x, float Base, float Amplitude, float Frequency, float Phase) |
Gradual steady decrease from max to min over the period, with an instant return to max at the end. | |
float | common::WaveformInvSawtooth (float x) |
float | common::WaveformPWM (float x, float DutyCycle, float Base, float Amplitude, float Frequency, float Phase) |
Pulse Width Modulation. | |
float | common::WaveformPWM (float x, float DutyCycle) |
template<typename T > | |
void | SthToStr (tstring *Str, const T &Sth) |
template<typename T > | |
bool | StrToSth (T *Sth, const tstring &Str) |
template<typename T > | |
const Format | common::operator% (const Format &fmt, const T &x) |
const Format | common::operator% (const Format &fmt, const tchar *x) |
Variables | |
const int1 | common::MININT1 = std::numeric_limits<int1>::min() |
const int1 | common::MAXINT1 = std::numeric_limits<int1>::max() |
const int2 | common::MININT2 = std::numeric_limits<int2>::min() |
const int2 | common::MAXINT2 = std::numeric_limits<int2>::max() |
const int4 | common::MININT4 = std::numeric_limits<int4>::min() |
const int4 | common::MAXINT4 = std::numeric_limits<int4>::max() |
const int8 | common::MININT8 = std::numeric_limits<int8>::min() |
const int8 | common::MAXINT8 = std::numeric_limits<int8>::max() |
const uint1 | common::MAXUINT1 = std::numeric_limits<uint1>::max() |
const uint2 | common::MAXUINT2 = std::numeric_limits<uint2>::max() |
const uint4 | common::MAXUINT4 = std::numeric_limits<uint4>::max() |
const uint8 | common::MAXUINT8 = std::numeric_limits<uint8>::max() |
const float | common::MINFLOAT = std::numeric_limits<float>::min() |
const float | common::MAXFLOAT = std::numeric_limits<float>::max() |
const float | common::E = 2.71828182845904523536f |
e | |
const float | common::LOG2E = 1.44269504088896340736f |
log2(e) | |
const float | common::LOG10E = 0.434294481903251827651f |
log10(e) | |
const float | common::LN2 = 0.693147180559945309417f |
ln(2) | |
const float | common::LN10 = 2.30258509299404568402f |
ln(10) | |
const float | common::PI = 3.14159265358979323846264338327950288419716939937510582f |
pi | |
const float | common::PI_2 = 1.57079632679489661923f |
pi/2 | |
const float | common::PI_4 = 0.785398163397448309616f |
pi/4 | |
const float | common::PI_X_2 = 6.28318530717958647692f |
2*pi | |
const float | common::_1_PI = 0.318309886183790671538f |
1/pi | |
const float | common::_2_PI = 0.636619772367581343076f |
2/pi | |
const float | common::_2_SQRTPI = 1.12837916709551257390f |
2/sqrt(pi) | |
const float | common::SQRT2 = 1.41421356237309504880f |
sqrt(2) | |
const float | common::SQRT3 = 1.7320508075688772935274463415059f |
sqrt(3) | |
const float | common::SQRT1_2 = 0.707106781186547524401f |
1/sqrt(2) | |
const tstring | common::EMPTY_STRING |
Łańcuch pusty - do wykorzystania aby można było pobierać do niego referencje itp. | |
const tchar *const | common::EOL |
Standardowy łańcuch końca wiersza zależny od systemu. | |
const char *const | common::BOM_UTF8 |
const char *const | common::BOM_UTF16_LE |
const char *const | common::BOM_UTF16_BE |
const tchar | common::DIR_SEP = _T('\\') |
Separator katalogów w ścieżce, zależny od platformy. | |
const tchar | common::_DIGITS_L [] |
const tchar | common::_DIGITS_U [] |
RandomGenerator | common::g_Rand |
Domyślny generator liczb losowych do używania w wątku głównym i kiedy nie musi być deterministyczny. |
Foundation module.
Część biblioteki CommonLib
Kodowanie Windows-1250, koniec wiersza CR+LF, test: Zażółć gęślą jaźń
Licencja: GNU LGPL.
Dokumentacja: Module_Base
Elementy modułu: Base Module