File indexing completed on 2024-04-28 05:42:10

0001 /*
0002  * Port for usage with qt-framework and development for kdesvn
0003  * Copyright (C) 2005-2009 by Rajko Albrecht (ral@alwins-world.de)
0004  * https://kde.org/applications/development/org.kde.kdesvn
0005  */
0006 /*
0007  * ====================================================================
0008  * Copyright (c) 2002-2005 The RapidSvn Group.  All rights reserved.
0009  * dev@rapidsvn.tigris.org
0010  *
0011  * This library is free software; you can redistribute it and/or
0012  * modify it under the terms of the GNU Lesser General Public
0013  * License as published by the Free Software Foundation; either
0014  * version 2.1 of the License, or (at your option) any later version.
0015  *
0016  * This library is distributed in the hope that it will be useful,
0017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0019  * Lesser General Public License for more details.
0020  *
0021  * You should have received a copy of the GNU Lesser General Public
0022  * License along with this library (in the file LGPL.txt); if not,
0023  * write to the Free Software Foundation, Inc., 51 Franklin St,
0024  * Fifth Floor, Boston, MA  02110-1301  USA
0025  *
0026  * This software consists of voluntary contributions made by many
0027  * individuals.  For exact contribution history, see the revision
0028  * history and logs, available at http://rapidsvn.tigris.org/.
0029  * ====================================================================
0030  */
0031 
0032 #ifndef SVNQT_PATH_H
0033 #define SVNQT_PATH_H
0034 
0035 #include <QString>
0036 #include <svnqt/svnqt_defines.h>
0037 #include <svnqt/svnqttypes.h>
0038 
0039 namespace svn
0040 {
0041 /**
0042  * Encapsulation for Subversion Path handling
0043  */
0044 class SVNQT_EXPORT Path
0045 {
0046 private:
0047     QString m_path;
0048 
0049     /**
0050      * initialize the class
0051      *
0052      * @param path Path string - when url this should NOT hold revision as @ parameter!!!!! (will filtered out)
0053      */
0054     void init(const QString &path);
0055 
0056 public:
0057     /**
0058      * Constructor that takes a string as parameter.
0059      * The string is converted to subversion internal
0060      * representation. The string is copied.
0061      *
0062      * @param path Path string - when url this should NOT hold revision as @ parameter!!!!! (will filtered out)
0063      */
0064     Path(const QString &path = QString()); // krazy:exclude=explicit
0065 
0066     ~Path() = default;
0067 
0068     /**
0069      * @return Path string
0070      */
0071     const QString &path() const;
0072 
0073     /**
0074      * @return Path string as c string
0075      */
0076     const QByteArray cstr() const;
0077 
0078     /**
0079      * check whether a path is set. Right now
0080      * this checks only if the string is non-
0081      * empty.
0082      *
0083      * @return true if there is a path set
0084      */
0085     bool isSet() const;
0086 
0087     /**
0088      * adds a new URL component to the path
0089      *
0090      * @param component new component to add
0091      */
0092     void addComponent(const QString &component);
0093 
0094     /** Reduce path to its parent folder.
0095      * If the path length is 1 (eg., only "/") it will cleared so
0096      * path length will get zero.
0097      * @sa svn_path_remove_component
0098      */
0099     void removeLast();
0100 
0101     /** Parse a string for a peg revision
0102      * @param pathorurl url to parse
0103      * @param _path target to store the cleaned url
0104      * @param _peg target where to store the peg url.
0105      * @throw svn::ClientException on errors
0106      */
0107     static void parsePeg(const QString &pathorurl, Path &_path, svn::Revision &_peg);
0108 
0109     /** return the length of the path-string */
0110     unsigned int length() const;
0111 
0112     /** returns the path with native separators */
0113     QString native() const;
0114 
0115     /** returns if the path is a valid url, eg. points to a remote */
0116     bool isUrl() const;
0117 };
0118 }
0119 
0120 #endif
0121 /* -----------------------------------------------------------------
0122  * local variables:
0123  * eval: (load-file "../../rapidsvn-dev.el")
0124  * end:
0125  */