X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fcontrollers%2Fhelper_funcs.h;h=3631b692b059b09905e9e274f926a04e66d47706;hb=7ea7dabed1b72cc25dcbdc482ac006f2b61dacfd;hp=afc15e4b1affed49a9735ed81b738daa8e629743;hpb=58d99b4a97b85a750704cf84c9639b408117271c;p=lyx.git diff --git a/src/frontends/controllers/helper_funcs.h b/src/frontends/controllers/helper_funcs.h index afc15e4b1a..3631b692b0 100644 --- a/src/frontends/controllers/helper_funcs.h +++ b/src/frontends/controllers/helper_funcs.h @@ -42,42 +42,31 @@ class LyXView; string const browseFile(LyXView *lv, string const & filename, string const & title, string const & pattern, - std::pair const & dir1, - std::pair const & dir2); + std::pair const & dir1 = std::make_pair(string(), string()), + std::pair const & dir2 = std::make_pair(string(), string())); -/** Functions to extract vectors of the first and second elems from a - vector > -*/ - -/// -template -std::vector const getFirst(std::vector > const & pairVec) -{ - typedef std::vector > PV; - - std::vector first(pairVec.size()); - - for (PV::size_type i = 0; i < pairVec.size(); ++i) { - first[i] = pairVec[i].first; - } - return first; -} -/// -template -std::vector const getSecond(std::vector > const & pairVec) -{ - typedef std::vector > PV; +/* Wrapper around browseFile which tries to provide a filename + relative to relpath. If the relative path is of the form "foo.txt" + or "bar/foo.txt", then it is returned as relative. OTOH, if it is + of the form "../baz/foo.txt", an absolute path is returned. This is + intended to be useful for insets which encapsulate files/ +*/ +string const browseRelFile(LyXView *lv, string const & filename, + string const & refpath, + string const & title, + string const & pattern, + std::pair const & dir1 = std::make_pair(string(), string()), + std::pair const & dir2 = std::make_pair(string(), string())); - std::vector second(pairVec.size()); - for (PV::size_type i = 0; i < pairVec.size(); ++i) { - second[i] = pairVec[i].second; - } +/// Returns a vector of units that can be used to create a valid LaTeX length. +std::vector const getLatexUnits(); - return second; -} +/** Functions to extract vectors of the first and second elems from a + vector > +*/ template struct firster { @@ -91,23 +80,25 @@ struct seconder { second_type const & operator()(Pair const & p) { return p.second; } }; +/// template -typename Pair::first_type const getFirst(std::vector const & pr) +std::vector const +getFirst(std::vector const & pr) { - std::vector tmp(pr.size); + std::vector tmp(pr.size()); std::transform(pr.begin(), pr.end(), tmp.begin(), firster()); return tmp; } +/// template -typename Pair::second_type const getSecond(std::vector const & pr) +std::vector const +getSecond(std::vector const & pr) { - std::vector tmp(pr.size); + std::vector tmp(pr.size()); std::transform(pr.begin(), pr.end(), tmp.begin(), seconder()); return tmp; } - #endif // HELPERFUNCS_H -