Audacity  3.0.3
AVDictionaryWrapper.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  AVDictionaryWrapper.h
6 
7  Dmitry Vedenko
8 
9 **********************************************************************/
10 
11 #pragma once
12 
13 #include <string_view>
14 #include <string>
15 #include <wx/string.h>
16 
17 struct FFmpegFunctions;
18 typedef struct AVDictionary AVDictionary;
19 
20 #define DICT_MATCH_CASE 1
21 #define DICT_IGNORE_SUFFIX 2
22 
23 class FFMPEG_SUPPORT_API AVDictionaryWrapper
24 {
25 public:
27  AVDictionaryWrapper(const AVDictionaryWrapper& rhs) noexcept;
29 
30  // We expect that &mFFmpeg == rhs.mFFmpeg
31  AVDictionaryWrapper& operator=(const AVDictionaryWrapper& rhs) noexcept;
32  AVDictionaryWrapper& operator=(AVDictionaryWrapper&& rhs) noexcept;
33 
34  explicit AVDictionaryWrapper(const FFmpegFunctions& ffmpeg) noexcept;
35  explicit AVDictionaryWrapper(const FFmpegFunctions& ffmpeg, AVDictionary* rhs) noexcept;
36 
37  AVDictionary* GetWrappedValue() noexcept;
38  const AVDictionary* GetWrappedValue() const noexcept;
39 
40  virtual ~AVDictionaryWrapper();
41 
42  void Set(const std::string_view& key, const std::string& value, int flags = 0) noexcept;
43  void Set(const std::string_view& key, const wxString& value, int flags = 0) noexcept;
44  void Set(const std::string_view& key, const char* value, int flags = 0) noexcept;
45 
46  template<typename T>
47  void Set(const std::string_view& key, const T& value, int flags = 0) noexcept
48  {
49  Set(key, std::to_string(value), flags);
50  }
51 
52  std::string_view Get(const std::string_view& key, const std::string_view& defaultValue, int flags = 0) const;
53  bool HasValue(const std::string_view& key, int flags = 0) const noexcept;
54 
55  AVDictionary* Release() noexcept;
56 protected:
57  const FFmpegFunctions& mFFmpeg;
58  AVDictionary* mAVDictionary { nullptr };
59 };
AVDictionary
struct AVDictionary AVDictionary
Definition: FFmpegTypes.h:112
KeyboardCapture::Release
void Release(wxWindow *handler)
Definition: KeyboardCapture.cpp:75
AVDictionaryWrapper
Definition: AVDictionaryWrapper.h:24
AVDictionaryWrapper::Set
void Set(const std::string_view &key, const T &value, int flags=0) noexcept
Definition: AVDictionaryWrapper.h:47
BasicUI::Get
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:26
FFmpegFunctions
Definition: FFmpegFunctions.h:85
key
static const AudacityProject::AttachedObjects::RegisteredFactory key
Definition: CommandManager.cpp:201