Files

306 lines
5.1 KiB
C++

// Copyright Onix Solutions Limited [OnixS]. All rights reserved.
//
// This software owned by Onix Solutions Limited [OnixS] and is
// protected by copyright law and international copyright treaties.
//
// Access to and use of the software is governed by the terms of the applicable
// OnixS Software Services Agreement (the Agreement) and Customer end user license
// agreements granting a non-assignable, non-transferable and non-exclusive license
// to use the software for it's own data processing purposes under the terms defined
// in the Agreement.
//
// Except as otherwise granted within the terms of the Agreement, copying or
// reproduction of any part of this source code or associated reference material
// to any other location for further reproduction or redistribution, and any
// amendments to this copyright notice, are expressly prohibited.
//
// Any reproduction or redistribution for sale or hiring of the Software not in
// accordance with the terms of the Agreement is a violation of copyright law.
//
#pragma once
#include <string>
#include <OnixS/CME/MDH/Bootstrap.h>
ONIXS_CMEMDH_NAMESPACE_BEGIN
#if defined (_MSC_VER)
typedef signed char Int8;
typedef unsigned char UInt8;
typedef signed short Int16;
typedef unsigned short UInt16;
typedef signed int Int32;
typedef unsigned int UInt32;
typedef signed long long Int64;
typedef unsigned long long UInt64;
#elif defined (__GNUC__)
typedef signed char Int8;
typedef unsigned char UInt8;
typedef signed short Int16;
typedef unsigned short UInt16;
#if defined (__LP64__)
typedef signed int Int32;
typedef unsigned int UInt32;
typedef signed long Int64;
typedef unsigned long UInt64;
#else
typedef signed int Int32;
typedef unsigned int UInt32;
typedef signed long long Int64;
typedef unsigned long long UInt64;
#endif
#else
// Compiler is not (yet) supported.
// Integral types must be defined explicitly.
#error \
Cannot identify compiler toolset to define integral types. \
Please contact support@onixs.biz on further assistance.
#endif
//
/// Integral constant.
template
<
typename Type,
Type Constant
>
struct IntegralConstant
{
/// Type of the constant.
typedef Type Value;
/// Returns value of the constant.
operator Value() const
{
return Constant;
}
/// Returns value of the constant.
Value operator()() const
{
return Constant;
}
/// Returns value of the constant.
static const Value value()
{
return Constant;
}
};
/// Serializes given integer into a string.
ONIXS_CMEMDH_EXPORTED
void
toStr(
std::string&,
Int8);
/// Serializes given integer into a string.
inline
std::string
toStr(
Int8 number)
{
std::string str;
toStr(str, number);
return str;
}
/// Serializes given integer into a string.
ONIXS_CMEMDH_EXPORTED
void
toStr(
std::string&,
UInt8);
/// Serializes given integer into a string.
inline
std::string
toStr(
UInt8 number)
{
std::string str;
toStr(str, number);
return str;
}
/// Serializes given integer into a string.
ONIXS_CMEMDH_EXPORTED
void
toStr(
std::string&,
Int16);
/// Serializes given integer into a string.
inline
std::string
toStr(
Int16 number)
{
std::string str;
toStr(str, number);
return str;
}
/// Serializes given integer into a string.
ONIXS_CMEMDH_EXPORTED
void
toStr(
std::string&,
UInt16);
/// Serializes given integer into a string.
inline
std::string
toStr(
UInt16 number)
{
std::string str;
toStr(str, number);
return str;
}
/// Serializes given integer into a string.
ONIXS_CMEMDH_EXPORTED
void
toStr(
std::string&,
Int32);
/// Serializes given integer into a string.
inline
std::string
toStr(
Int32 number)
{
std::string str;
toStr(str, number);
return str;
}
/// Serializes given integer into a string.
ONIXS_CMEMDH_EXPORTED
void
toStr(
std::string&,
UInt32);
/// Serializes given integer into a string.
inline
std::string
toStr(
UInt32 number)
{
std::string str;
toStr(str, number);
return str;
}
/// Serializes given integer into a string.
ONIXS_CMEMDH_EXPORTED
void
toStr(
std::string&,
Int64);
/// Serializes given integer into a string.
inline
std::string
toStr(
Int64 number)
{
std::string str;
toStr(str, number);
return str;
}
/// Serializes given integer into a string.
ONIXS_CMEMDH_EXPORTED
void
toStr(
std::string&,
UInt64);
/// Serializes given integer into a string.
inline
std::string
toStr(
UInt64 number)
{
std::string str;
toStr(str, number);
return str;
}
/// Serializes given constant into a string.
template
<
typename Type,
Type Constant
>
inline
void
toStr(
std::string& str,
IntegralConstant<Type, Constant> constant)
{
toStr(str, constant());
}
/// Serializes given constant into a string.
template
<
typename Type,
Type Constant
>
inline
std::string
toStr(
IntegralConstant<Type, Constant> constant)
{
std::string str;
toStr(str, constant);
return str;
}
ONIXS_CMEMDH_NAMESPACE_END