OKlibrary  0.2.1.6
RefactoringIncludeHandling.hpp
Go to the documentation of this file.
00001 // Oliver Kullmann, 23.12.2005 (Swansea)
00002 /* Copyright 2005 - 2007 Oliver Kullmann
00003 This file is part of the OKlibrary. OKlibrary is free software; you can redistribute
00004 it and/or modify it under the terms of the GNU General Public License as published by
00005 the Free Software Foundation and included in this library; either version 3 of the
00006 License, or any later version. */
00007 
00013 #ifndef REFACTORINGINCLUDEHANDLING_jjHHbgt6
00014 #define REFACTORINGINCLUDEHANDLING_jjHHbgt6
00015 
00016 #include <OKlib/Concepts/LibraryBasics.hpp>
00017 
00018 #include <OKlib/traits/TypeTraits.hpp>
00019 
00020 #include <OKlib/Programming/Refactoring/traits/string_type.hpp>
00021 #include <OKlib/Programming/Refactoring/traits/size_type.hpp>
00022 
00023 #include <OKlib/Concepts/InputOutput.hpp>
00024 
00025 #include <OKlib/Programming/Refactoring/BoostPathCorrected.hpp>
00026 
00027 #include <OKlib/Programming/Refactoring/IncludeHandling.hpp>
00028 
00029 namespace OKlib {
00030   namespace Concepts {
00031 
00032     struct IncludeDirective_tag : virtual BasicRequirements_tag, virtual FullyConstructibleEq_tag,  virtual EqualitySubstitutable_tag, virtual OutputStreamable_tag {};
00033 
00034     template <class IncDir>
00035     struct IncludeDirective {
00036       typedef typename ::OKlib::Refactoring::traits::string_type<IncDir>::type string_type;
00037       typedef typename ::OKlib::Refactoring::traits::size_type<IncDir>::type size_type;
00038       typedef ::OKlib::Refactoring::Include_forms Include_forms;
00039       BOOST_STATIC_ASSERT(::OKlib::traits::is_unqualified_unsigned_integral<size_type>::value);
00040       void constraints() {
00041         OKLIB_MODELS_CONCEPT_TAG(IncDir, IncludeDirective);
00042 
00043         OKLIB_MODELS_CONCEPT_REQUIRES(IncDir, BasicRequirements);
00044         OKLIB_MODELS_CONCEPT_TAG(IncDir, BasicRequirements);
00045         OKLIB_MODELS_CONCEPT_REQUIRES(IncDir, FullyConstructibleEq);
00046         OKLIB_MODELS_CONCEPT_TAG(IncDir, FullyConstructibleEq);
00047         OKLIB_MODELS_CONCEPT_REQUIRES(IncDir, EqualitySubstitutable);
00048         OKLIB_MODELS_CONCEPT_TAG(IncDir, EqualitySubstitutable);
00049         OKLIB_MODELS_CONCEPT_REQUIRES(IncDir, OutputStreamable);
00050         OKLIB_MODELS_CONCEPT_TAG(IncDir, OutputStreamable);
00051 
00052         OKLIB_MODELS_CONCEPT_REQUIRES(string_type, FullyConstructible);
00053 
00054         IncDir(str_c, s_c, s_c, if_c);
00055         static_cast<boost::filesystem::path>(dir_c);
00056 
00057         size_type siz; string_type str; Include_forms inc;
00058         str = static_cast<string_type>(dir_c.header_file());
00059         static_cast<string_type&>(dir.header_file()) = str;
00060         siz = static_cast<size_type>(dir_c.number_spaces_after_hash());
00061         static_cast<size_type&>(dir.number_spaces_after_hash()) = siz;
00062         siz = static_cast<size_type>(dir_c.number_spaces_after_include());
00063         static_cast<size_type&>(dir.number_spaces_after_include()) = siz;
00064         inc = static_cast<Include_forms>(dir_c.include_form());
00065         static_cast<Include_forms&>(dir.include_form()) = inc;
00066         str = static_cast<string_type>(dir_c.opening());
00067         str = static_cast<string_type>(dir.opening());
00068         str = static_cast<string_type>(dir_c.closing());
00069         str = static_cast<string_type>(dir.closing());
00070       }
00071       IncDir dir;
00072       const IncDir dir_c;
00073       const size_type s_c;
00074       const OKlib::Refactoring::Include_forms if_c;
00075       const string_type str_c;
00076     };
00077 
00078     class IncludeDirective_Archetype {
00079       struct convertible_to_bool {
00080         operator bool() { return bool(); }
00081       };
00082     public :
00083       typedef IncludeDirective_tag concept_tag;
00084       struct string_type {};
00085       typedef unsigned int size_type; // ToDo: Can this be made more generic?
00086       convertible_to_bool operator ==(const IncludeDirective_Archetype&) const { return convertible_to_bool(); }
00087       convertible_to_bool operator !=(const IncludeDirective_Archetype&) const { return convertible_to_bool(); }
00088       friend std::ostream& operator <<(std::ostream& out, const IncludeDirective_Archetype&) { return out; }
00089       IncludeDirective_Archetype() {}
00090       IncludeDirective_Archetype(string_type,size_type,size_type,OKlib::Refactoring::Include_forms) {}
00091       operator boost::filesystem::path() const { return boost::filesystem::path(); }
00092     private :
00093       string_type str;
00094       size_type siz;
00095       OKlib::Refactoring::Include_forms inc;
00096     public :
00097       string_type header_file() const { return string_type(); }
00098       string_type& header_file() { return str; }
00099       size_type number_spaces_after_hash() const { return size_type(); }
00100       size_type& number_spaces_after_hash() { return siz; }
00101       size_type number_spaces_after_include() const { return size_type(); }
00102       size_type& number_spaces_after_include() { return siz; }
00103       OKlib::Refactoring::Include_forms include_form() const { return OKlib::Refactoring::Include_forms(); }
00104       OKlib::Refactoring::Include_forms& include_form() { return inc; }
00105       string_type opening() const { return string_type(); }
00106       string_type closing() const { return string_type(); }
00107     };
00108 
00109   }
00110 
00111 }
00112 
00113 #endif