| Disk ARchive 2.8.1 Full featured and portable backup and archiving tool

Loading...
Searching...
No Matches
mycurl_slist.hpp
Go to the documentation of this file.
1/*********************************************************************/
2// dar - disk archive - a backup/restoration program
3// Copyright (C) 2002-2025 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_SLIST_H
27#define MYCURL_SLIST_H
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 <string>
41#include <deque>
42
43 namespace libdar
44{
47
48#if LIBCURL_AVAILABLE
49
50
52
53 class mycurl_slist
54 {
55 public:
56 mycurl_slist() { header = nullptr; };
57 mycurl_slist(const mycurl_slist & ref): appended(ref.appended) { header = rebuild(appended); };
58 mycurl_slist(mycurl_slist && ref) noexcept: appended(std::move(ref.appended)) { header = ref.header; ref.header = nullptr; };
59 mycurl_slist & operator = (const mycurl_slist & ref) { release(header); appended = ref.appended; header = rebuild(appended); return *this; };
60 mycurl_slist & operator = (mycurl_slist && ref) noexcept { std::swap(header, ref.header); std::swap(appended, ref.appended); return *this; };
61 ~mycurl_slist() { release(header); };
62
63 bool operator == (const mycurl_slist & ref) const;
64 bool operator != (const mycurl_slist & ref) const { return ! (*this == ref); };
65
66 void append(const std::string & s);
67 const curl_slist *get_address() const { return header; };
68 void clear() { release(header); appended.clear(); };
69 bool empty() const { return appended.empty(); };
70
71 private:
72 struct curl_slist* header;
73 std::deque<std::string> appended;
74
75 static curl_slist* rebuild(const std::deque<std::string> & ap);
76 static void release(curl_slist* & ptr) { curl_slist_free_all(ptr); ptr = nullptr; }
77 };
78
79#endif
80
82
83} // end of namespace
84
85#endif
my_config.h
include macro defined by the configure script and some specific additional ones
libdar
libdar namespace encapsulate all libdar symbols
Definition archive.hpp:47