-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creates
reader
type for converting from JSON source to AST node seq…
…uence A `jsonv::reader` instance reads from some form of JSON source (probably a string, but the `jsonv::ast_index` type can theoretically read from anything JSON-like) and converts it into `jsonv::ast_node`s. These abstract reading from JSON source to normalize `extract` implementations, which is needed for #150. - Resolves #171
- Loading branch information
Showing
18 changed files
with
1,382 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,20 @@ | ||
/** \file jsonv/detail/scope_exit.hpp | ||
* Definition of the \c on_scope_exit utility. | ||
* | ||
* Copyright (c) 2015 by Travis Gockel. All rights reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify it under the terms of the Apache License | ||
* as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later | ||
* version. | ||
* | ||
* \author Travis Gockel ([email protected]) | ||
**/ | ||
#ifndef __JSONV_DETAIL_SCOPE_EXIT_HPP_INCLUDED__ | ||
#define __JSONV_DETAIL_SCOPE_EXIT_HPP_INCLUDED__ | ||
/// \file jsonv/detail/scope_exit.hpp | ||
/// Definition of the \c on_scope_exit utility. | ||
/// | ||
/// Copyright (c) 2015 by Travis Gockel. All rights reserved. | ||
/// | ||
/// This program is free software: you can redistribute it and/or modify it under the terms of the Apache License | ||
/// as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later | ||
/// version. | ||
/// | ||
/// \author Travis Gockel ([email protected]) | ||
#pragma once | ||
|
||
#include <jsonv/config.hpp> | ||
|
||
#include <utility> | ||
|
||
namespace jsonv | ||
{ | ||
namespace detail | ||
namespace jsonv::detail | ||
{ | ||
|
||
template <typename Function> | ||
|
@@ -29,29 +25,29 @@ class scope_exit_invoker | |
_func(std::move(func)), | ||
_responsible(true) | ||
{ } | ||
|
||
scope_exit_invoker(scope_exit_invoker&& src) : | ||
_func(std::move(src._func)), | ||
_responsible(src._responsible) | ||
{ | ||
src._responsible = false; | ||
} | ||
|
||
scope_exit_invoker(const scope_exit_invoker&) = delete; | ||
scope_exit_invoker& operator=(const scope_exit_invoker&) = delete; | ||
scope_exit_invoker& operator=(scope_exit_invoker&&) = delete; | ||
|
||
~scope_exit_invoker() | ||
{ | ||
if (_responsible) | ||
_func(); | ||
} | ||
|
||
void release() | ||
{ | ||
_responsible = false; | ||
} | ||
|
||
private: | ||
Function _func; | ||
bool _responsible; | ||
|
@@ -64,6 +60,3 @@ scope_exit_invoker<Function> on_scope_exit(Function func) | |
} | ||
|
||
} | ||
} | ||
|
||
#endif/*__JSONV_DETAIL_SCOPE_EXIT_HPP_INCLUDED__*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.