OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "remoting/base/capabilities.h" | |
6 | |
7 #include <algorithm> | |
8 #include <vector> | |
9 | |
10 #include "base/string_util.h" | |
11 | |
12 namespace remoting { | |
13 | |
14 bool HasCapability(const std::string& capabilities, const std::string& key) { | |
15 std::vector<std::string> caps; | |
16 Tokenize(capabilities, " ", &caps); | |
17 return std::find(caps.begin(), caps.end(), key) != caps.end(); | |
18 } | |
19 | |
20 std::string IntersectCapabilities(const std::string& client_capabilities, | |
21 const std::string& host_capabilities) { | |
22 std::vector<std::string> client_caps; | |
23 Tokenize(client_capabilities, " ", &client_caps); | |
24 std::sort(client_caps.begin(), client_caps.end()); | |
25 | |
26 std::vector<std::string> host_caps; | |
27 Tokenize(host_capabilities, " ", &host_caps); | |
28 std::sort(host_caps.begin(), host_caps.end()); | |
29 | |
30 std::vector<std::string> result(std::min(client_caps.size(), | |
31 host_caps.size())); | |
32 std::vector<std::string>::iterator end = | |
33 std::set_intersection(client_caps.begin(), | |
34 client_caps.end(), | |
35 host_caps.begin(), | |
36 host_caps.end(), | |
37 result.begin()); | |
38 if (end != result.end()) | |
39 result.erase(end); | |
Sergey Ulanov
2013/04/18 00:34:53
shouldn't this be result.erase(end, result.end)?
e
alexeypa (please no reviews)
2013/04/18 18:56:36
Yes, it should.
| |
40 | |
41 return JoinString(result, " "); | |
42 } | |
43 | |
44 } // namespace remoting | |
OLD | NEW |