1 // Copyright 2019 Google LLC 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_READ_STREAM_H 16 #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_READ_STREAM_H 17 18 #include "google/cloud/bigquery/version.h" 19 #include "google/cloud/status_or.h" 20 21 namespace google { 22 namespace cloud { 23 namespace bigquery { 24 inline namespace BIGQUERY_CLIENT_NS { 25 class ReadStream; 26 27 namespace internal { 28 ReadStream MakeReadStream(std::string stream_name); 29 } // namespace internal 30 31 class ReadStream { 32 public: 33 ReadStream(ReadStream const&) = default; 34 ReadStream(ReadStream&&) = default; 35 ReadStream& operator=(ReadStream const&) = default; 36 ReadStream& operator=(ReadStream&&) = default; 37 stream_name()38 std::string const& stream_name() const { return stream_name_; } 39 40 friend bool operator==(ReadStream const& lhs, ReadStream const& rhs) { 41 return lhs.stream_name_ == rhs.stream_name_; 42 } 43 friend bool operator!=(ReadStream const& lhs, ReadStream const& rhs) { 44 return !(lhs == rhs); 45 } 46 47 private: 48 friend ReadStream internal::MakeReadStream(std::string stream_name); ReadStream(std::string stream_name)49 explicit ReadStream(std::string stream_name) 50 : stream_name_(std::move(stream_name)) {} 51 52 std::string stream_name_; 53 }; 54 55 // Serializes an instance of `ReadStream` for transmission to another process. 56 std::string SerializeReadStream(ReadStream const& /*read_stream*/); 57 58 // Deserializes the provided string to a `ReadStream`, if able. 59 StatusOr<ReadStream> DeserializeReadStream( 60 std::string const& /*serialized_read_stream*/); 61 62 } // namespace BIGQUERY_CLIENT_NS 63 } // namespace bigquery 64 } // namespace cloud 65 } // namespace google 66 67 #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_READ_STREAM_H 68