CTCLResult --  Provide an object oriented interace to the Tcl interpreter result.


#include <TCLResult.h>
class CTCLResult  : public CTCLObject
  CTCLResult (CTCLInterpreter* pInterp, bool reset=true );
  CTCLResult (const CTCLResult& aCTCLResult );
  virtual ~CTCLResult ( );

  CTCLResult& operator= (const CTCLResult& aCTCLResult);
  CTCLResult& operator= (const char* rhs);
  CTCLResult& operator=(std::string    rhs);

  int operator== (const CTCLResult& aCTCLResult) ;
  int operator!= (const CTCLResult& rhs);

  CTCLResult& operator+= (const char* pString);
  CTCLResult& operator+= (const std::string& rString);

  void Clear ()  ;
  void AppendElement (const char* pString)  ;
  void AppendElement (const std::string& rString);
  void commit() const;
  std::string getString();



Each Tcl command can return result string the result string can be used by subsequent commands in the event the command operated successfully, or by catch commands if the command failed. CTCLResult provides an extension of the CTCLObject class that builds up a string which can then be comitted to the result.


CTCLResult(CTCLInterpreter* pInterp,
           bool reset=true );
CTCLResult(const CTCLResult& aCTCLResult);

Constructs a Tcl interpreter result string. pInterp is the interpeter that will be associated with this result. reset controls whether or not the result string is reset when constructed, or if it is loaded with the current value of the result string. In the case of copy construction, the interpreter associated with aCTCLResult is used. aCTCLResult is committed to the interpreter result, and the object under construction is then loaded from that interpreter's result.

  CTCLResult& operator= (const CTCLResult& rhs);
  CTCLResult& operator= (const char* rhs);
  CTCLResult& operator=(std::string    rhs);

Assigns a value to the result from rhs. If the rhs is a CTCLResult, then the rhs is first committed to its interpreter result, the left hand object is then bound to the same interpreter as rhs and loaded with the result string of that interpreter.

  int operator== (const CTCLResult& rhs) ;
  int operator!= (const CTCLResult& rhs);

These functions suport comparison. Equality comparison is true (operator==) if the interpreters match as the assumption is that the user is working to maintain coherency if several CTCLResult objects are simultaneously live on a single interpreter. Inequality (operator!=) is defined as true when operator== is false.

CTCLResult& operator+= (const char* rhs);
CTCLResult& operator+=(const std::string& rhs);

rhs is textually appended to the result string being built up. Note that the semantics of this are different than for the base class where operator+= is a list append.

  void Clear()  ;

Clears the result string being built up as well as clearing the underlying interpreter's result.

  void AppendElement(const char* item)  ;
  void AppendElement(const std::string& item);

Appends item to the result string being built up as a list element. This means that under some circumstances extra quoting may be done to ensure that the result will be maintained as a valid list.

  void commit() const;
  std::string getString();

commit sets the interpreter result string equal to the string being built up in the object. getString does a commit and then returns the string.