libsaltpack
Loading...
Searching...
No Matches
ArmoredOutputStream.h
1/*
2 * Copyright 2016-2024 Luca Zanconato
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef SALTPACK_ARMOREDOUTPUTSTREAM_H
18#define SALTPACK_ARMOREDOUTPUTSTREAM_H
19
20#include <iostream>
21#include "types.h"
22
23namespace saltpack {
24
30 class ArmoredOutputStream : public std::ostream, std::streambuf {
31
32 public:
45 ArmoredOutputStream(std::ostream &out, const std::string& app, int mode, int lettersInWords, int wordsInPhrase);
46
58 ArmoredOutputStream(std::ostream &out, const std::string& app, int mode);
59
71 ArmoredOutputStream(std::ostream &out, int mode, int lettersInWords, int wordsInPhrase);
72
83 ArmoredOutputStream(std::ostream &out, int mode);
84
89
95 int overflow(int c) override;
96
103 void finalise();
104
105 private:
106 std::ostream &output;
107 std::string app;
108 int mode;
109 BYTE_ARRAY buffer;
110 size_t count;
111
112 size_t lettersInWord;
113 size_t wordsInPhrase;
114 size_t lCount;
115 size_t wCount;
116
117 void writeToOutput(const std::string& data);
118 };
119}
120
121#endif //SALTPACK_ARMOREDOUTPUTSTREAM_H
Output Stream to generate BaseX armored content.
Definition ArmoredOutputStream.h:30
ArmoredOutputStream(std::ostream &out, int mode)
ArmoredOutputStream(std::ostream &out, int mode, int lettersInWords, int wordsInPhrase)
ArmoredOutputStream(std::ostream &out, const std::string &app, int mode, int lettersInWords, int wordsInPhrase)
ArmoredOutputStream(std::ostream &out, const std::string &app, int mode)
int overflow(int c) override
The saltpack library namespace.
Definition ArmoredInputStream.h:24
std::vector< BYTE > BYTE_ARRAY
Definition types.h:30