/** @file sample for Glib::strescape and Glib::strcompress
 *
 * Last CVS checkin:
 * $Date: $
 * $Author: scheff $
 */

/**************************************************************************/

// standard C/C++ header:
#include <iostream>
#include <string>

// Gnome header:
#include <glibmm/init.h>
#include <glibmm/stringutils.h>

/**************************************************************************/

using namespace std;

/** waits for user confirm.
 *
 * @param action text with next action
 */
static void pause(const char *action)
{
  cout << "Press [ENTER] to " << action << ": " << flush;
  string str; getline(cin, str);
}

/** provides the main function of application.
 *
 * @param argc number of command line arguments
 * @param argv pointer to array of pointers to strings with command line
 *        arguments
 * @return 0 ... application exited regularly\n
 *         else ... execution of application aborted
 */
int main(int argc, char *argv[])
{
  Glib::init();
  pause("start");
  // samples
  const char *samples[] = {
    ""
    "Hello",
    "Hi \"",
    "\"quoted\"",
    "\\\"quoted\\\""
  };
  int n = sizeof samples / sizeof samples[0];
  // perform checks:
  for (int i = 0; i < n; ++i) {
    // perform a check
    string sample = samples[i];
    cout << "sample = '" << sample << '\'' << endl
      << "Glib::strcompress(sample) = '"
      << Glib::strcompress(sample) << '\'' << endl
      << "Glib::strescape(sample) = '"
      << Glib::strescape(sample) << '\'' << endl;
    pause("continue");
  }
  // done
  pause("finish");
  return 0;
}

