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

composite.h

00001 /*****************************************************************************
00002  * composite.h
00003  * Last Change: 2003-12-27
00004  * Copyright (c) 2003 Sebastian "randomZ" Beschke
00005  ****************
00006  * This file is part of the libsofu project, a parser library for an all-purpose
00007  * ASCII file format. More information can be found on the project web site
00008  * at http://sofu.sourceforge.net/ .
00009  *
00010  * libsofu is published under the terms of the MIT license, which basically means
00011  * "Do with it whatever you want". For more information, see the license.txt
00012  * file that should be enclosed with libsofu distributions. A copy of the license
00013  * is (at the time of this writing) also available at
00014  * http://www.opensource.org/licenses/mit-license.php .
00015  *****************************************************************************/
00016 
00017 #ifndef INC_SOFU_COMPOSITE_H
00018 #define INC_SOFU_COMPOSITE_H
00019 
00020 #include "main.h"
00021 #include "object.h"
00022 
00023 namespace Sofu
00024 {
00025     class Value;
00026     class List;
00027 
00028     class Composite : public Object
00029     {
00030         private:
00031             map<string, Object*> properties;
00032         public:
00033             Composite(void);
00034             Composite(const Composite& cpy);
00035             ~Composite(void);
00036             
00037             Object*& operator[](const string& propname);
00038             Object* object(const string& propname);
00039             Value* value(const string& propname);
00040             List* list(const string& propname);
00041             Composite* composite(const string& propname);
00042             
00043             void set(const string& propname, Object* ivalue);
00044             
00045             class iterator;
00046             iterator begin(void);
00047             iterator end(void);
00048             
00049             class iterator
00050             {
00051                 private:
00052                     friend class Composite;
00053                     map<string, Object*>::iterator itor;
00054                     iterator(map<string, Object*>::iterator iitor, Composite* icomp);
00055                     Composite* comp;
00056                 public:
00057                     iterator(void);
00058                     ~iterator(void);
00059                     
00060                     iterator& operator=(iterator& rhs);
00061                     
00062                     bool operator==(const iterator& rhs) const;
00063                     bool operator!=(const iterator& rhs) const;
00064                     
00065                     iterator& operator+=(int steps);
00066                     iterator& operator-=(int steps);
00067                     iterator& operator++(void);
00068                     iterator& operator--(void);
00069                     
00070                     pair<string, Object*> operator*(void);
00071                     Object* object(void);
00072                     Value* value(void);
00073                     List* list(void);
00074                     Composite* composite(void);
00075                     
00076                     string name(void);
00077                     void set(Object* ivalue);
00078             };
00079     };
00080     
00084     struct Exc_WrongPropertyType : public Exc
00085     {
00086         string propertyName;
00087         string assumedType;
00088     
00089         Exc_WrongPropertyType(const string& ipropertyName,
00090             const string& iassumedType)
00091         : Exc(string("Tried to treat property ") + ipropertyName
00092             + string(" as a ") + iassumedType + string(", which it is not.")),
00093           propertyName(ipropertyName), assumedType(iassumedType)
00094         { }
00095     };
00096     
00097     struct Exc_UnassignedIterator : public Exc
00098     {
00099         Exc_UnassignedIterator(void)
00100         : Exc("Tried to use an iterator which is currently not assigned to"
00101             "point to something")
00102         { }
00103     };
00104 }
00105 
00106 #endif // INC_COMPOSITE_H

Generated on Wed Jan 7 21:34:45 2004 for libsofu by doxygen 1.3.5