bibhtml  1.0
 All Classes Functions Variables Enumerations
bibtex.hpp
1 
2 // bibhtml: Generates HTML page (with images) from BibTex files
3 // See: https://www.telecom-paris.fr/~elc/software/
4 //
5 // Copyright 2020 Eric Lecolinet (eric.lecolinet@gmail.com)
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 // http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 
19 #ifndef __BibTex__
20 #define __BibTex__
21 
22 #include <string>
23 #include <fstream>
24 
25 
28 class BibWriter {
29 public:
31  bool write(const std::string& filename, const BibEntries&);
32 
34  void write(std::ostream&, const BibEntry&, bool inHtmlFile);
35 };
36 
37 
40 class BibReader {
41 public:
45  BibReader(const std::string& filename, bool isAuxiliaryFile = false);
46 
48  bool status() {return status_;}
49 
50 protected:
51  bool readEntry();
52  char readField();
53  char readSlotName(std::string&, char firstChar);
54  char readUnquotedValue(std::string&, char firstChar);
55  char readQuotedValue(std::string&);
56  char readBracedValue(std::string&);
57  char nextChar();
58  char nextChar(std::string& value);
59  void error(const std::string& msg);
60  void parseAuthors(const std::string& value, std::string& parsed);
61  static void parseAuthors(const std::string& authors_def, BibAuthors& authors);
62  static void parseValue(const std::string& value, std::string& parsed);
63 
64 private:
65  std::string filename_;
66  std::ifstream fin_;
67  bool status_{false};
68  class BibEntry* entry_{nullptr};
69  bool isAuxiliary_{false};
70  unsigned long lineNo_;
71 };
72 
73 #endif