//
// functions for testing.
//
// these functions substitute for basic stuff that might not
//   implemented correctly.  they are either sleazy and
//   questionable, or extremely clever.
// they assume that the lstring class is implemented using a
//   Seq<char> as its first/only member variable.
// the underlying idea here is one I got from a book on Java,
//   which uses a similar idea to show how easy it is to break
//   the class abstraction barrier in C++.  this couldn't be
//   done in Java.  
// -- blm
//

typedef Seq<char> charseq;

// ---- substitute for << operator.

// first overload << for charseq.
ostream & operator << (ostream & o, const charseq & cseq) {
  if (cseq.empty())
    return o;
  else {
    o << cseq.hd();
    return o << cseq.tl();
  }
}

// get the Seq<char> from the lstring, by trickery.
charseq * peekIntoString(const lstring & s) {
  return (charseq *) &s;
}

// print the lstring's contents to standard out.
void print(const lstring & s) {
  cout << *peekIntoString(s);
  return;
}

// print lstring's contents, between single quotes, with identifying 
//   message.
void printWithMsg(const char * msg, const lstring & s) {
  cout << msg << "'" << *peekIntoString(s) << "'\n";
  return;
}