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
00028
00029
00030
00031
00037 #if !defined( _OESS_1__SCHEME__IMPL__CLS_TAGS_HPP_ )
00038 #define _OESS_1__SCHEME__IMPL__CLS_TAGS_HPP_
00039
00040 #include <cls_2/h/tag_no_value.hpp>
00041 #include <cls_2/h/tag_vector_of_tags.hpp>
00042 #include <cls_2/h/tag_text.hpp>
00043 #include <cls_2/scalar/h/tag_scalar.hpp>
00044 #include <cls_2/scalar/h/nonspace_format.hpp>
00045 #include <cls_2/scalar/h/min_max.hpp>
00046
00047 namespace oess_1 {
00048
00049 namespace scheme {
00050
00051 namespace impl {
00052
00053
00054
00055
00056
00057
00058
00059
00060
00069 class tag_base_t :
00070 public cls_2::tag_scalar_t< std::string,
00071 cls_2::scalar_nonspace_format_t >
00072 {
00073 typedef cls_2::tag_scalar_t< std::string,
00074 cls_2::scalar_nonspace_format_t > base_type_t;
00075
00076 public :
00077 tag_base_t();
00078
00079
00080 tag_base_t(
00081 const char * tag_name,
00082 bool is_mandatory );
00083 virtual ~tag_base_t();
00084
00085
00086 const std::string &
00087 query_type_name() const;
00088
00089
00090 bool
00091 is_virtual() const;
00092
00093
00094 void
00095 make_defined(
00096 const std::string & name,
00097 bool is_virtual );
00098
00099 private :
00100 cls_2::tag_no_value_t m_tag_virtual;
00101
00102
00103 cls_2::tag_no_value_t m_tag_public;
00104 };
00105
00106
00107
00108
00109
00110
00111
00112
00113 class tag_cpp_mapping_t :
00114 public cls_2::tag_no_value_t
00115 {
00116 typedef cls_2::tag_no_value_t base_type_t;
00117 public :
00119 tag_cpp_mapping_t(
00121 cls_2::tag_t & owner );
00122 virtual ~tag_cpp_mapping_t();
00123
00124
00125 bool
00126 is_name_defined() const;
00127
00128
00129 const std::string &
00130 query_type_name() const;
00131
00132
00133 void
00134 make_defined(
00135 const std::string & name );
00136
00137 private :
00138 cls_2::tag_scalar_t< std::string,
00139 cls_2::scalar_nonspace_format_t >
00140 m_tag_name;
00141 };
00142
00143
00144
00145
00146
00150 class tag_attr_type_t :
00151 public cls_2::tag_scalar_t< std::string,
00152 cls_2::scalar_nonspace_format_t >
00153 {
00154 typedef cls_2::tag_scalar_t< std::string,
00155 cls_2::scalar_nonspace_format_t > base_type_t;
00156 public :
00158 tag_attr_type_t(
00159 cls_2::tag_t & owner );
00160 virtual ~tag_attr_type_t();
00161
00164
00165 virtual int
00166 on_finish( cls_2::parser_context_t & context );
00167
00169 const std::string &
00170 query_type_name() const;
00171
00173 bool
00174 is_ptr() const;
00175
00177
00178 bool
00179 is_extension() const;
00180
00182 void
00183 make_defined_as_value(
00184 const std::string & name );
00185
00187 void
00188 make_defined_as_ptr(
00189 const std::string & name );
00190
00192
00193 void
00194 make_defined_as_extension(
00195 const std::string & name );
00196
00197 private :
00199 cls_2::tag_no_value_t m_tag_ptr;
00201
00202 cls_2::tag_no_value_t m_extension;
00203 };
00204
00205
00206
00207
00208
00218 class tag_attr_present_if_t
00219 : public cls_2::tag_no_value_t
00220 {
00222 typedef cls_2::tag_no_value_t base_type_t;
00223 public :
00225 tag_attr_present_if_t(
00226 cls_2::tag_t & owner );
00227 virtual ~tag_attr_present_if_t();
00228
00230 bool
00231 is_cpp() const;
00232
00234
00237 std::string
00238 cpp() const;
00239
00241
00244 void
00245 make_cpp(
00246 const std::string & value );
00247
00248 private :
00250 cls_2::tag_text_t m_cpp;
00251 };
00252
00253
00254
00255
00256
00268 class tag_attr_default_t
00269 : public cls_2::tag_no_value_t
00270 {
00272 typedef cls_2::tag_no_value_t base_type_t;
00273 public :
00275 tag_attr_default_t(
00276 cls_2::tag_t & owner );
00277 virtual ~tag_attr_default_t();
00278
00280 bool
00281 is_cpp() const;
00282
00284
00287 std::string
00288 cpp() const;
00289
00291
00294 void
00295 make_cpp(
00296 const std::string & value );
00297
00299 const tag_attr_present_if_t &
00300 present_if() const;
00301
00303
00306 tag_attr_present_if_t &
00307 changeable_present_if();
00308
00309 private :
00311 cls_2::tag_text_t m_cpp;
00312
00314 tag_attr_present_if_t m_present_if;
00315 };
00316
00317
00318
00319
00320
00321
00322
00323
00324 class tag_attr_t :
00325 public cls_2::tag_scalar_t< std::string,
00326 cls_2::scalar_nonspace_format_t >
00327 {
00328 typedef cls_2::tag_scalar_t< std::string,
00329 cls_2::scalar_nonspace_format_t > base_type_t;
00330 public :
00331 tag_attr_t();
00332
00333 tag_attr_t(
00334 const char * tag_name,
00335 bool is_mandatory );
00336 virtual ~tag_attr_t();
00337
00338
00339 const std::string &
00340 query_attr_name() const;
00341
00342
00343 const tag_attr_type_t &
00344 query_attr_type() const;
00345
00346 tag_attr_type_t &
00347 query_attr_type();
00348
00349
00350
00351
00352
00353 void
00354 make_defined_as_single_obj(
00355 const std::string & name );
00356
00357
00358 bool
00359 is_stl_vector() const;
00360
00361 void
00362 make_defined_as_stl_vector(
00363 const std::string & name );
00364
00365
00366 bool
00367 is_stl_list() const;
00368
00369 void
00370 make_defined_as_stl_list(
00371 const std::string & name );
00372
00373
00374 bool
00375 is_stl_deque() const;
00376
00377 void
00378 make_defined_as_stl_deque(
00379 const std::string & name );
00380
00381
00382 bool
00383 is_stl_set() const;
00384
00385 void
00386 make_defined_as_stl_set(
00387 const std::string & name );
00388
00389
00390 bool
00391 is_stl_multiset() const;
00392
00393 void
00394 make_defined_as_stl_multiset(
00395 const std::string & name );
00396
00397
00398 bool
00399 is_stl_map() const;
00400
00401 void
00402 make_defined_as_stl_map(
00403 const std::string & name,
00404 const std::string & key_type );
00405
00406
00407 bool
00408 is_stl_multimap() const;
00409
00410 void
00411 make_defined_as_stl_multimap(
00412 const std::string & name,
00413 const std::string & key_type );
00414
00415
00416 bool
00417 is_fixed_vector() const;
00418
00419 void
00420 make_defined_as_fixed_vector(
00421 const std::string & name,
00422 size_t capacity );
00423
00424
00425 const std::string &
00426 query_map_key() const;
00427
00428
00429 size_t
00430 query_fixed_vector_size() const;
00431
00433
00434 const tag_attr_default_t &
00435 query_default() const;
00436
00438
00439 tag_attr_default_t &
00440 query_default();
00441
00442 private :
00443 typedef cls_2::tag_scalar_t< std::string,
00444 cls_2::scalar_nonspace_format_t >
00445 tag_nonspaced_string_t;
00446
00447 tag_attr_type_t m_tag_type;
00448
00449 cls_2::tag_no_value_t m_tag_stl_vector;
00450 cls_2::tag_no_value_t m_tag_stl_list;
00451 cls_2::tag_no_value_t m_tag_stl_deque;
00452 cls_2::tag_no_value_t m_tag_stl_set;
00453 cls_2::tag_no_value_t m_tag_stl_map;
00454
00455 cls_2::tag_no_value_t m_tag_is_multiset;
00456 cls_2::tag_no_value_t m_tag_is_multimap;
00457
00458 tag_nonspaced_string_t m_tag_map_key;
00459
00460 cls_2::scalar_constraint::min_max_t< unsigned long >
00461 m_fixed_vector_constr;
00462 cls_2::tag_scalar_t< unsigned long >
00463 m_tag_fixed_vector;
00464
00466
00467 tag_attr_default_t m_default;
00468
00469 void
00470 init_tags();
00471 };
00472
00473 class tag_extension_t;
00474
00475
00476
00477
00478
00496 class tag_extension_wrapper_t
00497 : public cls_2::tag_no_value_t
00498 {
00500 typedef cls_2::tag_no_value_t base_type_t;
00501 public :
00503 tag_extension_wrapper_t(
00504 cls_2::tag_t & owner,
00505 const char * name,
00506 bool is_mandatory );
00507 virtual ~tag_extension_wrapper_t();
00508
00510
00513 const tag_extension_t *
00514 get() const;
00515
00517 tag_extension_t &
00518 make_extension();
00519
00522
00523 virtual int
00524 on_start( cls_2::parser_context_t & ctx );
00525
00526 virtual int
00527 on_finish( cls_2::parser_context_t & context );
00528
00529 virtual int
00530 on_tag( cls_2::parser_context_t & context,
00531 cls_2::tag_t & tag );
00532
00533 virtual int
00534 on_tok_space(
00535 cls_2::parser_context_t & context,
00536 const char * tok_value );
00537
00538 virtual int
00539 on_tok_nonspace(
00540 cls_2::parser_context_t & context,
00541 const char * tok_value );
00542
00543 virtual int
00544 on_tok_string(
00545 cls_2::parser_context_t & context,
00546 const char * tok_value );
00547
00548 virtual cls_2::tag_t **
00549 query_tags();
00550
00551 virtual void
00552 reset();
00553
00554 virtual void
00555 format(
00556 cls_2::tag_formatter_t & fmt );
00558
00559 private :
00561 auto_ptr_3::obj_ptr_t< tag_extension_t > m_extension;
00562 };
00563
00564
00565
00566
00567
00572 class tag_extension_t
00573 : public cls_2::tag_no_value_t
00574 {
00576 typedef cls_2::tag_no_value_t base_type_t;
00577 public :
00579 tag_extension_t();
00580 virtual ~tag_extension_t();
00581
00583
00586 const tag_extension_t *
00587 extension() const;
00588
00590 tag_extension_t &
00591 make_extension();
00592
00595 const cls_2::tag_vector_of_tags_t< tag_attr_t > &
00596 query_attrs() const;
00597
00598 cls_2::tag_vector_of_tags_t< tag_attr_t > &
00599 query_attrs();
00601
00602 private :
00604 cls_2::tag_vector_of_tags_t< tag_attr_t >
00605 m_attrs;
00606
00608 tag_extension_wrapper_t m_extension;
00609 };
00610
00611
00612
00613
00614
00631 class tag_type_t
00632 : public cls_2::tag_scalar_t< std::string,
00633 cls_2::scalar_nonspace_format_t >
00634 {
00636 typedef cls_2::tag_scalar_t< std::string,
00637 cls_2::scalar_nonspace_format_t > base_type_t;
00638 public :
00639 tag_type_t();
00641 tag_type_t(
00642 const char * tag_name,
00643 bool is_mandatory );
00644 virtual ~tag_type_t();
00645
00647 const std::string &
00648 query_type_name() const;
00649
00651 bool
00652 is_abstract() const;
00653
00658 bool
00659 is_extensible() const;
00660
00665 bool
00666 is_subclassing_by_extension() const;
00667
00670 void
00671 make_defined(
00672 const std::string & name,
00673 bool is_abstract,
00674 bool is_extensible );
00675
00678 const cls_2::tag_vector_of_tags_t< tag_base_t > &
00679 query_bases() const;
00680
00681 cls_2::tag_vector_of_tags_t< tag_base_t > &
00682 query_bases();
00684
00687 const cls_2::tag_vector_of_tags_t< tag_attr_t > &
00688 query_attrs() const;
00689
00690 cls_2::tag_vector_of_tags_t< tag_attr_t > &
00691 query_attrs();
00693
00696 const tag_cpp_mapping_t &
00697 query_cpp_mapping() const;
00698
00699 tag_cpp_mapping_t &
00700 query_cpp_mapping();
00702
00704
00708 const tag_extension_t *
00709 extension() const;
00710
00712
00715 tag_extension_t &
00716 make_extension();
00717
00719
00722 void
00723 turn_subclassing_by_extension_on();
00724
00726
00729 bool
00730 is_extension_of(
00733 std::string & class_name ) const;
00734
00740 void
00741 derive_as_extension_of( const std::string & name );
00742
00743 private :
00745 cls_2::tag_no_value_t m_tag_abstract;
00746
00751 cls_2::tag_no_value_t m_extensible;
00752
00757 cls_2::tag_no_value_t m_subclassing_by_extension;
00758
00764 cls_2::tag_scalar_t< std::string,
00765 cls_2::scalar_nonspace_format_t >
00766 m_extension_of;
00767
00769 cls_2::tag_vector_of_tags_t< tag_base_t >
00770 m_tag_base;
00771
00773 cls_2::tag_vector_of_tags_t< tag_attr_t >
00774 m_tag_attr;
00775
00777 tag_cpp_mapping_t m_tag_cpp_mapping;
00778
00783 tag_extension_wrapper_t m_extension;
00784 };
00785
00786
00787
00788
00789
00791
00795 bool
00796 cls_parse(
00798 std::istream & in,
00801 const char * opt_stream_name,
00803 cls_2::tag_vector_of_tags_t< tag_type_t > & tag,
00805 std::string & error_desc );
00806
00807 }
00808
00809 }
00810
00811 }
00812
00813 #endif