Path.h

Go to the documentation of this file.
00001 /* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 5 -*- */
00002 
00009 /*
00010 -----BEGIN PGP SIGNED MESSAGE-----
00011 Hash: SHA1
00012 
00013 Created by Daniel Aarno on Sat Dec 11, 2004.
00014 Copyright (c) 2004 by Daniel Aarno - <macbishop@users.sf.net>
00015 M. Sc. in Electrical Engineering - http://www.e.kth.se/~e98_aar
00016 
00017 All Rights Reserved
00018 ATTRIBUTION ASSURANCE LICENSE (adapted from the original BSD license)
00019 Redistribution and use in source and binary forms, with or without
00020 modification, are permitted provided that the conditions below are met.
00021 These conditions require a modest attribution to  (the
00022 "Author"), who hopes that its promotional value may help justify the
00023 thousands of dollars in otherwise billable time invested in writing
00024 this and other freely available, open-source software.
00025 
00026 1. Redistributions of source code, in whole or part and with or without
00027 modification (the "Code"), must prominently display this GPG-signed
00028 text in verifiable form.
00029 2. Redistributions of the Code in binary form must be accompanied by
00030 this GPG-signed text in any documentation and, each time the resulting
00031 executable program or a program dependent thereon is launched, a
00032 prominent display (e.g., splash screen or banner text) of the Author's
00033 attribution information, which includes:
00034 (a) Name ("Daniel Aarno"),
00035 (b) Professional identification ("M. Sc. in Electrical Engineering"), and
00036 (c) URL ("http://www.e.kth.se/~e98_aar").
00037 3. Neither the name nor any trademark of the Author may be used to
00038 endorse or promote products derived from this software without specific
00039 prior written permission.
00040 4. Users are entirely responsible, to the exclusion of the Author and
00041 any other persons, for compliance with (1) regulations set by owners or
00042 administrators of employed equipment, (2) licensing terms of any other
00043 software, and (3) local regulations regarding use, including those
00044 regarding import, export, and use of encryption software.
00045 
00046 THIS FREE SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND
00047 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00048 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
00049 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
00050 EVENT SHALL THE AUTHOR OR ANY CONTRIBUTOR BE LIABLE FOR
00051 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00052 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00053 EFFECTS OF UNAUTHORIZED OR MALICIOUS NETWORK ACCESS;
00054 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00055 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
00056 AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00057 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00058 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
00059 IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00060 -----BEGIN PGP SIGNATURE-----
00061 Version: GnuPG v1.2.4 (GNU/Linux)
00062 
00063 iD8DBQFB+7cvi6ECThHTSIkRAo5dAKDH4z2wWRazlRiXerFPkJ86DJ5UDwCgxjnN
00064 cXDsc9GkCO2JieyNCIN1490=
00065 =p4ad
00066 -----END PGP SIGNATURE-----
00067 */
00068 
00069 #ifndef _PATH_
00070 #define _PATH_
00071 
00072 #include <string>
00073 #include <vector>
00074 
00075 
00082 class Path : public std::string
00083 {
00084 public:
00086      static const char PATH_DELIM;
00087 
00089      Path() { *this += PATH_DELIM; }
00090      Path(const char* path) : std::string(path) {}
00091      Path(const std::string &path) : std::string(path) {}
00092      
00100       Path(const std::vector<std::string> &compV);
00101 
00103      void appendComponent(const std::string &comp);
00104 
00106      void appendExtension(const std::string &ext);
00107 
00113      void deleteLastComponent();
00114 
00120      void deleteExtension();
00121 
00129      void expandTilde();
00130 
00139      void abbreviateWithTilde();
00140      
00147      const bool isAbsolute() const { return operator[](0) == PATH_DELIM; }
00148 
00160      const std::vector<std::string> getComponents() const;
00161 
00163      const std::string getLastComponent() const;
00164 
00169      const std::string getExtension() const;
00170 };
00171 
00172 #endif

Generated on Sun Mar 11 15:33:24 2007 for MetalWarriors by  doxygen 1.4.7