You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

163 lines
5.5 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: pantheios/inserters/ch.hpp
  3. *
  4. * Purpose: Shorthand inserter ch for pantheios::character.
  5. *
  6. * Created: 21st June 2005
  7. * Updated: 16th October 2010
  8. *
  9. * Home: http://www.pantheios.org/
  10. *
  11. * Copyright (c) 2005-2010, Matthew Wilson and Synesis Software
  12. * Copyright (c) 1999-2005, Synesis Software and Matthew Wilson
  13. * All rights reserved.
  14. *
  15. * Redistribution and use in source and binary forms, with or without
  16. * modification, are permitted provided that the following conditions are
  17. * met:
  18. *
  19. * - Redistributions of source code must retain the above copyright notice,
  20. * this list of conditions and the following disclaimer.
  21. * - Redistributions in binary form must reproduce the above copyright
  22. * notice, this list of conditions and the following disclaimer in the
  23. * documentation and/or other materials provided with the distribution.
  24. * - Neither the name(s) of Matthew Wilson and Synesis Software nor the
  25. * names of any contributors may be used to endorse or promote products
  26. * derived from this software without specific prior written permission.
  27. *
  28. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
  29. * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  30. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  31. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  32. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  33. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  34. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  35. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  36. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  37. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  38. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  39. *
  40. * ////////////////////////////////////////////////////////////////////// */
  41. /** \file pantheios/inserters/ch.hpp
  42. *
  43. * [C++ only] Definition of the pantheios::character string inserter
  44. * for built-in character type(s).
  45. *
  46. * This file is not included by default.
  47. *
  48. <pre>
  49. \#include &lt;pantheios/inserters/character.hpp>
  50. \#include &lt;pantheios/pantheios.hpp>
  51. . . .
  52. char c = '~';
  53. pantheios::log_DEBUG("c=", pantheios::character(c));
  54. </pre>
  55. *
  56. * The short alias \c ch is available, via inclusion of
  57. * pantheios/inserters/ch.hpp
  58. *
  59. <pre>
  60. \#include &lt;pantheios/inserters/ch.hpp>
  61. . . .
  62. char c = '~';
  63. pantheios::log_DEBUG("c=", pantheios::ch(c));
  64. </pre>
  65. */
  66. #ifndef PANTHEIOS_INCL_PANTHEIOS_INSERTERS_HPP_CH
  67. #define PANTHEIOS_INCL_PANTHEIOS_INSERTERS_HPP_CH
  68. /* /////////////////////////////////////////////////////////////////////////
  69. * Version information
  70. */
  71. #ifndef PANTHEIOS_DOCUMENTATION_SKIP_SECTION
  72. # define PANTHEIOS_VER_PANTHEIOS_INSERTERS_HPP_CH_MAJOR 1
  73. # define PANTHEIOS_VER_PANTHEIOS_INSERTERS_HPP_CH_MINOR 0
  74. # define PANTHEIOS_VER_PANTHEIOS_INSERTERS_HPP_CH_REVISION 1
  75. # define PANTHEIOS_VER_PANTHEIOS_INSERTERS_HPP_CH_EDIT 1
  76. #endif /* !PANTHEIOS_DOCUMENTATION_SKIP_SECTION */
  77. /* /////////////////////////////////////////////////////////////////////////
  78. * Includes
  79. */
  80. #ifndef PANTHEIOS_INCL_PANTHEIOS_H_PANTHEIOS
  81. # include <pantheios/pantheios.h>
  82. #endif /* !PANTHEIOS_INCL_PANTHEIOS_H_PANTHEIOS */
  83. #ifndef PANTHEIOS_INCL_PANTHEIOS_INSERTERS_HPP_CHARACTER
  84. # include <pantheios/inserters/character.hpp>
  85. #endif /* !PANTHEIOS_INCL_PANTHEIOS_INSERTERS_HPP_CHARACTER */
  86. /* /////////////////////////////////////////////////////////////////////////
  87. * Namespace
  88. */
  89. #if !defined(PANTHEIOS_NO_NAMESPACE)
  90. namespace pantheios
  91. {
  92. #endif /* !PANTHEIOS_NO_NAMESPACE */
  93. /* /////////////////////////////////////////////////////////////////////////
  94. * Inserter classes
  95. */
  96. /** Class for inserting characters into Pantheios diagnostic logging
  97. * statements.
  98. *
  99. * \ingroup group__application_layer_interface__inserters
  100. *
  101. * This class converts a character variable into a string, thereby enabling
  102. * it to be inserted into a logging statement. Consider the following
  103. * statement:
  104. *
  105. * \code
  106. char c = '#';
  107. char s[] = "abc";
  108. std::string str("def");
  109. pantheios::log(pantheios::notice, "s=", s, ", c=", pantheios::character(c), ", str=", str);
  110. * \endcode
  111. *
  112. * This will produce the output:
  113. *
  114. * &nbsp;&nbsp;&nbsp;&nbsp;<b>s=abc, c=#, str=def</b>
  115. *
  116. * \note Currently, Pantheios does not support the insertion of character types
  117. * in diagnostic logging statements, due to the various ambiguities inherent
  118. * in the C++ language. (See chapters 14, 15, 19, 24 of
  119. * <a href = "http://imperfectcplusplus.com" target="_blank">Imperfect C++</a>
  120. * for discussions of these issues.) It is possible that a future version of
  121. * the library will be able to incorporate them directly, so long as that does
  122. * not sacrifice Pantheios's central claim of not paying for what you don't use.
  123. */
  124. typedef character ch;
  125. /* /////////////////////////////////////////////////////////////////////////
  126. * Namespace
  127. */
  128. #if !defined(PANTHEIOS_NO_NAMESPACE)
  129. } /* namespace pantheios */
  130. #endif /* !PANTHEIOS_NO_NAMESPACE */
  131. /* /////////////////////////////////////////////////////////////////////////
  132. * Inclusion
  133. */
  134. #ifdef STLSOFT_PPF_pragma_once_SUPPORT
  135. # pragma once
  136. #endif /* STLSOFT_PPF_pragma_once_SUPPORT */
  137. /* ////////////////////////////////////////////////////////////////////// */
  138. #endif /* !PANTHEIOS_INCL_PANTHEIOS_INSERTERS_HPP_CH */
  139. /* ///////////////////////////// end of file //////////////////////////// */