]> git.lyx.org Git - lyx.git/blob - src/tabular_funcs.h
another compile fix from herbert
[lyx.git] / src / tabular_funcs.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ======================================================
4  *
5  *           LyX, The Document Processor
6  *
7  *           Copyright 2000-2001 The LyX Team.
8  *
9  *           @author: Jürgen Vigna
10  *
11  * ======================================================
12  */
13
14 #ifndef TABULAR_FUNCS_H
15 #define TABULAR_FUNCS_H
16
17 #ifdef __GNUG__
18 #pragma interface
19 #endif
20
21 #include "LString.h"
22 #include "tabular.h"
23 #include "support/lstrings.h" // for tostr
24
25 #include <iosfwd>
26
27 // Perfect case for a template... (Lgb)
28 // or perhaps not...
29 template<class T>
30 string const write_attribute(string const & name, T const & t)
31 {
32         if (tostr(t).empty())
33                 return string();
34
35         string str = " " + name + "=\"" + tostr(t) + "\"";
36         return str;
37 }
38 template<>
39 string const write_attribute(string const & name, bool const & b);
40 template<>
41 string const write_attribute(string const & name, int const & b);
42 template<>
43 string const write_attribute(string const & name, LyXLength const & value);
44 string const tostr(LyXAlignment const & num);
45 string const tostr(LyXTabular::VAlignment const & num);
46 string const tostr(LyXTabular::BoxType const & num);
47
48 // I would have liked a fromstr template a lot better. (Lgb)
49 extern bool string2type(string const str, LyXAlignment & num);
50 extern bool string2type(string const str, LyXTabular::VAlignment & num);
51 extern bool string2type(string const str, LyXTabular::BoxType & num);
52 extern bool string2type(string const str, bool & num);
53 extern bool getTokenValue(string const & str, char const * token, string &ret);
54 extern bool getTokenValue(string const & str, char const * token, int & num);
55 extern bool getTokenValue(string const & str, char const * token,
56                           LyXAlignment & num);
57 extern bool getTokenValue(string const & str, char const * token,
58                           LyXTabular::VAlignment & num);
59 extern bool getTokenValue(string const & str, char const * token,
60                           LyXTabular::BoxType & num);
61 extern bool getTokenValue(string const & str, char const * token, bool & flag);
62 extern bool getTokenValue(string const & str, char const * token,
63                           LyXLength & len);
64 extern void l_getline(std::istream & is, string & str);
65
66 #endif