]>
git.proxmox.com Git - ceph.git/blob - ceph/src/dmclock/sim/src/str_list.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
5 * Copyright (C) 2009 Red Hat Inc.
7 * Forked from Red Hat's Ceph project.
9 * This is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser General Public License version
11 * 2.1, as published by the Free Software Foundation. See file
16 #ifndef CEPH_STRLIST_H
17 #define CEPH_STRLIST_H
26 * Split **str** into a list of strings, using the ";,= \t" delimiters and output the result in **str_list**.
28 * @param [in] str String to split and save as list
29 * @param [out] str_list List modified containing str after it has been split
31 extern void get_str_list(const std::string
& str
,
32 std::list
<std::string
>& str_list
);
35 * Split **str** into a list of strings, using the **delims** delimiters and output the result in **str_list**.
37 * @param [in] str String to split and save as list
38 * @param [in] delims characters used to split **str**
39 * @param [out] str_list List modified containing str after it has been split
41 extern void get_str_list(const std::string
& str
,
43 std::list
<std::string
>& str_list
);
46 * Split **str** into a list of strings, using the ";,= \t" delimiters and output the result in **str_vec**.
48 * @param [in] str String to split and save as Vector
49 * @param [out] str_vec Vector modified containing str after it has been split
51 extern void get_str_vec(const std::string
& str
,
52 std::vector
<std::string
>& str_vec
);
55 * Split **str** into a list of strings, using the **delims** delimiters and output the result in **str_vec**.
57 * @param [in] str String to split and save as Vector
58 * @param [in] delims characters used to split **str**
59 * @param [out] str_vec Vector modified containing str after it has been split
61 extern void get_str_vec(const std::string
& str
,
63 std::vector
<std::string
>& str_vec
);
66 * Split **str** into a list of strings, using the ";,= \t" delimiters and output the result in **str_list**.
68 * @param [in] str String to split and save as Set
69 * @param [out] str_list Set modified containing str after it has been split
71 extern void get_str_set(const std::string
& str
,
72 std::set
<std::string
>& str_list
);
75 * Split **str** into a list of strings, using the **delims** delimiters and output the result in **str_list**.
77 * @param [in] str String to split and save as Set
78 * @param [in] delims characters used to split **str**
79 * @param [out] str_list Set modified containing str after it has been split
81 extern void get_str_set(const std::string
& str
,
83 std::set
<std::string
>& str_list
);
86 * Return a String containing the vector **v** joined with **sep**
88 * If **v** is empty, the function returns an empty string
89 * For each element in **v**,
90 * it will concatenate this element and **sep** with result
92 * @param [in] v Vector to join as a String
93 * @param [in] sep String used to join each element from **v**
94 * @return empty string if **v** is empty or concatenated string
96 inline std::string
str_join(const std::vector
<std::string
>& v
, const std::string
& sep
)
100 std::vector
<std::string
>::const_iterator i
= v
.begin();
102 for (++i
; i
!= v
.end(); ++i
) {