-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
69 changed files
with
3,933 additions
and
1,088 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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright 2023 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "common/any.h" | ||
|
||
#include <string> | ||
|
||
#include "absl/strings/str_cat.h" | ||
#include "absl/strings/string_view.h" | ||
#include "internal/strings.h" | ||
|
||
namespace cel { | ||
|
||
std::string Any::DebugString() const { | ||
std::string value_scratch; | ||
absl::string_view value_view; | ||
if (auto flat = value().TryFlat(); flat.has_value()) { | ||
value_view = *flat; | ||
} else { | ||
value_scratch = static_cast<std::string>(value()); | ||
value_view = value_scratch; | ||
} | ||
return absl::StrCat("google.protobuf.Any{type_url: ", | ||
internal::FormatStringLiteral(type_url()), | ||
", value: ", internal::FormatBytesLiteral(value_view), | ||
"}"); | ||
} | ||
|
||
} // namespace cel |
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
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,50 @@ | ||
// Copyright 2023 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// IWYU pragma: private | ||
|
||
#include "common/types/thread_compatible_type_provider.h" | ||
|
||
#include "absl/status/status.h" | ||
#include "absl/status/statusor.h" | ||
#include "absl/strings/str_cat.h" | ||
#include "absl/strings/string_view.h" | ||
#include "common/type.h" | ||
#include "common/type_provider.h" | ||
|
||
namespace cel::common_internal { | ||
|
||
absl::StatusOr<TypeView> ThreadCompatibleTypeProvider::FindType( | ||
TypeFactory&, absl::string_view name, Type&) { | ||
return absl::NotFoundError(absl::StrCat("no such type: ", name)); | ||
} | ||
|
||
absl::StatusOr<StructTypeFieldView> | ||
ThreadCompatibleTypeProvider::FindStructTypeFieldByName(TypeFactory&, | ||
absl::string_view type, | ||
absl::string_view, | ||
StructTypeField&) { | ||
return absl::NotFoundError(absl::StrCat("no such struct type: ", type)); | ||
} | ||
|
||
absl::StatusOr<StructTypeFieldView> | ||
ThreadCompatibleTypeProvider::FindStructTypeFieldByName(TypeFactory&, | ||
StructTypeView type, | ||
absl::string_view, | ||
StructTypeField&) { | ||
return absl::NotFoundError( | ||
absl::StrCat("no such struct type: ", type.DebugString())); | ||
} | ||
|
||
} // namespace cel::common_internal |
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,56 @@ | ||
// Copyright 2023 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// IWYU pragma: private | ||
|
||
#ifndef THIRD_PARTY_CEL_CPP_COMMON_TYPES_THREAD_COMPATIBLE_TYPE_PROVIDER_H_ | ||
#define THIRD_PARTY_CEL_CPP_COMMON_TYPES_THREAD_COMPATIBLE_TYPE_PROVIDER_H_ | ||
|
||
#include "absl/status/statusor.h" | ||
#include "absl/strings/string_view.h" | ||
#include "common/memory.h" | ||
#include "common/type.h" | ||
#include "common/type_provider.h" | ||
|
||
namespace cel::common_internal { | ||
|
||
// `ThreadCompatibleTypeProvider` is a basic implementation of `TypeProvider` | ||
// which is thread compatible. By default this implementation just returns | ||
// `NOT_FOUND` for most methods. | ||
class ThreadCompatibleTypeProvider : public virtual TypeProvider { | ||
public: | ||
explicit ThreadCompatibleTypeProvider(MemoryManagerRef memory_manager) | ||
: memory_manager_(memory_manager) {} | ||
|
||
MemoryManagerRef GetMemoryManager() const final { return memory_manager_; } | ||
|
||
absl::StatusOr<TypeView> FindType(TypeFactory& type_factory, | ||
absl::string_view name, | ||
Type& scratch) override; | ||
|
||
absl::StatusOr<StructTypeFieldView> FindStructTypeFieldByName( | ||
TypeFactory& type_factory, absl::string_view type, absl::string_view name, | ||
StructTypeField& scratch) override; | ||
|
||
absl::StatusOr<StructTypeFieldView> FindStructTypeFieldByName( | ||
TypeFactory& type_factory, StructTypeView type, absl::string_view name, | ||
StructTypeField& scratch) override; | ||
|
||
private: | ||
MemoryManagerRef memory_manager_; | ||
}; | ||
|
||
} // namespace cel::common_internal | ||
|
||
#endif // THIRD_PARTY_CEL_CPP_COMMON_TYPES_THREAD_COMPATIBLE_TYPE_PROVIDER_H_ |
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
Oops, something went wrong.