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.
22 #include <dpl/wrt-dao-ro/path_builder.h>
27 const char PATH_SEPARATOR = '/';
30 class PathBuilderImpl : DPL::Noncopyable
37 explicit PathBuilderImpl(const std::string& path) :
38 m_stream(path, std::ios_base::app)
42 void Append(const std::string& path)
44 // TODO Check additionally if last char is not separator.
45 if (m_stream.tellp() > 0) {
46 m_stream << PATH_SEPARATOR;
51 void Concat(const std::string& arg)
69 return (m_stream.tellp() == 0);
72 std::string GetFullPath() const
74 return m_stream.str();
78 std::ostringstream m_stream;
81 PathBuilder::PathBuilder() : m_impl(new PathBuilderImpl())
85 PathBuilder::PathBuilder(const std::string& path) :
86 m_impl(new PathBuilderImpl(path))
90 PathBuilder::~PathBuilder()
95 PathBuilder& PathBuilder::Append(const std::string& path)
101 PathBuilder& PathBuilder::Concat(const std::string& arg)
107 PathBuilder& PathBuilder::Concat(int arg)
113 PathBuilder& PathBuilder::Reset()
119 bool PathBuilder::Empty() const
121 return m_impl->Empty();
124 std::string PathBuilder::GetFullPath() const
126 return m_impl->GetFullPath();