Aegisub/aegisub/src/ass_attachment.h
2014-03-09 15:12:40 -07:00

56 lines
2.1 KiB
C++

// 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
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;
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;
std::string const& GetEntryData() const { return entry_data; }
std::string const& GetSSAText() const { return entry_data; }
AssEntryGroup Group() const override { return group; }
AssAttachment(AssAttachment const& rgt);
AssAttachment(std::string const& header, AssEntryGroup group);
AssAttachment(agi::fs::path const& name, AssEntryGroup group);
};