Annotation of parser3/src/types/pa_wcontext.C, revision 1.4
1.1 paf 1: /*
2: Parser
3: Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
1.2 paf 4: Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
1.1 paf 5:
1.4 ! paf 6: $Id: pa_wcontext.C,v 1.3 2001/03/12 18:13:50 paf Exp $
1.1 paf 7: */
8:
9: #include "pa_wcontext.h"
10: #include "pa_exception.h"
1.3 paf 11: #include "pa_request.h"
1.1 paf 12:
13: // appends a fstring to result
14: void WContext::write(const String& astring, String::Untaint_lang lang) {
15: fstring.append(astring, lang);
16: }
17:
1.4 ! paf 18: void WContext::write(Value& avalue) {
! 19: if(fvalue) { // already have value?
! 20: if(avalue.name()==UNNAMED_NAME)
! 21: THROW(0,0, // must not construct twice
! 22: &fvalue->name(),
! 23: "(%s) may not be overwritten with '%s' (%s), use constructor instead",
! 24: fvalue->type(), avalue.name().cstr(), avalue.type());
! 25: else
! 26: THROW(0,0, // must not construct twice
! 27: &avalue.name(),
! 28: "(%s) illegal assignment attempt to '%s' (%s), use constructor instead",
! 29: avalue.type(), fvalue->name().cstr(), fvalue->type());
! 30: } else {
! 31: fvalue=&avalue;
! 32: // not constructing anymore [if were constructing]
! 33: // so to allow method calls after real constructor-method call
! 34: // sample:
! 35: // $complex[
! 36: // $class:constructor[$i]
! 37: // ^i.inc[] ^rem{allow such calls}
! 38: // $field[$1]
! 39: fconstructing=false;
! 40: }
! 41: }
! 42:
1.1 paf 43: // if value is VString writes fstring,
44: // else writes Value; raises an error if already
45: void WContext::write(Value& avalue, String::Untaint_lang lang) {
46: const String *fstring=avalue.get_string();
47: if(fstring)
48: write(*fstring, lang);
49: else
1.4 ! paf 50: write(avalue);
1.1 paf 51: }
E-mail: