/* vim: set sw=4 sts=4 et foldmethod=syntax : *//* * Copyright (c) 2007 Tiziano Müller * Copyright (c) 2007 David Leverton * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General * Public License version 2, as published by the Free Software Foundation. * * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with * this program; if not, write to the Free Software Foundation, Inc., 59 Temple * Place, Suite 330, Boston, MA 02111-1307 USA */#ifndef PALUDIS_GUARD_PALUDIS_UTIL_ELF_DYNAMIC_SECTION_HH#define PALUDIS_GUARD_PALUDIS_UTIL_ELF_DYNAMIC_SECTION_HH 1#include<paludis/util/elf_sections.hh>#include<paludis/util/clone.hh>#include<paludis/util/singleton.hh>#include<paludis/util/pimp.hh>#include<paludis/util/wrapped_forward_iterator-fwd.hh>#include<paludis/util/simple_visitor.hh>#include<paludis/util/type_list.hh>#include<memory>#include<string>#include<iosfwd>namespacepaludis{template<typenameElfType_>classDynamicEntry;template<typenameElfType_>classDynamicEntryUnknown;template<typenameElfType_>classDynamicEntryValue;template<typenameElfType_>classDynamicEntryPointer;template<typenameElfType_>classDynamicEntryString;template<typenameElfType_>classDynamicEntryFlag;template<typenameElfType_>classDynamicEntry:publicvirtualDeclareAbstractAcceptMethods<DynamicEntry<ElfType_>,typenameMakeTypeList<DynamicEntryUnknown<ElfType_>,DynamicEntryValue<ElfType_>,DynamicEntryPointer<ElfType_>,DynamicEntryString<ElfType_>,DynamicEntryFlag<ElfType_>>::Type>,publicvirtualCloneable<DynamicEntry<ElfType_>>{private:std::string_tag_name;typenameElfType_::Word_index;public:DynamicEntry(conststd::string&);~DynamicEntry();virtualvoidinitialize(typenameElfType_::Word,consttypenameElfType_::DynamicEntry&entry);std::stringtag_name()const{return_tag_name;}std::stringdescription()const;};template<typenameElfType_>classDynamicEntryUnknown:publicvirtualDynamicEntry<ElfType_>,publicImplementAcceptMethods<DynamicEntry<ElfType_>,DynamicEntryUnknown<ElfType_>>,publicCloneUsingThis<DynamicEntry<ElfType_>,DynamicEntryUnknown<ElfType_>>{public:DynamicEntryUnknown();virtual~DynamicEntryUnknown();};template<typenameElfType_>classDynamicEntryFlag:publicvirtualDynamicEntry<ElfType_>,publicImplementAcceptMethods<DynamicEntry<ElfType_>,DynamicEntryFlag<ElfType_>>,publicCloneUsingThis<DynamicEntry<ElfType_>,DynamicEntryFlag<ElfType_>>{public:DynamicEntryFlag(conststd::string&);~DynamicEntryFlag();};template<typenameElfType_>classDynamicEntryValue:publicvirtualDynamicEntry<ElfType_>,publicImplementAcceptMethods<DynamicEntry<ElfType_>,DynamicEntryValue<ElfType_>>,publicCloneUsingThis<DynamicEntry<ElfType_>,DynamicEntryValue<ElfType_>>{private:typenameElfType_::DynamicValue_value;public:DynamicEntryValue(conststd::string&);virtual~DynamicEntryValue();virtualvoidinitialize(typenameElfType_::Word,consttypenameElfType_::DynamicEntry&entry);typenameElfType_::DynamicValueoperator()()const{return_value;}};template<typenameElfType_>classDynamicEntryPointer:publicvirtualDynamicEntry<ElfType_>,publicImplementAcceptMethods<DynamicEntry<ElfType_>,DynamicEntryPointer<ElfType_>>,publicCloneUsingThis<DynamicEntry<ElfType_>,DynamicEntryPointer<ElfType_>>{private:typenameElfType_::DynamicPointer_pointer;public:DynamicEntryPointer(conststd::string&);virtual~DynamicEntryPointer();virtualvoidinitialize(typenameElfType_::Word,consttypenameElfType_::DynamicEntry&);typenameElfType_::DynamicPointeroperator()()const{return_pointer;}};namespacelittlelf_internals{template<typenameElfType_>classDynEntriesStringResolvingVisitor;}template<typenameElfType_>classDynamicEntryString:publicvirtualDynamicEntry<ElfType_>,publicImplementAcceptMethods<DynamicEntry<ElfType_>,DynamicEntryString<ElfType_>>,publicCloneUsingThis<DynamicEntry<ElfType_>,DynamicEntryString<ElfType_>>{friendclasslittlelf_internals::DynEntriesStringResolvingVisitor<ElfType_>;private:typenameElfType_::DynamicValue_value;std::string_str;public:DynamicEntryString(conststd::string&);virtual~DynamicEntryString();virtualvoidinitialize(typenameElfType_::Word,consttypenameElfType_::DynamicEntry&);std::stringoperator()()const{return_str;}private:voidresolve_string(std::stringstr){_str=str;}typenameElfType_::DynamicValueget_string_index()const{return_value;}};template<typenameElfType_>classDynamicEntries:publicSingleton<DynamicEntries<ElfType_>>{friendclassSingleton<DynamicEntries>;private:Pimp<DynamicEntries>_imp;public:voidregister_type(typenameElfType_::DynamicTag,std::shared_ptr<DynamicEntry<ElfType_>>);std::shared_ptr<DynamicEntry<ElfType_>>get_entry(typenameElfType_::DynamicTag)const;boolhas_entry(typenameElfType_::DynamicTag)const;private:DynamicEntries();~DynamicEntries();};template<typenameElfType_>structDynamicSectionEntryIteratorTag;template<typenameElfType_>classPALUDIS_VISIBLEDynamicSection:publicSection<ElfType_>,publicImplementAcceptMethods<Section<ElfType_>,DynamicSection<ElfType_>>{private:Pimp<DynamicSection>_imp;public:DynamicSection(typenameElfType_::Word,consttypenameElfType_::SectionHeader&,std::istream&,bool);virtual~DynamicSection();virtualstd::stringget_type()const;voidresolve_entry_names(Section<ElfType_>&);typedefDynamicSectionEntryIteratorTag<ElfType_>EntryIteratorTag;typedefWrappedForwardIterator<EntryIteratorTag,DynamicEntry<ElfType_>>EntryIterator;EntryIteratorentry_begin()const;EntryIteratorentry_end()const;};}#endif