• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ossia / score / 41569965004

03 Nov 2026 03:04AM UTC coverage: 53.588% (+1.9%) from 51.66%
41569965004

push

github

jcelerier
ci: build the documentation on Ubuntu 24.04, which its deps script targets

ubuntu-latest is now 26.04, where ubuntu.noble.deps.sh's Qt package names
(libqt6websockets6-dev and the like) no longer exist.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KdPguhTJiZUHjuouE7tkj5

197270 of 368126 relevant lines covered (53.59%)

304198.31 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

72.73
/src/plugins/score-lib-process/Process/Preset.cpp
1
#include "Preset.hpp"
2

3
#include <Process/ProcessList.hpp>
4

5
#include <score/serialization/JSONVisitor.hpp>
6

7
namespace Process
8
{
9

10
std::shared_ptr<Preset>
11
Preset::fromJson(const ProcessFactoryList& procs, const QByteArray& obj) noexcept
799 ✔
12
{
13
  rapidjson::Document doc;
799 ✔
14
  Process::Preset p;
799 ✔
15
  doc.Parse(obj.data(), obj.size());
799 ✔
16
  if(doc.HasParseError())
799 ✔
17
    return {};
1 ✔
18

19
  if(!doc.IsObject())
798 ✔
20
    return {};
×
21

22
  if(!doc.GetObject().HasMember("Key")
1,596 ✔
23
     || !(doc.GetObject().HasMember("Preset") || doc.GetObject().HasMember("PresetData")))
798 ✔
24
    return {};
1 ✔
25

26
  JSONWriter wr{doc};
797 ✔
27
  const auto& k = wr.obj["Key"];
797 ✔
28
  p.key.key <<= k["Uuid"];
797 ✔
29
  p.key.effect = k["Effect"].toString();
797 ✔
30

31
  if(!procs.get(p.key.key))
797 ✔
32
    return {};
×
33

34
  if(auto raw = wr.obj.tryGet("PresetData"))
797 ✔
35
  {
36
    p.data = QByteArray::fromBase64(raw->toByteArray());
2 ✔
37
  }
2 ✔
38
  else
39
  {
40
    rapidjson::StringBuffer buf;
795 ✔
41
    JsonWriter writer(buf);
795 ✔
42
    wr.obj["Preset"].obj.Accept(writer);
795 ✔
43
    p.data = QByteArray(buf.GetString(), buf.GetSize());
795 ✔
44
  }
795 ✔
45
  p.name = wr.obj["Name"].toString();
797 ✔
46

47
  // Optional: old presets do not have a category
48
  if(doc.GetObject().HasMember("Category"))
797 ✔
49
    p.category = wr.obj["Category"].toString();
687 ✔
50
  if(doc.GetObject().HasMember("Description"))
797 ✔
51
    p.description = wr.obj["Description"].toString();
1 ✔
52

53
  return std::make_shared<Process::Preset>(std::move(p));
797 ✔
54
}
799 ✔
55

56
QByteArray Preset::toJson() const noexcept
199 ✔
57
{
58
  JSONReader ser;
199 ✔
59
  ser.readFrom(*this);
199 ✔
60
  return ser.toByteArray();
199 ✔
61
}
199 ✔
62

63
}
64

65
template <>
66
SCORE_LIB_PROCESS_EXPORT void DataStreamReader::read(const Process::Preset& p)
1,512 ✔
67
{
68
  m_stream << p.key.key << p.key.effect << p.data << p.name << p.category
1,512 ✔
69
           << p.description;
1,512 ✔
70
}
1,512 ✔
71

72
// We only load the members of the process here.
73
template <>
74
SCORE_LIB_PROCESS_EXPORT void DataStreamWriter::write(Process::Preset& p)
×
75
{
76
  m_stream >> p.key.key >> p.key.effect >> p.data >> p.name >> p.category
×
77
      >> p.description;
×
78
}
×
79

80
template <>
81
SCORE_LIB_PROCESS_EXPORT void JSONReader::read(const Process::Preset& p)
199 ✔
82
{
83
  stream.StartObject();
199 ✔
84
  stream.Key("Key");
199 ✔
85
  stream.StartObject();
199 ✔
86
  stream.Key("Uuid");
199 ✔
87
  readFrom(p.key.key);
199 ✔
88
  stream.Key("Effect");
199 ✔
89
  readFrom(p.key.effect);
199 ✔
90
  stream.EndObject();
199 ✔
91

92
  obj["Name"] = p.name;
199 ✔
93
  if(!p.category.isEmpty())
199 ✔
94
    obj["Category"] = p.category;
13 ✔
95
  if(!p.description.isEmpty())
199 ✔
96
    obj["Description"] = p.description;
1 ✔
97

98
  {
99
    // TODO not very optimal...
100
    rapidjson::Document doc;
199 ✔
101
    doc.Parse(p.data.data(), p.data.size());
199 ✔
102

103
    if(!doc.HasParseError())
199 ✔
104
    {
105
      stream.Key("Preset");
197 ✔
106
      doc.Accept(stream);
197 ✔
107
    }
197 ✔
108
    else
109
    {
110
      // A process whose data is not JSON would otherwise be saved as null
111
      stream.Key("PresetData");
2 ✔
112
      readFrom(QString::fromLatin1(p.data.toBase64()));
2 ✔
113
    }
114
  }
199 ✔
115
  stream.EndObject();
199 ✔
116
}
199 ✔
117

118
// We only load the members of the process here.
119
template <>
120
SCORE_LIB_PROCESS_EXPORT void JSONWriter::write(Process::Preset& p)
×
121
{
122
  const auto& k = obj["Key"];
×
123
  p.key.key <<= k["Uuid"];
×
124
  p.key.effect = k["Effect"].toString();
×
125

126
  if(auto raw = obj.tryGet("PresetData"))
×
127
  {
128
    p.data = QByteArray::fromBase64(raw->toByteArray());
×
129
  }
×
130
  else
131
  {
132
    // TODO not very optimal...
133
    rapidjson::StringBuffer buf;
×
134
    JsonWriter writer(buf);
×
135
    obj["Preset"].obj.Accept(writer);
×
136
    p.data = QByteArray(buf.GetString(), buf.GetSize());
×
137
  }
×
138
  p.name = obj["Name"].toString();
×
139
  if(auto cat = obj.tryGet("Category"))
×
140
    p.category = cat->toString();
×
141
  if(auto desc = obj.tryGet("Description"))
×
142
    p.description = desc->toString();
×
143
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc