2 * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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
17 * @file BufferHandler.cpp
18 * @author Maciej Karpiuk (m.karpiuk2@samsung.com)
20 * @brief BufferHandler class implementation.
26 #include <BufferHandler.h>
27 #include <xml-utils.h>
31 namespace InitialValues {
33 BufferHandler::BufferHandler(EncodingType type) : m_encoding(type) {}
34 BufferHandler::~BufferHandler() {}
36 void BufferHandler::Start(const XML::Parser::Attributes &)
41 void BufferHandler::Characters(const std::string & data)
43 m_data.reserve(m_data.size() + data.size());
44 m_data.insert(m_data.end(), data.begin(), data.end());
47 void BufferHandler::End()
51 // PEM requires that "----- END" section comes right after "\n" character
54 std::string trimmed = XML::trimEachLine(std::string(m_data.begin(), m_data.end()));
55 m_data = RawBuffer(trimmed.begin(), trimmed.end());
59 // Base64 decoder also does not accept any whitespaces
63 std::string trimmed = XML::trimEachLine(std::string(m_data.begin(), m_data.end()));
66 base64.append(RawBuffer(trimmed.begin(), trimmed.end()));
68 m_data = base64.get();