]>
git.proxmox.com Git - ceph.git/blob - ceph/src/dmclock/sim/src/str_list.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2009-2010 Dreamhost
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.
22 static bool get_next_token(const string
&s
, size_t& pos
, const char *delims
, string
& token
)
24 int start
= s
.find_first_not_of(delims
, pos
);
32 end
= s
.find_first_of(delims
, start
);
39 token
= s
.substr(start
, end
- start
);
43 void get_str_list(const string
& str
, const char *delims
, list
<string
>& str_list
)
50 while (pos
< str
.size()) {
51 if (get_next_token(str
, pos
, delims
, token
)) {
52 if (token
.size() > 0) {
53 str_list
.push_back(token
);
59 void get_str_list(const string
& str
, list
<string
>& str_list
)
61 const char *delims
= ";,= \t";
62 return get_str_list(str
, delims
, str_list
);
65 void get_str_vec(const string
& str
, const char *delims
, vector
<string
>& str_vec
)
71 while (pos
< str
.size()) {
72 if (get_next_token(str
, pos
, delims
, token
)) {
73 if (token
.size() > 0) {
74 str_vec
.push_back(token
);
80 void get_str_vec(const string
& str
, vector
<string
>& str_vec
)
82 const char *delims
= ";,= \t";
83 return get_str_vec(str
, delims
, str_vec
);
86 void get_str_set(const string
& str
, const char *delims
, set
<string
>& str_set
)
93 while (pos
< str
.size()) {
94 if (get_next_token(str
, pos
, delims
, token
)) {
95 if (token
.size() > 0) {
96 str_set
.insert(token
);
102 void get_str_set(const string
& str
, set
<string
>& str_set
)
104 const char *delims
= ";,= \t";
105 return get_str_set(str
, delims
, str_set
);