Belle II Software development
StringHandler.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10
11#include <framework/gearbox/InputHandler.h>
12#include <sstream>
13
14namespace Belle2 {
19 namespace gearbox {
22 public:
24 explicit StringContext(const std::string& data): m_stream(data) {};
26 virtual int readXmlData(char* buffer, int buffsize) override
27 {
28 m_stream.read(buffer, buffsize);
29 return m_stream.gcount();
30 }
31 protected:
33 std::istringstream m_stream;
34 };
35
43 public:
45 explicit StringHandler(const std::string& uri): InputHandler(uri) {}
47 virtual ~StringHandler() {}
49 virtual InputContext* open(const std::string& path) override;
50 };
51 }
53}
Class representing a resource context for gearbox.
Definition: InputHandler.h:25
Class to provide an InputContext for a given XML resource name.
Definition: InputHandler.h:47
InputContext which just returns the value of a string previously assigned.
Definition: StringHandler.h:21
virtual int readXmlData(char *buffer, int buffsize) override
Return a block of the data.
Definition: StringHandler.h:26
StringContext(const std::string &data)
Take an XML fragment as parameter and create a context for it.
Definition: StringHandler.h:24
std::istringstream m_stream
Assigned data string.
Definition: StringHandler.h:33
InputHandler which just takes the uri as XML data.
Definition: StringHandler.h:42
virtual InputContext * open(const std::string &path) override
Create a new context, path will be ignored.
StringHandler(const std::string &uri)
Create a new InputHandler which always returns uri as XML content.
Definition: StringHandler.h:45
virtual ~StringHandler()
empty, virtual destructor
Definition: StringHandler.h:47
Abstract base class for different kinds of events.