KLdap

ber.h
1/*
2 This file is part of libkldap.
3 SPDX-FileCopyrightText: 2004-2006 Szombathelyi György <gyurco@freemail.hu>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#pragma once
9
10#include <QByteArray>
11
12#include "kldap_core_export.h"
13#include <memory>
14// clazy:excludeall=copyable-polymorphic
15
16namespace KLDAPCore
17{
18/**
19 * This class allows encoding and decoding Qt structures using Basic
20 * Encoding Rules.
21 */
22class KLDAP_CORE_EXPORT Ber
23{
24public:
25 /**
26 * Constructs a Ber object.
27 */
28 Ber();
29 /**
30 * Constructs a Ber object from the value.
31 */
32 explicit Ber(const QByteArray &value);
33 /**
34 * Destroys the Ber object.
35 */
36 ~Ber();
37
38 Ber(const Ber &that);
39 Ber &operator=(const Ber &that);
40
41 /**
42 * Returns the Ber object as a flat QByteArray.
43 */
44 [[nodiscard]] QByteArray flatten() const;
45
46 /**
47 * Appends the data with the specified format to the Ber object.
48 * This function works like printf, except that it's appending the
49 * parameters, not replacing them. The allowed format characters and
50 * the expected parameter types are:
51 * <ul>
52 * <li>
53 * b Boolean. An int parameter should be supplied.
54 * A boolean element is output.
55 * </li>
56 * <li>
57 * e Enumeration. An int parameter should be supplied.
58 * An enumeration element is output.
59 * </li>
60 * <li>
61 * i Integer. An int parameter should be supplied.
62 * An integer element is output.
63 * </li>
64 * <li>
65 * B Bitstring. A pointer to a QByteArray which contains the
66 * bitstring is supplied, followed by the number of bits in the
67 * bitstring. A bitstring element is output.
68 * </li>
69 * <li>
70 * n Null. No parameter is required. A null element is output.
71 * </li>
72 * <li>
73 * O,o,s Octet string. A QByteArray * is supplied.
74 * An octet string element is output.
75 * Due to versatility of Qt's QByteArray, these three format
76 * strings are all accepts the same parameter, but using the 's'
77 * format the string will be encoded only to the first zero
78 * character (a null terminated string)!
79 * </li>
80 * <li>
81 * t Tag. An int specifying the tag to give the next element
82 * is provided. This works across calls.
83 * </li>
84 * <li>
85 * v,V Several octet strings. A QList<QByteArray>* is supplied.
86 * Note that a construct like ’{v}’ is required to get an actual
87 * SEQUENCE OF octet strings. Also note that the 'v' format recognizes
88 * the QByteArray only to the first zero character, so it's not
89 * appropriate for binary data, just only for null terminated strings!
90 * </li>
91 * <li>
92 * { Begin sequence. No parameter is required.
93 * </li>
94 * <li>
95 * } End sequence. No parameter is required.
96 * </li>
97 * <li>
98 * [ Begin set. No parameter is required.
99 * </li>
100 * <li>
101 * ] End set. No parameter is required.
102 * </li>
103 * </ul>
104 */
105 int printf(QString format, ...); // Passing by-value since it's used by va_start
106 int scanf(QString format, ...);
107 unsigned int peekTag(int &size);
108 unsigned int skipTag(int &size);
109
110private:
111 class BerPrivate;
112 std::unique_ptr<BerPrivate> const d;
113};
114}
This class allows encoding and decoding Qt structures using Basic Encoding Rules.
Definition ber.h:23
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:16:06 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.