Skip to content

Commit

Permalink
Remove external header handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
kovacsv committed Jun 1, 2020
1 parent 5df8598 commit d6de027
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 36 deletions.
4 changes: 2 additions & 2 deletions Sources/NodeEngineTest/NodeEditorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ TEST (NodeEditorNeedToSaveTest)
ASSERT (env.nodeEditor.NeedToSave ());

MemoryOutputStream outputStream;
ASSERT (env.nodeEditor.Save (outputStream, nullptr));
ASSERT (env.nodeEditor.Save (outputStream));
ASSERT (!env.nodeEditor.NeedToSave ());

env.nodeEditor.New ();
Expand All @@ -29,7 +29,7 @@ TEST (NodeEditorNeedToSaveTest)
ASSERT (env.nodeEditor.NeedToSave ());

MemoryInputStream inputStream (outputStream.GetBuffer ());
ASSERT (env.nodeEditor.Open (inputStream, nullptr));
ASSERT (env.nodeEditor.Open (inputStream));
ASSERT (!env.nodeEditor.NeedToSave ());
env.nodeEditor.AddNode (UINodePtr (new IntegerUpDownNode (String (L"Integer"), Point (0.0, 0.0), 0, 1)));
ASSERT (env.nodeEditor.NeedToSave ());
Expand Down
27 changes: 6 additions & 21 deletions Sources/NodeUIEngine/NUIE_NodeEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ namespace NUIE

static const std::string NodeEditorFileMarker = "NodeEditorFile";

ExternalHeaderIO::~ExternalHeaderIO ()
{

}

ExternalFileIO::~ExternalFileIO ()
{

Expand Down Expand Up @@ -187,25 +182,19 @@ void NodeEditor::New ()
Update ();
}

bool NodeEditor::Open (const std::wstring& fileName, const ExternalFileIO* externalFileIO, const ExternalHeaderIO* externalHeader)
bool NodeEditor::Open (const std::wstring& fileName, const ExternalFileIO* externalFileIO)
{
std::vector<char> buffer;
if (DBGERROR (!externalFileIO->ReadBufferFromFile (fileName, buffer))) {
return false;
}

NE::MemoryInputStream inputStream (buffer);
return Open (inputStream, externalHeader);
return Open (inputStream);
}

bool NodeEditor::Open (NE::InputStream& inputStream, const ExternalHeaderIO* externalHeader)
bool NodeEditor::Open (NE::InputStream& inputStream)
{
if (externalHeader != nullptr) {
if (!externalHeader->Read (inputStream)) {
return false;
}
}

std::string fileMarker;
inputStream.Read (fileMarker);
if (fileMarker != NodeEditorFileMarker) {
Expand All @@ -226,10 +215,10 @@ bool NodeEditor::Open (NE::InputStream& inputStream, const ExternalHeaderIO* ext
return true;
}

bool NodeEditor::Save (const std::wstring& fileName, const ExternalFileIO* externalFileIO, const ExternalHeaderIO* externalHeader) const
bool NodeEditor::Save (const std::wstring& fileName, const ExternalFileIO* externalFileIO) const
{
NE::MemoryOutputStream outputStream;
if (DBGERROR (!Save (outputStream, externalHeader))) {
if (DBGERROR (!Save (outputStream))) {
return false;
}

Expand All @@ -241,12 +230,8 @@ bool NodeEditor::Save (const std::wstring& fileName, const ExternalFileIO* exter
return true;
}

bool NodeEditor::Save (NE::OutputStream& outputStream, const ExternalHeaderIO* externalHeader) const
bool NodeEditor::Save (NE::OutputStream& outputStream) const
{
if (externalHeader != nullptr) {
externalHeader->Write (outputStream);
}

const Version& currentVersion = GetCurrentVersion ();
outputStream.Write (NodeEditorFileMarker);
currentVersion.Write (outputStream);
Expand Down
17 changes: 4 additions & 13 deletions Sources/NodeUIEngine/NUIE_NodeEditor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@
namespace NUIE
{

class ExternalHeaderIO
{
public:
virtual ~ExternalHeaderIO ();

virtual bool Read (NE::InputStream& inputStream) const = 0;
virtual void Write (NE::OutputStream& outputStream) const = 0;
};

class ExternalFileIO
{
public:
Expand Down Expand Up @@ -72,10 +63,10 @@ class NodeEditor
void SetSelectedNodes (const NE::NodeCollection& newSelectedNodes);

void New ();
bool Open (const std::wstring& fileName, const ExternalFileIO* externalFileIO, const ExternalHeaderIO* externalHeader);
bool Open (NE::InputStream& inputStream, const ExternalHeaderIO* externalHeader);
bool Save (const std::wstring& fileName, const ExternalFileIO* externalFileIO, const ExternalHeaderIO* externalHeader) const;
bool Save (NE::OutputStream& outputStream, const ExternalHeaderIO* externalHeader) const;
bool Open (const std::wstring& fileName, const ExternalFileIO* externalFileIO);
bool Open (NE::InputStream& inputStream);
bool Save (const std::wstring& fileName, const ExternalFileIO* externalFileIO) const;
bool Save (NE::OutputStream& outputStream) const;
bool NeedToSave () const;

void SetSelectedNodesParameters ();
Expand Down

0 comments on commit d6de027

Please sign in to comment.