From b31f0cfc4dc481e15df07d7ab12249c539333910 Mon Sep 17 00:00:00 2001 From: Julien Rioux Date: Tue, 20 Sep 2011 17:25:07 +0000 Subject: [PATCH] Fixes to Format.{h,cpp} following advices from Richard and Vincent. Caching the string value of extensions is not necessary. It was a nice textbook exercise in getter/setter methods but it is cause for confusion and prone to mistakes in maintenance. Also, extension_list_ doesn't need to be mutable. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39714 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Format.cpp | 9 +++++++-- src/Format.h | 6 ++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Format.cpp b/src/Format.cpp index 13c8cfff7a..189754370b 100644 --- a/src/Format.cpp +++ b/src/Format.cpp @@ -93,7 +93,7 @@ bool operator<(Format const & a, Format const & b) Format::Format(string const & n, string const & e, string const & p, string const & s, string const & v, string const & ed, int flags) - : name_(n), extensions_(e), prettyname_(p), shortcut_(s), viewer_(v), + : name_(n), prettyname_(p), shortcut_(s), viewer_(v), editor_(ed), flags_(flags) { extension_list_ = getVectorFromString(e, ","); @@ -107,6 +107,12 @@ bool Format::dummy() const } +string const Format::extensions() const +{ + return getStringFromVector(extension_list_, ", "); +} + + bool Format::hasExtension(string const & e) const { return (find(extension_list_.begin(), extension_list_.end(), e) @@ -130,7 +136,6 @@ string const Format::parentFormat() const void Format::setExtensions(string const & e) { - extensions_ = e; extension_list_ = getVectorFromString(e, ","); } diff --git a/src/Format.h b/src/Format.h index 335b484a55..e9ac7a47a9 100644 --- a/src/Format.h +++ b/src/Format.h @@ -63,7 +63,7 @@ public: return extension_list_.empty() ? empty_string() : extension_list_[0]; } /// - std::string const & extensions() const { return extensions_; } + std::string const extensions() const; /// void setExtensions(std::string const & v); /// @@ -96,9 +96,7 @@ private: /// Internal name. Needs to be unique. std::string name_; /// Filename extensions, the first one being the default - mutable std::vector extension_list_; - /// All filename extensions - std::string extensions_; + std::vector extension_list_; /// Name presented to the user. Needs to be unique. std::string prettyname_; /// Keyboard shortcut for the View and Export menu. -- 2.39.5