]> git.proxmox.com Git - ceph.git/blame - ceph/src/common/str_list.cc
import quincy beta 17.1.0
[ceph.git] / ceph / src / common / str_list.cc
CommitLineData
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
17using std::string;
18using std::vector;
7c673cae 19using std::list;
11fdf7f2 20using ceph::for_each_substr;
7c673cae
FG
21
22void get_str_list(const string& str, const char *delims, list<string>& str_list)
23{
7c673cae 24 str_list.clear();
11fdf7f2
TL
25 for_each_substr(str, delims, [&str_list] (auto token) {
26 str_list.emplace_back(token.begin(), token.end());
27 });
7c673cae
FG
28}
29
30void get_str_list(const string& str, list<string>& str_list)
31{
32 const char *delims = ";,= \t";
11fdf7f2
TL
33 get_str_list(str, delims, str_list);
34}
35
36list<string> get_str_list(const string& str, const char *delims)
37{
38 list<string> result;
39 get_str_list(str, delims, result);
40 return result;
7c673cae
FG
41}
42
43void get_str_vec(const string& str, const char *delims, vector<string>& str_vec)
44{
7c673cae 45 str_vec.clear();
11fdf7f2
TL
46 for_each_substr(str, delims, [&str_vec] (auto token) {
47 str_vec.emplace_back(token.begin(), token.end());
48 });
7c673cae
FG
49}
50
51void get_str_vec(const string& str, vector<string>& str_vec)
52{
53 const char *delims = ";,= \t";
11fdf7f2 54 get_str_vec(str, delims, str_vec);
7c673cae
FG
55}
56
11fdf7f2 57vector<string> get_str_vec(const string& str, const char *delims)
7c673cae 58{
11fdf7f2 59 vector<string> result;
20effc67
TL
60 for_each_substr(str, delims, [&result] (auto token) {
61 result.emplace_back(token.begin(), token.end());
62 });
11fdf7f2
TL
63 return result;
64}