From 1fc435298c02d76cb55d31464ddf799f02321ed9 Mon Sep 17 00:00:00 2001 From: Adam Wardynski <award@.(win7-laptop)> Date: Fri, 6 May 2011 01:21:34 +0200 Subject: [PATCH] Update string repr of WcclFile with imports section. --- libwccl/wcclfile.cpp | 6 ++++++ libwccl/wcclfile.h | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/libwccl/wcclfile.cpp b/libwccl/wcclfile.cpp index 9509c5d..377018e 100644 --- a/libwccl/wcclfile.cpp +++ b/libwccl/wcclfile.cpp @@ -38,6 +38,12 @@ boost::shared_ptr<const TagRuleSequence> WcclFile::get_tag_rules_ptr() const std::ostream& WcclFile::write_to(std::ostream& os) const { + if (has_lexicons()) { + foreach(const Lexicons::map_t::value_type& v, lexicons_->get_lexicons()) { + os << "import(\"" << v.second->file_name() << ", \"" + << v.second->name() << "\")\n"; + } + } foreach(const boost::shared_ptr<FunctionalOpSequence>& s, all_sections_) { os << s->to_string(tagset_) << '\n'; } diff --git a/libwccl/wcclfile.h b/libwccl/wcclfile.h index 2919b49..f287a81 100644 --- a/libwccl/wcclfile.h +++ b/libwccl/wcclfile.h @@ -77,6 +77,7 @@ public: void import_lexicon(const boost::shared_ptr<Lexicon>& lexicon); bool has_lexicon(const std::string& name) const; + bool has_lexicons() const; boost::shared_ptr<const Lexicon> get_lexicon_ptr(const std::string& name) const; const Lexicon& get_lexicon(const std::string& name) const; boost::shared_ptr<const Lexicons> get_lexicons_ptr() const; @@ -307,6 +308,12 @@ bool WcclFile::has_lexicon(const std::string& name) const return lexicons_->has_lexicon(name); } +inline +bool WcclFile::has_lexicons() const +{ + return lexicons_; +} + inline boost::shared_ptr<const Lexicon> WcclFile::get_lexicon_ptr(const std::string& name) const { -- GitLab