MCPcopy Create free account
hub / github.com/apple/foundationdb / ClientVersionRef

Class ClientVersionRef

fdbclient/include/fdbclient/ClientVersion.h:27–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25#include "flow/Arena.h"
26
27struct ClientVersionRef {
28 StringRef clientVersion;
29 StringRef sourceVersion;
30 StringRef protocolVersion;
31
32 ClientVersionRef() { initUnknown(); }
33
34 ClientVersionRef(Arena& arena, ClientVersionRef const& cv)
35 : clientVersion(arena, cv.clientVersion), sourceVersion(arena, cv.sourceVersion),
36 protocolVersion(arena, cv.protocolVersion) {}
37 ClientVersionRef(StringRef clientVersion, StringRef sourceVersion, StringRef protocolVersion)
38 : clientVersion(clientVersion), sourceVersion(sourceVersion), protocolVersion(protocolVersion) {}
39 ClientVersionRef(StringRef versionString) {
40 std::vector<StringRef> parts = versionString.splitAny(LiteralStringRef(","));
41 if (parts.size() != 3) {
42 initUnknown();
43 return;
44 }
45 clientVersion = parts[0];
46 sourceVersion = parts[1];
47 protocolVersion = parts[2];
48 }
49
50 void initUnknown() {
51 clientVersion = LiteralStringRef("Unknown");
52 sourceVersion = LiteralStringRef("Unknown");
53 protocolVersion = LiteralStringRef("Unknown");
54 }
55
56 template <class Ar>
57 void serialize(Ar& ar) {
58 serializer(ar, clientVersion, sourceVersion, protocolVersion);
59 }
60
61 size_t expectedSize() const { return clientVersion.size() + sourceVersion.size() + protocolVersion.size(); }
62
63 bool operator<(const ClientVersionRef& rhs) const {
64 if (protocolVersion != rhs.protocolVersion) {
65 return protocolVersion < rhs.protocolVersion;
66 }
67
68 // These comparisons are arbitrary because they aren't ordered
69 if (clientVersion != rhs.clientVersion) {
70 return clientVersion < rhs.clientVersion;
71 }
72
73 return sourceVersion < rhs.sourceVersion;
74 }
75};
76
77#endif

Callers 3

setNetworkOptionFunction · 0.85
loadVersionMethod · 0.85
getRequestMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected