00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef CEYLAN_XML_VISITOR_H_
00028 #define CEYLAN_XML_VISITOR_H_
00029
00030
00031 #include "CeylanTree.h"
00032 #include "CeylanXML.h"
00033 #include "CeylanVisitor.h"
00034 #include "CeylanXMLElement.h"
00035
00036
00037 #include <string>
00038 #include <stack>
00039 #include <list>
00040
00041
00042
00043
00044 namespace Ceylan
00045 {
00046
00047
00048
00049 namespace System
00050 {
00051
00052
00053
00054 class OutputStream ;
00055
00056
00057 }
00058
00059
00060
00061
00062 namespace XML
00063 {
00064
00065
00066
00067
00068 class XMLElement ;
00069
00070
00071
00076 class CEYLAN_DLL XMLVisitorException : public Ceylan::XML::XMLException
00077 {
00078
00079 public:
00080
00081 explicit XMLVisitorException( const std::string & reason ) ;
00082
00083 virtual ~XMLVisitorException() throw() ;
00084
00085 } ;
00086
00087
00088
00090 class XMLMarkup ;
00091
00092
00093
00095 class XMLText ;
00096
00097
00098
00099
00106 class CEYLAN_DLL XMLVisitor : public TreeHeightAwareVisitor<XMLElement>
00107 {
00108
00109
00110 public:
00111
00112
00113
00118 XMLVisitor() ;
00119
00120
00121
00126 virtual ~XMLVisitor() throw() ;
00127
00128
00129
00142 virtual void visit( XMLMarkup & xmlMarkup ) = 0 ;
00143
00144
00145
00158 virtual void visit( XMLText & xmlText ) = 0 ;
00159
00160
00161
00173 virtual const std::string toString(
00174 Ceylan::VerbosityLevels level = Ceylan::high ) const ;
00175
00176
00177
00178
00179 private:
00180
00181
00182
00193 XMLVisitor( const XMLVisitor & source ) ;
00194
00195
00196
00204 XMLVisitor & operator = ( const XMLVisitor & source ) ;
00205
00206
00207 } ;
00208
00209
00210
00211
00212
00222 class CEYLAN_DLL XMLSavingVisitor : public XMLVisitor
00223 {
00224
00225
00226 public:
00227
00228
00229
00240 XMLSavingVisitor( System::OutputStream & output ) ;
00241
00242
00243
00248 virtual ~XMLSavingVisitor() throw() ;
00249
00250
00251
00253 virtual Height getHeight() const ;
00254
00255
00257 virtual void incrementHeight() ;
00258
00259
00261 virtual void decrementHeight() ;
00262
00263
00264
00277 virtual void visit( XMLMarkup & xmlMarkup ) ;
00278
00279
00280
00293 virtual void visit( XMLText & xmlText ) ;
00294
00295
00296
00308 virtual const std::string toString(
00309 Ceylan::VerbosityLevels level = Ceylan::high ) const ;
00310
00311
00312
00314 static std::string OffsetForMarkup ;
00315
00316
00317 typedef std::string ClosingMarkup ;
00318
00319
00320
00321
00322 protected:
00323
00324
00326 System::OutputStream * _output ;
00327
00328
00329
00330
00331
00332
00333
00334
00335 #pragma warning( push )
00336 #pragma warning( disable : 4251 )
00337
00338 std::stack<ClosingMarkup> _markupsToClose ;
00339
00340 #pragma warning( pop )
00341
00342
00343
00344 private:
00345
00346
00357 XMLSavingVisitor( const XMLSavingVisitor & source ) ;
00358
00359
00367 XMLSavingVisitor & operator = (
00368 const XMLSavingVisitor & source ) ;
00369
00370
00371 } ;
00372
00373
00374
00375
00376
00387 class CEYLAN_DLL XMLSearchingVisitor : public XMLVisitor
00388 {
00389
00390
00391 public:
00392
00393
00394
00403 XMLSearchingVisitor( MarkupName & searchedMarkupName ) ;
00404
00405
00406
00411 virtual ~XMLSearchingVisitor() throw() ;
00412
00413
00414
00446 std::list<XMLMarkup *> & getMatchingMarkups() ;
00447
00448
00449
00459 virtual void visit( XMLMarkup & xmlMarkup ) ;
00460
00461
00462
00471 virtual void visit( XMLText & xmlText ) ;
00472
00473
00474
00486 virtual const std::string toString(
00487 Ceylan::VerbosityLevels level = Ceylan::high ) const ;
00488
00489
00490
00491
00492 protected:
00493
00494
00496 MarkupName _searchedMarkup ;
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506 #pragma warning( push )
00507 #pragma warning( disable : 4251 )
00508
00510 std::list<XMLMarkup *> _matchingNodes ;
00511
00512 #pragma warning( pop )
00513
00514
00515
00516 private:
00517
00518
00529 XMLSearchingVisitor( const XMLSearchingVisitor & source ) ;
00530
00531
00532
00540 XMLSearchingVisitor & operator = (
00541 const XMLSearchingVisitor & source ) ;
00542
00543
00544
00545 } ;
00546
00547
00548 }
00549
00550
00551 }
00552
00553
00554
00555 #endif // CEYLAN_XML_VISITOR_H_
00556