Skip to content

Commit c914920

Browse files
MaxKellermannvshankar
authored andcommitted
include/cephfs/types.h: move struct keys_and_values to separate header
This struct is only used in two sources and moving it to a separate header means we can eliminate the heavy header dependency on boost::spirit. Signed-off-by: Max Kellermann <[email protected]>
1 parent 308f3be commit c914920

File tree

5 files changed

+42
-21
lines changed

5 files changed

+42
-21
lines changed

src/client/Client.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ using namespace std::literals::string_view_literals;
114114
#include "posix_acl.h"
115115

116116
#include "include/ceph_assert.h"
117+
#include "include/cephfs/keys_and_values.h"
117118
#include "include/stat.h"
118119

119120
#include "include/cephfs/ceph_ll_client.h"
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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) 2020 Red Hat, Inc.
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+
#pragma once
15+
16+
#include <boost/spirit/include/qi.hpp>
17+
18+
#include <map>
19+
#include <string>
20+
21+
// parse a map of keys/values.
22+
namespace qi = boost::spirit::qi;
23+
24+
template <typename Iterator>
25+
struct keys_and_values
26+
: qi::grammar<Iterator, std::map<std::string, std::string>()>
27+
{
28+
keys_and_values()
29+
: keys_and_values::base_type(query)
30+
{
31+
query = pair >> *(qi::lit(' ') >> pair);
32+
pair = key >> '=' >> value;
33+
key = qi::char_("a-zA-Z_") >> *qi::char_("a-zA-Z_0-9");
34+
value = +qi::char_("a-zA-Z0-9-_.");
35+
}
36+
qi::rule<Iterator, std::map<std::string, std::string>()> query;
37+
qi::rule<Iterator, std::pair<std::string, std::string>()> pair;
38+
qi::rule<Iterator, std::string()> key, value;
39+
};

src/include/cephfs/types.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#include "include/types.h" // for version_t
3131
#include "include/utime.h"
3232

33-
#include <boost/spirit/include/qi.hpp>
3433
#include "include/ceph_assert.h"
3534
#include <boost/serialization/strong_typedef.hpp>
3635
#include "common/ceph_json.h"
@@ -1385,24 +1384,4 @@ inline void decode(inode_t<Allocator> &c, ::ceph::buffer::list::const_iterator &
13851384
c.decode(p);
13861385
}
13871386

1388-
// parse a map of keys/values.
1389-
namespace qi = boost::spirit::qi;
1390-
1391-
template <typename Iterator>
1392-
struct keys_and_values
1393-
: qi::grammar<Iterator, std::map<std::string, std::string>()>
1394-
{
1395-
keys_and_values()
1396-
: keys_and_values::base_type(query)
1397-
{
1398-
query = pair >> *(qi::lit(' ') >> pair);
1399-
pair = key >> '=' >> value;
1400-
key = qi::char_("a-zA-Z_") >> *qi::char_("a-zA-Z_0-9");
1401-
value = +qi::char_("a-zA-Z0-9-_.");
1402-
}
1403-
qi::rule<Iterator, std::map<std::string, std::string>()> query;
1404-
qi::rule<Iterator, std::pair<std::string, std::string>()> pair;
1405-
qi::rule<Iterator, std::string()> key, value;
1406-
};
1407-
14081387
#endif

src/mds/Server.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <boost/lexical_cast.hpp>
2121
#include "include/ceph_assert.h" // lexical_cast includes system assert.h
2222
#include "include/cephfs/metrics/Types.h"
23+
#include "include/cephfs/keys_and_values.h"
2324
#include "include/random.h" // for ceph::util::generate_random_number()
2425

2526
#include <boost/config/warning_disable.hpp>

src/mon/ConnectionTracker.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "common/Formatter.h"
1717
#include "common/dout.h"
1818
#include "include/ceph_assert.h"
19+
#include "include/cephfs/keys_and_values.h"
1920

2021
#define dout_subsys ceph_subsys_mon
2122
#undef dout_prefix

0 commit comments

Comments
 (0)