File indexing completed on 2024-04-28 05:32:12
0001 /* 0002 this file is part of the oxygen gtk engine 0003 SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #include "oxygenpathlist.h" 0009 0010 #include <sstream> 0011 0012 namespace Oxygen 0013 { 0014 0015 //_________________________________________________________ 0016 void PathList::split( const std::string& path, const std::string& separator ) 0017 { 0018 0019 clear(); 0020 std::string local( path ); 0021 if( local.empty() ) return; 0022 if( local[local.size()-1] == '\n' ) local = local.substr( 0, local.size()-1 ); 0023 0024 size_t position( std::string::npos ); 0025 while( ( position = local.find( separator ) ) != std::string::npos ) 0026 { 0027 push_back( local.substr(0, position ) ); 0028 local = local.substr( position + separator.length() ); 0029 } 0030 0031 if( !local.empty() ) push_back( local ); 0032 return; 0033 0034 } 0035 0036 //_________________________________________________________ 0037 std::string PathList::join( const std::string& separator ) const 0038 { 0039 std::ostringstream out; 0040 for( const_iterator iter = begin(); iter != end(); ++iter ) 0041 { 0042 if( iter != begin() ) out << separator; 0043 out << *iter; 0044 } 0045 0046 return out.str(); 0047 } 0048 0049 }