libosmscout  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups
Utility stuff

General utility stuff like enhanced string operations, special data structures... More...

Classes

class  osmscout::Breaker
 A breaker object instance allows to trigger cancelation of long running processes. More...
 
class  osmscout::Cache< K, V, IK >
 Generic FIFO cache implementation with O(n log n) semantic. More...
 
class  osmscout::CLASS_FINAL
 Representation of an (complex/multipolygon) area. More...
 
class  osmscout::NumberSet
 

Typedefs

typedef uint64_t osmscout::FileOffset
 Type for describing the position of data within a file. More...
 
typedef uint64_t osmscout::Id
 Type to be used for libosmscout internal ids (unsigned numbers with 64 bit size). More...
 
typedef int64_t osmscout::OSMId
 Type to be used for OSM ids (signed numbers with 64 bit size). More...
 
typedef uint16_t osmscout::TypeId
 Type for describing a type of an way, area or node. More...
 

Functions

template<typename N >
uint8_t osmscout::BitsNeededToEncodeNumber (N number)
 Returns the number of bytes needed to encode the number. More...
 
template<typename N >
osmscout::BitsToBytes (N bits)
 Returns the number of bytes needed to encode the given number of bits. More...
 
OSMSCOUT_API std::string osmscout::ByteSizeToString (FileOffset size)
 
template<typename N >
uint8_t osmscout::BytesNeededToEncodeNumber (N number)
 Returns the number of bytes needed to encode the number. More...
 
OSMSCOUT_API size_t osmscout::CountWords (const std::string &text)
 
template<typename N >
unsigned int osmscout::DecodeNumber (const char *buffer, N &number)
 Decode a variable length encoded number from the buffer back to the variable. More...
 
template<typename N >
unsigned int osmscout::DecodeNumberSigned (const char *buffer, N &number)
 Decode a signed variable length encoded number from the buffer back to the variable. More...
 
template<typename N >
unsigned int osmscout::DecodeNumberUnsigned (const char *buffer, N &number)
 Decode an unsigned variable length encoded number from the buffer back to the variable. More...
 
template<typename N >
unsigned int osmscout::EncodeNumber (N number, char *buffer)
 Encode a number into the given buffer using some variable length encoding. More...
 
template<typename N >
unsigned int osmscout::EncodeNumberSigned (N number, char *buffer)
 Encode a signed number into the given buffer using some variable length encoding. More...
 
template<typename N >
unsigned int osmscout::EncodeNumberUnsigned (N number, char *buffer)
 Encode an unsigned number into the given buffer using some variable length encoding. More...
 
OSMSCOUT_API bool osmscout::GetDigitValue (char digit, size_t &result)
 Returns the numerical value of the given character, if the character is a digit in a numerical value. More...
 
OSMSCOUT_API std::string osmscout::GetFirstInStringList (const std::string &stringList, const std::string &divider)
 Assumes that the string consists of a number of values separated by one of the given divider. More...
 
OSMSCOUT_API void osmscout::GroupStringListToStrings (std::list< std::string >::const_iterator token, size_t listSize, size_t parts, std::list< std::list< std::string > > &lists)
 Given a list of strings, individual strings will be combined into a given number of sub groups (individual string concatenated and separated by a space). More...
 
OSMSCOUT_API uint64_t osmscout::InterleaveNumbers (uint32_t a, uint32_t b)
 Encodes the given numbers into a new number of twice the size that has the bits of each nunber alternating interleaved. More...
 
OSMSCOUT_API std::string osmscout::LocaleStringToUTF8String (const std::string &text)
 Convert the given std::string in the current locale to a std::string containing a corresponding UTF8 character sequence. More...
 
OSMSCOUT_API std::wstring osmscout::LocaleStringToWString (const std::string &text)
 Converts the given std::string with content in the current locale to a std::wstring. More...
 
template<typename N >
std::string osmscout::NumberToString (const N &number)
 Converts the given (possibly negative) decimal number to a std::string. More...
 
OSMSCOUT_API void osmscout::SimplifyTokenList (std::list< std::string > &tokens)
 Simplifying a token list by merging tokens that start with an upper case letter followed by a token starting with a lower case letter. More...
 
OSMSCOUT_API std::list
< std::string > 
osmscout::SplitStringAtSpace (const std::string &input)
 Converts the given string into a list of whitespace separated (std::isspace()) strings. More...
 
OSMSCOUT_API bool osmscout::StringToBool (const char *string, bool &value)
 Convert the given string to a boolean value. More...
 
template<typename N >
bool osmscout::StringToNumber (const std::string &string, N &number, size_t base=10)
 Converts a string holding a (possibly negative) numerical value of the given base to the numerical value itself. More...
 
OSMSCOUT_API bool osmscout::StringToNumber (const char *string, double &value)
 
OSMSCOUT_API bool osmscout::StringToNumber (const std::string &string, double &value)
 
OSMSCOUT_API void osmscout::TokenizeString (const std::string &input, std::list< std::string > &tokens)
 Converts the given string into a list of whitespace or colon-separated strings. More...
 
OSMSCOUT_API std::string osmscout::UTF8StringToLocaleString (const std::string &text)
 Convert the given std::string in UTF-8 a std::string containing to corresponding string in the current locale. More...
 
OSMSCOUT_API std::u32string osmscout::UTF8StringToU32String (const std::string &text)
 Convert the given std::string containign a UTF8 character sequence to a std::u32string. More...
 
OSMSCOUT_API std::wstring osmscout::UTF8StringToWString (const std::string &text)
 Convert the given std::string containign a UTF8 character sequence to a std::wstring. More...
 
OSMSCOUT_API std::string osmscout::WStringToLocaleString (const std::wstring &text)
 Converts the given std::wstring to a std::string with content in the current locale. More...
 
OSMSCOUT_API std::string osmscout::WStringToUTF8String (const std::wstring &text)
 Convert the given std::wstring to a std::string containing a corresponding UTF8 character sequence. More...
 

Variables

const size_t osmscout::coordByteSize =7
 Number of bytes needed to store a lat,lon coordinate pair. More...
 
OSMSCOUT_API const double osmscout::latConversionFactor =134217727.0/180.0
 Coordinates will be stored as unsigned long values in file. More...
 
OSMSCOUT_API const double osmscout::lonConversionFactor =134217727.0/360.0
 Coordinates will be stored as unsigned long values in file. More...
 

Detailed Description

General utility stuff like enhanced string operations, special data structures...

Typedef Documentation

typedef uint64_t osmscout::FileOffset

Type for describing the position of data within a file.

typedef uint64_t osmscout::Id

Type to be used for libosmscout internal ids (unsigned numbers with 64 bit size).

typedef int64_t osmscout::OSMId

Type to be used for OSM ids (signed numbers with 64 bit size).

typedef uint16_t osmscout::TypeId

Type for describing a type of an way, area or node.

Function Documentation

template<typename N >
uint8_t osmscout::BitsNeededToEncodeNumber ( number)

Returns the number of bytes needed to encode the number.

The function calculates the number of bytes that contain information, dropping leading bytes that only contain zero.

template<typename N >
N osmscout::BitsToBytes ( bits)
inline

Returns the number of bytes needed to encode the given number of bits.

std::string osmscout::ByteSizeToString ( FileOffset  size)
template<typename N >
uint8_t osmscout::BytesNeededToEncodeNumber ( number)

Returns the number of bytes needed to encode the number.

The function calculates the number of bytes that contain information, dropping leading bytes that only contain zero.

Referenced by osmscout::BytesNeededToAddressFileData().

size_t osmscout::CountWords ( const std::string &  text)
template<typename N >
unsigned int osmscout::DecodeNumber ( const char *  buffer,
N &  number 
)
inline

Decode a variable length encoded number from the buffer back to the variable.

The methods returns the number of bytes read.

template<typename N >
unsigned int osmscout::DecodeNumberSigned ( const char *  buffer,
N &  number 
)
inline

Decode a signed variable length encoded number from the buffer back to the variable.

The methods returns the number of bytes read.

template<typename N >
unsigned int osmscout::DecodeNumberUnsigned ( const char *  buffer,
N &  number 
)
inline

Decode an unsigned variable length encoded number from the buffer back to the variable.

The methods returns the number of bytes read.

template<typename N >
unsigned int osmscout::EncodeNumber ( number,
char *  buffer 
)
inline

Encode a number into the given buffer using some variable length encoding.

The current implementation requires the buffer to have at least space for sizeof(N)*8/7 bytes for an unsigned number and sizeof(N)*8/7 + 1/8 bytes for a signed number

This are 5 bytes for a 32bit value and 10 bytes for a64bit value.

The methods returns the number of bytes written.

template<typename N >
unsigned int osmscout::EncodeNumberSigned ( number,
char *  buffer 
)
inline

Encode a signed number into the given buffer using some variable length encoding.

The first bit (if set) signals a negative numer. The highest bit in a byte is set, if there is an additional byte following. So we use one bit for signaling signess and use 7 of 8 bytes per byte for data.

The current implementation thus requires the buffer to have at least space for sizeof(N)*8/7 + 1/8 bytes:

This are 5 bytes for a 32bit value and 10 bytes for a 64bit value.

The methods returns the number of bytes written.

template<typename N >
unsigned int osmscout::EncodeNumberUnsigned ( number,
char *  buffer 
)
inline

Encode an unsigned number into the given buffer using some variable length encoding.

The highest bit in a byte is set, if there is an additional byte following. So we use 7 of 8 bytes per byte for data.

The current implementation requires the buffer to have at least space for sizeof(N)*8/7 bytes:

This are 5 bytes for a 32bit value and 10 bytes for a 64bit value.

The methods returns the number of bytes written.

bool osmscout::GetDigitValue ( char  digit,
size_t &  result 
)

Returns the numerical value of the given character, if the character is a digit in a numerical value.

The current code allows digits in the range from 0-9 and a-f and A-F. And thus supports numerical bases from 1-16.

Referenced by osmscout::StringToNumberSigned(), and osmscout::StringToNumberUnsigned().

std::string osmscout::GetFirstInStringList ( const std::string &  stringList,
const std::string &  divider 
)

Assumes that the string consists of a number of values separated by one of the given divider.

If the list consists of one entry, no divider is used.

Returns the first entry in the list

Note
stringList must not be empty
at least one devidier must be given
void osmscout::GroupStringListToStrings ( std::list< std::string >::const_iterator  token,
size_t  listSize,
size_t  parts,
std::list< std::list< std::string > > &  lists 
)

Given a list of strings, individual strings will be combined into a given number of sub groups (individual string concatenated and separated by a space).

If you pass a list of 5 strings to be divided into 3 parts, a list of string-list will be returned, where each list contains exactly 3 strings.

Referenced by osmscout::LocationService::InitializeLocationSearchEntries().

uint64_t osmscout::InterleaveNumbers ( uint32_t  a,
uint32_t  b 
)

Encodes the given numbers into a new number of twice the size that has the bits of each nunber alternating interleaved.

This can be used to convert two dimensional coordinates into one number, where coordinates close in 2D are close in the one dimensional projection, too.

Referenced by osmscout::CLASS_FINAL::GetId().

std::string osmscout::LocaleStringToUTF8String ( const std::string &  text)

Convert the given std::string in the current locale to a std::string containing a corresponding UTF8 character sequence.

Parameters
textthe std::wstring to get converted
Returns
the converted std::string

References osmscout::LocaleStringToWString(), and osmscout::WStringToUTF8String().

std::wstring osmscout::LocaleStringToWString ( const std::string &  text)

Converts the given std::string with content in the current locale to a std::wstring.

Parameters
textString to get converted
Returns
corresponding std::wstring

Referenced by osmscout::LocaleStringToUTF8String().

void osmscout::SimplifyTokenList ( std::list< std::string > &  tokens)

Simplifying a token list by merging tokens that start with an upper case letter followed by a token starting with a lower case letter.

Referenced by osmscout::LocationService::InitializeLocationSearchEntries().

std::list< std::string > osmscout::SplitStringAtSpace ( const std::string &  input)

Converts the given string into a list of whitespace separated (std::isspace()) strings.

bool osmscout::StringToBool ( const char *  string,
bool &  value 
)

Convert the given string to a boolean value.

Parameters
stringstring with a potential boolean value (either 'true' or 'false')
valuevalue to copy the result to if no error occured
Returns
'true' if the value was parsed, else 'false'

Referenced by osmscout::ParseBoolArgument().

template<typename N >
bool osmscout::StringToNumber ( const std::string &  string,
N &  number,
size_t  base = 10 
)
inline
bool osmscout::StringToNumber ( const char *  string,
double &  value 
)
bool osmscout::StringToNumber ( const std::string &  string,
double &  value 
)
void osmscout::TokenizeString ( const std::string &  input,
std::list< std::string > &  tokens 
)

Converts the given string into a list of whitespace or colon-separated strings.

Referenced by osmscout::LocationService::InitializeLocationSearchEntries(), and osmscout::LocationService::SearchForLocationByString().

std::string osmscout::UTF8StringToLocaleString ( const std::string &  text)

Convert the given std::string in UTF-8 a std::string containing to corresponding string in the current locale.

Parameters
textthe std::wstring to get converted
Returns
the converted std::string

References osmscout::UTF8StringToWString(), and osmscout::WStringToLocaleString().

Referenced by osmscout::Place::GetDisplayString().

OSMSCOUT_API std::u32string osmscout::UTF8StringToU32String ( const std::string &  text)

Convert the given std::string containign a UTF8 character sequence to a std::u32string.

Parameters
textString to get converted
Returns
corresponding std::wstring

Referenced by osmscout::TextLoader::AddCharactersToTextureAtlas().

OSMSCOUT_API std::wstring osmscout::UTF8StringToWString ( const std::string &  text)

Convert the given std::string containign a UTF8 character sequence to a std::wstring.

Parameters
textString to get converted
Returns
corresponding std::wstring

Referenced by osmscout::MapPainterAgg::DrawContourLabel(), osmscout::MapPainterAgg::DrawLabel(), osmscout::MapPainterAgg::GetTextDimension(), osmscout::UTF8NormForLookup(), osmscout::UTF8StringToLocaleString(), osmscout::UTF8StringToLower(), and osmscout::UTF8StringToUpper().

std::string osmscout::WStringToLocaleString ( const std::wstring &  text)

Converts the given std::wstring to a std::string with content in the current locale.

Parameters
textString to get converted
Returns
corresponding std::string

Referenced by osmscout::UTF8StringToLocaleString().

OSMSCOUT_API std::string osmscout::WStringToUTF8String ( const std::wstring &  text)

Convert the given std::wstring to a std::string containing a corresponding UTF8 character sequence.

Parameters
textthe std::wstring to get converted
Returns
the converted std::string

Referenced by osmscout::LocaleStringToUTF8String(), osmscout::UTF8NormForLookup(), osmscout::UTF8StringToLower(), and osmscout::UTF8StringToUpper().

Variable Documentation

const size_t osmscout::coordByteSize =7

Number of bytes needed to store a lat,lon coordinate pair.

Referenced by osmscout::CoordDataFile::Get().

const double osmscout::latConversionFactor =134217727.0/180.0

Coordinates will be stored as unsigned long values in file.

For the conversion the float value is shifted to positive value and afterwards multiplied by conversion factor to get long values without significant values after colon.

Referenced by osmscout::CLASS_FINAL::DecodeFromBuffer(), osmscout::CLASS_FINAL::EncodeToBuffer(), osmscout::CLASS_FINAL::GetHash(), and osmscout::IsValidToWrite().

const double osmscout::lonConversionFactor =134217727.0/360.0

Coordinates will be stored as unsigned long values in file.

For the conversion the float value is shifted to positive value and afterwards multiplied by conversion factor to get long values without significant values after colon.

Referenced by osmscout::CLASS_FINAL::DecodeFromBuffer(), osmscout::CLASS_FINAL::EncodeToBuffer(), osmscout::CLASS_FINAL::GetHash(), and osmscout::IsValidToWrite().