IODA Bundle
PartFileHandleFactory.cc
Go to the documentation of this file.
1 /*
2  * (C) Copyright 1996-2016 ECMWF.
3  *
4  * This software is licensed under the terms of the Apache Licence Version 2.0
5  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6  * In applying this licence, ECMWF does not waive the privileges and immunities
7  * granted to it by virtue of its status as an intergovernmental organisation nor
8  * does it submit to any jurisdiction.
9  */
10 
11 #include <sstream>
12 
14 #include "eckit/io/PartFileHandle.h"
15 #include "eckit/utils/StringTools.h"
16 
17 using namespace eckit;
18 using namespace std;
19 
20 namespace odc {
21 
22 PartFileHandleFactory::PartFileHandleFactory()
23 : DataHandleFactory("partfile")
24 {}
25 
26 DataHandle* PartFileHandleFactory::makeHandle(const string& descriptor) const
27 {
28  vector<string> ps (StringTools::split(":", descriptor));
29  string fileName (ps[0]);
30  vector<string> range (StringTools::split(",", ps[ps.size() - 1]));
31 
32  Offset offset (atoi(range[0].c_str()));
33  Length length (atoi(range[1].c_str()));
34 
35  return new PartFileHandle(fileName, offset, length);
36 }
37 
38 } // namespace odc
eckit::DataHandle * makeHandle(const std::string &) const
Definition: ColumnInfo.h:23
Definition: encode.cc:30