Skip to content

Commit

Permalink
Simplify and small changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinH committed Apr 5, 2024
1 parent 2d2971b commit 1974957
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 65 deletions.
5 changes: 4 additions & 1 deletion doc/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@

Pre-1.0.0 milestones in rough reverse chronological order.

* Restrict some phase 1 features[^1].
* Make functions[^2] a phase 2 features.
* Remove schema support (temporarily?).
* Integrate value extensions with phase 2.
* Reduce member extensions to the essentials.
* Remove the minus token from config keys.
* Change the semantics of star and move evaluation to phase two.
Expand All @@ -27,5 +28,7 @@ Development of taoCONFIG started in September 2018 to provide a more expressive

Copyright (c) 2018-2024 Dr. Colin Hirsch and Daniel Frey

[^1]: Previously "member extensions".
[^2]: Previously "value extensions".
[JAXN]: https://github.com/stand-art/jaxn
[JSON]: https://tools.ietf.org/html/rfc8259
12 changes: 6 additions & 6 deletions include/tao/config/internal/phase2_access.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@ namespace tao::config::internal

[[nodiscard]] inline const concat* phase2_access( const concat& c, const key1& suffix, const int down )
{
if( suffix.empty() ) {
if( ( c.concat.size() < 2 ) && ( statistics( c ).references() == 0 ) ) {
return &c;
}
throw phase2_access_return();
if( !suffix.empty() ) {
return phase2_access( c, suffix.at( 0 ), pop_front( suffix ), down );
}
if( statistics( c ).is_primitive() ) {
return &c;
}
return phase2_access( c, suffix.at( 0 ), pop_front( suffix ), down );
throw phase2_access_return();
}

[[nodiscard]] inline const concat* phase2_access( const object& o, const key1& prefix, const key1& suffix )
Expand Down
48 changes: 0 additions & 48 deletions include/tao/config/internal/phase2_guard.hpp

This file was deleted.

10 changes: 1 addition & 9 deletions include/tao/config/internal/phase2_references.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "json.hpp"
#include "object.hpp"
#include "phase2_access.hpp"
#include "phase2_guard.hpp"
#include "string_utility.hpp"

namespace tao::config::internal
Expand All @@ -31,24 +30,18 @@ namespace tao::config::internal

[[nodiscard]] std::size_t process()
{
assert( m_stack.empty() );

for( auto& p : m_root.object ) {
process_concat( key1{ key1_part( p.first, m_root.position ) }, p.second );
}
assert( m_stack.empty() );
return m_changes;
}

private:
object& m_root;
std::size_t m_changes = 0;
std::set< const void* > m_stack;

void process_concat( const key1& prefix, concat& c )
{
const phase2_guard dog( m_stack, c );

for( auto& e : c.concat ) {
if( const concat* d = process_entry( prefix, e ); d != nullptr ) {
assert( d != &c ); // TODO: This needs to be ensured elsewhere/in another way.
Expand Down Expand Up @@ -89,7 +82,7 @@ namespace tao::config::internal
}
assert( !prefix.empty() );

return phase2_access( m_root, pop_back( prefix ), suffix );
return phase2_access( m_root, pop_back( prefix ), suffix ); // Returns nullptr if not primitive.
}

[[nodiscard]] std::optional< key1_part > process_inner_reference( const key1& prefix, const std::vector< reference2_part >& reference )
Expand Down Expand Up @@ -142,7 +135,6 @@ namespace tao::config::internal
}
return nullptr;
case entry_kind::ASTERISK:
// process_concat( prefix + key1_part( part_asterisk, m_root.position ), e.get_concat() );
return nullptr;
case entry_kind::REFERENCE:
return process_reference_parts( prefix, e.get_reference() );
Expand Down
2 changes: 1 addition & 1 deletion src/test/config/value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace tao::config

try {
(void)v.as< std::string >();
++failed;
++failed; // LCOV_EXCL_LINE
}
catch( const std::exception& e ) {
TAO_CONFIG_TEST_ASSERT( e.what() == s );
Expand Down
5 changes: 5 additions & 0 deletions tests/extensions.jaxn
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,10 @@
a: "",
b: "foo",
c: "01"
},
unready: {
a: "env_value",
b: "env_value",
c: "env_value"
}
}
7 changes: 7 additions & 0 deletions tests/extensions.success
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,10 @@ string
b = (string "foo")
c = (string $3031)
}

unready
{
a = (env "TAO_CONFIG")
b = (default (a) (c))
c = (env "TAO_CONFIG")
}

0 comments on commit 1974957

Please sign in to comment.