mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:17:36 +00:00
Meta: Generate CSS::MediaFeatureID enum
This works largely the same as the PropertyID and ValueID generators, but using LibMain, Core::Stream, and TRY(). Rather than have a MediaFeatureID::Invalid, I decided to return an Optional. We'll see if that turns out better or not. :^)
This commit is contained in:
parent
e986331a4f
commit
b7bb86462b
5 changed files with 168 additions and 4 deletions
|
@ -1,13 +1,16 @@
|
|||
/*
|
||||
* Copyright (c) 2019-2021, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2022, Samuel Atkins <atkinssj@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/JsonObject.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <ctype.h>
|
||||
|
||||
String title_casify(String const& dashy_name)
|
||||
|
@ -45,3 +48,13 @@ String camel_casify(StringView dashy_name)
|
|||
}
|
||||
return builder.to_string();
|
||||
}
|
||||
|
||||
ErrorOr<JsonValue> read_entire_file_as_json(StringView filename)
|
||||
{
|
||||
auto file = TRY(Core::Stream::File::open(filename, Core::Stream::OpenMode::Read));
|
||||
auto json_size = TRY(file->size());
|
||||
auto json_data = TRY(ByteBuffer::create_uninitialized(json_size));
|
||||
if (!file->read_or_error(json_data.bytes()))
|
||||
return Error::from_string_literal("Failed to read json file.");
|
||||
return JsonValue::from_string(json_data);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue