ladybird/Userland/Libraries/LibJS/Runtime/ThrowableStringBuilder.h
Timothy Flynn 7163e4d456 LibJS: Change ThrowableStringBuilder to privately inherit StringBuilder
Not an issue currently, but while developing, it's easy to miss cases
where an infallible AK::StringBuilder method is still used. By making
this inheritance private, and explicitly pulling in base methods we
can safely use, we get extra help from the compiler to indicate such
mistakes immediately.
2023-02-10 17:26:20 +00:00

36 lines
841 B
C++

/*
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/StringBuilder.h>
#include <AK/StringView.h>
#include <LibJS/Forward.h>
#include <LibJS/Runtime/Completion.h>
#include <LibJS/Runtime/ErrorTypes.h>
#include <LibJS/Runtime/VM.h>
namespace JS {
class ThrowableStringBuilder : private AK::StringBuilder {
public:
explicit ThrowableStringBuilder(VM&);
ThrowCompletionOr<void> append(char);
ThrowCompletionOr<void> append(StringView);
ThrowCompletionOr<void> append(Utf16View const&);
ThrowCompletionOr<void> append_code_point(u32 value);
ThrowCompletionOr<String> to_string() const;
using AK::StringBuilder::is_empty;
using AK::StringBuilder::string_view;
using AK::StringBuilder::trim;
private:
VM& m_vm;
};
}