-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: implement object listing (#293)
- Loading branch information
Showing
7 changed files
with
166 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
add_library(strings_lib human_readable.cc) | ||
add_library(strings_lib escaping.cc human_readable.cc) | ||
cxx_link(strings_lib base absl::strings absl::str_format) | ||
|
||
cxx_test(strings_test strings_lib LABELS CI) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright 2024, Roman Gershman. All rights reserved. | ||
// See LICENSE for licensing terms. | ||
// | ||
#include <absl/strings/ascii.h> | ||
|
||
namespace strings { | ||
using namespace std; | ||
|
||
inline bool IsValidUrlChar(char ch) { | ||
return absl::ascii_isalnum(ch) || ch == '-' || ch == '_' || ch == '_' || ch == '.' || ch == '!' || | ||
ch == '~' || ch == '*' || ch == '(' || ch == ')'; | ||
} | ||
|
||
static size_t InternalUrlEncode(absl::string_view src, char* dest) { | ||
static const char digits[] = "0123456789ABCDEF"; | ||
|
||
char* start = dest; | ||
for (char ch_c : src) { | ||
unsigned char ch = static_cast<unsigned char>(ch_c); | ||
if (IsValidUrlChar(ch)) { | ||
*dest++ = ch_c; | ||
} else { | ||
*dest++ = '%'; | ||
*dest++ = digits[(ch >> 4) & 0x0F]; | ||
*dest++ = digits[ch & 0x0F]; | ||
} | ||
} | ||
*dest = 0; | ||
|
||
return static_cast<size_t>(dest - start); | ||
} | ||
|
||
void AppendUrlEncoded(const std::string_view src, string* dest) { | ||
size_t sz = dest->size(); | ||
dest->resize(dest->size() + src.size() * 3 + 1); | ||
char* next = &dest->front() + sz; | ||
size_t written = InternalUrlEncode(src, next); | ||
dest->resize(sz + written); | ||
} | ||
|
||
} // namespace strings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright 2024, Roman Gershman. All rights reserved. | ||
// See LICENSE for licensing terms. | ||
// | ||
|
||
#pragma once | ||
|
||
#include <string_view> | ||
|
||
namespace strings { | ||
|
||
void AppendUrlEncoded(const std::string_view src, std::string* dest); | ||
|
||
} // namespace strings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
add_library(gcp_lib gcs.cc) | ||
|
||
cxx_link(gcp_lib http_client_lib TRDP::rapidjson) | ||
cxx_link(gcp_lib http_client_lib strings_lib TRDP::rapidjson) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters