Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

Pathname.C

Go to the documentation of this file.
00001 // Copyright (C) 2001, Compaq Computer Corporation
00002 // 
00003 // This file is part of Vesta.
00004 // 
00005 // Vesta is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 // 
00010 // Vesta is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with Vesta; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019 // Created on Wed Mar 12 16:07:53 PST 1997 by heydon
00020 
00021 // Last modified on Mon Aug  9 17:12:27 EDT 2004 by ken@xorian.net
00022 //      modified on Thu Mar 13 21:55:20 PST 1997 by heydon
00023 
00024 #include <Basics.H>
00025 #include <Atom.H>
00026 #include <IntKey.H>
00027 #include <Sequence.H>
00028 #include "Pathname.H"
00029 
00030 using std::ostream;
00031 
00032 class PathPair {
00033   public:
00034     PathPair() throw () { /*SKIP*/ }
00035     PathPair(Pathname::T prefix, Atom base) throw ()
00036       : prefix(prefix), base(base) { /*SKIP*/ }
00037     Pathname::T prefix;
00038     Atom base;
00039 };
00040 
00041 // sequence type
00042 typedef Sequence<PathPair> PathSeq;
00043 
00044 // global sequence
00045 PathSeq paths(/*sizeHint=*/ 500);
00046 
00047 Pathname::T Pathname::New(Pathname::T prefix, const char *arc) throw ()
00048 {
00049     Atom base(arc);
00050     PathPair pair(prefix, base);
00051     Pathname::T res = paths.size();
00052     paths.addhi(pair);
00053     return res;
00054 }
00055 
00056 void Pathname::Print(ostream &os, Pathname::T path) throw ()
00057 {
00058     PathPair pair = paths.get(path);
00059     if (pair.prefix >= 0) {
00060         // print prefix recursively
00061         Pathname::Print(os, pair.prefix);
00062         os << '/';
00063     }
00064     os << pair.base;
00065 }

Generated on Mon May 8 00:48:59 2006 for Vesta by  doxygen 1.4.2