Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

container.hh

00001 /*
00002 *  Name:      container.hh
00003 *  Author:    Rafael Jesus Alcantara Perez
00004 *             Angel Jimenez Jimenez
00005 *  Summary:   HTML container
00006 *  Date:      $Date: 2003/04/14 00:18:34 $
00007 *  Revision:  $Revision: 1.1 $
00008 *
00009 *  Copyright (C) 1994-2002  Rafael Jesus Alcantara Perez <rafa@dedalo-ing.com>
00010 *
00011 *  This program is free software; you can redistribute it and/or modify
00012 *  it under the terms of the GNU General Public License as published by
00013 *  the Free Software Foundation; either version 2 of the License, or
00014 *  (at your option) any later version.
00015 *
00016 *  This program is distributed in the hope that it will be useful,
00017 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019 *  GNU General Public License for more details.
00020 *
00021 *  You should have received a copy of the GNU General Public License
00022 *  along with this program; if not, write to the Free Software
00023 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00024 *  MA 02111-1307, USA.
00025 */
00026 
00027 #ifndef _MPCL_TEXT_HTML_CONTAINER__
00028 #define _MPCL_TEXT_HTML_CONTAINER__
00029 
00030 #include "../../util/collection/map.hh"
00031 #include "../../util/general-functions.hh"
00032 #include "tag.hh"
00033 
00034 
00036 namespace mpcl
00037 {
00038 
00040   namespace text
00041   {
00042 
00044     namespace html
00045     {
00046 
00047       using util::collection::TMap;
00048 
00050       class TContainer;
00051 
00053       typedef
00054         TSmartPointer<TContainer>
00055         QTContainer;
00056 
00058       typedef
00059         TSmartPointer<const TContainer>
00060         QKTContainer;
00061 
00082       class TContainer : public TTag
00083       {
00084 
00085         public:
00086 
00088           typedef
00089             TMap<TString, QTTag>
00090             TStringToTagMap;
00091 
00092 
00093         protected:
00094 
00096           TTagList   tTagList;
00097 
00103           mutable TStringToTagMap   tStringToTagMap;
00104 
00105 
00106         public:
00107 
00108           //
00109           //  C O N S T R U C T O R S
00110           //
00111 
00112           TContainer (void)    :
00113             TTag            () ,
00114             tTagList        () ,
00115             tStringToTagMap ()
00116           {
00117             tAttributeMap ["class-identifier"] = "container";
00118             tAttributeMap.bind ("group-align", "misaligned");
00119           }
00120 
00121           TContainer ( const char* pkcIDENTIFIER                 ,
00122                        const char* pkcVALUE       = ""           ,
00123                        const char* pkcGROUP_ALIGN = "misaligned" ) :
00124             TTag            (pkcIDENTIFIER, pkcVALUE)              ,
00125             tTagList        ()                                     ,
00126             tStringToTagMap ()
00127           {
00128             tAttributeMap ["class-identifier"] = "container";
00129             tAttributeMap.bind ("group-align", pkcGROUP_ALIGN);
00130           }
00131 
00132           void clear (void)
00133           {
00134             tTagList.clear();
00135             tStringToTagMap.clear();
00136           }
00137 
00145           virtual QTTag findOrInsertTag (const TString& rkyIDENTIFIER);
00146 
00155           void insertAs ( const TString& rkyTAG_IDENTIFIER ,
00156                           const QTTag&   rkqtTAG           ,
00157                           iterator       tINDEX            );
00158 
00165           virtual void insertUpdating (const QTTag& rkqtTAG)
00166           {
00167             insertAs (rkqtTAG->identifier(), rkqtTAG, end());
00168           }
00169 
00178           virtual void insertUpdating (const QTTag& rkqtTAG, iterator tINDEX)
00179           {
00180             insertAs (rkqtTAG->identifier(), rkqtTAG, tINDEX);
00181           }
00182 
00187           virtual void insert (const QTTag& rkqtTAG)
00188           {
00189             insertUpdating (rkqtTAG);
00190           }
00191 
00198           virtual void insert (const QTTag& rkqtTAG, iterator tINDEX)
00199           {
00200             insertUpdating (rkqtTAG, tINDEX);
00201           }
00202 
00203           void reset (void)
00204           {
00205             iterator   I    = tTagList.begin();
00206             iterator   tEnd = tTagList.end();
00207 
00208             TTag::reset();
00209             for (; ( I != tEnd ) ;++I)
00210             {
00211               (*I)->reset();
00212             }
00213           }
00214 
00221           void setClass (const TString& rkyCLASS, bool gDELEGATE = false);
00222 
00229           void setClass (const char* pkcCLASS, bool gDELEGATE = false);
00230 
00236           void setId (const char* pkcID, bool gDELEGATE = false);
00237 
00243           void setId (const TString& rkyID, bool gDELEGATE = false);
00244 
00245           void update (void)
00246           {
00247             iterator   I    = tTagList.begin();
00248             iterator   tEnd = tTagList.end();
00249 
00250             for (; ( I != tEnd ) ;++I)
00251             {
00252               (*I)->update();
00253             }
00254           }
00255 
00256 
00257         public:
00258 
00259           //
00260           //  S E L E C T O R S
00261           //
00262 
00263           iterator begin (void)
00264           {
00265             return tTagList.begin();
00266           }
00267 
00268           const_iterator begin (void) const
00269           {
00270             return tTagList.begin();
00271           }
00272 
00273           iterator end (void)
00274           {
00275             return tTagList.end();
00276           }
00277 
00278           const_iterator end (void) const
00279           {
00280             return tTagList.end();
00281           }
00282 
00289           virtual QTTag findTag (const TString& rkyIDENTIFIER) const;
00290 
00297           virtual bool hasTag (const TString& rkyIDENTIFIER) const
00298           {
00299             return !findTag (rkyIDENTIFIER).isNull();
00300           }
00301 
00302           QTTag tag (const TString& rkyIDENTIFIER) const;
00303 
00310           const TTag& operator [] (const char* pkcIDENTIFIER) const
00311           {
00312             return *tag (pkcIDENTIFIER);
00313           }
00314 
00321           const TTag& operator [] (const TString& rkyIDENTIFIER) const
00322           {
00323             return *tag (rkyIDENTIFIER);
00324           }
00325 
00332           TTag& operator [] (const char* pkcIDENTIFIER)
00333           {
00334             return *tag (pkcIDENTIFIER);
00335           }
00336 
00343           TTag& operator [] (const TString& rkyIDENTIFIER)
00344           {
00345             return *tag (rkyIDENTIFIER);
00346           }
00347 
00353           size_type size (void) const
00354           {
00355             return tTagList.size();
00356           }
00357 
00358 
00359         protected:
00360 
00361           //
00362           //  S E L E C T O R S
00363           //
00364 
00365           void writeUsing ( std::basic_ostream<char>& rtTARGET_OSTREAM        ,
00366                             const TString&            rkyQUALIFIED_IDENTIFIER ) const;
00367 
00368       };  // class TContainer
00369 
00370     }  // namespace html
00371 
00372   }  // namespace text
00373 
00374 }  // namespace mpcl
00375 
00376 
00377 #endif  // not _MPCL_TEXT_HTML_CONTAINER__

Generated on Mon Oct 13 02:35:22 2003 for MPCL by doxygen1.2.18