#endif /* !PANTHEIOS_INCL_H_STDIO */
/* /////////////////////////////////////////////////////////////////////////
* Namespace
*/
#if !defined(PANTHEIOS_NO_NAMESPACE)
namespace pantheios
{
#endif /* !PANTHEIOS_NO_NAMESPACE */
/* /////////////////////////////////////////////////////////////////////////
* Inserter classes
*/
/** Class for inserting binary regions types into Pantheios diagnostic
* logging statements.
*
* \ingroup group__application_layer_interface__inserters
*
* This class formats a binary region into a string, thereby enabling it to
* be inserted into a logging statement. Consider the following statement:
* \code
int ar[2] = { 0x00112233, 0x44556677 };
char s[] = "abc";
std::string str("def");
pantheios::log(pantheios::notice, "s=", s, ", b64=", pantheios::b64(ar, sizeof(ar)), ", str=", str);
* \endcode
*
* This will produce the output:
\htmlonly
s=abc, b64=0011223344556677, str=def
\endhtmlonly
*
* The bytes can be grouped and these groups separated. Consider the
* following statement:
* \code
int ar[2] = { 0x00112233, 0x44556677 };
char s[] = "abc";
std::string str("def");
pantheios::log(pantheios::notice, "s=", s, ", b64=", pantheios::b64(ar, sizeof(ar), 2, "-"), ", str=", str);
* \endcode
*
* This will produce the output:
* \htmlonly
s=abc, b64=2233-0011-6677-4455, str=def
\endhtmlonly
*
* The output can be split into lines. Consider the following statement:
* \code
int ar[2] = { 0x00112233, 0x44556677 };
char s[] = "abc";
std::string str("def");
pantheios::log(pantheios::notice, "s=", s, ", b64=", pantheios::b64(ar, sizeof(ar), 2, "-", 3, "\n\t"), ", str=", str);
* \endcode
*
* This will produce the output:
\htmlonly
s=abc, b64=2233-0011-6677
4455, str=def
\endhtmlonly
*/
class b64
{
/// \name Member Types
/// @{
public:
typedef b64 class_type;
typedef b64_api::B64_RC B64_RC;
/// @}
/// \name Construction
/// @{
public:
b64( void const* pv
, size_t cb);
b64( void const* pv
, size_t cb
, unsigned flags);
b64( void const* pv
, size_t cb
, unsigned flags
, int lineLen
, B64_RC* rc = NULL);
~b64() stlsoft_throw_0();
/// @}
/// \name Accessors
/// @{
public:
/// A possibly non-nul-terminated non-null pointer to the c-style string representation of the integer
pan_char_t const* data() const;
/// A nul-terminated non-null pointer to the c-style string representation of the integer
pan_char_t const* c_str() const;
/// The length of the c-style string representation of the integer
size_t length() const;
/// @}
/// \name Implementation
/// @{
private:
void construct_() const;
void construct_();
/// @}
/// \name Member Variables
/// @{
private:
pan_char_t const* m_value;
size_t m_len;
void const* m_pv;
size_t m_cb;
unsigned m_flags;
int m_lineLen;
B64_RC* m_rc;
/// @}
/// \name Not to be implemented
/// @{
private:
#if !defined(STLSOFT_COMPILER_IS_GCC)
b64(class_type const&);
#endif /* compiler */
class_type& operator =(class_type const&);
/// @}
};
/* /////////////////////////////////////////////////////////////////////////
* String Access Shims
*/
#ifndef PANTHEIOS_DOCUMENTATION_SKIP_SECTION
# if !defined(PANTHEIOS_NO_NAMESPACE)
namespace shims
{
# endif /* !PANTHEIOS_NO_NAMESPACE */
/** \overload c_str_data_a(b64 const&) */
# ifdef PANTHEIOS_USE_WIDE_STRINGS
inline wchar_t const* c_str_data_w(b64 const& i)
{
return i.data();
}
# else /* ? PANTHEIOS_USE_WIDE_STRINGS */
inline char const* c_str_data_a(b64 const& i)
{
return i.data();
}
# endif /* PANTHEIOS_USE_WIDE_STRINGS */
/** \overload c_str_data(b64 const&) */
inline pan_char_t const* c_str_data(b64 const& i)
{
return i.data();
}
/** \overload c_str_len_a(b64 const&) */
# ifdef PANTHEIOS_USE_WIDE_STRINGS
inline size_t c_str_len_w(b64 const& i)
# else /* ? PANTHEIOS_USE_WIDE_STRINGS */
inline size_t c_str_len_a(b64 const& i)
# endif /* PANTHEIOS_USE_WIDE_STRINGS */
{
return i.length();
}
/** \overload c_str_len(b64 const&) */
inline size_t c_str_len(b64 const& i)
{
return i.length();
}
/** \overload c_str_ptr_a(b64 const&) */
# ifdef PANTHEIOS_USE_WIDE_STRINGS
inline wchar_t const* c_str_ptr_w(b64 const& i)
{
return i.c_str();
}
# else /* ? PANTHEIOS_USE_WIDE_STRINGS */
inline char const* c_str_ptr_a(b64 const& i)
{
return i.c_str();
}
# endif /* PANTHEIOS_USE_WIDE_STRINGS */
/** \overload c_str_ptr(b64 const&) */
inline pan_char_t const* c_str_ptr(b64 const& i)
{
return i.c_str();
}
# if !defined(PANTHEIOS_NO_NAMESPACE)
} /* namespace shims */
# if defined(STLSOFT_COMPILER_IS_GCC)
/* GCC does not seem to correctly handle the phases of
* processing of C++ templates, so we need to 'use' the
* shims into the same namespace as the inserter class
* in order that ADL can suffice instead.
*/
# ifdef PANTHEIOS_USE_WIDE_STRINGS
using ::pantheios::shims::c_str_data_w;
using ::pantheios::shims::c_str_len_w;
using ::pantheios::shims::c_str_ptr_w;
# else /* ? PANTHEIOS_USE_WIDE_STRINGS */
using ::pantheios::shims::c_str_data_a;
using ::pantheios::shims::c_str_len_a;
using ::pantheios::shims::c_str_ptr_a;
# endif /* PANTHEIOS_USE_WIDE_STRINGS */
using ::pantheios::shims::c_str_data;
using ::pantheios::shims::c_str_len;
using ::pantheios::shims::c_str_ptr;
# endif /* compiler */
# endif /* !PANTHEIOS_NO_NAMESPACE */
#endif /* !PANTHEIOS_DOCUMENTATION_SKIP_SECTION */
/* /////////////////////////////////////////////////////////////////////////
* Namespace
*/
#if !defined(PANTHEIOS_NO_NAMESPACE)
} /* namespace pantheios */
namespace stlsoft
{
// 'Export' the string access shims into the STLSoft namespace
//
// c_str_ptr(_a) is not necessary for version 1.0 of Pantheios, but it's
// defined and exported in order to allow for the case where someone
// may find a legitimate use for the conversion classes additional to
// the type-tunneling of the Pantheios API.
# ifdef PANTHEIOS_USE_WIDE_STRINGS
using ::pantheios::shims::c_str_data_w;
using ::pantheios::shims::c_str_len_w;
using ::pantheios::shims::c_str_ptr_w;
# else /* ? PANTHEIOS_USE_WIDE_STRINGS */
using ::pantheios::shims::c_str_data_a;
using ::pantheios::shims::c_str_len_a;
using ::pantheios::shims::c_str_ptr_a;
# endif /* PANTHEIOS_USE_WIDE_STRINGS */
using ::pantheios::shims::c_str_data;
using ::pantheios::shims::c_str_len;
using ::pantheios::shims::c_str_ptr;
}
#endif /* !PANTHEIOS_NO_NAMESPACE */
/* /////////////////////////////////////////////////////////////////////////
* Inclusion
*/
#ifdef STLSOFT_PPF_pragma_once_SUPPORT
# pragma once
#endif /* STLSOFT_PPF_pragma_once_SUPPORT */
/* ////////////////////////////////////////////////////////////////////// */
#endif /* !PANTHEIOS_INCL_PANTHEIOS_INSERTERS_HPP_B64 */
/* ///////////////////////////// end of file //////////////////////////// */