]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/controllers/biblio.h
Convert most of the bibtex machinery to docstring.
[lyx.git] / src / frontends / controllers / biblio.h
index d6277f16de426ca139e688fa3f0f28839e4eec97..55882cff56cbf998853885fe5f15ed1454d206f5 100644 (file)
@@ -6,24 +6,28 @@
  *
  * \author Angus Leeming
  *
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
  */
 
 #ifndef BIBLIOHELPERS_H
 #define BIBLIOHELPERS_H
 
-#ifdef __GNUG__
-#pragma interface
-#endif
+#include "support/docstring.h"
 
-#include "LString.h"
 #include <map>
 #include <vector>
 
+class Buffer;
+
 /** Functions of use to citation and bibtex GUI controllers and views */
+namespace lyx {
 namespace biblio {
 
-///
+class CiteEngine_enum;
+
+CiteEngine_enum getEngine(Buffer const &);
+
+
 enum CiteStyle {
        CITE,
        CITET,
@@ -35,44 +39,48 @@ enum CiteStyle {
        CITEYEARPAR
 };
 
-///
+
 enum Search {
-       ///
        SIMPLE,
-       ///
        REGEX
 };
 
-///
+
 enum Direction {
-       ///
        FORWARD,
-       ///
        BACKWARD
 };
 
+
+/** Each citation engine recognizes only a subset of all possible
+ *  citation commands. Given a latex command \c input, this function
+ *  returns an appropriate command, valid for \c engine.
+ */
+std::string const asValidLatexCommand(std::string const & input,
+                                     CiteEngine_enum const & engine);
+
 /// First entry is the bibliography key, second the data
-typedef std::map<string, string> InfoMap;
+typedef std::map<std::string, docstring> InfoMap;
 
 /// Returns a vector of bibliography keys
-std::vector<string> const getKeys(InfoMap const &);
+std::vector<std::string> const getKeys(InfoMap const &);
 
 /** Returns the BibTeX data associated with a given key.
     Empty if no info exists. */
-string const getInfo(InfoMap const &, string const &);
+docstring const getInfo(InfoMap const &, std::string const & key);
 
-// rturn the year from the bibtex data record
-string const getYear(InfoMap const & map, string const & key);
+/// return the year from the bibtex data record
+docstring const getYear(InfoMap const & map, std::string const & key);
 
 /// return the short form of an authorlist
-string const getAbbreviatedAuthor(InfoMap const & map, string const & key);
+docstring const getAbbreviatedAuthor(InfoMap const & map, std::string const & key);
 
 // return only the family name
-string const familyName(string const & name);
+docstring const familyName(docstring const & name);
 
 /** Search a BibTeX info field for the given key and return the
     associated field. */
-string const parseBibTeX(string data, string const & findkey);
+docstring const parseBibTeX(docstring data, std::string const & findkey);
 
 /** Returns an iterator to the first key that meets the search
     criterion, or end() if unsuccessful.
@@ -86,19 +94,25 @@ string const parseBibTeX(string data, string const & findkey);
     an enum defining the search direction.
 */
 
-std::vector<string>::const_iterator
+std::vector<std::string>::const_iterator
 searchKeys(InfoMap const & map,
-          std::vector<string> const & keys_to_search,
-          string const & search_expression,
-          std::vector<string>::const_iterator start,
+          std::vector<std::string> const & keys_to_search,
+          docstring const & search_expression,
+          std::vector<std::string>::const_iterator start,
           Search,
           Direction,
           bool caseSensitive=false);
 
-/// Type returned by getCitationStyle, below
-struct CitationStyle {
+
+class CitationStyle {
+public:
+       ///
+       CitationStyle(CiteStyle s = CITE, bool f = false, bool force = false)
+               : style(s), full(f), forceUCase(force) {}
+       /// \param latex_str a LaTeX command, "cite", "Citep*", etc
+       CitationStyle(std::string const & latex_str);
        ///
-       CitationStyle() : style(CITE), full(false), forceUCase(false) {}
+       std::string const asLatexStr() const;
        ///
        CiteStyle style;
        ///
@@ -107,20 +121,9 @@ struct CitationStyle {
        bool forceUCase;
 };
 
-/// Given the LaTeX command, return the appropriate CitationStyle
-CitationStyle const getCitationStyle(string const & command);
-
-/** Returns the LaTeX citation command
-
-User supplies :
-The CiteStyle enum,
-a flag forcing the full author list,
-a flag forcing upper case, e.g. "della Casa" becomes "Della Case"
-*/
-string const getCiteCommand(CiteStyle, bool full, bool forceUCase);
 
 /// Returns a vector of available Citation styles.
-std::vector<CiteStyle> const getCiteStyles(bool usingNatbib);
+std::vector<CiteStyle> const getCiteStyles(CiteEngine_enum const &);
 
 /**
    "Translates" the available Citation Styles into strings for this key.
@@ -135,8 +138,8 @@ std::vector<CiteStyle> const getCiteStyles(bool usingNatbib);
    the InfoMap of bibkeys info,
    the available citation styles
 */
-std::vector<string> const
-getNumericalStrings(string const & key,
+std::vector<docstring> const
+getNumericalStrings(std::string const & key,
                    InfoMap const & map,
                    std::vector<CiteStyle> const & styles);
 
@@ -152,10 +155,12 @@ getNumericalStrings(string const & key,
    the InfoMap of bibkeys info,
    the available citation styles
 */
-std::vector<string> const
-getAuthorYearStrings(string const & key,
+std::vector<docstring> const
+getAuthorYearStrings(std::string const & key,
                     InfoMap const & map,
                     std::vector<CiteStyle> const & styles);
+
 } // namespace biblio
+} // namespace lyx
 
 #endif // BIBLIOHELPERS_H