]> git.lyx.org Git - lyx.git/blob - src/tabular_funcs.h
Alfredo's second patch
[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 #include "LString.h"
18 #include "tabular.h"
19 #include "support/lstrings.h" // for tostr
20
21 #include <iosfwd>
22
23 // Perfect case for a template... (Lgb)
24 // or perhaps not...
25 template<class T>
26 string const write_attribute(string const & name, T const & t)
27 {
28         if (tostr(t).empty())
29                 return string();
30
31         string str = " " + name + "=\"" + tostr(t) + "\"";
32         return str;
33 }
34 template<>
35 string const write_attribute(string const & name, bool const & b);
36 template<>
37 string const write_attribute(string const & name, int const & b);
38 template<>
39 string const write_attribute(string const & name, LyXLength const & value);
40 string const tostr(LyXAlignment const & num);
41 string const tostr(LyXTabular::VAlignment const & num);
42 string const tostr(LyXTabular::BoxType const & num);
43
44 // I would have liked a fromstr template a lot better. (Lgb)
45 extern bool string2type(string const str, LyXAlignment & num);
46 extern bool string2type(string const str, LyXTabular::VAlignment & num);
47 extern bool string2type(string const str, LyXTabular::BoxType & num);
48 extern bool string2type(string const str, bool & num);
49 extern bool getTokenValue(string const & str, char const * token, string &ret);
50 extern bool getTokenValue(string const & str, char const * token, int & num);
51 extern bool getTokenValue(string const & str, char const * token,
52                           LyXAlignment & num);
53 extern bool getTokenValue(string const & str, char const * token,
54                           LyXTabular::VAlignment & num);
55 extern bool getTokenValue(string const & str, char const * token,
56                           LyXTabular::BoxType & num);
57 extern bool getTokenValue(string const & str, char const * token, bool & flag);
58 extern bool getTokenValue(string const & str, char const * token,
59                           LyXLength & len);
60 extern void l_getline(std::istream & is, string & str);
61
62 #endif