mirror of
https://github.com/tristanpenman/valijson.git
synced 2025-01-19 00:46:03 +01:00
4c9864de73
This commit contains the third major design of a C++ library for JSON Schema validation. It is definitely not what I would consider production-ready, but I do think that the overall design of the library is robust.
56 lines
1.1 KiB
C++
56 lines
1.1 KiB
C++
//
|
|
// coroutine.hpp
|
|
// ~~~~~~~~~~~~~
|
|
//
|
|
// Copyright (c) 2009-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
|
//
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
//
|
|
|
|
#ifndef URDL_DETAIL_COROUTINE_HPP
|
|
#define URDL_DETAIL_COROUTINE_HPP
|
|
|
|
#include "urdl/detail/abi_prefix.hpp"
|
|
|
|
namespace urdl {
|
|
namespace detail {
|
|
|
|
class coroutine
|
|
{
|
|
protected:
|
|
coroutine() : coro_value_(0) {}
|
|
int coro_value_;
|
|
};
|
|
|
|
#define URDL_CORO_BEGIN \
|
|
switch (this->coroutine::coro_value_) \
|
|
{ \
|
|
case 0:
|
|
|
|
#define URDL_CORO_YIELD_IMPL(s,n) \
|
|
do \
|
|
{ \
|
|
this->coroutine::coro_value_ = n; \
|
|
s; \
|
|
return; \
|
|
case n: \
|
|
; \
|
|
} while (0)
|
|
|
|
#if defined(_MSC_VER)
|
|
# define URDL_CORO_YIELD(s) URDL_CORO_YIELD_IMPL(s, __COUNTER__ + 1)
|
|
#else // defined(_MSC_VER)
|
|
# define URDL_CORO_YIELD(s) URDL_CORO_YIELD_IMPL(s, __LINE__)
|
|
#endif // defined(_MSC_VER)
|
|
|
|
#define URDL_CORO_END \
|
|
}
|
|
|
|
} // namespace detail
|
|
} // namespace urdl
|
|
|
|
#include "urdl/detail/abi_suffix.hpp"
|
|
|
|
#endif // URDL_DETAIL_COROUTINE_HPP
|