Project
Loading...
Searching...
No Matches
InputDocument.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#ifndef O2_MCH_MAPPING_TEST_INPUT_DOCUMENT_H
13#define O2_MCH_MAPPING_TEST_INPUT_DOCUMENT_H
14
15#include <rapidjson/document.h>
16#include <cstdio>
17#include <rapidjson/filereadstream.h>
18
19template <typename StreamType>
21{
22 public:
24 : mFile(fopen(filename, "r")),
25 mReadBuffer(new char[65536]),
26 mStream(mFile, mReadBuffer, sizeof(mReadBuffer)),
27 mDocument()
28 {
29 mDocument.ParseStream(mStream);
30 }
31
32 rapidjson::Document& document() { return mDocument; }
33
35 {
36 delete[] mReadBuffer;
37 fclose(mFile);
38 }
39
40 private:
41 FILE* mFile;
42 char* mReadBuffer;
43 StreamType mStream;
44 rapidjson::Document mDocument;
45};
46
48
49#endif
InputDocument(const char *filename)
virtual ~InputDocument()
rapidjson::Document & document()
std::string filename()