libmpd++
DASH MPD parsing and manipulation library
 
Loading...
Searching...
No Matches
Label.hh
Go to the documentation of this file.
1#ifndef _BBC_PARSE_DASH_MPD_LABEL_HH_
2#define _BBC_PARSE_DASH_MPD_LABEL_HH_
3/*****************************************************************************
4 * DASH MPD parsing library in C++: Label class
5 *****************************************************************************
6 * Copyright: (C) 2025 British Broadcasting Corporation
7 * Author(s): David Waring <david.waring2@bbc.co.uk>
8 * License: LGPLv3
9 *
10 * For full license terms please see the LICENSE file distributed with this
11 * library or refer to: https://www.gnu.org/licenses/lgpl-3.0.txt.
12 */
13#include <optional>
14#include <string>
15
16#include "macros.hh"
17
20// Forward declarations for types only used by pointer or reference
21namespace xmlpp {
22 class Element;
23 class Node;
24}
27
29
30class Period;
31
37class LIBMPDPP_PUBLIC_API Label : public std::string {
38public:
39 Label() : std::string(), m_id(0), m_lang() {};
40 Label(const std::string &val) : std::string(val), m_id(0), m_lang() {};
41 Label(std::string &&val) : std::string(std::move(val)), m_id(0), m_lang() {};
42 Label(const Label &other) : std::string(other), m_id(other.m_id), m_lang(other.m_lang) {};
43 Label(Label &&other) : std::string(std::move(other)), m_id(other.m_id), m_lang(std::move(other.m_lang)) {};
44
45 virtual ~Label() {};
46
47 Label &operator=(const std::string &val) { std::string::operator=(val); return *this; };
48 Label &operator=(std::string &&val) { std::string::operator=(std::move(val)); return *this; };
49
50 Label &operator=(const Label &to_copy) { std::string::operator=(to_copy); m_id = to_copy.m_id; m_lang = to_copy.m_lang; return *this; };
51 Label &operator=(Label &&to_move) { std::string::operator=(std::move(to_move)); m_id = to_move.m_id; m_lang = std::move(to_move.m_lang); return *this; };
52
53 bool operator==(const Label &to_compare) const;
54
55 // @id
56 unsigned int id() const { return m_id; };
57 Label &id(unsigned int val) { m_id = val; return *this; };
58
59 //@lang
60 bool hasLang() const { return m_lang.has_value(); };
61 const std::optional<std::string> &lang() const { return m_lang; };
62 Label &lang(const std::nullopt_t&) { m_lang.reset(); return *this; };
63 Label &lang(const std::string &val) { m_lang = val; return *this; };
64 Label &lang(std::string &&val) { m_lang = std::move(val); return *this; };
65 Label &lang(const std::optional<std::string> &val) { m_lang = val; return *this; };
66 Label &lang(std::optional<std::string> &&val) { m_lang = std::move(val); return *this; };
67
69protected:
70 friend class Period;
71 friend class RepresentationBase;
72 Label(xmlpp::Node &node);
73 void setXMLElement(xmlpp::Element &elem) const;
75
76private:
77 // LabelType attributes from ISO 23009-1:2022 Clause 5.3.10.3
78 unsigned int m_id;
79 std::optional<std::string> m_lang;
80
81 // LabelType data type from ISO 23009-1:2022 Clause 5.3.10.3
82 std::string m_label;
83};
84
86
87/* vim:ts=8:sts=4:sw=4:expandtab:
88 */
89#endif /*_BBC_PARSE_DASH_MPD_LABEL_HH_*/
Definition Label.hh:37
unsigned int id() const
Definition Label.hh:56
const std::optional< std::string > & lang() const
Definition Label.hh:61
Label & operator=(std::string &&val)
Definition Label.hh:48
Label & lang(const std::nullopt_t &)
Definition Label.hh:62
Label(const std::string &val)
Definition Label.hh:40
Label & operator=(const Label &to_copy)
Definition Label.hh:50
bool hasLang() const
Definition Label.hh:60
Label & lang(const std::optional< std::string > &val)
Definition Label.hh:65
Label & lang(const std::string &val)
Definition Label.hh:63
Label & operator=(const std::string &val)
Definition Label.hh:47
Label(Label &&other)
Definition Label.hh:43
bool operator==(const Label &to_compare) const
Label & operator=(Label &&to_move)
Definition Label.hh:51
Label(std::string &&val)
Definition Label.hh:41
Label & lang(std::optional< std::string > &&val)
Definition Label.hh:66
Label & id(unsigned int val)
Definition Label.hh:57
Label()
Definition Label.hh:39
virtual ~Label()
Definition Label.hh:45
Label(const Label &other)
Definition Label.hh:42
Label & lang(std::string &&val)
Definition Label.hh:64
Definition Period.hh:53
Definition RepresentationBase.hh:54
#define LIBMPDPP_NAMESPACE_END
Definition macros.hh:54
#define LIBMPDPP_PUBLIC_API
Used to mark something as part of the public API.
Definition macros.hh:21
#define LIBMPDPP_NAMESPACE_BEGIN
Definition macros.hh:50
Definition SegmentAvailability.hh:87