All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
FileReadTool.cpp
Go to the documentation of this file.
1 #include "FileReadTool.h"
2 #include <fstream>
3 
5 
6 FileReadTool::FileReadTool( const std::string& type,
7  const std::string& name,
8  const IInterface* parent):
9  base_class(type, name, parent)
10 {
11  //declareInterface<IFileAccess>(this);
12 }
13 
14 std::unique_ptr<std::istream> FileReadTool::open(const std::string &url) {
15  // remove the optional "file://" from the beginning of the url
16  std::string path;
17  if ( url.compare(0,7,"file://") == 0 ) {
18  path = url.substr(7);
19  } else {
20  path = url;
21  }
22  return std::unique_ptr<std::istream>(new std::ifstream{path});
23 }
24 
25 const std::vector<std::string> &FileReadTool::protocols() const
26 {
28  static const std::vector<std::string> s_protocols = {{"file"}};
29  return s_protocols;
30 }
Basic implementation of the IFileAccess interface.
Definition: FileReadTool.h:16
list path
Definition: __init__.py:15
STL namespace.
#define DECLARE_COMPONENT(type)
Definition: PluginService.h:36
Definition of the basic interface.
Definition: IInterface.h:234
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
const std::vector< std::string > & protocols() const override
Protocols supported by the instance.
std::unique_ptr< std::istream > open(const std::string &url) override
string type
Definition: gaudirun.py:151