]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | /* | |
4 | * Ceph - scalable distributed file system | |
5 | * | |
6 | * Copyright (C) 2009-2010 Dreamhost | |
7 | * | |
8 | * This is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU Lesser General Public | |
10 | * License version 2.1, as published by the Free Software | |
11 | * Foundation. See file COPYING. | |
12 | * | |
13 | */ | |
14 | ||
15 | #include "include/str_list.h" | |
16 | ||
17 | using std::string; | |
18 | using std::vector; | |
19 | using std::set; | |
20 | using std::list; | |
11fdf7f2 | 21 | using ceph::for_each_substr; |
7c673cae FG |
22 | |
23 | void get_str_list(const string& str, const char *delims, list<string>& str_list) | |
24 | { | |
7c673cae | 25 | str_list.clear(); |
11fdf7f2 TL |
26 | for_each_substr(str, delims, [&str_list] (auto token) { |
27 | str_list.emplace_back(token.begin(), token.end()); | |
28 | }); | |
7c673cae FG |
29 | } |
30 | ||
31 | void get_str_list(const string& str, list<string>& str_list) | |
32 | { | |
33 | const char *delims = ";,= \t"; | |
11fdf7f2 TL |
34 | get_str_list(str, delims, str_list); |
35 | } | |
36 | ||
37 | list<string> get_str_list(const string& str, const char *delims) | |
38 | { | |
39 | list<string> result; | |
40 | get_str_list(str, delims, result); | |
41 | return result; | |
7c673cae FG |
42 | } |
43 | ||
44 | void get_str_vec(const string& str, const char *delims, vector<string>& str_vec) | |
45 | { | |
7c673cae | 46 | str_vec.clear(); |
11fdf7f2 TL |
47 | for_each_substr(str, delims, [&str_vec] (auto token) { |
48 | str_vec.emplace_back(token.begin(), token.end()); | |
49 | }); | |
7c673cae FG |
50 | } |
51 | ||
52 | void get_str_vec(const string& str, vector<string>& str_vec) | |
53 | { | |
54 | const char *delims = ";,= \t"; | |
11fdf7f2 | 55 | get_str_vec(str, delims, str_vec); |
7c673cae FG |
56 | } |
57 | ||
11fdf7f2 | 58 | vector<string> get_str_vec(const string& str, const char *delims) |
7c673cae | 59 | { |
11fdf7f2 TL |
60 | vector<string> result; |
61 | get_str_vec(str, delims, result); | |
62 | return result; | |
63 | } | |
7c673cae | 64 | |
11fdf7f2 TL |
65 | void get_str_set(const string& str, const char *delims, set<string>& str_set) |
66 | { | |
7c673cae | 67 | str_set.clear(); |
11fdf7f2 TL |
68 | for_each_substr(str, delims, [&str_set] (auto token) { |
69 | str_set.emplace(token.begin(), token.end()); | |
70 | }); | |
7c673cae FG |
71 | } |
72 | ||
73 | void get_str_set(const string& str, set<string>& str_set) | |
74 | { | |
75 | const char *delims = ";,= \t"; | |
11fdf7f2 TL |
76 | get_str_set(str, delims, str_set); |
77 | } | |
78 | ||
79 | set<string> get_str_set(const string& str, const char *delims) | |
80 | { | |
81 | set<string> result; | |
82 | get_str_set(str, delims, result); | |
83 | return result; | |
7c673cae | 84 | } |