libmpd++
DASH MPD parsing and manipulation library
 
Loading...
Searching...
No Matches
SingleRFC7233Range.hh
Go to the documentation of this file.
1#ifndef _BBC_PARSE_DASH_MPD_SINGLE_RFC7233_RANGE_HH_
2#define _BBC_PARSE_DASH_MPD_SINGLE_RFC7233_RANGE_HH_
3/*****************************************************************************
4 * DASH MPD parsing library in C++: SingleRFC7233Range 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
36public:
37 using size_type = size_t;
38
40 :m_fromByte(0)
41 ,m_toByte()
42 {};
43 SingleRFC7233Range(const std::string &range_str);
44 SingleRFC7233Range(size_type from, const std::optional<size_type> &to = std::nullopt)
45 :m_fromByte(from)
46 ,m_toByte(to)
47 {};
48
49 virtual ~SingleRFC7233Range() {};
50
51 bool operator==(const SingleRFC7233Range &) const;
52
53 operator std::string() const;
54
55 size_type from() const { return m_fromByte; };
56 SingleRFC7233Range &from(size_type val) { m_fromByte = val; return *this; };
57
58 size_type to(size_type max_bytes) const { return m_toByte.has_value()?(m_toByte.value()<max_bytes?m_toByte.value():max_bytes-1):max_bytes-1; };
59 const std::optional<size_type> &to() const { return m_toByte; };
60 SingleRFC7233Range &to(const std::nullopt_t&) { m_toByte.reset(); return *this; };
61 SingleRFC7233Range &to(size_type val) { m_toByte = val; return *this; };
62
64protected:
65 friend class Period;
66 SingleRFC7233Range(xmlpp::Node&);
67 void setXMLElement(xmlpp::Element&) const;
69
70private:
71 void convertString(const std::string&);
72
73 size_type m_fromByte;
74 std::optional<size_type> m_toByte;
75};
76
78
79/* vim:ts=8:sts=4:sw=4:expandtab:
80 */
81#endif /*_BBC_PARSE_DASH_MPD_SINGLE_RFC7233_RANGE_HH_*/
Definition Period.hh:53
Definition SingleRFC7233Range.hh:35
SingleRFC7233Range & to(const std::nullopt_t &)
Definition SingleRFC7233Range.hh:60
size_t size_type
Definition SingleRFC7233Range.hh:37
SingleRFC7233Range()
Definition SingleRFC7233Range.hh:39
size_type to(size_type max_bytes) const
Definition SingleRFC7233Range.hh:58
SingleRFC7233Range & to(size_type val)
Definition SingleRFC7233Range.hh:61
SingleRFC7233Range(const std::string &range_str)
virtual ~SingleRFC7233Range()
Definition SingleRFC7233Range.hh:49
SingleRFC7233Range & from(size_type val)
Definition SingleRFC7233Range.hh:56
bool operator==(const SingleRFC7233Range &) const
const std::optional< size_type > & to() const
Definition SingleRFC7233Range.hh:59
size_type from() const
Definition SingleRFC7233Range.hh:55
SingleRFC7233Range(size_type from, const std::optional< size_type > &to=std::nullopt)
Definition SingleRFC7233Range.hh:44
#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