00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef FALCON_PATH_H
00017 #define FALCON_PATH_H
00018
00019 #include <falcon/setup.h>
00020 #include <falcon/string.h>
00021 #include <falcon/gcalloc.h>
00022
00023 namespace Falcon
00024 {
00025 class URI;
00026
00050 class FALCON_DYN_CLASS Path: public GCAlloc
00051 {
00052 String m_path;
00053
00054 String m_device;
00055 String m_location;
00056 String m_file;
00057 String m_extension;
00058
00059 bool m_bValid;
00060
00061
00062
00063 URI* m_owner;
00064
00065 void compose();
00066 public:
00067
00069 Path();
00070
00072 Path( URI *owner );
00073
00075 Path( const String &path ):
00076 m_bValid( true ),
00077 m_owner(0)
00078 {
00079 set( path );
00080 }
00081
00085 Path( const Path &other ):
00086 m_bValid( true ),
00087 m_owner(0)
00088 {
00089 copy( other );
00090 }
00091
00095 void copy( const Path &other );
00096
00098 bool set( const String &p );
00099
00101 const String &get() const { return m_path; }
00102
00104 String getWinFormat() const { String fmt; getWinFormat( fmt ); return fmt; }
00105
00107 void getWinFormat( String &str ) const;
00108
00110 String getResource() const { String fmt; getResource( fmt ); return fmt; }
00111
00117 bool getResource( String &str ) const;
00118
00121 String getLocation() const { String fmt; getLocation( fmt ); return fmt; }
00122
00128 bool getLocation( String &str ) const;
00129
00131 String getWinLocation() const { String fmt; getWinLocation( fmt ); return fmt; }
00132
00138 bool getWinLocation( String &str ) const;
00139
00143 String getFilename() const { String fmt; getFilename( fmt ); return fmt; }
00144
00150 bool getFilename( String &str ) const;
00151
00153 String getFile() const { String fmt; getFile( fmt ); return fmt; }
00154
00160 bool getFile( String &str ) const;
00161
00162
00164 String getExtension() const { String fmt; getExtension( fmt ); return fmt; }
00165
00171 bool getExtension( String &str ) const;
00172
00174 void setResource( const String &res );
00175
00177 void setLocation( const String &loc );
00178
00180 void setFile( const String &file );
00181
00183 void setFilename( const String &fname );
00184
00186 void setExtension( const String &extension );
00187
00189 bool isAbsolute() const;
00190
00192 bool isLocation() const;
00193
00197 bool isValid() const { return m_bValid; }
00198
00205 void split( String &loc, String &name, String &ext );
00206
00213 void split( String &res, String &loc, String &name, String &ext );
00214
00223 void splitWinFormat( String &res, String &loc, String &name, String &ext );
00224
00232 void join( const String &loc, const String &name, const String &ext );
00233
00241 void join( const String &res, const String &loc, const String &name, const String &ext );
00242
00253 void extendLocation( const String &npath );
00254
00255 Path & operator =( const Path &other ) { copy( other ); return *this; }
00256 bool operator ==( const Path &other ) const { return other.m_path == m_path; }
00257 bool operator !=( const Path &other ) const { return other.m_path != m_path; }
00258 bool operator <( const Path &other ) const { return m_path < other.m_path; }
00259
00260 };
00261
00262 }
00263
00264 #endif