]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/helper_funcs.C
Implementation of controller-view split for FormCharacter.
[lyx.git] / src / frontends / controllers / helper_funcs.C
1 /* This file is part of
2  * ====================================================== 
3  *
4  *           LyX, The Document Processor
5  *
6  *           Copyright 2001 The LyX Team.
7  *
8  * ======================================================
9  *
10  * \file helper_funcs.C
11  * \author Angus Leeming <a.leeming@ic.ac.uk>
12  */
13
14 #include <vector>
15
16 #ifdef __GNUG__
17 #pragma implementation
18 #endif
19
20 #include <config.h>
21 #include "LString.h"
22 #include "helper_funcs.h"
23
24 using std::vector;
25
26 string const getStringFromVector(vector<string> const & vec,
27                                  string const & delim)
28 {
29         string str;
30         for (vector<string>::size_type i=0; i<vec.size(); ++i) {
31                 if (i > 0) str += delim;
32                 str += vec[i];
33         }
34         return str;
35 }
36
37 vector<string> const getVectorFromString(string const & str,
38                                          string const & delim)
39 {
40         vector<string> vec;
41         string keys(str);
42
43         for(;;) {
44                 string::size_type const idx = keys.find(delim);
45                 if (idx == string::npos) break;
46                 
47                 vec.push_back(keys.substr(0, idx));
48
49                 string::size_type const start = idx + delim.size();
50                 keys = keys.substr(start);
51         }
52
53         return vec;
54 }
55