Skip to content

Commit

Permalink
Merge pull request #245 from wravery/idtype-accessors
Browse files Browse the repository at this point in the history
Add `response::IdType` accessors for backwards compatibility
  • Loading branch information
wravery committed May 7, 2022
2 parents c0d6bf1 + 773ef2a commit 31af73f
Show file tree
Hide file tree
Showing 13 changed files with 368 additions and 39 deletions.
2 changes: 1 addition & 1 deletion cmake/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.3.0
4.3.1
53 changes: 47 additions & 6 deletions include/graphqlservice/GraphQLResponse.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,16 @@ struct [[nodiscard]] IdType
// Implicit ByteData constructors
GRAPHQLRESPONSE_EXPORT IdType(size_t count, typename ByteData::value_type value = 0);
GRAPHQLRESPONSE_EXPORT IdType(std::initializer_list<typename ByteData::value_type> values);
GRAPHQLRESPONSE_EXPORT IdType(
typename ByteData::const_iterator begin, typename ByteData::const_iterator end);
template <typename InputIt>
IdType(InputIt begin, InputIt end);

// Assignment
GRAPHQLRESPONSE_EXPORT IdType& operator=(IdType&& rhs) noexcept;
IdType& operator=(const IdType& rhs) = delete;

// Conversion
GRAPHQLRESPONSE_EXPORT IdType(ByteData&& data) noexcept;
GRAPHQLRESPONSE_EXPORT IdType& operator=(ByteData&& data) noexcept;

GRAPHQLRESPONSE_EXPORT IdType(OpaqueString&& opaque) noexcept;
GRAPHQLRESPONSE_EXPORT IdType& operator=(OpaqueString&& opaque) noexcept;

template <typename ValueType>
[[nodiscard]] const ValueType& get() const;
Expand All @@ -95,16 +92,60 @@ struct [[nodiscard]] IdType

GRAPHQLRESPONSE_EXPORT [[nodiscard]] bool operator<(const IdType& rhs) const noexcept;

// Check the Type
// Check the type
GRAPHQLRESPONSE_EXPORT [[nodiscard]] bool isBase64() const noexcept;

// Shared accessors
GRAPHQLRESPONSE_EXPORT [[nodiscard]] bool empty() const noexcept;
GRAPHQLRESPONSE_EXPORT [[nodiscard]] size_t size() const noexcept;
GRAPHQLRESPONSE_EXPORT [[nodiscard]] size_t max_size() const noexcept;
GRAPHQLRESPONSE_EXPORT void reserve(size_t new_cap);
GRAPHQLRESPONSE_EXPORT [[nodiscard]] size_t capacity() const noexcept;
GRAPHQLRESPONSE_EXPORT void shrink_to_fit();
GRAPHQLRESPONSE_EXPORT void clear() noexcept;

// ByteData accessors
GRAPHQLRESPONSE_EXPORT [[nodiscard]] const std::uint8_t& at(size_t pos) const;
GRAPHQLRESPONSE_EXPORT [[nodiscard]] std::uint8_t& at(size_t pos);
GRAPHQLRESPONSE_EXPORT [[nodiscard]] const std::uint8_t& operator[](size_t pos) const;
GRAPHQLRESPONSE_EXPORT [[nodiscard]] std::uint8_t& operator[](size_t pos);
GRAPHQLRESPONSE_EXPORT [[nodiscard]] const std::uint8_t& front() const;
GRAPHQLRESPONSE_EXPORT [[nodiscard]] std::uint8_t& front();
GRAPHQLRESPONSE_EXPORT [[nodiscard]] const std::uint8_t& back() const;
GRAPHQLRESPONSE_EXPORT [[nodiscard]] std::uint8_t& back();
GRAPHQLRESPONSE_EXPORT [[nodiscard]] const std::uint8_t* data() const;
GRAPHQLRESPONSE_EXPORT [[nodiscard]] std::uint8_t* data();

// ByteData iterators
GRAPHQLRESPONSE_EXPORT [[nodiscard]] ByteData::const_iterator begin() const;
GRAPHQLRESPONSE_EXPORT [[nodiscard]] ByteData::iterator begin();
GRAPHQLRESPONSE_EXPORT [[nodiscard]] ByteData::const_iterator cbegin() const;
GRAPHQLRESPONSE_EXPORT [[nodiscard]] ByteData::const_iterator end() const;
GRAPHQLRESPONSE_EXPORT [[nodiscard]] ByteData::iterator end();
GRAPHQLRESPONSE_EXPORT [[nodiscard]] ByteData::const_iterator cend() const;
GRAPHQLRESPONSE_EXPORT [[nodiscard]] ByteData::const_reverse_iterator rbegin() const;
GRAPHQLRESPONSE_EXPORT [[nodiscard]] ByteData::reverse_iterator rbegin();
GRAPHQLRESPONSE_EXPORT [[nodiscard]] ByteData::const_reverse_iterator crbegin() const;
GRAPHQLRESPONSE_EXPORT [[nodiscard]] ByteData::const_reverse_iterator rend() const;
GRAPHQLRESPONSE_EXPORT [[nodiscard]] ByteData::reverse_iterator rend();
GRAPHQLRESPONSE_EXPORT [[nodiscard]] ByteData::const_reverse_iterator crend() const;

// OpaqueString accessors
GRAPHQLRESPONSE_EXPORT [[nodiscard]] const char* c_str() const;

private:
std::variant<ByteData, OpaqueString> _data;
};

#ifdef GRAPHQL_DLLEXPORTS
// Export all of the specialized template methods
template <>
GRAPHQLRESPONSE_EXPORT IdType::IdType(
typename ByteData::const_iterator begin, typename ByteData::const_iterator end);
template <>
GRAPHQLRESPONSE_EXPORT IdType::IdType(
typename ByteData::const_pointer begin, typename ByteData::const_pointer end);
template <>
GRAPHQLRESPONSE_EXPORT const IdType::ByteData& IdType::get<IdType::ByteData>() const;
template <>
GRAPHQLRESPONSE_EXPORT const IdType::OpaqueString& IdType::get<IdType::OpaqueString>() const;
Expand Down
4 changes: 2 additions & 2 deletions include/graphqlservice/internal/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

namespace graphql::internal {

constexpr std::string_view FullVersion { "4.3.0" };
constexpr std::string_view FullVersion { "4.3.1" };

constexpr size_t MajorVersion = 4;
constexpr size_t MinorVersion = 3;
constexpr size_t PatchVersion = 0;
constexpr size_t PatchVersion = 1;

} // namespace graphql::internal

Expand Down
4 changes: 2 additions & 2 deletions res/ClientGen.rc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

#include <winver.h>

#define GRAPHQL_RC_VERSION 4,3,0,0
#define GRAPHQL_RC_VERSION_STR "4.3.0"
#define GRAPHQL_RC_VERSION 4,3,1,0
#define GRAPHQL_RC_VERSION_STR "4.3.1"

#ifndef DEBUG
#define VER_DEBUG 0
Expand Down
4 changes: 2 additions & 2 deletions res/SchemaGen.rc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

#include <winver.h>

#define GRAPHQL_RC_VERSION 4,3,0,0
#define GRAPHQL_RC_VERSION_STR "4.3.0"
#define GRAPHQL_RC_VERSION 4,3,1,0
#define GRAPHQL_RC_VERSION_STR "4.3.1"

#ifndef DEBUG
#define VER_DEBUG 0
Expand Down
4 changes: 2 additions & 2 deletions res/graphqlclient_version.rc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

#include <winver.h>

#define GRAPHQL_RC_VERSION 4,3,0,0
#define GRAPHQL_RC_VERSION_STR "4.3.0"
#define GRAPHQL_RC_VERSION 4,3,1,0
#define GRAPHQL_RC_VERSION_STR "4.3.1"

#ifndef DEBUG
#define VER_DEBUG 0
Expand Down
4 changes: 2 additions & 2 deletions res/graphqljson_version.rc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

#include <winver.h>

#define GRAPHQL_RC_VERSION 4,3,0,0
#define GRAPHQL_RC_VERSION_STR "4.3.0"
#define GRAPHQL_RC_VERSION 4,3,1,0
#define GRAPHQL_RC_VERSION_STR "4.3.1"

#ifndef DEBUG
#define VER_DEBUG 0
Expand Down
4 changes: 2 additions & 2 deletions res/graphqlpeg_version.rc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

#include <winver.h>

#define GRAPHQL_RC_VERSION 4,3,0,0
#define GRAPHQL_RC_VERSION_STR "4.3.0"
#define GRAPHQL_RC_VERSION 4,3,1,0
#define GRAPHQL_RC_VERSION_STR "4.3.1"

#ifndef DEBUG
#define VER_DEBUG 0
Expand Down
4 changes: 2 additions & 2 deletions res/graphqlresponse_version.rc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

#include <winver.h>

#define GRAPHQL_RC_VERSION 4,3,0,0
#define GRAPHQL_RC_VERSION_STR "4.3.0"
#define GRAPHQL_RC_VERSION 4,3,1,0
#define GRAPHQL_RC_VERSION_STR "4.3.1"

#ifndef DEBUG
#define VER_DEBUG 0
Expand Down
4 changes: 2 additions & 2 deletions res/graphqlservice_version.rc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

#include <winver.h>

#define GRAPHQL_RC_VERSION 4,3,0,0
#define GRAPHQL_RC_VERSION_STR "4.3.0"
#define GRAPHQL_RC_VERSION 4,3,1,0
#define GRAPHQL_RC_VERSION_STR "4.3.1"

#ifndef DEBUG
#define VER_DEBUG 0
Expand Down
6 changes: 3 additions & 3 deletions samples/today/TodayMock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const response::IdType& getFakeAppointmentId() noexcept
{
static const auto s_fakeId = []() noexcept {
std::string fakeIdString("fakeAppointmentId");
response::IdType::ByteData result(fakeIdString.size());
response::IdType result(fakeIdString.size());

std::copy(fakeIdString.cbegin(), fakeIdString.cend(), result.begin());

Expand All @@ -37,7 +37,7 @@ const response::IdType& getFakeTaskId() noexcept
{
static const auto s_fakeId = []() noexcept {
std::string fakeIdString("fakeTaskId");
response::IdType::ByteData result(fakeIdString.size());
response::IdType result(fakeIdString.size());

std::copy(fakeIdString.cbegin(), fakeIdString.cend(), result.begin());

Expand All @@ -51,7 +51,7 @@ const response::IdType& getFakeFolderId() noexcept
{
static const auto s_fakeId = []() noexcept {
std::string fakeIdString("fakeFolderId");
response::IdType::ByteData result(fakeIdString.size());
response::IdType result(fakeIdString.size());

std::copy(fakeIdString.cbegin(), fakeIdString.cend(), result.begin());

Expand Down
Loading

0 comments on commit 31af73f

Please sign in to comment.