Aegisub/aegisub/src/ass_attachment.h

57 lines
2.1 KiB
C
Raw Normal View History

// Copyright (c) 2013, Thomas Goyne <plorkyeran@aegisub.org>
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
//
// Aegisub Project http://www.aegisub.org/
#include "ass_entry.h"
#include <libaegisub/fs_fwd.h>
#include <boost/flyweight.hpp>
#include <vector>
/// @class AssAttachment
2014-03-08 02:13:23 +01:00
class AssAttachment : public AssEntry {
/// ASS uuencoded entry data, including header.
boost::flyweight<std::string> entry_data;
/// Name of the attached file, with SSA font mangling if it is a ttf
boost::flyweight<std::string> filename;
2012-11-25 01:08:29 +01:00
AssEntryGroup group;
public:
/// Get the size of the attached file in bytes
size_t GetSize() const;
/// Add a line of data (without newline) read from a subtitle file
void AddData(std::string const& data) { entry_data = entry_data.get() + data + "\r\n"; }
/// Extract the contents of this attachment to a file
/// @param filename Path to save the attachment to
void Extract(agi::fs::path const& filename) const;
/// Get the name of the attached file
/// @param raw If false, remove the SSA filename mangling
std::string GetFileName(bool raw=false) const;
2014-03-08 02:02:32 +01:00
std::string const& GetEntryData() const { return entry_data; }
std::string const& GetSSAText() const { return entry_data; }
AssEntryGroup Group() const override { return group; }
2013-12-11 16:55:17 +01:00
AssAttachment(AssAttachment const& rgt);
AssAttachment(std::string const& header, AssEntryGroup group);
AssAttachment(agi::fs::path const& name, AssEntryGroup group);
};