Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages  

Doc.h

00001 //
00002 // OpenVRML
00003 //
00004 // Copyright (C) 1998  Chris Morley
00005 // 
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License, or (at your option) any later version.
00010 // 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 // 
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 // 
00020 
00021 # ifndef OPENVRML_DOC_H
00022 #   define OPENVRML_DOC_H
00023 
00024 #   include <stdio.h>
00025 #   include <iosfwd>
00026 #   include <string>
00027 #   include "common.h"
00028 
00029 namespace OpenVRML {
00030 
00031     class Doc2;
00032 
00033     class OPENVRML_SCOPE Doc {
00034         char * d_url;
00035         std::ostream * d_ostream;
00036         FILE * d_fp;
00037         char * d_tmpfile; // Local copy of http: files
00038 
00039     public:
00040         explicit Doc(const std::string & url = std::string(),
00041                      const Doc * relative = 0);
00042         Doc(const std::string & url, const Doc2 * relative);
00043         ~Doc();
00044 
00045         void seturl(const char * url, const Doc * relative = 0);
00046         void seturl(const char * url, const Doc2 * relative = 0);
00047 
00048         const char * url() const;          // "http://www.foo.com/dir/file.xyz#Viewpoint"
00049         const char * urlBase() const;      // "file" or ""
00050         const char * urlExt() const;       // "xyz" or ""
00051         const char * urlPath() const;      // "http://www.foo.com/dir/" or ""
00052         const char * urlProtocol() const;  // "http"
00053         const char * urlModifier() const;  // "#Viewpoint" or ""
00054 
00055         const char * localName();    // "/tmp/file.xyz" or NULL
00056         const char * localPath();    // "/tmp/" or NULL
00057 
00058 
00059         FILE * fopen(const char * mode);
00060         void fclose();
00061 
00062         std::ostream & outputStream();
00063 
00064     private:
00065         // Non-copyable.
00066         Doc(Doc const &);
00067         Doc & operator=(Doc const &);
00068 
00069         bool filename(char * fn, int nfn);
00070         
00071 #   ifdef macintosh
00072         char * convertCommonToMacPath(char * fn, int nfn);
00073 #   endif
00074     };
00075 }
00076 
00077 # endif