mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-19 13:47:56 +00:00
os: make 'Buffered_xml' util publicly available
The 'Buffered_xml' utility is used by three components and a fourth is on the way. To avoid another duplication of the code, this patch makes it publicly available at 'os/buffered_xml.h'.
This commit is contained in:
parent
a740b066a6
commit
cde8163770
@ -17,6 +17,7 @@
|
||||
/* Genode includes */
|
||||
#include <util/reconstructible.h>
|
||||
#include <os/session_policy.h>
|
||||
#include <os/buffered_xml.h>
|
||||
#include <util/color.h>
|
||||
|
||||
/* decorator includes */
|
||||
@ -81,40 +82,9 @@ class Decorator::Config
|
||||
|
||||
private:
|
||||
|
||||
struct Buffered_xml
|
||||
{
|
||||
Allocator &_alloc;
|
||||
char const * const _ptr; /* pointer to dynamically allocated buffer */
|
||||
Xml_node const _xml; /* referring to buffer of '_ptr' */
|
||||
|
||||
/**
|
||||
* \throw Allocator::Out_of_memory
|
||||
*/
|
||||
static char const *_init_ptr(Allocator &alloc, Xml_node node)
|
||||
{
|
||||
char *ptr = (char *)alloc.alloc(node.size());
|
||||
Genode::memcpy(ptr, node.addr(), node.size());
|
||||
return ptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* \throw Allocator::Out_of_memory
|
||||
*/
|
||||
Buffered_xml(Allocator &alloc, Xml_node node)
|
||||
:
|
||||
_alloc(alloc), _ptr(_init_ptr(alloc, node)), _xml(_ptr, node.size())
|
||||
{ }
|
||||
|
||||
~Buffered_xml() { _alloc.free(const_cast<char *>(_ptr), _xml.size()); }
|
||||
|
||||
Xml_node xml() const { return _xml; }
|
||||
};
|
||||
|
||||
Genode::Allocator &_alloc;
|
||||
|
||||
Reconstructible<Buffered_xml> _buffered_config;
|
||||
Reconstructible<Genode::Buffered_xml> _buffered_config;
|
||||
|
||||
/**
|
||||
* Maximum number of configured window controls
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
/* Genode includes */
|
||||
#include <timer_session/connection.h>
|
||||
#include <os/buffered_xml.h>
|
||||
|
||||
/* local includes */
|
||||
#include <fading_dialog.h>
|
||||
@ -50,37 +51,6 @@ class Launcher::Panel_dialog : Input_event_handler, Dialog_generator,
|
||||
|
||||
Genode::Allocator &_alloc;
|
||||
|
||||
struct Buffered_xml
|
||||
{
|
||||
Allocator &_alloc;
|
||||
char const * const _ptr; /* pointer to dynamically allocated buffer */
|
||||
Xml_node const _xml; /* referring to buffer of '_ptr' */
|
||||
|
||||
/**
|
||||
* \throw Allocator::Out_of_memory
|
||||
*/
|
||||
static char const *_init_ptr(Allocator &alloc, Xml_node node)
|
||||
{
|
||||
char *ptr = (char *)alloc.alloc(node.size());
|
||||
Genode::memcpy(ptr, node.addr(), node.size());
|
||||
return ptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* \throw Allocator::Out_of_memory
|
||||
*/
|
||||
Buffered_xml(Allocator &alloc, Xml_node node)
|
||||
:
|
||||
_alloc(alloc), _ptr(_init_ptr(alloc, node)), _xml(_ptr, node.size())
|
||||
{ }
|
||||
|
||||
~Buffered_xml() { _alloc.free(const_cast<char *>(_ptr), _xml.size()); }
|
||||
|
||||
Xml_node xml() const { return _xml; }
|
||||
};
|
||||
|
||||
Constructible<Buffered_xml> _config;
|
||||
|
||||
List<Element> _elements;
|
||||
|
@ -11,16 +11,16 @@
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
#ifndef _SRC__INIT__BUFFERED_XML_H_
|
||||
#define _SRC__INIT__BUFFERED_XML_H_
|
||||
#ifndef _OS__BUFFERED_XML_H_
|
||||
#define _OS__BUFFERED_XML_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <util/xml_node.h>
|
||||
|
||||
namespace Init { class Buffered_xml; }
|
||||
namespace Genode { class Buffered_xml; }
|
||||
|
||||
|
||||
class Init::Buffered_xml
|
||||
class Genode::Buffered_xml
|
||||
{
|
||||
private:
|
||||
|
||||
@ -61,4 +61,4 @@ class Init::Buffered_xml
|
||||
Xml_node xml() const { return _xml; }
|
||||
};
|
||||
|
||||
#endif /* _SRC__INIT__BUFFERED_XML_H_ */
|
||||
#endif /* _OS__BUFFERED_XML_H_ */
|
@ -19,12 +19,12 @@
|
||||
#include <base/child.h>
|
||||
#include <os/session_requester.h>
|
||||
#include <os/session_policy.h>
|
||||
#include <os/buffered_xml.h>
|
||||
|
||||
/* local includes */
|
||||
#include <types.h>
|
||||
#include <verbose.h>
|
||||
#include <report.h>
|
||||
#include <buffered_xml.h>
|
||||
#include <name_registry.h>
|
||||
#include <service.h>
|
||||
#include <utils.h>
|
||||
|
@ -16,11 +16,11 @@
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/attached_rom_dataspace.h>
|
||||
#include <os/buffered_xml.h>
|
||||
|
||||
/* local includes */
|
||||
#include "types.h"
|
||||
#include "service.h"
|
||||
#include "buffered_xml.h"
|
||||
#include "state_reporter.h"
|
||||
|
||||
namespace Init { class Server; }
|
||||
|
Loading…
Reference in New Issue
Block a user