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

0001 /***************************************************************************
0002  *   Copyright (C) 2007-2009 by Rajko Albrecht  ral@alwins-world.de        *
0003  *   https://kde.org/applications/development/org.kde.kdesvn               *
0004  *                                                                         *
0005  * This program is free software; you can redistribute it and/or           *
0006  * modify it under the terms of the GNU Lesser General Public              *
0007  * License as published by the Free Software Foundation; either            *
0008  * version 2.1 of the License, or (at your option) any later version.      *
0009  *                                                                         *
0010  * This program is distributed in the hope that it will be useful,         *
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of          *
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU       *
0013  * Lesser General Public License for more details.                         *
0014  *                                                                         *
0015  * You should have received a copy of the GNU Lesser General Public        *
0016  * License along with this program (in the file LGPL.txt); if not,         *
0017  * write to the Free Software Foundation, Inc., 51 Franklin St,            *
0018  * Fifth Floor, Boston, MA  02110-1301  USA                                *
0019  *                                                                         *
0020  * This software consists of voluntary contributions made by many          *
0021  * individuals.  For exact contribution history, see the revision          *
0022  * history and logs, available at https://commits.kde.org/kdesvn.          *
0023  ***************************************************************************/
0024 
0025 #include "diffoptions.h"
0026 #include "pool.h"
0027 #include "stringarray.h"
0028 #include "svnqt_defines.h"
0029 
0030 #include <svn_diff.h>
0031 #include <svn_version.h>
0032 
0033 namespace svn
0034 {
0035 void DiffOptions::init(const svn_diff_file_options_t *_diffopts)
0036 {
0037     _ignoreeol = _diffopts->ignore_eol_style;
0038     _showc = _diffopts->show_c_function;
0039     switch (_diffopts->ignore_space) {
0040     case svn_diff_file_ignore_space_change:
0041         _ignorespace = IgnoreSpaceChange;
0042         break;
0043     case svn_diff_file_ignore_space_all:
0044         _ignorespace = IgnoreSpaceAll;
0045         break;
0046     case svn_diff_file_ignore_space_none:
0047     default:
0048         _ignorespace = IgnoreSpaceNone;
0049         break;
0050     }
0051 }
0052 
0053 DiffOptions::DiffOptions(const QStringList &options)
0054 {
0055     Pool pool;
0056     StringArray _ar(options);
0057     svn_diff_file_options_t *_diffopts = svn_diff_file_options_create(pool);
0058     if (_diffopts) {
0059         svn_error_t *error = svn_diff_file_options_parse(_diffopts, _ar.array(pool), pool);
0060         if (error == nullptr) {
0061             init(_diffopts);
0062         }
0063     }
0064 }
0065 
0066 DiffOptions::DiffOptions(const svn_diff_file_options_t *options)
0067 {
0068     if (options) {
0069         init(options);
0070     }
0071 }
0072 
0073 svn_diff_file_options_t *DiffOptions::options(const Pool &pool) const
0074 {
0075     svn_diff_file_options_t *_diffopts = svn_diff_file_options_create(pool);
0076     _diffopts->ignore_eol_style = _ignoreeol;
0077     _diffopts->show_c_function = _showc;
0078     switch (_ignorespace) {
0079     case IgnoreSpaceChange:
0080         _diffopts->ignore_space = svn_diff_file_ignore_space_change;
0081         break;
0082     case IgnoreSpaceAll:
0083         _diffopts->ignore_space = svn_diff_file_ignore_space_all;
0084         break;
0085     case IgnoreSpaceNone:
0086     default:
0087         _diffopts->ignore_space = svn_diff_file_ignore_space_none;
0088         break;
0089     }
0090     return _diffopts;
0091 }
0092 
0093 }