Ice 3.8
C++ API Reference
Loading...
Searching...
No Matches
VersionFunctions.h
1// Copyright (c) ZeroC, Inc.
2
3#ifndef ICE_VERSION_FUNCTIONS_H
4#define ICE_VERSION_FUNCTIONS_H
5
6#include "Config.h"
7#include "Ice/Version.h"
8
9#include <sstream>
10
11namespace Ice
12{
13 /// Identifies protocol version 1.0.
15
16 /// Identifies encoding version 1.0.
18
19 /// Identifies encoding version 1.1.
21
22 /// Identifies the latest protocol version.
24
25 /// Identifies the latest protocol encoding version.
27
28 /// Identifies the latest encoding version.
30
31 /// Converts a protocol version into a string.
32 /// @param v The protocol version.
33 /// @return A string representing the protocol version.
34 ICE_API std::string protocolVersionToString(const ProtocolVersion& v);
35
36 /// Converts a string into a protocol version.
37 /// @param v The string containing a stringified protocol version.
38 /// @return The protocol version.
39 /// @throws ParseException If the given string is not in the X.Y format.
40 ICE_API ProtocolVersion stringToProtocolVersion(std::string_view v);
41
42 /// Converts an encoding version into a string.
43 /// @param v The encoding version.
44 /// @return A string representing the encoding version.
45 ICE_API std::string encodingVersionToString(const EncodingVersion& v);
46
47 /// Converts a string into an encoding version.
48 /// @param v The string containing a stringified encoding version.
49 /// @return The encoding version.
50 /// @throws ParseException If the given string is not in the X.Y format.
51 ICE_API EncodingVersion stringToEncodingVersion(std::string_view v);
52}
53
54namespace IceInternal
55{
56 ICE_API void stringToMajorMinor(std::string_view, std::uint8_t&, std::uint8_t&);
57
58 template<typename T> std::string versionToString(const T& v)
59 {
60 std::ostringstream os;
61 os << v;
62 return os.str();
63 }
64
65 template<typename T> T stringToVersion(std::string_view str)
66 {
67 T v;
68 stringToMajorMinor(str, v.major, v.minor);
69 return v;
70 }
71}
72
73#endif
std::string encodingVersionToString(const EncodingVersion &v)
Converts an encoding version into a string.
constexpr ProtocolVersion currentProtocol
Identifies the latest protocol version.
constexpr EncodingVersion Encoding_1_0
Identifies encoding version 1.0.
constexpr EncodingVersion Encoding_1_1
Identifies encoding version 1.1.
ProtocolVersion stringToProtocolVersion(std::string_view v)
Converts a string into a protocol version.
constexpr EncodingVersion currentEncoding
Identifies the latest encoding version.
constexpr ProtocolVersion Protocol_1_0
Identifies protocol version 1.0.
constexpr EncodingVersion currentProtocolEncoding
Identifies the latest protocol encoding version.
std::string protocolVersionToString(const ProtocolVersion &v)
Converts a protocol version into a string.
EncodingVersion stringToEncodingVersion(std::string_view v)
Converts a string into an encoding version.
The Ice RPC framework.
Definition SampleEvent.h:59
Represents a version of the Slice encoding.
Definition Version.h:65
Represents a version of the Ice protocol.
Definition Version.h:36