ARTS  2.4.0(git:4fb77825)
docserver.h
Go to the documentation of this file.
1 /* Copyright (C) 2012 Oliver Lemke <olemke@core-dump.info>
2 
3  This program is free software; you can redistribute it and/or modify it
4  under the terms of the GNU General Public License as published by the
5  Free Software Foundation; either version 2, or (at your option) any
6  later version.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16  USA. */
17 
26 #ifndef docserver_h
27 #define docserver_h
28 
29 #include "arts.h"
30 #include "exceptions.h"
31 
32 #ifdef ENABLE_DOCSERVER
33 class Docserver {
34  private:
35  string mbaseurl;
36  Index mport;
37  ostream* mos;
38  vector<string> tokens;
39 
40  void begin_page(string title);
41  void end_page();
42  void begin_content();
43  void end_content();
44 
45  String insert_agenda_link(const String& aname);
46  String insert_group_link(const String& gname);
47  String insert_wsm_link(const String& mname);
48  String insert_wsv_link(const String& vname);
49 
50  void insert_title(const string& title = "");
51  void insert_breadcrumb_token(size_t token_id);
52  void insert_breadcrumbs();
53  void insert_error_message(const string& error = "");
54 
55  void insert_stylesheet();
56  void insert_index();
57  void insert_doc();
58  void insert_error(const string& error);
59 
60  void list_agendas();
61  void list_groups();
62  void list_methods();
63  void list_variables();
64 
65  String description_add_links(const String& desc, const String& mname = "");
66 
67  void doc_method(const string& mname);
68  void doc_variable_methods(const string& vname);
69  void doc_variable(const string& vname);
70  void doc_agenda(const string& aname);
71  void doc_group(const string& gname);
72 
73  void find_token_type();
74 
75  static string html_escape_char(const char ch);
76  static string html_escape_string(const string& s);
77 
78  void split_tokens(const string& s);
79 
80  void limit_line_length(ostringstream& curline,
81  ostringstream& token,
82  const String& indent,
83  size_t linelen);
84 
85  ostream& get_os() {
86  if (!mos) throw runtime_error("Output stream for docserver is NULL.");
87  return *mos;
88  }
89 
90  public:
91  Docserver(const Index port, const string& baseurl = "");
92 
93  static std::tuple<size_t, std::vector<string> >
94  list_broken_description_links();
95 
96  static vector<string> find_broken_description_links(const String& desc,
97  const String& mname = "");
98 
99  string new_page(const string& url);
100 
101  void set_ostream(ostream& os) { mos = &os; }
102  void clear_ostream() { mos = NULL; }
103 
104  const string& get_baseurl() { return mbaseurl; }
105  int launch(bool daemon);
106 };
107 
108 #endif /* ENABLE_DOCSERVER */
109 
110 #endif /* docserver_h */
limit_line_length
void limit_line_length(ostream &os, ostringstream &curline, ostringstream &token, const String &indent, size_t linelen)
Limit length of output.
Definition: methods_aux.cc:633
exceptions.h
The declarations of all the exception classes.
my_basic_string< char >
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
arts.h
The global header file for ARTS.