Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ccvers.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@
#define CC_VERSION \
MK_CC_VERSION(CC_MAJOR_VERSION, CC_MINOR_VERSION, CC_PATCH_VERSION)

static constexpr uint32_t kVersion = (CC_MAJOR_VERSION << 8) | CC_MINOR_VERSION;
19 changes: 6 additions & 13 deletions src/CalChartFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -625,22 +625,15 @@ void CalChartFrame::OnCmdPasteSheet(wxCommandEvent&)
if (numPoints != GetShow()->GetNumPoints()) {
wxMessageBox(wxString::Format("Cannot paste - number of points in pasted sheet (%i) does not match number of points in current show (%i)",
numPoints, GetShow()->GetNumPoints()));
wxTheClipboard->Close();
return;
}
std::stringstream sheetStream;
sheetStream.write((char*)(clipboardObject.GetData()) + sizeof(numPoints),
clipboardObject.GetDataSize() - sizeof(numPoints));
auto reader = CalChart::Reader({ (uint8_t const*)(clipboardObject.GetData()) + sizeof(numPoints),
clipboardObject.GetDataSize() - sizeof(numPoints) });
reader.Get<uint32_t>();
reader.Get<uint32_t>();

CalChart::ReadLong(sheetStream);
CalChart::ReadLong(sheetStream);

sheetStream.unsetf(std::ios_base::skipws);
std::istream_iterator<uint8_t> theBegin(sheetStream);
std::istream_iterator<uint8_t> theEnd{};
std::vector<uint8_t> data(theBegin, theEnd);

CalChart::Show::Sheet_container_t sht(
1, CalChart::Sheet(numPoints, data.data(), data.size()));
CalChart::Show::Sheet_container_t sht(1, CalChart::Sheet(numPoints, reader));
GetFieldView()->DoInsertSheets(sht, GetFieldView()->GetCurrentSheetNum());
}
wxTheClipboard->Close();
Expand Down
19 changes: 9 additions & 10 deletions src/core/CalChartContinuity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,16 @@ std::vector<std::unique_ptr<ContProcedure>> ParseContinuity(std::string const& s
}
}

std::vector<std::unique_ptr<ContProcedure>> Deserialize(std::vector<uint8_t> const& data)
std::vector<std::unique_ptr<ContProcedure>> Deserialize(Reader reader)
{
auto result = std::vector<std::unique_ptr<ContProcedure>>{};

auto begin = data.data();
auto end = data.data() + data.size();
while (std::distance(begin, end) > 0) {
auto next_result = std::unique_ptr<ContProcedure>{};
std::tie(next_result, begin) = DeserializeContProcedure(begin, end);
while (reader.size() > 0) {
auto [ next_result, new_reader ] = DeserializeContProcedure(reader);
result.push_back(std::move(next_result));
reader = new_reader;
}
if (begin != end) {
if (reader.size() != 0) {
throw std::runtime_error("Error, did not parse all the data correctly");
}
return result;
Expand All @@ -99,8 +97,8 @@ Continuity::Continuity(std::vector<std::unique_ptr<ContProcedure>> from_cont)
{
}

Continuity::Continuity(std::vector<uint8_t> const& data)
: m_parsedContinuity(Deserialize(data))
Continuity::Continuity(Reader reader)
: m_parsedContinuity(Deserialize(reader))
{
}

Expand Down Expand Up @@ -175,7 +173,8 @@ void Continuity_serialize_test()
}) {
auto uut1 = Continuity{ i };
auto serialize_result = uut1.Serialize();
auto uut2 = Continuity{ serialize_result };
auto reader = Reader({ serialize_result.data(), serialize_result.size()});
auto uut2 = Continuity{ reader };
assert(uut1 == uut2);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/CalChartContinuity.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Continuity {
// this could throw runtime_error on bad parses.
Continuity(std::string const& s = "", ParseErrorHandlers const* correction = nullptr);
Continuity(std::vector<std::unique_ptr<ContProcedure>>);
Continuity(std::vector<uint8_t> const&);
Continuity(Reader);
~Continuity();

Continuity(Continuity const&);
Expand Down
Loading