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
38 explicit PathBuilderImpl(const std::string& path) :
39 m_stream(path, std::ios_base::app)
43 void Append(const std::string& path)
45 // TODO Check additionally if last char is not separator.
46 if (m_stream.tellp() > 0) {
47 m_stream << PATH_SEPARATOR;
52 void Concat(const std::string& arg)
70 return (m_stream.tellp() == 0);
73 std::string GetFullPath() const
75 return m_stream.str();
79 std::ostringstream m_stream;
82 PathBuilder::PathBuilder() : m_impl(new PathBuilderImpl())
86 PathBuilder::PathBuilder(const std::string& path) :
87 m_impl(new PathBuilderImpl(path))
91 PathBuilder::~PathBuilder()
96 PathBuilder& PathBuilder::Append(const std::string& path)
102 PathBuilder& PathBuilder::Concat(const std::string& arg)
108 PathBuilder& PathBuilder::Concat(int arg)
114 PathBuilder& PathBuilder::Reset()
120 bool PathBuilder::Empty() const
122 return m_impl->Empty();
125 std::string PathBuilder::GetFullPath() const
127 return m_impl->GetFullPath();