CoCoALib-0.9905 date: 23 May 2007


OpenMathXML.H

Go to the documentation of this file.
00001 #ifndef CoCoA_OpenMathXML_H
00002 #define CoCoA_OpenMathXML_H
00003 
00004 //   Copyright (c)  2005  John Abbott
00005 
00006 //   This file is part of the source of CoCoALib, the CoCoA Library.
00007 
00008 //   CoCoALib is free software; you can redistribute it and/or modify
00009 //   it under the terms of the GNU General Public License (version 2)
00010 //   as published by the Free Software Foundation.  A copy of the full
00011 //   licence may be found in the file COPYING in this directory.
00012 
00013 //   CoCoALib is distributed in the hope that it will be useful,
00014 //   but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 //   GNU General Public License for more details.
00017 
00018 //   You should have received a copy of the GNU General Public License
00019 //   along with CoCoA; if not, write to the Free Software
00020 //   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 
00022 
00023 #include "CoCoA/OpenMath.H"
00024 #include "CoCoA/ZZ.H"
00025 
00026 #include <iostream>
00027 // using std::ostream;
00028 #include <stack>
00029 // using std::stack;
00030 #include <string>
00031 // using std::string
00032 
00033 
00034 namespace CoCoA
00035 {
00036 
00037   class OpenMathOutputXML: public OpenMathOutputBase
00038   {
00039   public:
00040     OpenMathOutputXML(std::ostream& out);
00041     ~OpenMathOutputXML();
00042     virtual void mySend(long n);
00043     virtual void mySend(unsigned long n);
00044     virtual void mySend(const ZZ& N);  // outputs an integer
00045     virtual void mySend(const OpenMathSymbol& s);
00046     virtual void mySendApplyStart();
00047     virtual void mySendApplyEnd();
00048     virtual void mySendObjectStart();
00049     virtual void mySendObjectEnd();
00050     //void OutputAttribute();//??????
00051   private:
00052     std::ostream& myOut;  // UGLY, RISKY!!???!!
00053     std::size_t myLevel;  // nesting level
00054     std::stack<OpenMathTag> myTagStack;  // only really needed for debugging
00055     const char* myIndent();
00056   };
00057 
00058 
00059   class OpenMathInputXML: public OpenMathInputBase
00060   {
00061   public:
00062     OpenMathInputXML(std::istream& in); // just sets ref count to zero.
00063     virtual ~OpenMathInputXML();
00064 
00065     virtual void advance();
00066     virtual OpenMathTag myCurrTag();
00067     virtual std::size_t NumDescendants() const;
00068     virtual bool myRecv(long & n); // SHORT INTEGER
00069     virtual bool myRecv(ZZ& N);    // LONG INTEGER
00070     virtual bool myRecv(OpenMathSymbol& s);
00071   private:
00072     enum status_t { NotYetRead, AlreadyRead };
00073     status_t myStatus;
00074     OpenMathTag myCurrTagType;
00075     ZZ myIntegerValue;
00076     OpenMathSymbol mySymbol;
00077     std::istream& myIn;  // UGLY, RISKY!!???!!
00078     std::size_t myLevel;  // nesting level
00079     std::stack<OpenMathTag> myTagStack;  // only really needed for debugging
00080   private:
00081     char ReadChar();
00082     char SkipWSReadChar();
00083     void ReadNextNode();
00084     bool SkipMatch(const std::string& expected);
00085     bool ReadDecimalString(std::string& DecimalDigits);
00086     bool ReadStringInQuotes(std::string& QuotedString);
00087   };
00088 
00089 
00090 } // end of namespace CoCoA
00091 
00092 
00093 // RCS header/log in the next few lines
00094 // $Header: /Volumes/Home/cocoa/cvs-repository/CoCoALib-0.99/include/CoCoA/OpenMathXML.H,v 1.1.1.1 2007/03/09 15:16:11 abbott Exp $
00095 // $Log: OpenMathXML.H,v $
00096 // Revision 1.1.1.1  2007/03/09 15:16:11  abbott
00097 // Imported files
00098 //
00099 // Revision 1.7  2006/12/06 17:14:12  cocoa
00100 // -- removed #include "config.H"
00101 //
00102 // Revision 1.6  2006/11/27 14:22:04  cocoa
00103 // -- ooops, missing semicolon
00104 //
00105 // Revision 1.5  2006/11/27 13:53:10  cocoa
00106 // changed mySend(std::size_t n)  into  mySend(unsigned long n)
00107 //
00108 // Revision 1.4  2006/11/27 13:04:35  cocoa
00109 // Added explicit OpenMath output operators for all integer types.
00110 //
00111 // Revision 1.3  2006/11/02 13:25:44  cocoa
00112 // Simplification of header files: the OpenMath classes have been renamed.
00113 // Many minor consequential changes.
00114 //
00115 // Revision 1.2  2006/10/06 14:04:15  cocoa
00116 // Corrected position of #ifndef in header files.
00117 // Separated CoCoA_ASSERT into assert.H from config.H;
00118 // many minor consequential changes (have to #include assert.H).
00119 // A little tidying of #include directives (esp. in Max's code).
00120 //
00121 
00122 #endif

Generated on Wed May 23 13:43:35 2007 for CoCoALib by  doxygen 1.4.6