]> git.lyx.org Git - features.git/commitdiff
Do not inherit from std::map.
authorRichard Heck <rgheck@comcast.net>
Thu, 14 Feb 2008 05:00:54 +0000 (05:00 +0000)
committerRichard Heck <rgheck@comcast.net>
Thu, 14 Feb 2008 05:00:54 +0000 (05:00 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22993 a592a061-630c-0410-9148-cb99ea01b6c8

src/BiblioInfo.cpp
src/BiblioInfo.h
src/frontends/qt4/GuiCitation.cpp
src/insets/InsetBibitem.cpp
src/insets/InsetBibtex.cpp

index 9f00a3753d53fbe3b9b5d80b7914dd69b1ce0737..1f76e55af391e411556a1c17fb9dd63f7de0f6f1 100644 (file)
@@ -42,8 +42,13 @@ namespace lyx {
 //
 //////////////////////////////////////////////////////////////////////
 
-BibTeXInfo::BibTeXInfo()
-       : isBibTeX(true)
+BibTeXInfo::BibTeXInfo(bool ib)
+       : isBibTeX_(ib)
+{}
+
+       
+BibTeXInfo::BibTeXInfo(docstring const & key, docstring const & type)
+       : isBibTeX_(true), bibKey_(key), entryType_(type)
 {}
 
        
@@ -97,7 +102,7 @@ static docstring familyName(docstring const & name)
 
 docstring const BibTeXInfo::getAbbreviatedAuthor() const
 {
-       if (!isBibTeX) 
+       if (!isBibTeX_
                return docstring();
  
        docstring author = getValueForField("author");
@@ -105,7 +110,7 @@ docstring const BibTeXInfo::getAbbreviatedAuthor() const
        if (author.empty()) {
                author = getValueForField("editor");
                if (author.empty())
-                       return bibKey;
+                       return bibKey_;
        }
 
        // OK, we've got some names. Let's format them.
@@ -126,7 +131,7 @@ docstring const BibTeXInfo::getAbbreviatedAuthor() const
 
 docstring const BibTeXInfo::getYear() const
 {
-       if (!isBibTeX) 
+       if (!isBibTeX_
                return docstring();
  
        docstring year = getValueForField("year");
@@ -138,7 +143,7 @@ docstring const BibTeXInfo::getYear() const
 
 docstring const BibTeXInfo::getInfo() const
 {
-       if (!isBibTeX) {
+       if (!isBibTeX_) {
                BibTeXInfo::const_iterator it = find(from_ascii("ref"));
                return it->second;
        }
index 7f57a31c6b54de510b5ad12a61bcefb2c36f849a..525cab50fdec27b0c290d1929d5622d18758d149 100644 (file)
@@ -73,13 +73,18 @@ std::vector<CiteStyle> const getCiteStyles(CiteEngine const );
 /// bibliography entry.
 /// The keys are BibTeX fields (e.g., author, title, etc), 
 /// and the values are the associated field values.
-class BibTeXInfo : public std::map<docstring, docstring> {
+class BibTeXInfo {
 public:
        ///
-       BibTeXInfo();
-       ///Search for the given field and return the associated info.
-       ///The point of this is that BibTeXInfo::operator[] has no const
-       ///form.
+       typedef std::map<docstring, docstring>::const_iterator const_iterator;
+       /// argument sets isBibTeX_, so should be false only if it's coming
+       /// from a bibliography environment
+       BibTeXInfo(bool ib = true);
+       /// constructor that sets the entryType
+       BibTeXInfo(docstring const & key, docstring const & type);
+       /// Search for the given field and return the associated info.
+       /// The point of this is that BibTeXInfo::operator[] has no const
+       /// form.
        docstring const & getValueForField(docstring const & field) const;
        ///
        docstring const & getValueForField(std::string const & field) const;
@@ -91,14 +96,32 @@ public:
        docstring const getYear() const;
        /// Returns formatted BibTeX data suitable for framing.
        docstring const getInfo() const;
+       ///
+       int count(docstring const & f) const { return bimap_.count(f); }
+       ///
+       const_iterator find(docstring const & f) const { return bimap_.find(f); }
+       ///
+       const_iterator end() const { return bimap_.end(); }
+       ///
+       docstring & operator[](docstring const & f) 
+               { return bimap_[f]; }
+       ///
+       docstring allData() const { return allData_; }
+       ///
+       void allData(docstring const & d) { allData_ = d; }
+       ///
+       docstring entryType() const { return entryType_; }
+private:
        /// the BibTeX key for this entry
-       docstring bibKey;
+       docstring bibKey_;
        /// a single string containing all BibTeX data associated with this key
-       docstring allData;
+       docstring allData_;
        /// the BibTeX entry type (article, book, incollection, ...)
-       docstring entryType;
+       docstring entryType_;
        /// true if from BibTeX; false if from bibliography environment
-       bool isBibTeX;
+       bool isBibTeX_;
+       /// our map: <field, value>
+       std::map <docstring, docstring> bimap_;
 };
 
 
index d9b8a4f8f03f4cff3bff79bf42cacee569754fda..1c6499586fa4240fa24b88da4145dde3cf85df40 100644 (file)
@@ -641,7 +641,7 @@ void GuiCitation::filterByEntryType(
                BiblioInfo::const_iterator cit = bibkeysInfo_.find(key);
                if (cit == bibkeysInfo_.end())
                        continue;
-               if (cit->second.entryType == entryType)
+               if (cit->second.entryType() == entryType)
                        result.push_back(key);
        }
        keyVector = result;
@@ -725,7 +725,7 @@ vector<docstring> GuiCitation::searchKeys(
                if (only_keys)
                        data = to_utf8(*it);
                else if (field.empty())
-                       data = to_utf8(*it) + ' ' + to_utf8(kvm.allData);
+                       data = to_utf8(*it) + ' ' + to_utf8(kvm.allData());
                else if (kvm.hasField(field))
                        data = to_utf8(kvm.getValueForField(field));
                
index db5bc53e4ec9ec8d454f9db54390529e92d56a0e..3a6f083cb065489a3ed1a488c2698c02fa2ab0c7 100644 (file)
@@ -198,12 +198,11 @@ void InsetBibitem::fillWithBibKeys(Buffer const & buf,
        BiblioInfo & keys, InsetIterator const & it) const
 {
        docstring const key = getParam("key");
-       BibTeXInfo keyvalmap;
+       BibTeXInfo keyvalmap(false);
        keyvalmap[from_ascii("label")] = getParam("label");
        DocIterator doc_it(it); 
        doc_it.forwardPos();
        keyvalmap[from_ascii("ref")] = doc_it.paragraph().asString(buf, false);
-       keyvalmap.isBibTeX = false;
        keys[key] = keyvalmap;
 }
 
index e80e839691408b0bc9640911f221caf3e2ee6df7..7d017204cee39baaf11364fea7fc901b5a1c932d 100644 (file)
@@ -740,8 +740,7 @@ void InsetBibtex::fillWithBibKeys(Buffer const & buffer,
                                docstring value;
                                docstring commaNewline;
                                docstring data;
-                               BibTeXInfo keyvalmap;
-                               keyvalmap.entryType = entryType;
+                               BibTeXInfo keyvalmap(key, entryType);
                                
                                bool readNext = removeWSAndComma(ifs);
  
@@ -773,9 +772,7 @@ void InsetBibtex::fillWithBibKeys(Buffer const & buffer,
 
                                // add the new entry
                                keylist.entryTypes.insert(entryType);
-                               keyvalmap.allData = data;
-                               keyvalmap.isBibTeX = true;
-                               keyvalmap.bibKey = key;
+                               keyvalmap.allData(data);
                                keylist[key] = keyvalmap;
                        }
                } //< searching '@'