libcruft-util/json/schema/type.hpp

48 lines
1.4 KiB
C++

/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Copyright 2018 Danny Robson <danny@nerdcruft.net>
*/
#pragma once
#include "base.hpp"
#include "../tree.hpp"
///////////////////////////////////////////////////////////////////////////////
namespace util::json::schema::constraint {
class type final : public base {
public:
enum type_t {
INTEGER = 1 << 0,
NUMBER = 1 << 1,
STRING = 1 << 2,
OBJECT = 1 << 3,
ARRAY = 1 << 4,
BOOLEAN = 1 << 5,
NONE = 1 << 6,
};
type (::json::tree::node const &definition);
virtual ~type () = default;
output_iterator validate (output_iterator, ::json::tree::node &target) const noexcept override;
std::ostream& describe (std::ostream&) const override;
private:
type_t const m_type;
};
}