tResourcePath Class Reference

helper class to construct a resource path More...

#include <tResourceManager.h>

Collaboration diagram for tResourcePath:

Collaboration graph
[legend]

List of all members.

Public Member Functions

tString const & Author () const
 get the author of the resource
tString const & Category () const
 get the category of the resource
tString const & Name () const
 get the name of the resource
tString const & Version () const
 get the version of the resource
tString const & Type () const
 get the type of the resource
tString const & Extension () const
 get the extension (like xml or png)
tString const & URI () const
 get the URI to the file, if any
tString const & Path () const
 get the full path of the resource
bool Valid () const
 is this a valid resource path?
 tResourcePath ()
 default constructor. Valid() will return false if called on an object constructed this way.
 tResourcePath (tString const &Author, tString const &Category, tString const &Name, tString const &Version, tString const &Type, tString const &Extension, tString const &URI)
 construct the path from the given arguments
 tResourcePath (tString const &path)
 construct a path from a resource location
bool operator== (tResourcePath const &other) const
bool operator!= (tResourcePath const &other) const

Private Attributes

tString m_Author
 the author of the resource
tString m_Category
 the category of the resource
tString m_Name
 the name of the resource
tString m_Version
 the version of the resource
tString m_Type
 the type of the resource
tString m_Extension
 the extension (like xml or png)
tString m_URI
 the URI to the file, if any
tString m_Path
 the full path of the resource
bool m_Valid


Detailed Description

helper class to construct a resource path

Definition at line 49 of file tResourceManager.h.


Constructor & Destructor Documentation

tResourcePath::tResourcePath (  )  [inline]

default constructor. Valid() will return false if called on an object constructed this way.

Definition at line 74 of file tResourceManager.h.

00074 :m_Valid(false){}

tResourcePath::tResourcePath ( tString const &  Author,
tString const &  Category,
tString const &  Name,
tString const &  Version,
tString const &  Type,
tString const &  Extension,
tString const &  URI 
)

construct the path from the given arguments

Definition at line 288 of file tResourceManager.cpp.

References m_Path, m_Valid, st_checkAuthor(), st_checkCategory(), st_checkExtension(), st_checkName(), st_checkType(), and st_checkVersion().

00294                                                  :
00295     m_Author   (Author   ),
00296     m_Category (Category ),
00297     m_Name     (Name     ),
00298     m_Version  (Version  ),
00299     m_Type     (Type     ),
00300     m_Extension(Extension),
00301     m_URI      (URI      ),
00302     m_Valid(false) {
00303     m_Path << Author << '/';
00304     if(!st_checkAuthor(Author)) return;
00305     if(!Category.empty()) {
00306         if(!st_checkCategory(Category)) return;
00307         m_Path << Category << '/';
00308     }
00309     if(!st_checkName(Name)) return;
00310     if(!st_checkExtension(Extension)) return;
00311     if(!st_checkType(Extension)) return;
00312     if(!st_checkVersion(Version)) return;
00313     m_Path << Name << '-' << Version << '.' << Type << '.' << Extension;
00314     if(!URI.empty()) {
00315         m_Path << '(' << URI << ')';
00316     }
00317     m_Valid = true;
00318 }

Here is the call graph for this function:

tResourcePath::tResourcePath ( tString const &  path  ) 

construct a path from a resource location

Definition at line 320 of file tResourceManager.cpp.

References m_Author, m_Category, m_Extension, m_Name, m_Path, m_Type, m_URI, m_Valid, m_Version, st_checkAuthor(), st_checkCategory(), st_checkExtension(), st_checkName(), st_checkType(), st_checkVersion(), and tERR_WARN.

00320                                                 : m_Path(Path), m_Valid(false) {
00321     // check if an URI is attached
00322     tString::size_type uridelim = m_Path.find('(');
00323     if(uridelim != tString::npos) {
00324         // find the corresponding opening bracket
00325         if(*m_Path.rbegin() != ')') {
00326             tERR_WARN("Incomplete URI specification");
00327             return;
00328         }
00329         m_URI = m_Path.substr(uridelim + 1, m_Path.size() - uridelim - 2);
00330         --uridelim;
00331     } else {
00332         uridelim = m_Path.size() - 1;
00333     }
00334 
00335     tString::size_type authordelim = Path.find('/');
00336     if(authordelim == tString::npos || authordelim >= uridelim) {
00337         tERR_WARN("Resource paths need to contain at least one slash");
00338         return;
00339     }
00340     m_Author = Path.substr(0, authordelim);
00341     if(!st_checkAuthor(m_Author)) return;
00342     tString::size_type categorydelim = Path.rfind('/', uridelim);
00343     if(categorydelim != authordelim) {
00344         m_Category = Path.substr(authordelim + 1, categorydelim - authordelim - 1);
00345         if(!st_checkCategory(m_Category)) return;
00346     }
00347     tString::size_type namedelim = Path.find('-', categorydelim);
00348     if(namedelim == tString::npos || namedelim >= uridelim) {
00349         tERR_WARN("Resource path is missing the version delimiter ('-')");
00350         return;
00351     }
00352     m_Name = Path.substr(categorydelim+1, namedelim - categorydelim - 1);
00353     if(!st_checkName(m_Name)) return;
00354 
00355     // now parse from the back to the front to find the version (which can
00356     // contain dots)
00357     tString::size_type extensiondelim = Path.rfind('.', uridelim);
00358     if(extensiondelim == tString::npos || extensiondelim <= namedelim || extensiondelim >= Path.size() - 1) {
00359         tERR_WARN("Resource path is missing the extension delimiter ('.')");
00360     }
00361     m_Extension = Path.substr(extensiondelim + 1, uridelim - extensiondelim);
00362     if(!st_checkExtension(m_Extension)) return;
00363     tString::size_type typedelim = Path.rfind('.', extensiondelim - 1);
00364     if(typedelim == tString::npos || typedelim <= namedelim) {
00365         tERR_WARN("Resource path is missing the type delimiter ('.')");
00366     }
00367     m_Type = Path.substr(typedelim + 1, extensiondelim - typedelim - 1);
00368     if(!st_checkType(m_Type)) return;
00369 
00370     // the rest is (hopefully) the version, now...
00371     m_Version = Path.substr(namedelim + 1, typedelim - namedelim - 1);
00372     if(!st_checkVersion(m_Version)) return;
00373     m_Valid=true;
00374 }

Here is the call graph for this function:


Member Function Documentation

tString const& tResourcePath::Author (  )  const [inline]

get the author of the resource

Definition at line 62 of file tResourceManager.h.

References m_Author.

tString const& tResourcePath::Category (  )  const [inline]

get the category of the resource

Definition at line 63 of file tResourceManager.h.

References m_Category.

tString const& tResourcePath::Name (  )  const [inline]

get the name of the resource

Definition at line 64 of file tResourceManager.h.

References m_Name.

tString const& tResourcePath::Version (  )  const [inline]

get the version of the resource

Definition at line 65 of file tResourceManager.h.

References m_Version.

tString const& tResourcePath::Type (  )  const [inline]

get the type of the resource

Definition at line 66 of file tResourceManager.h.

References m_Type.

tString const& tResourcePath::Extension (  )  const [inline]

get the extension (like xml or png)

Definition at line 67 of file tResourceManager.h.

References m_Extension.

tString const& tResourcePath::URI (  )  const [inline]

get the URI to the file, if any

Definition at line 68 of file tResourceManager.h.

References m_URI.

tString const& tResourcePath::Path (  )  const [inline]

get the full path of the resource

Definition at line 69 of file tResourceManager.h.

References m_Path.

Referenced by tXmlParserNamespace::tXmlResource::ValidateXml().

Here is the caller graph for this function:

bool tResourcePath::Valid (  )  const [inline]

is this a valid resource path?

Definition at line 71 of file tResourceManager.h.

References m_Valid.

Referenced by rResourceTexture::rResourceTexture().

Here is the caller graph for this function:

bool tResourcePath::operator== ( tResourcePath const &  other  )  const

Definition at line 376 of file tResourceManager.cpp.

References m_Author, m_Category, m_Extension, m_Name, m_Type, and m_Version.

00376                                                                {
00377     return m_Author    == other.m_Author    &&
00378            m_Category  == other.m_Category  &&
00379            m_Name      == other.m_Name      &&
00380            m_Version   == other.m_Version   &&
00381            m_Type      == other.m_Type      &&
00382            m_Extension == other.m_Extension;
00383 }

bool tResourcePath::operator!= ( tResourcePath const &  other  )  const

Definition at line 386 of file tResourceManager.cpp.

References m_Author, m_Category, m_Extension, m_Name, m_Type, and m_Version.

00386                                                                {
00387     return m_Author    != other.m_Author    ||
00388            m_Category  != other.m_Category  ||
00389            m_Name      != other.m_Name      ||
00390            m_Version   != other.m_Version   ||
00391            m_Type      != other.m_Type      ||
00392            m_Extension != other.m_Extension;
00393 }


Member Data Documentation

tString tResourcePath::m_Author [private]

the author of the resource

Definition at line 51 of file tResourceManager.h.

Referenced by Author(), operator!=(), operator==(), and tResourcePath().

tString tResourcePath::m_Category [private]

the category of the resource

Definition at line 52 of file tResourceManager.h.

Referenced by Category(), operator!=(), operator==(), and tResourcePath().

tString tResourcePath::m_Name [private]

the name of the resource

Definition at line 53 of file tResourceManager.h.

Referenced by Name(), operator!=(), operator==(), and tResourcePath().

tString tResourcePath::m_Version [private]

the version of the resource

Definition at line 54 of file tResourceManager.h.

Referenced by operator!=(), operator==(), tResourcePath(), and Version().

tString tResourcePath::m_Type [private]

the type of the resource

Definition at line 55 of file tResourceManager.h.

Referenced by operator!=(), operator==(), tResourcePath(), and Type().

tString tResourcePath::m_Extension [private]

the extension (like xml or png)

Definition at line 56 of file tResourceManager.h.

Referenced by Extension(), operator!=(), operator==(), and tResourcePath().

tString tResourcePath::m_URI [private]

the URI to the file, if any

Definition at line 57 of file tResourceManager.h.

Referenced by tResourcePath(), and URI().

tString tResourcePath::m_Path [private]

the full path of the resource

Definition at line 58 of file tResourceManager.h.

Referenced by Path(), and tResourcePath().

bool tResourcePath::m_Valid [private]

Definition at line 60 of file tResourceManager.h.

Referenced by tResourcePath(), and Valid().


The documentation for this class was generated from the following files:
Generated on Sat Mar 15 23:59:10 2008 for Armagetron Advanced by  doxygen 1.5.4