Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Ericson2314 committed Jul 21, 2024
1 parent 48aa3bb commit 1344bcd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
20 changes: 9 additions & 11 deletions src/libstore/dummy-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,28 @@ DummyStoreConfig::DummyStoreConfig(
throw UsageError("`%s` store URIs must not contain an authority part %s", scheme, authority);
}

std::string DummyStoreConfig::doc()
std::string DummyStoreConfig::doc() const
{
return
#include "dummy-store.md"
;
}


const DummyStoreConfig::Descriptions DummyStoreConfig::descriptions{};


struct DummyStore : public virtual DummyStoreConfig, public virtual Store
struct DummyStore : virtual Store
{
using Config = DummyStoreConfig;

DummyStore(const Config & config)
: StoreConfig(config)
, DummyStoreConfig(config)
, Store{static_cast<const Store::Config &>(*this)}
ref<const Config> config;

DummyStore(ref<const Config> config)
: Store{*config}
, config(config)
{ }

std::string getUri() override
{
return *uriSchemes().begin();
return *Config::uriSchemes().begin() + "://";
}

void queryPathInfoUncached(const StorePath & path,
Expand Down Expand Up @@ -82,7 +80,7 @@ struct DummyStore : public virtual DummyStoreConfig, public virtual Store

ref<Store> DummyStore::Config::openStore() const
{
return make_ref<DummyStore>(*this);
return make_ref<DummyStore>(ref{shared_from_this()});
}

static RegisterStoreImplementation<DummyStore::Config> regDummyStore;
Expand Down
14 changes: 7 additions & 7 deletions src/libstore/store-registration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,12 @@ ref<const StoreConfig> adl_serializer<ref<const StoreConfig>>::from_json(const j

case json::value_t::object: {
auto & obj = json.get_ref<const json::object_t &>();
ref = StoreReference {
.variant = StoreReference::Specified{
.scheme = getString(valueAt(obj, "scheme")),
.authority = getString(valueAt(obj, "authority")),
},
ref = StoreReference{
.variant =
StoreReference::Specified{
.scheme = getString(valueAt(obj, "scheme")),
.authority = getString(valueAt(obj, "authority")),
},
.params = obj,
};
break;
Expand All @@ -143,8 +144,7 @@ ref<const StoreConfig> adl_serializer<ref<const StoreConfig>>::from_json(const j
case json::value_t::discarded:
default:
throw UsageError(
"Invalid JSON for Store configuration: is type '%s' but must be string or object",
json.type_name());
"Invalid JSON for Store configuration: is type '%s' but must be string or object", json.type_name());
};

return resolveStoreConfig(std::move(ref));
Expand Down

0 comments on commit 1344bcd

Please sign in to comment.