1616#include < map> // std::map
1717#include < ostream> // std::ostream
1818#include < string> // std::string
19- #include < tuple> // std::tie
2019#include < utility> // std::pair
2120#include < vector> // std::vector
2221
@@ -83,6 +82,14 @@ class SOURCEMETA_BLAZE_OUTPUT_EXPORT SimpleOutput {
8382 std::reference_wrapper<const std::string> schema_location;
8483 };
8584
85+ // / A single collected annotation, in evaluation order
86+ struct AnnotationEntry {
87+ sourcemeta::core::WeakPointer instance_location;
88+ sourcemeta::core::WeakPointer evaluate_path;
89+ std::reference_wrapper<const std::string> schema_location;
90+ sourcemeta::core::JSON value;
91+ };
92+
8693 auto operator ()(const EvaluationType type, const bool result,
8794 const Instruction &step,
8895 const InstructionExtra &step_metadata,
@@ -97,12 +104,6 @@ class SOURCEMETA_BLAZE_OUTPUT_EXPORT SimpleOutput {
97104 [[nodiscard]] auto cbegin () const -> const_iterator;
98105 [[nodiscard]] auto cend () const -> const_iterator;
99106
100- // / Access annotations that were collected during evaluation, indexed by
101- // / instance location and evaluation path
102- [[nodiscard]] auto annotations () const -> const auto & {
103- return this ->annotations_ ;
104- }
105-
106107 // / Move out the collected error entries, leaving this output empty. Useful to
107108 // / take ownership of the trace without copying when the output is no longer
108109 // / needed
@@ -114,22 +115,14 @@ class SOURCEMETA_BLAZE_OUTPUT_EXPORT SimpleOutput {
114115 return result;
115116 }
116117
117- // NOLINTNEXTLINE(bugprone-exception-escape)
118- struct Location {
119- auto operator <(const Location &other) const noexcept -> bool {
120- // Perform a lexicographical comparison
121- return std::tie (this ->instance_location , this ->evaluate_path ,
122- this ->schema_location .get ()) <
123- std::tie (other.instance_location , other.evaluate_path ,
124- other.schema_location .get ());
125- }
126-
127- // NOLINTBEGIN(cppcoreguidelines-avoid-const-or-ref-data-members)
128- const sourcemeta::core::WeakPointer instance_location;
129- const sourcemeta::core::WeakPointer evaluate_path;
130- const std::reference_wrapper<const std::string> schema_location;
131- // NOLINTEND(cppcoreguidelines-avoid-const-or-ref-data-members)
132- };
118+ // / Access the annotations collected during evaluation, as a flat log in
119+ // / evaluation order. The log records every emission as-is, so a location may
120+ // / repeat and hold the same value more than once. Consumers that need them
121+ // / grouped by location, or collapsed to distinct values, index this log
122+ // / themselves
123+ [[nodiscard]] auto annotations () const -> const auto & {
124+ return this ->annotations_ ;
125+ }
133126
134127private:
135128// Exporting symbols that depends on the standard C++ library is considered
@@ -148,7 +141,7 @@ class SOURCEMETA_BLAZE_OUTPUT_EXPORT SimpleOutput {
148141 std::pair<sourcemeta::core::WeakPointer, sourcemeta::core::WeakPointer>,
149142 std::vector<Entry>>
150143 masked_traces;
151- std::map<Location, std:: vector<sourcemeta::core:: JSON > > annotations_;
144+ std::vector<AnnotationEntry > annotations_;
152145#if defined(_MSC_VER)
153146#pragma warning(default : 4251)
154147#endif
0 commit comments