forked from envoyproxy/envoy-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for String Accessors to the C++ engine builder (envoyprox…
…y#2619) Add support for String Accessors to the C++ engine builder Introduces a C++ StringAccessor interface and method to convert to an envoy_string_accessor. Minor cleanup of key_value_store handling in engine_builder.cc Part of: envoyproxy#2498 Risk Level: Low Testing: New unit tests Docs Changes: N/A Release Notes: Updated version_history.rst Signed-off-by: Ryan Hamilton <rch@google.com> Signed-off-by: Chidera Olibie <colibie@google.com>
- Loading branch information
1 parent
cf9a96e
commit dbe0d3b
Showing
7 changed files
with
125 additions
and
11 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
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
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,22 @@ | ||
#include "library/cc/string_accessor.h" | ||
|
||
#include "library/common/data/utility.h" | ||
|
||
namespace Envoy { | ||
namespace Platform { | ||
|
||
namespace { | ||
|
||
envoy_data c_string_accessor_read(const void* context) { | ||
auto accessor = *static_cast<const StringAccessorSharedPtr*>(context); | ||
return Data::Utility::copyToBridgeData(accessor->get()); | ||
} | ||
|
||
} // namespace | ||
|
||
envoy_string_accessor StringAccessor::asEnvoyStringAccessor(StringAccessorSharedPtr accessor) { | ||
return envoy_string_accessor{&c_string_accessor_read, new StringAccessorSharedPtr(accessor)}; | ||
} | ||
|
||
} // namespace Platform | ||
} // namespace Envoy |
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,36 @@ | ||
#pragma once | ||
|
||
#include <memory> | ||
|
||
#include "envoy/common/pure.h" | ||
|
||
#include "absl/types/optional.h" | ||
#include "library/common/api/c_types.h" | ||
|
||
namespace Envoy { | ||
namespace Platform { | ||
|
||
/** | ||
* `StringAccessor` is an interface that may be implemented to provide access to an arbitrary | ||
* string from the application. | ||
*/ | ||
class StringAccessor : public std::enable_shared_from_this<StringAccessor> { | ||
public: | ||
virtual ~StringAccessor() = default; | ||
|
||
/** | ||
* Returns the string associated with this accessor. | ||
*/ | ||
virtual const std::string& get() const PURE; | ||
|
||
/** | ||
* Maps an implementation to its internal representation. | ||
* @return portable internal type used to call an implementation. | ||
*/ | ||
static envoy_string_accessor asEnvoyStringAccessor(std::shared_ptr<StringAccessor> accessor); | ||
}; | ||
|
||
using StringAccessorSharedPtr = std::shared_ptr<StringAccessor>; | ||
|
||
} // namespace Platform | ||
} // namespace Envoy |
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