Library: add option to bypass the sanitising in EntryID

While in general it is fine to clean-up any entity IDs
to be US-ASCII alphanumerics (plus some allowed interpunction),
the GenNodes and also keys in object-bindings for diff are
considerd internal interfaces, assuming that any passed
ID symbol is already sanitised and checked. So the
sanitise operation can be skipped. This changeset
adds the same option directly to lib::EntryID,
allowing to create an EntryID that matches
a similar GenNode's (hash) ID.
This commit is contained in:
Fischlurch 2016-05-28 03:21:04 +02:00
parent 16086caf42
commit 5dbe877318
2 changed files with 23 additions and 1 deletions

View file

@ -229,6 +229,19 @@ namespace idi {
EntryID (string const& symbolID)
: BareEntryID (util::sanitise(symbolID), getTypeHash<TY>())
{ }
explicit
EntryID (const char* symbolID)
: BareEntryID (util::sanitise(symbolID), getTypeHash<TY>())
{ }
/** case-2b: rely on an internal, already sanitised symbol.
* The symbol string will be passed through as-is, while
* the type information from TY will be hashed in.
*/
explicit
EntryID (Symbol const& internalSymbol)
: BareEntryID (string(internalSymbol), getTypeHash<TY>())
{ }
/** @return true if the upcast would yield exactly the same

View file

@ -137,10 +137,19 @@ namespace test{
using proc::asset::idi::getAssetIdent;
ForkID tID(" test ⚡ ☠ ☭ ⚡ track ");
CHECK (getAssetIdent(tID) == Asset::Ident("test_track", Category(STRUCT,"forks"), "lumi", 0));
// Symbol-ID will be "sanitised"
CHECK ("test_track" == tID.getSym());
CHECK (tID == ForkID("☢ test ☢ track ☢"));
CHECK (tID == ForkID(string{"☢ test ☢ track ☢"}));
// but: there is a pass-through for internal symbols
CHECK (tID != ForkID(Symbol{"☢ test ☢ track ☢"}));
CHECK (tID.getHash() == ForkID("☢ test ☢ track ☢").getHash());
CHECK (getAssetIdent(tID) == Asset::Ident("test_track", Category(STRUCT,"forks"), "lumi", 0));
CHECK (tID.getSym() == getAssetIdent(tID).name);
CHECK (getAssetIdent(ForkID()).category == Category (STRUCT,"forks"));
CHECK (getAssetIdent(ClipID()).category == Category (STRUCT,"clips"));