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.

75 lines
2.3 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: examples/cpp/inserters/example.cpp.inserter.m2w/example.cpp.inserter.m2w.cpp
  3. *
  4. * Purpose: C++ example program for Pantheios. Demonstrates:
  5. *
  6. * - use of Pantheios inserters for m2w types
  7. * - use of pantheios::logputs() in bail-out conditions
  8. *
  9. * Created: 25th September 2010
  10. * Updated: 11th December 2010
  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. // wide-strings, and would not be necessary in your program.
  25. #include <pantheios/pantheios.h>
  26. #ifndef PANTHEIOS_USE_WIDE_STRINGS
  27. # error This example only compatible with wide-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/m2w.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[] = L"example.cpp.inserter.m2w";
  37. /* ////////////////////////////////////////////////////////////////////// */
  38. int main(int argc, wchar_t** argv)
  39. {
  40. try
  41. {
  42. pan::log_NOTICE(L"main(", pan::args(argc, argv, pan::args::arg0FileOnly), L")");
  43. pan::log_NOTICE(L"A multibyte string: ", pan::m2w("plain-old-me"));
  44. return EXIT_SUCCESS;
  45. }
  46. catch(std::bad_alloc&)
  47. {
  48. pantheios::log(pantheios::alert, L"out of memory");
  49. }
  50. catch(std::exception& x)
  51. {
  52. pantheios::log_CRITICAL(L"Exception: ", x);
  53. }
  54. catch(...)
  55. {
  56. pantheios::logputs(pantheios::emergency, L"Unexpected unknown error");
  57. }
  58. return EXIT_FAILURE;
  59. }
  60. /* ///////////////////////////// end of file //////////////////////////// */