Small cleaning.
This commit is contained in:
parent
70220fc6e9
commit
d7fe11913f
26 changed files with 613 additions and 548 deletions
|
@ -18,9 +18,6 @@ public:
|
|||
void openDevice(AudioDevice* device) override;
|
||||
|
||||
void play(AudioDevice* device, AudioSample* sample, unsigned duration) override;
|
||||
|
||||
private:
|
||||
void openDevice(const AudioDevicePtr& device) override;
|
||||
};
|
||||
|
||||
using NullAudioInterfacePtr = std::shared_ptr<NullAudioInterface>;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "FileLogger.h"
|
||||
|
||||
#include "AudioSynth.h"
|
||||
#include "AudioDevice.h"
|
||||
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
@ -26,37 +27,37 @@ std::unique_ptr<WasapiInterface> WasapiInterface::Create()
|
|||
return std::make_unique<WasapiInterface>();
|
||||
}
|
||||
|
||||
void WasapiInterface::OpenDevice(const AudioDevicePtr& device)
|
||||
void WasapiInterface::openDevice(AudioDevice* device)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void WasapiInterface::SetAccessType(const AudioDevicePtr& device)
|
||||
void WasapiInterface::setAccessType(AudioDevice* device)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void WasapiInterface::SetSampleFormat(const AudioDevicePtr& device)
|
||||
void WasapiInterface::setSampleFormat(AudioDevice* device)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void WasapiInterface::SetSampleRate(const AudioDevicePtr& device)
|
||||
void WasapiInterface::setSampleRate(AudioDevice* device)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void WasapiInterface::SetPeriod(const AudioDevicePtr& device)
|
||||
void WasapiInterface::setPeriod(AudioDevice* device)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void WasapiInterface::SetBufferSize(const AudioDevicePtr& device)
|
||||
void WasapiInterface::setBufferSize(AudioDevice* device)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void WasapiInterface::SetChannelNumber(const AudioDevicePtr& device)
|
||||
void WasapiInterface::setChannelNumber(AudioDevice* device)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -76,7 +77,7 @@ const IID IID_IMMDeviceEnumerator = __uuidof(IMMDeviceEnumerator);
|
|||
const IID IID_IAudioClient = __uuidof(IAudioClient);
|
||||
const IID IID_IAudioRenderClient = __uuidof(IAudioRenderClient);
|
||||
|
||||
void WasapiInterface::Play(const AudioDevicePtr& device)
|
||||
void WasapiInterface::play(AudioDevice* device, AudioSample* sample, unsigned duration)
|
||||
{
|
||||
std::cout << "Into wasapi play" << std::endl;
|
||||
IMMDeviceEnumerator* pEnumerator = nullptr;
|
||||
|
|
|
@ -1,36 +1,35 @@
|
|||
#pragma once
|
||||
|
||||
#include "IAudioInterface.h"
|
||||
#include "AudioDevice.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class AudioDevice;
|
||||
|
||||
class WasapiInterface : public IAudioInterface
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
WasapiInterface();
|
||||
|
||||
~WasapiInterface();
|
||||
|
||||
static std::unique_ptr<WasapiInterface> Create();
|
||||
|
||||
void OpenDevice(const AudioDevicePtr& device) override;
|
||||
void play(AudioDevice* device, AudioSample* sample, unsigned duration) override;
|
||||
private:
|
||||
void openDevice(AudioDevice* device) override;
|
||||
|
||||
void SetAccessType(const AudioDevicePtr& device);
|
||||
void setAccessType(AudioDevice* device);
|
||||
|
||||
void SetSampleFormat(const AudioDevicePtr& device);
|
||||
void setSampleFormat(AudioDevice* device);
|
||||
|
||||
void SetSampleRate(const AudioDevicePtr& device);
|
||||
void setSampleRate(AudioDevice* device);
|
||||
|
||||
void SetPeriod(const AudioDevicePtr& device);
|
||||
void setPeriod(AudioDevice* device);
|
||||
|
||||
void SetBufferSize(const AudioDevicePtr& device);
|
||||
void setBufferSize(AudioDevice* device);
|
||||
|
||||
void SetChannelNumber(const AudioDevicePtr& device);
|
||||
|
||||
void Play(const AudioDevicePtr& device) override;
|
||||
void setChannelNumber(AudioDevice* device);
|
||||
};
|
||||
|
||||
using AlsaInterfacePtr = std::shared_ptr<WasapiInterface>;
|
||||
using WasapiInterfacePtr = std::unique_ptr<WasapiInterface>;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <iostream>
|
||||
#include <bitset>
|
||||
|
||||
int MidiChannelEventAdapter::ReadEvent(std::ifstream* file, char firstByte, MidiChannelEvent* event, MidiChannelEvent::Type& lastEventType)
|
||||
int MidiChannelEventAdapter::readEvent(std::ifstream* file, char firstByte, MidiChannelEvent* event, MidiChannelEvent::Type& lastEventType)
|
||||
{
|
||||
int first_four_bits = 0xF0;
|
||||
int second_four_bits = 0xF;
|
||||
|
@ -34,11 +34,11 @@ int MidiChannelEventAdapter::ReadEvent(std::ifstream* file, char firstByte, Midi
|
|||
{
|
||||
if (isStatusByte)
|
||||
{
|
||||
byteCount += ReadEventData(file, event);
|
||||
byteCount += readEventData(file, event);
|
||||
}
|
||||
else
|
||||
{
|
||||
byteCount += ReadEventData(file, event, firstByte);
|
||||
byteCount += readEventData(file, event, firstByte);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ int MidiChannelEventAdapter::ReadEvent(std::ifstream* file, char firstByte, Midi
|
|||
return byteCount;
|
||||
}
|
||||
|
||||
int MidiChannelEventAdapter::ReadEventData(std::ifstream* file, MidiChannelEvent* event, char c)
|
||||
int MidiChannelEventAdapter::readEventData(std::ifstream* file, MidiChannelEvent* event, char c)
|
||||
{
|
||||
int value0 = int(c);
|
||||
int value1 = *BinaryStream::getNextByteAsInt(file);
|
||||
|
@ -63,7 +63,7 @@ int MidiChannelEventAdapter::ReadEventData(std::ifstream* file, MidiChannelEvent
|
|||
return 1;
|
||||
}
|
||||
|
||||
int MidiChannelEventAdapter::ReadEventData(std::ifstream* file, MidiChannelEvent* event)
|
||||
int MidiChannelEventAdapter::readEventData(std::ifstream* file, MidiChannelEvent* event)
|
||||
{
|
||||
int value0 = *BinaryStream::getNextByteAsInt(file);
|
||||
int value1 = *BinaryStream::getNextByteAsInt(file);
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
class MidiChannelEventAdapter
|
||||
{
|
||||
public:
|
||||
static int ReadEvent(std::ifstream* file, char firstByte, MidiChannelEvent* event, MidiChannelEvent::Type& lastEventType);
|
||||
static int readEvent(std::ifstream* file, char firstByte, MidiChannelEvent* event, MidiChannelEvent::Type& lastEventType);
|
||||
|
||||
static int ReadEventData(std::ifstream* file, MidiChannelEvent* event, char c);
|
||||
static int ReadEventData(std::ifstream* file, MidiChannelEvent* event);
|
||||
static int readEventData(std::ifstream* file, MidiChannelEvent* event, char c);
|
||||
static int readEventData(std::ifstream* file, MidiChannelEvent* event);
|
||||
};
|
||||
|
|
|
@ -3,11 +3,9 @@
|
|||
#include "MetaMidiEvent.h"
|
||||
#include <fstream>
|
||||
|
||||
|
||||
class MidiMetaEventAdapter
|
||||
{
|
||||
public:
|
||||
|
||||
static int ReadEvent(std::ifstream* file, MetaMidiEvent* event, int& lastMidiChannel);
|
||||
|
||||
static int ReadIntEvent(std::ifstream* file, MetaMidiEvent* event, int length=-1);
|
||||
|
|
|
@ -87,7 +87,7 @@ int MidiReader::processEvent(MidiTrack* track)
|
|||
auto event = std::make_unique<MidiChannelEvent>();
|
||||
event->SetTimeDelta(timeDelta);
|
||||
//std::cout << "Midi event" << std::endl;
|
||||
byteCount += MidiChannelEventAdapter::ReadEvent(mFile->getInHandle(), c, event.get(), mLastChannelEventType);
|
||||
byteCount += MidiChannelEventAdapter::readEvent(mFile->getInHandle(), c, event.get(), mLastChannelEventType);
|
||||
track->AddEvent(std::move(event));
|
||||
}
|
||||
return byteCount;
|
||||
|
|
|
@ -29,6 +29,11 @@ AbstractApp* GuiApplication::getMainApplication() const
|
|||
return mMainApplication.get();
|
||||
}
|
||||
|
||||
AbstractUIInterface* GuiApplication::getUiInterface() const
|
||||
{
|
||||
return mUiInterface.get();
|
||||
}
|
||||
|
||||
void GuiApplication::initializeViews()
|
||||
{
|
||||
mDesktopManager->getWindowManager()->getMainWindow()->setSize(800, 600);
|
||||
|
|
|
@ -21,10 +21,7 @@ public:
|
|||
|
||||
void run();
|
||||
|
||||
AbstractUIInterface* getUiInterface() const override
|
||||
{
|
||||
return mUiInterface.get();
|
||||
}
|
||||
AbstractUIInterface* getUiInterface() const override;
|
||||
|
||||
void setUiInterfaceBackend(UiInterfaceFactory::Backend backend);
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
class StatusBar : public Widget
|
||||
{
|
||||
public:
|
||||
|
||||
StatusBar();
|
||||
|
||||
static std::unique_ptr<StatusBar> Create();
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
class TabbedPanelWidget : public Widget
|
||||
{
|
||||
|
||||
public:
|
||||
TabbedPanelWidget();
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "TemplateFile.h"
|
||||
|
||||
#include "StringUtils.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
TemplateFile::TemplateFile(const Path& path)
|
||||
|
|
|
@ -0,0 +1,169 @@
|
|||
#include "TemplateNodes.h"
|
||||
|
||||
#include "StringUtils.h"
|
||||
|
||||
TemplateNode::TemplateNode(TemplateNode* parent)
|
||||
: mParent(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
TemplateNode* TemplateNode::getParent() const
|
||||
{
|
||||
return mParent;
|
||||
}
|
||||
|
||||
void TemplateNode::addChild(std::unique_ptr<TemplateNode> child)
|
||||
{
|
||||
mChildren.push_back(std::move(child));
|
||||
}
|
||||
|
||||
std::size_t TemplateNode::getNumChildren() const
|
||||
{
|
||||
return mChildren.size();
|
||||
}
|
||||
|
||||
std::string TemplateNode::getIdentifier() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
TemplateNode* TemplateNode::getChild(std::size_t index) const
|
||||
{
|
||||
return mChildren[index].get();
|
||||
}
|
||||
|
||||
std::string TemplateNode::getRawContent() const
|
||||
{
|
||||
std::string content;
|
||||
for (const auto& child : mChildren)
|
||||
{
|
||||
content += child->getRawContent() + "\n";
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
void TemplateNode::setExtensionParent(TemplateNode* parent)
|
||||
{
|
||||
mExtensionParent = parent;
|
||||
}
|
||||
|
||||
std::string TemplateNode::render(TemplateNode* parentContext)
|
||||
{
|
||||
if (!parentContext && mExtensionParent)
|
||||
{
|
||||
parentContext = mExtensionParent;
|
||||
}
|
||||
|
||||
std::string content;
|
||||
for (size_t idx = 0; idx < mChildren.size(); idx++)
|
||||
{
|
||||
content += mChildren[idx]->render(parentContext);
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
TemplateExtends::TemplateExtends(TemplateNode* parent, const std::string& path)
|
||||
: TemplateNode(parent)
|
||||
{
|
||||
mPath = StringUtils::stripQuotes(path);
|
||||
};
|
||||
|
||||
std::string TemplateExtends::getRawContent() const
|
||||
{
|
||||
return "TemplateExtends: " + mPath;
|
||||
}
|
||||
|
||||
std::string TemplateExtends::getPath() const
|
||||
{
|
||||
return mPath;
|
||||
}
|
||||
|
||||
TemplateBlock::TemplateBlock(TemplateNode* parent, const std::string& name)
|
||||
: TemplateNode(parent),
|
||||
mName(name)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void TemplateBlock::addLine(const std::string& line)
|
||||
{
|
||||
mBody.push_back(line);
|
||||
}
|
||||
|
||||
std::string TemplateBlock::getRawContent() const
|
||||
{
|
||||
std::string content = "TemplateBlock: " + mName + "\n";
|
||||
content += TemplateNode::getRawContent();
|
||||
return content;
|
||||
}
|
||||
|
||||
std::string TemplateBlock::renderAsParent(TemplateNode* base)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
std::string TemplateBlock::render(TemplateNode* parentContext)
|
||||
{
|
||||
std::string content;
|
||||
if (parentContext)
|
||||
{
|
||||
if (auto parent_node = parentContext->getFirstChildShallow<TemplateBlock>(getIdentifier()))
|
||||
{
|
||||
content = dynamic_cast<TemplateBlock*>(parent_node)->renderAsParent(this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
TemplateExpression::TemplateExpression(TemplateNode* parent, const std::string& content)
|
||||
: TemplateNode(parent),
|
||||
mContent(content)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string TemplateExpression::getRawContent() const
|
||||
{
|
||||
return "TemplateExpression: " + mContent;
|
||||
}
|
||||
|
||||
TemplateTextBody::TemplateTextBody(TemplateNode* parent)
|
||||
: TemplateNode(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void TemplateTextBody::addLine(const std::string& content)
|
||||
{
|
||||
mContent.push_back(content);
|
||||
}
|
||||
|
||||
bool TemplateTextBody::hasContent() const
|
||||
{
|
||||
return !mContent.empty();
|
||||
}
|
||||
|
||||
std::string TemplateTextBody::render(TemplateNode* parentContext)
|
||||
{
|
||||
std::string content;
|
||||
for (const auto& line : mContent)
|
||||
{
|
||||
content += line + '\n';
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
std::string TemplateTextBody::getRawContent() const
|
||||
{
|
||||
std::string content;
|
||||
for (const auto& line : mContent)
|
||||
{
|
||||
content += "TemplateBody: " + line + "\n";
|
||||
}
|
||||
return content;
|
||||
}
|
|
@ -1,49 +1,27 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class TemplateNode
|
||||
{
|
||||
public:
|
||||
TemplateNode(TemplateNode* parent);
|
||||
|
||||
TemplateNode(TemplateNode* parent)
|
||||
: mParent(parent)
|
||||
{
|
||||
virtual ~TemplateNode() = default;
|
||||
|
||||
}
|
||||
TemplateNode* getParent() const;
|
||||
|
||||
TemplateNode* getParent() const
|
||||
{
|
||||
return mParent;
|
||||
}
|
||||
virtual void addChild(std::unique_ptr<TemplateNode> child);
|
||||
|
||||
virtual void addChild(std::unique_ptr<TemplateNode> child)
|
||||
{
|
||||
mChildren.push_back(std::move(child));
|
||||
}
|
||||
std::size_t getNumChildren() const;
|
||||
|
||||
std::size_t getNumChildren() const
|
||||
{
|
||||
return mChildren.size();
|
||||
}
|
||||
virtual std::string getIdentifier() const;
|
||||
|
||||
virtual std::string getIdentifier() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
TemplateNode* getChild(std::size_t index) const;
|
||||
|
||||
TemplateNode* getChild(std::size_t index) const
|
||||
{
|
||||
return mChildren[index].get();
|
||||
}
|
||||
|
||||
virtual std::string getRawContent() const
|
||||
{
|
||||
std::string content;
|
||||
for (const auto& child : mChildren)
|
||||
{
|
||||
content += child->getRawContent() + "\n";
|
||||
}
|
||||
return content;
|
||||
}
|
||||
virtual std::string getRawContent() const;
|
||||
|
||||
template<typename T>
|
||||
T* getFirstChildShallow(const std::string& identifier = {}) const
|
||||
|
@ -68,25 +46,9 @@ public:
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void setExtensionParent(TemplateNode* parent)
|
||||
{
|
||||
mExtensionParent = parent;
|
||||
}
|
||||
void setExtensionParent(TemplateNode* parent);
|
||||
|
||||
virtual std::string render(TemplateNode* parentContext = nullptr)
|
||||
{
|
||||
if (!parentContext && mExtensionParent)
|
||||
{
|
||||
parentContext = mExtensionParent;
|
||||
}
|
||||
|
||||
std::string content;
|
||||
for (size_t idx = 0; idx < mChildren.size(); idx++)
|
||||
{
|
||||
content += mChildren[idx]->render(parentContext);
|
||||
}
|
||||
return content;
|
||||
}
|
||||
virtual std::string render(TemplateNode* parentContext = nullptr);
|
||||
|
||||
protected:
|
||||
std::vector<std::unique_ptr<TemplateNode> > mChildren;
|
||||
|
@ -99,21 +61,12 @@ using TemplateNodePtr = std::unique_ptr<TemplateNode>;
|
|||
class TemplateExtends : public TemplateNode
|
||||
{
|
||||
public:
|
||||
TemplateExtends(TemplateNode* parent, const std::string& path)
|
||||
: TemplateNode(parent)
|
||||
{
|
||||
mPath = StringUtils::stripQuotes(path);
|
||||
};
|
||||
TemplateExtends(TemplateNode* parent, const std::string& path);
|
||||
|
||||
std::string getRawContent() const override
|
||||
{
|
||||
return "TemplateExtends: " + mPath;
|
||||
}
|
||||
virtual ~TemplateExtends() = default;
|
||||
|
||||
std::string getPath() const
|
||||
{
|
||||
return mPath;
|
||||
}
|
||||
std::string getRawContent() const override;
|
||||
std::string getPath() const;
|
||||
|
||||
private:
|
||||
std::string mPath;
|
||||
|
@ -122,46 +75,17 @@ private:
|
|||
class TemplateBlock : public TemplateNode
|
||||
{
|
||||
public:
|
||||
TemplateBlock(TemplateNode* parent, const std::string& name)
|
||||
: TemplateNode(parent),
|
||||
mName(name)
|
||||
{
|
||||
TemplateBlock(TemplateNode* parent, const std::string& name);
|
||||
|
||||
}
|
||||
virtual ~TemplateBlock() = default;
|
||||
|
||||
void addLine(const std::string& line)
|
||||
{
|
||||
mBody.push_back(line);
|
||||
}
|
||||
void addLine(const std::string& line);
|
||||
|
||||
std::string getRawContent() const override
|
||||
{
|
||||
std::string content = "TemplateBlock: " + mName + "\n";
|
||||
content += TemplateNode::getRawContent();
|
||||
return content;
|
||||
}
|
||||
std::string getRawContent() const override;
|
||||
|
||||
std::string renderAsParent(TemplateNode* base)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
std::string renderAsParent(TemplateNode* base);
|
||||
|
||||
std::string render(TemplateNode* parentContext) override
|
||||
{
|
||||
std::string content;
|
||||
if (parentContext)
|
||||
{
|
||||
if (auto parent_node = parentContext->getFirstChildShallow<TemplateBlock>(getIdentifier()))
|
||||
{
|
||||
content = dynamic_cast<TemplateBlock*>(parent_node)->renderAsParent(this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
return content;
|
||||
}
|
||||
std::string render(TemplateNode* parentContext) override;
|
||||
|
||||
private:
|
||||
std::string mName;
|
||||
|
@ -171,17 +95,11 @@ private:
|
|||
class TemplateExpression : public TemplateNode
|
||||
{
|
||||
public:
|
||||
TemplateExpression(TemplateNode* parent, const std::string& content)
|
||||
: TemplateNode(parent),
|
||||
mContent(content)
|
||||
{
|
||||
TemplateExpression(TemplateNode* parent, const std::string& content);
|
||||
|
||||
}
|
||||
virtual ~TemplateExpression() = default;
|
||||
|
||||
std::string getRawContent() const override
|
||||
{
|
||||
return "TemplateExpression: " + mContent;
|
||||
}
|
||||
std::string getRawContent() const override;
|
||||
|
||||
private:
|
||||
std::string mContent;
|
||||
|
@ -190,42 +108,17 @@ private:
|
|||
class TemplateTextBody : public TemplateNode
|
||||
{
|
||||
public:
|
||||
TemplateTextBody(TemplateNode* parent)
|
||||
: TemplateNode(parent)
|
||||
{
|
||||
TemplateTextBody(TemplateNode* parent);
|
||||
|
||||
}
|
||||
virtual ~TemplateTextBody() = default;
|
||||
|
||||
void addLine(const std::string& content)
|
||||
{
|
||||
mContent.push_back(content);
|
||||
}
|
||||
void addLine(const std::string& content);
|
||||
|
||||
bool hasContent() const
|
||||
{
|
||||
return !mContent.empty();
|
||||
}
|
||||
std::string getRawContent() const override;
|
||||
|
||||
std::string render(TemplateNode* parentContext) override
|
||||
{
|
||||
std::string content;
|
||||
for (const auto& line : mContent)
|
||||
{
|
||||
content += line + '\n';
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
std::string getRawContent() const override
|
||||
{
|
||||
std::string content;
|
||||
for (const auto& line : mContent)
|
||||
{
|
||||
content += "TemplateBody: " + line + "\n";
|
||||
}
|
||||
return content;
|
||||
}
|
||||
bool hasContent() const;
|
||||
|
||||
std::string render(TemplateNode* parentContext) override;
|
||||
private:
|
||||
std::vector<std::string> mContent;
|
||||
};
|
|
@ -131,7 +131,7 @@ void File::close()
|
|||
FileFormat::Format File::inferFormat() const
|
||||
{
|
||||
const auto extension = getExtension();
|
||||
return FileFormat::InferFormat(extension);
|
||||
return FileFormat::inferFormat(extension);
|
||||
}
|
||||
|
||||
void File::writeText(const std::string& text)
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "FileFormats.h"
|
||||
|
||||
#include "StringUtils.h"
|
||||
|
||||
FileFormat::ExtensionMap FileFormat::mExtensions = []
|
||||
{
|
||||
ExtensionMap ret;
|
||||
|
@ -8,3 +10,25 @@ FileFormat::ExtensionMap FileFormat::mExtensions = []
|
|||
ret[Format::Wav] = ".wav";
|
||||
return ret;
|
||||
}();
|
||||
|
||||
bool FileFormat::isFormat(const std::string& extension, Format format)
|
||||
{
|
||||
return StringUtils::ToLower(extension) == mExtensions[format];
|
||||
}
|
||||
|
||||
FileFormat::Format FileFormat::inferFormat(const std::string& query)
|
||||
{
|
||||
for(const auto& extension : mExtensions)
|
||||
{
|
||||
if(extension.second == query)
|
||||
{
|
||||
return extension.first;
|
||||
}
|
||||
}
|
||||
return Format::Unknown;
|
||||
}
|
||||
|
||||
std::string FileFormat::getExtension(Format format)
|
||||
{
|
||||
return mExtensions[format];
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "StringUtils.h"
|
||||
|
||||
class FileFormat{
|
||||
|
||||
|
@ -27,31 +26,14 @@ public:
|
|||
|
||||
using ExtensionMap = std::map<Format, std::string>;
|
||||
|
||||
public:
|
||||
static bool isFormat(const std::string& extension, Format format);
|
||||
|
||||
static Format inferFormat(const std::string& query);
|
||||
|
||||
static std::string getExtension(Format format);
|
||||
|
||||
private:
|
||||
static ExtensionMap mExtensions;
|
||||
|
||||
public:
|
||||
|
||||
bool IsFormat(const std::string& extension, Format format)
|
||||
{
|
||||
return StringUtils::ToLower(extension) == mExtensions[format];
|
||||
}
|
||||
|
||||
static Format InferFormat(const std::string& query)
|
||||
{
|
||||
for(const auto& extension : mExtensions)
|
||||
{
|
||||
if(extension.second == query)
|
||||
{
|
||||
return extension.first;
|
||||
}
|
||||
}
|
||||
return Format::Unknown;
|
||||
}
|
||||
|
||||
std::string GetExtension(Format format)
|
||||
{
|
||||
return mExtensions[format];
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -4,9 +4,7 @@
|
|||
|
||||
class HttpResponse
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
HttpResponse();
|
||||
|
||||
~HttpResponse();
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "ZlibEncoder.h"
|
||||
#include "CyclicRedundancyChecker.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "BufferBitStream.h"
|
||||
#include "OutputBitStream.h"
|
||||
#include "ImageBitStream.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
#include "PngFilter.h"
|
||||
#include "Lz77Encoder.h"
|
||||
|
|
Loading…
Reference in a new issue