ARTS  2.2.66
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_broken_doc_links();
57  vector<string> find_broken_description_links(const String& desc, const String& mname = "");
58  void insert_index();
59  void insert_doc();
60  void insert_error(const string& error);
61 
62  void list_agendas();
63  void list_groups();
64  void list_methods();
65  void list_variables();
66 
67  String description_add_links(const String& desc, const String& mname = "");
68 
69  void doc_method(const string& mname);
70  void doc_variable_methods(const string& vname);
71  void doc_variable(const string& vname);
72  void doc_agenda(const string& aname);
73  void doc_group(const string& gname);
74 
75  void find_token_type();
76 
77  string html_escape_char(const char ch);
78  string html_escape_string(const string& s);
79 
80  void split_tokens(const string& s);
81 
82  void limit_line_length(ostringstream& curline,
83  ostringstream& token,
84  const String& indent,
85  size_t linelen);
86 
87  ostream& get_os()
88  {
89  if (!mos) throw runtime_error("Output stream for docserver is NULL.");
90  return *mos;
91  }
92 
93 public:
94  Docserver(const Index port, const string& baseurl = "");
95 
96  string new_page(const string& url);
97 
98  void set_ostream(ostream& os) { mos = &os; }
99  void clear_ostream() { mos = NULL; }
100 
101  const string& get_baseurl() { return mbaseurl; }
102  int launch(bool daemon);
103 };
104 
105 #endif /* ENABLE_DOCSERVER */
106 
107 #endif /* docserver_h */
108 
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:35
The implementation for String, the ARTS string class.
Definition: mystring.h:63
The global header file for ARTS.
The declarations of all the exception classes.
void limit_line_length(ostream &os, ostringstream &curline, ostringstream &token, const String &indent, size_t linelen)
Limit length of output.
Definition: methods_aux.cc:656