| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
NOTICE: This repo will soon contain the code for all the other related google-cloud-cpp-* repos. As a new monorepo (#3612), the versioning of this repo will be changing to have a single per-repo version. See googleapis#3615 for more info.
This repository contains idiomatic C++ client libraries for the following Google Cloud Platform services.
See each library's README.md file for more information about:
NOTE: This repo and these libraries do not follow Semantic Versioning.
Each library (linked above) contains a directory named quickstart/ that's intended to help you get up and running in a matter of minutes. This quickstart/ directory contains a minimal "Hello World" program demonstrating how to use the library, along with minimal build files for common build systems, such as CMake and Bazel.
As an example, the following code snippet, taken from Google Cloud Storage, should give you a taste of what it's like to use one of these C++ libraries.
#include "google/cloud/storage/client.h"
#include <iostream>
int main(int argc, char* argv[]) {
if (argc != 2) {
std::cerr << "Missing bucket name.\n";
std::cerr << "Usage: quickstart <bucket-name>\n";
return 1;
}
std::string const bucket_name = argv[1];
// Create aliases to make the code easier to read.
namespace gcs = google::cloud::storage;
// Create a client to communicate with Google Cloud Storage. This client
// uses the default configuration for authentication and project id.
google::cloud::StatusOr<gcs::Client> client =
gcs::Client::CreateDefaultClient();
if (!client) {
std::cerr << "Failed to create Storage Client, status=" << client.status()
<< "\n";
return 1;
}
auto writer = client->WriteObject(bucket_name, "quickstart.txt");
writer << "Hello World!";
writer.Close();
if (writer.metadata()) {
std::cout << "Successfully created object: " << *writer.metadata() << "\n";
} else {
std::cerr << "Error creating object: " << writer.metadata().status()
<< "\n";
return 1;
}
auto reader = client->ReadObject(bucket_name, "quickstart.txt");
std::string contents{std::istreambuf_iterator<char>{reader}, {}};
std::cout << contents << "\n";
return 0;
}See CONTRIBUTING.md for details on how to contribute to this project, including how to build and test your changes as well as how to properly format your code.
Apache 2.0; see LICENSE for details.
| Back | FazBrowse Home | New Git URL |