On 08/27/2015 07:34 PM, Giuseppe Castagno wrote:
I wonder if in INetURLObject I can put a single method like this: bool INetURLObject::IsWebDAV() { return ( hasScheme( "http" ) || hasScheme( "https" ) || hasScheme( "vnd.sun.start.webdav" ) || hasScheme( "vnd.sun.start.webdavs" ) ); } to have this test in a single place? Currently I repeat it four times.
Sure, or maybe something more descriptive like isAnyWebDavScheme (so casual readers don't erroneously assume it only checks for vnd.sun.star.webdav). Also, for schemes known in INetProtocol, feel free to use the hasScheme(INetProtocol) overload, which should be slightly faster (which is likely negligible) and less prone to typos.
Finally, looking at the code in INetURLObject I noticed this comment: http://opengrok.libreoffice.org/xref/core/tools/source/fsys/urlobj.cxx#114 and this chunk of code: http://opengrok.libreoffice.org/xref/core/tools/source/fsys/urlobj.cxx#335 should vnd.sun.star.webdavs be added as well?
No, all that is only about those schemes that INetURLObject has intimate knowledge of. Traditionally, for any URL scheme to be "usable" in LO it needed to be added to INetURLObject, with scheme-specific parsing support and all (and that is how the rather random collection of schemes in INetProtocol came about over time). But that is largely unnecessary today.