File indexing completed on 2024-12-22 04:40:03

0001 /*
0002     SPDX-FileCopyrightText: 2007-2009 Sergio Pistone <sergio_pistone@yahoo.com.ar>
0003     SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic <max@smoothware.net>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef FORMATDATA_H
0009 #define FORMATDATA_H
0010 
0011 #include <QString>
0012 #include <QMap>
0013 
0014 namespace SubtitleComposer {
0015 class FormatData
0016 {
0017     friend class Format;
0018 
0019 public:
0020     FormatData(const FormatData &formatData) :
0021         m_formatName(formatData.m_formatName),
0022         m_data(formatData.m_data) {}
0023 
0024     FormatData & operator=(const FormatData &formatData)
0025     {
0026         if(this == &formatData)
0027             return *this;
0028 
0029         m_formatName = formatData.m_formatName;
0030         m_data = formatData.m_data;
0031 
0032         return *this;
0033     }
0034 
0035     inline const QString & formatName()
0036     {
0037         return m_formatName;
0038     }
0039 
0040     inline const QString & value(const QString &key)
0041     {
0042         static const QString empty;
0043         return m_data.contains(key) ? m_data[key] : empty;
0044     }
0045 
0046     inline void setValue(const QString &key, const QString &value)
0047     {
0048         m_data[key] = value;
0049     }
0050 
0051     inline void clear()
0052     {
0053         m_data.clear();
0054     }
0055 
0056 private:
0057     FormatData(const QString &formatName) : m_formatName(formatName) {}
0058 
0059     QString m_formatName;
0060     QMap<QString, QString> m_data;
0061 };
0062 }
0063 
0064 #endif