Disk ARchive  2.7.15
Full featured and portable backup and archiving tool
mycurl_easyhandle_sharing.hpp
Go to the documentation of this file.
1 /*********************************************************************/
2 // dar - disk archive - a backup/restoration program
3 // Copyright (C) 2002-2024 Denis Corbin
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 //
19 // to contact the author, see the AUTHOR file
20 /*********************************************************************/
21 
25 
26 #ifndef MYCURL_EASYHANDLE_SHARING_HPP
27 #define MYCURL_EASYHANDLE_SHARING_HPP
28 
29 #include "../my_config.h"
30 
31 extern "C"
32 {
33 #if LIBCURL_AVAILABLE
34 #if HAVE_CURL_CURL_H
35 #include <curl/curl.h>
36 #endif
37 #endif
38 } // end extern "C"
39 
40 #include <deque>
41 #include "erreurs.hpp"
43 
44 namespace libdar
45 {
48 
49 #if LIBCURL_AVAILABLE
50 
52 
53  class mycurl_easyhandle_sharing
54  {
55  public:
56  mycurl_easyhandle_sharing() {}; // fields "table" and "global_params" are objects are get initialized by their default constructors
57  mycurl_easyhandle_sharing(const mycurl_easyhandle_sharing & ref): global_params(ref.global_params) { table.clear(); };
58  mycurl_easyhandle_sharing(mycurl_easyhandle_sharing && ref) noexcept: table(std::move(ref.table)), global_params(std::move(ref.global_params)) {};
59  mycurl_easyhandle_sharing & operator = (const mycurl_easyhandle_sharing & ref) = delete;
60  mycurl_easyhandle_sharing & operator = (mycurl_easyhandle_sharing && ref) noexcept = delete;
61  ~mycurl_easyhandle_sharing() = default;
62 
63 
65  template<class T> void setopt_global(CURLoption opt, const T & val) { global_params.add(opt, val); }
66 
68 
70  std::shared_ptr<mycurl_easyhandle_node> alloc_instance();
71 
72 
73  private:
74  std::deque<std::shared_ptr<mycurl_easyhandle_node> > table;
75  mycurl_param_list global_params;
76  };
77 
78 #else
79 
80  class mycurl_easyhandle_sharing
81  {
82  public:
83  mycurl_easyhandle_sharing() { throw Ecompilation("remote repository"); };
84  };
85 
86 #endif
87 
89 
90 } // end of namespace
91 
92 #endif
contains all the excetion class thrown by libdar
used to optimize session creation done by libcurl
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47