X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcollection.cpp;h=bf1c5edc211e93b33f1dacc833e0ac1a38657a5e;hb=b1bc25649c1f22abf940a807d934f1e9bb780c28;hp=d52ee22399ba7500c880798f2fcf3036d9cd095c;hpb=4f036ceabe12869c86cb6821f698fbb65cd47ea6;p=libs%2Fdatafile.git diff --git a/source/collection.cpp b/source/collection.cpp index d52ee22..bf1c5ed 100644 --- a/source/collection.cpp +++ b/source/collection.cpp @@ -1,5 +1,7 @@ #include "collection.h" +using namespace std; + namespace Msp { namespace DataFile { @@ -9,6 +11,11 @@ Collection::~Collection() delete *i; } +void Collection::add_source(CollectionSource &s) +{ + sources.push_back(&s); +} + Collection::Loader::Loader(Collection &c): coll(c) @@ -27,5 +34,25 @@ CollectionItemTypeBase::~CollectionItemTypeBase() delete tag; } +void CollectionItemTypeBase::set_keyword(const string &k) +{ + kwd = k; + if(suffixes.empty()) + add_suffix("."+kwd); +} + +void CollectionItemTypeBase::add_suffix(const string &s) +{ + suffixes.push_back(s); +} + +bool CollectionItemTypeBase::match_name(const string &name) const +{ + for(vector::const_iterator i=suffixes.begin(); i!=suffixes.end(); ++i) + if(name.size()>i->size() && !name.compare(name.size()-i->size(), string::npos, *i)) + return true; + return false; +} + } // namespace DataFile } // namespace Msp