2 * Copyright (c) 2011 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 PathBuilder.cpp
18 * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
20 * @brief Implementation file for PathBuilde class.
23 #include <dpl/wrt-dao-ro/path_builder.h>
28 const char PATH_SEPARATOR = '/';
31 class PathBuilderImpl : DPL::Noncopyable
37 explicit PathBuilderImpl(const std::string& path) :
38 m_stream(path, std::ios_base::app)
41 void Append(const std::string& path)
43 // TODO Check additionally if last char is not separator.
44 if (m_stream.tellp() > 0) {
45 m_stream << PATH_SEPARATOR;
50 void Concat(const std::string& arg)
68 return (m_stream.tellp() == 0);
71 std::string GetFullPath() const
73 return m_stream.str();
77 std::ostringstream m_stream;
80 PathBuilder::PathBuilder() : m_impl(new PathBuilderImpl())
83 PathBuilder::PathBuilder(const std::string& path) :
84 m_impl(new PathBuilderImpl(path))
87 PathBuilder::~PathBuilder()
92 PathBuilder& PathBuilder::Append(const std::string& path)
98 PathBuilder& PathBuilder::Concat(const std::string& arg)
104 PathBuilder& PathBuilder::Concat(int arg)
110 PathBuilder& PathBuilder::Reset()
116 bool PathBuilder::Empty() const
118 return m_impl->Empty();
121 std::string PathBuilder::GetFullPath() const
123 return m_impl->GetFullPath();