File:  [parser3project] / parser3 / src / include / Attic / pa_wcontext.h
Revision 1.22: download - view: text, annotated - select for diffs - revision graph
Thu Mar 8 12:19:20 2001 UTC (25 years, 4 months ago) by paf
Branches: MAIN
CVS tags: HEAD
z

/*
  $Id: pa_wcontext.h,v 1.22 2001/03/08 12:19:20 paf Exp $
*/

#ifndef PA_WCONTEXT_H
#define PA_WCONTEXT_H

#include "pa_value.h"
#include "pa_vstring.h"
#include "pa_vhash.h"

class WContext : public Value {
public: // Value

	// all: for error reporting after fail(), etc
	const char *type() const { return "wcontext"; }
	// WContext: accumulated fstring
	String *get_string() { return &fstring; };

	// WContext: none yet | transparent
	VClass *get_class() { return fvalue?fvalue->get_class():0; }
	// wcontext: transparent
	VAliased *get_aliased() { return fvalue?fvalue->get_aliased():0; }

public: // WContext

	// appends a fstring to result
	virtual void write(String *astring);

	// if value is VString writes fstring,
	// else writes Value; raises an error if already
	virtual void write(Value *avalue);

public: // usage

	WContext(Pool& apool, Value *avalue, bool aconstructing) : Value(apool), 
		fvalue(avalue),
		fconstructing(aconstructing),
		fstring(*new(apool) String(apool)) {
	}

	bool constructing() { return fconstructing; }

	// retrives the resulting value
	Value *object() const {
		return fvalue;
	}
	// retrives the resulting value
	// that can be VString if value==0 or the Value object
	Value *result() const {
		return fvalue?fvalue:NEW VString(fstring);
	}

protected:
	Value *fvalue;
private:
	bool fconstructing;
	String& fstring;
};

#endif

E-mail: