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.

74 lines
2.3 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: examples/cpp/inserters/example.cpp.inserter.w2m/example.cpp.inserter.w2m.cpp
  3. *
  4. * Purpose: C++ example program for Pantheios. Demonstrates:
  5. *
  6. * - use of Pantheios inserters for w2m types
  7. * - use of pantheios::logputs() in bail-out conditions
  8. *
  9. * Created: 10th December 2010
  10. * Updated: 6th August 2012
  11. *
  12. * www: http://www.pantheios.org/
  13. *
  14. * License: This source code is placed into the public domain 2006
  15. * by Synesis Software Pty Ltd. There are no restrictions
  16. * whatsoever to your use of the software.
  17. *
  18. * This software is provided "as is", and any warranties,
  19. * express or implied, of any kind and for any purpose, are
  20. * disclaimed.
  21. *
  22. * ////////////////////////////////////////////////////////////////////// */
  23. // The following four lines are used only to verify that we're compiling for
  24. // multibyte strings, and would not be necessary in your program.
  25. #include <pantheios/pantheios.h>
  26. #ifdef PANTHEIOS_USE_WIDE_STRINGS
  27. # error This example only compatible with multibyte string builds
  28. #endif /* PANTHEIOS_USE_WIDE_STRINGS */
  29. /* Pantheios Header Files */
  30. #include <pantheios/pan.hpp>
  31. #include <pantheios/inserters/args.hpp>
  32. #include <pantheios/inserters/w2m.hpp>
  33. /* ////////////////////////////////////////////////////////////////////// */
  34. /* Define the stock front-end process identity, so that it links when using
  35. * fe.N, fe.simple, etc. */
  36. PANTHEIOS_EXTERN_C PAN_CHAR_T const PANTHEIOS_FE_PROCESS_IDENTITY[] = PANTHEIOS_LITERAL_STRING("example.cpp.inserter.w2m");
  37. /* ////////////////////////////////////////////////////////////////////// */
  38. int main(int argc, char** argv)
  39. {
  40. try
  41. {
  42. pan::log_NOTICE("main(", pan::args(argc, argv, pan::args::arg0FileOnly), ")");
  43. pan::log_NOTICE("A multibyte string: ", pan::w2m(L"plain-old-me"));
  44. return EXIT_SUCCESS;
  45. }
  46. catch(std::bad_alloc&)
  47. {
  48. pantheios::log(pantheios::alert, "out of memory");
  49. }
  50. catch(std::exception& x)
  51. {
  52. pantheios::log_CRITICAL("Exception: ", x);
  53. }
  54. catch(...)
  55. {
  56. pantheios::logputs(pantheios::emergency, "Unexpected unknown error");
  57. }
  58. return EXIT_FAILURE;
  59. }
  60. /* ///////////////////////////// end of file //////////////////////////// */