From: Mikko Rasa Date: Sat, 22 Sep 2007 17:04:16 +0000 (+0000) Subject: Add Loader::get_source X-Git-Tag: 1.0~20 X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=b42b462c13b3a50c3b209bc8c34bf1fcf3a151b2;p=libs%2Fdatafile.git Add Loader::get_source Add a version of the two-parameter load_sub function that determines the loader class automatically --- diff --git a/source/loader.h b/source/loader.h index 9c09336..e1522de 100644 --- a/source/loader.h +++ b/source/loader.h @@ -255,8 +255,8 @@ protected: { actions.insert(ActionMap::value_type(k, 0)); } /** - Loads a sub-object from the statement being currently processed. The Loader - class of the sub-object is automatically used. + Loads a sub-object from the statement being processed. The Loader class of + the sub-object is automatically used. */ template void load_sub(S &s) @@ -274,6 +274,10 @@ protected: loader.load(*cur_st); } + template + void load_sub(S &s, T &p) + { load_sub(s, p); } + /** Loads a sub-object with a custom Loader class that takes one argument in addition to to object to be loaded. @@ -286,6 +290,18 @@ protected: L loader(s, p); loader.load(*cur_st); } + + /** + Returns the source of the statement being processed. This can be used to + implement relative paths in include-like statements. Note that the source + may not necessarily be a file. + */ + const std::string &get_source() const + { + if(!cur_st) + throw InvalidState("get_source called without current statement"); + return cur_st->source; + } private: typedef std::map ActionMap;