demarshaling.h
Go to the documentation of this file.
1 // SPDX-License-Identifier: LGPL-3.0-or-later OR BSD-3-Clause
2 /***************************************************************************
3  * Copyright (C) 2020 by Robert Middleton *
4  * robert.middleton@rm5248.com *
5  * *
6  * This file is part of the dbus-cxx library. *
7  ***************************************************************************/
8 #ifndef DBUSCXX_DEMARSHALING_H
9 #define DBUSCXX_DEMARSHALING_H
10 
11 #include <stdint.h>
12 #include <dbus-cxx/variant.h>
13 #include <dbus-cxx/path.h>
14 #include <dbus-cxx/signature.h>
15 #include <dbus-cxx/enums.h>
17 #include <memory>
18 
19 namespace DBus {
20 
27 class Demarshaling {
28 public:
29  Demarshaling();
30 
35  Demarshaling( const uint8_t* data, uint32_t dataLen, Endianess endian );
36 
37  ~Demarshaling();
38 
46  void set_data( const uint8_t* data, uint32_t dataLen );
47 
48  void set_endianess( Endianess endian );
49 
55  void set_data_offset( uint32_t offset );
56 
57  void align( int alignment );
58 
59  uint32_t current_offset() const;
60 
61  uint8_t demarshal_uint8_t();
62  bool demarshal_boolean();
63  int16_t demarshal_int16_t();
64  uint16_t demarshal_uint16_t();
65  int32_t demarshal_int32_t();
66  uint32_t demarshal_uint32_t();
67  int64_t demarshal_int64_t();
68  uint64_t demarshal_uint64_t();
69  double demarshal_double();
70  std::string demarshal_string();
74 
75 private:
81  void is_valid( uint32_t numBytesWanted );
82  int16_t demarshalShortBig();
83  int16_t demarshalShortLittle();
84  int32_t demarshalIntBig();
85  int32_t demarshalIntLittle();
86  int64_t demarshalLongBig();
87  int64_t demarshalLongLittle();
88 
89 private:
90  class priv_data;
91 
92  DBUS_CXX_PROPAGATE_CONST( std::unique_ptr<priv_data> ) m_priv;
93 };
94 
95 }
96 
97 #endif /* DBUSCXX_DEMARSHALING_H */
Routines for demarshaling data.
Definition: demarshaling.h:27
int16_t demarshalShortLittle()
Definition: demarshaling.cpp:226
void is_valid(uint32_t numBytesWanted)
Checks to make sure that we're not overruing any array via an assertion.
Definition: demarshaling.cpp:307
int64_t demarshal_int64_t()
Definition: demarshaling.cpp:90
uint8_t demarshal_uint8_t()
Definition: demarshaling.cpp:43
int64_t demarshalLongLittle()
Definition: demarshaling.cpp:288
DBUS_CXX_PROPAGATE_CONST(std::unique_ptr< priv_data >) m_priv
void set_data(const uint8_t *data, uint32_t dataLen)
Set the data C array to marshal/demarshal.
uint16_t demarshal_uint16_t()
Definition: demarshaling.cpp:66
Signature demarshal_signature()
Definition: demarshaling.cpp:139
uint32_t demarshal_uint32_t()
Definition: demarshaling.cpp:82
Demarshaling()
Definition: demarshaling.cpp:29
~Demarshaling()
Definition: demarshaling.cpp:40
int16_t demarshal_int16_t()
Definition: demarshaling.cpp:58
int32_t demarshal_int32_t()
Definition: demarshaling.cpp:74
Variant demarshal_variant()
Definition: demarshaling.cpp:149
uint64_t demarshal_uint64_t()
Definition: demarshaling.cpp:98
double demarshal_double()
Definition: demarshaling.cpp:106
uint32_t current_offset() const
Definition: demarshaling.cpp:326
int32_t demarshalIntLittle()
Definition: demarshaling.cpp:254
int64_t demarshalLongBig()
Definition: demarshaling.cpp:269
std::string demarshal_string()
Definition: demarshaling.cpp:121
void set_endianess(Endianess endian)
Definition: demarshaling.cpp:330
Path demarshal_path()
Definition: demarshaling.cpp:132
void set_data_offset(uint32_t offset)
Set the offset in the data to demarshal.
Definition: demarshaling.cpp:334
bool demarshal_boolean()
Definition: demarshaling.cpp:48
void align(int alignment)
Definition: demarshaling.cpp:312
int32_t demarshalIntBig()
Definition: demarshaling.cpp:239
int16_t demarshalShortBig()
Definition: demarshaling.cpp:212
Represents a DBus Path.
Definition: path.h:21
Represents a DBus signature.
Definition: signature.h:74
A Variant is a type-safe union for DBus operations.
Definition: variant.h:42
Global DBus namespace, where everything happens.
Definition: callmessage.cpp:18
Endianess
Definition: enums.h:114