/* * Copyright (c) 1995, 1996 Gunther Schadow. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef PG_XIOS_H_ #define PG_XIOS_H_ #include #pragma interface #include "Delimiters.h" #ifdef WITH_XDR # include "Xdr.h" #endif /* * The encoding of the `null value'. Note the distinction between * a null value and a value which is not present. */ #define NULLVAL "\"\"" /* * How to print special symbols to the debug stream */ #ifndef DS_STYLE #define DS_STYLE 1 #endif #if DS_STYLE == 1 # define DSNULL "nil" # define DSNOPS "" # define DSVOID "void" # define DSBGR0 "(" # define DSBGR1 "" # define DSFRST " " # define DSSEPR " " # define DSEGRP ")\n" # define DSBQUO "\"" # define DSEQUO "\"" #elif DS_STYLE == 2 # define DSNULL "" # define DSNOPS "" # define DSVOID "" # define DSBGR0 "[" # define DSBGR1 "] {" # define DSFRST "<1st>" # define DSSEPR ", " # define DSEGRP "}" # define DSBQUO "`" # define DSEQUO "\'" #elif DS_STYLE 3 # define DSNULL "null;" # define DSNOPS "nil;" # define DSVOID "void;" # define DSBGR0 "*" # define DSBGR1 "() {" # define DSFRST "first;" # define DSSEPR "; " # define DSEGRP "; }" # define DSBQUO "\"" # define DSEQUO "\"" #else # error illegal DS_STYLE #endif /* * We extend the fstream class by a set of flags which tell the * I/O mode in use. Currently we have the following coding modes: * * 1.) HL7 Encoding Rules as described in the HL7 standard * 2.) ASTM Encoding Rules * 3.) debug mode used to generate human readable output * 4.) XDR (RFC 1014) * * Even though these flags are mutually exclusive, we define * them as seperate flags just in case we once want to add other * encoding rules. * * Normally, toplevel is used. but we have to increase the level, if * we use a type as a part of a composite type (see below). */ class xios { enum __flags { __touched = 1, __debug = 1<<1, __hl7er = 1<<2, __astmer = 1<<3, #if WITH_XDR __xdr = 1<<4, #endif ERMASK = ( __debug | __hl7er | __astmer #if WITH_XDR | __xdr #endif ), }; private: int _flags; ios* _ios; Delimiters::level_t _level; Delimiters _delimiters; #if WITH_XDR Xdr _xdr; #endif static int _index; public: xios(ios& s); void debug(); void hl7er(); void astmer(); void touch(); void untouch(); bool isdebug() const; bool ishl7er() const; bool isastmer() const; bool istouched() const; Delimiters::level_t getlevel() const; void setlevel(Delimiters::level_t l); inline friend xios *__xios(const ios& s); inline friend ios& debug(ios& s); inline friend ios& hl7er(ios& s); inline friend ios& astmer(ios& s); inline friend ios& touch(ios& s); inline friend ios& untouch(ios& s); inline friend bool ishl7er(const ios& io); inline friend bool isastmer(const ios& io); inline friend bool isdebug(const ios& io); inline friend bool istouched(const ios& io); inline friend Delimiters::level_t level(const ios& io); inline friend void setlevel(ios&, Delimiters::level_t l); inline friend Delimiters& delims(ios& io); inline friend const char *getdel(const ios& io, Delimiters::level_t offset); #if WITH_XDR void xdr(); bool isxdr() const; inline friend ios& xdr(ios& s); inline friend bool isxdr(const ios& io); inline friend Xdr& getxdr(ios& io); #endif }; #ifndef OUTLINE # include "xios.icc" #endif #endif /* !PG_XIOS_ */