libosmscout  1.1.1
HTMLWriter.h
Go to the documentation of this file.
1 #ifndef OSMSCOUT_HTMLWRITER_H
2 #define OSMSCOUT_HTMLWRITER_H
3 
4 /*
5  This source is part of the libosmscout library
6  Copyright (C) 2016 Tim Teulings
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Lesser General Public
10  License as published by the Free Software Foundation; either
11  version 2.1 of the License, or (at your option) any later version.
12 
13  This library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public
19  License along with this library; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22 
23 #include <fstream>
24 
26 
27 #include <osmscout/ObjectRef.h>
28 
30 
31 namespace osmscout {
32 
41  {
42  private:
43  std::ofstream file;
44  std::string filename;
45 
46  public:
47  HTMLWriter();
48  virtual ~HTMLWriter();
49 
50  void Open(const std::string& filename);
51  void Close();
52  void CloseFailsafe();
53 
54  inline bool IsOpen() const
55  {
56  return file.is_open();
57  }
58 
59  inline bool HasError() const
60  {
61  return file.fail();
62  }
63 
64  inline std::string GetFilename() const
65  {
66  return filename;
67  }
68 
69  std::string Sanitize(const std::string& string) const;
70 
71  void WriteDocumentStart();
72  void WriteHeader(const std::string& title,
73  const std::string& description,
74  const std::string& keywords,
75  const std::string& stylesheetLocation);
76  void WriteHeaderStart(const std::string& title,
77  const std::string& description,
78  const std::string& keywords,
79  const std::string& stylesheetLocation);
80  void WriteMeta(const std::string& name,
81  const std::string& content);
82  void WriteHeaderEnd();
83 
84  void WriteBodyStart();
85 
86  void WriteText(const std::string& text);
87 
88  void WriteListStart();
89  void WriteListEntryStart();
90  void WriteListEntryEnd();
91  void WriteListEnd();
92 
93  void WriteLink(const std::string& url,
94  const std::string& title);
95 
96  void WriteOSMObjectLink(const ObjectOSMRef& object,
97  const std::string& name);
98 
99  void WriteBodyEnd();
100 
101  void WriteDocumentEnd();
102  };
103 }
104 
105 #endif
Definition: HTMLWriter.h:40
Definition: Area.h:38
#define OSMSCOUT_API
Definition: CoreImportExport.h:45
bool IsOpen() const
Definition: HTMLWriter.h:54
bool HasError() const
Definition: HTMLWriter.h:59
std::string GetFilename() const
Definition: HTMLWriter.h:64