X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Floader.h;h=e1522de11aaa8be8dbcba9d40f74c669cbf373d6;hb=2f79370bffe0bac865dc97c5114dc87c1936fbb4;hp=9c0933694e074389a5931f3af8a5e2fc029ca6f7;hpb=505042fcda16151f5ace243c243d34af3efcf677;p=libs%2Fdatafile.git 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;