/**************************************************************************
 *
 * messages.cpp - Example program for the messages facet. 
 *                See Class Reference Section
 *
 ***************************************************************************
 *
 * Copyright (c) 1994-1999 Rogue Wave Software, Inc.  All Rights Reserved.
 *
 * This computer software is owned by Rogue Wave Software, Inc. and is
 * protected by U.S. copyright laws and other laws and by international
 * treaties.  This computer software is furnished by Rogue Wave Software,
 * Inc. pursuant to a written license agreement and may be used, copied,
 * transmitted, and stored only in accordance with the terms of such
 * license and with the inclusion of the above copyright notice.  This
 * computer software or any other copies thereof may not be provided or
 * otherwise made available to any other person.
 *
 * U.S. Government Restricted Rights.  This computer software is provided
 * with Restricted Rights.  Use, duplication, or disclosure by the
 * Government is subject to restrictions as set forth in subparagraph (c)
 * (1) (ii) of The Rights in Technical Data and Computer Software clause
 * at DFARS 252.227-7013 or subparagraphs (c) (1) and (2) of the
 * Commercial Computer Software – Restricted Rights at 48 CFR 52.227-19,
 * as applicable.  Manufacturer is Rogue Wave Software, Inc., 5500
 * Flatiron Parkway, Boulder, Colorado 80301 USA.
 *
 **************************************************************************/

#include <string>

#include <locale>
#include <iostream>
#include <rwstdmessages.h>

int main ()
{
#ifndef _RWSTD_NO_NAMESPACE
  using namespace std;
#endif

  locale loc;

  // Get a reference to the messages<char> facet
  const messages<char>& mess = 
#ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
    use_facet<messages<char> >(loc);
#else
    use_facet(loc,(messages<char>*)0);
#endif

  // Open a catalog and try to grab
  // both some valid messages, and an invalid message
  string def("Message Not Found");
  messages<char>::catalog cat =
#ifdef __WIN32__
          mess.open("rwstdmessages.dll",loc);
#else
          mess.open("./rwstdmessages.cat",loc);
#endif
  if (cat != (messages<char>::catalog) -1)
  {
    string msg0 = mess.get(cat,1,_RW_MSG_HELLO,def);
    string msg1 = mess.get(cat,1,_RW_MSG_GOODBYE,def);
    string msg2 = mess.get(cat,1,_RW_MSG_NOGOOD,def);  // invalid msg #
    string msg3 = mess.get(cat,2,_RW_MSG_TREES,def);

    mess.close(cat);
    cout << msg0 << endl << msg1 << endl
         << msg2 << endl << msg3 << endl;
  }
  else
    cout << "Unable to open message catalog" << endl;

  return 0;
}

