]> git.lyx.org Git - features.git/commitdiff
Fixes to Format.{h,cpp} following advices from Richard and Vincent.
authorJulien Rioux <jrioux@lyx.org>
Tue, 20 Sep 2011 17:25:07 +0000 (17:25 +0000)
committerJulien Rioux <jrioux@lyx.org>
Tue, 20 Sep 2011 17:25:07 +0000 (17:25 +0000)
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
src/Format.h

index 13c8cfff7a1dec6e87ad5037da9e553ce269b715..189754370b95f242eb05a4853505c6be8b9b2bcf 100644 (file)
@@ -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, ",");
 }
 
index 335b484a552b48457a43f94975a86f82a6c03872..e9ac7a47a9f94a63018af35d61ff5771d6c6e076 100644 (file)
@@ -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<std::string> extension_list_;
-       /// All filename extensions
-       std::string extensions_;
+       std::vector<std::string> extension_list_;
        /// Name presented to the user. Needs to be unique.
        std::string prettyname_;
        /// Keyboard shortcut for the View and Export menu.