summaryrefslogtreecommitdiff
path: root/Userland/Applications/Spreadsheet/Writers
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-09-07 12:56:50 +0200
committerAndreas Kling <kling@serenityos.org>2021-09-07 13:53:14 +0200
commit6ad427993a64c846c93ecc1fd3bf3f6d6be9cd3d (patch)
treebf364b00ad62291a34426cc8a820a18b7b8c1aaa /Userland/Applications/Spreadsheet/Writers
parent55b0b06897b7160b5fbc18ff9186a2242bbdf318 (diff)
downloadserenity-6ad427993a64c846c93ecc1fd3bf3f6d6be9cd3d.zip
Everywhere: Behaviour => Behavior
Diffstat (limited to 'Userland/Applications/Spreadsheet/Writers')
-rw-r--r--Userland/Applications/Spreadsheet/Writers/CSV.h4
-rw-r--r--Userland/Applications/Spreadsheet/Writers/Test/TestXSVWriter.cpp4
-rw-r--r--Userland/Applications/Spreadsheet/Writers/XSV.h28
3 files changed, 18 insertions, 18 deletions
diff --git a/Userland/Applications/Spreadsheet/Writers/CSV.h b/Userland/Applications/Spreadsheet/Writers/CSV.h
index 1b7c7ba511..d7650e760a 100644
--- a/Userland/Applications/Spreadsheet/Writers/CSV.h
+++ b/Userland/Applications/Spreadsheet/Writers/CSV.h
@@ -15,8 +15,8 @@ namespace Writer {
template<typename ContainerType>
class CSV : public XSV<ContainerType> {
public:
- CSV(OutputStream& output, const ContainerType& data, const Vector<StringView>& headers = {}, WriterBehaviour behaviours = default_behaviours())
- : XSV<ContainerType>(output, data, { ",", "\"", WriterTraits::Repeat }, headers, behaviours)
+ CSV(OutputStream& output, const ContainerType& data, const Vector<StringView>& headers = {}, WriterBehavior behaviors = default_behaviors())
+ : XSV<ContainerType>(output, data, { ",", "\"", WriterTraits::Repeat }, headers, behaviors)
{
}
};
diff --git a/Userland/Applications/Spreadsheet/Writers/Test/TestXSVWriter.cpp b/Userland/Applications/Spreadsheet/Writers/Test/TestXSVWriter.cpp
index 542c544ea8..fd294d3a0c 100644
--- a/Userland/Applications/Spreadsheet/Writers/Test/TestXSVWriter.cpp
+++ b/Userland/Applications/Spreadsheet/Writers/Test/TestXSVWriter.cpp
@@ -53,7 +53,7 @@ TEST_CASE(can_write_with_header)
EXPECT_EQ(StringView { stream.bytes() }, expected_output);
}
-TEST_CASE(can_write_with_different_behaviours)
+TEST_CASE(can_write_with_different_behaviors)
{
Vector<Vector<String>> data = {
{ "Well", "Hello\"", "Friends" },
@@ -63,7 +63,7 @@ TEST_CASE(can_write_with_different_behaviours)
auto buffer = ByteBuffer::create_uninitialized(1024).release_value();
OutputMemoryStream stream { buffer };
- Writer::CSV csv(stream, data, { "A", "B\"", "C" }, Writer::WriterBehaviour::QuoteOnlyInFieldStart | Writer::WriterBehaviour::WriteHeaders);
+ Writer::CSV csv(stream, data, { "A", "B\"", "C" }, Writer::WriterBehavior::QuoteOnlyInFieldStart | Writer::WriterBehavior::WriteHeaders);
auto expected_output = R"~(A,B",C
Well,Hello",Friends
diff --git a/Userland/Applications/Spreadsheet/Writers/XSV.h b/Userland/Applications/Spreadsheet/Writers/XSV.h
index b72e35525b..08ce3a0b5c 100644
--- a/Userland/Applications/Spreadsheet/Writers/XSV.h
+++ b/Userland/Applications/Spreadsheet/Writers/XSV.h
@@ -16,7 +16,7 @@
namespace Writer {
-enum class WriterBehaviour : u32 {
+enum class WriterBehavior : u32 {
None = 0,
WriteHeaders = 1,
AllowNewlinesInFields = WriteHeaders << 1,
@@ -24,14 +24,14 @@ enum class WriterBehaviour : u32 {
QuoteAll = WriteHeaders << 3,
};
-inline WriterBehaviour operator&(WriterBehaviour left, WriterBehaviour right)
+inline WriterBehavior operator&(WriterBehavior left, WriterBehavior right)
{
- return static_cast<WriterBehaviour>(static_cast<u32>(left) & static_cast<u32>(right));
+ return static_cast<WriterBehavior>(static_cast<u32>(left) & static_cast<u32>(right));
}
-inline WriterBehaviour operator|(WriterBehaviour left, WriterBehaviour right)
+inline WriterBehavior operator|(WriterBehavior left, WriterBehavior right)
{
- return static_cast<WriterBehaviour>(static_cast<u32>(left) | static_cast<u32>(right));
+ return static_cast<WriterBehavior>(static_cast<u32>(left) | static_cast<u32>(right));
}
struct WriterTraits {
@@ -54,23 +54,23 @@ enum class WriteError {
#undef E
};
-constexpr WriterBehaviour default_behaviours()
+constexpr WriterBehavior default_behaviors()
{
- return WriterBehaviour::None;
+ return WriterBehavior::None;
}
template<typename ContainerType, typename HeaderType = Vector<StringView>>
class XSV {
public:
- XSV(OutputStream& output, const ContainerType& data, const WriterTraits& traits, const HeaderType& headers = {}, WriterBehaviour behaviours = default_behaviours())
+ XSV(OutputStream& output, const ContainerType& data, const WriterTraits& traits, const HeaderType& headers = {}, WriterBehavior behaviors = default_behaviors())
: m_data(data)
, m_traits(traits)
- , m_behaviours(behaviours)
+ , m_behaviors(behaviors)
, m_names(headers)
, m_output(output)
{
if (!headers.is_empty())
- m_behaviours = m_behaviours | WriterBehaviour::WriteHeaders;
+ m_behaviors = m_behaviors | WriterBehavior::WriteHeaders;
generate();
}
@@ -101,7 +101,7 @@ private:
void generate()
{
- auto with_headers = (m_behaviours & WriterBehaviour::WriteHeaders) != WriterBehaviour::None;
+ auto with_headers = (m_behaviors & WriterBehavior::WriteHeaders) != WriterBehavior::None;
if (with_headers) {
write_row(m_names);
if (m_output.write({ "\n", 1 }) != 1)
@@ -139,12 +139,12 @@ private:
{
auto string = String::formatted("{}", FormatIfSupported(entry));
- auto safe_to_write_normally = (m_behaviours & WriterBehaviour::QuoteAll) == WriterBehaviour::None
+ auto safe_to_write_normally = (m_behaviors & WriterBehavior::QuoteAll) == WriterBehavior::None
&& !string.contains("\n")
&& !string.contains(m_traits.separator);
if (safe_to_write_normally) {
- if ((m_behaviours & WriterBehaviour::QuoteOnlyInFieldStart) == WriterBehaviour::None)
+ if ((m_behaviors & WriterBehavior::QuoteOnlyInFieldStart) == WriterBehavior::None)
safe_to_write_normally = !string.contains(m_traits.quote);
else
safe_to_write_normally = !string.starts_with(m_traits.quote);
@@ -190,7 +190,7 @@ private:
const ContainerType& m_data;
const WriterTraits& m_traits;
- WriterBehaviour m_behaviours;
+ WriterBehavior m_behaviors;
const HeaderType& m_names;
WriteError m_error { WriteError::None };
OutputStream& m_output;