Sha256: cf47193f1e4644ce0cf3ebbb397fcc23d8573270ac56ff4429ba4cf3a75512ec

Contents?: true

Size: 1.83 KB

Versions: 24

Compression:

Stored size: 1.83 KB

Contents

// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/

#ifndef TAO_JSON_PEGTL_INTERNAL_MARKER_HPP
#define TAO_JSON_PEGTL_INTERNAL_MARKER_HPP

#include "../config.hpp"
#include "../rewind_mode.hpp"

namespace TAO_JSON_PEGTL_NAMESPACE::internal
{
   template< typename Iterator, rewind_mode M >
   class marker
   {
   public:
      static constexpr rewind_mode next_rewind_mode = M;

      explicit marker( const Iterator& /*unused*/ ) noexcept
      {
      }

      marker( const marker& ) = delete;
      marker( marker&& ) = delete;

      ~marker() = default;

      void operator=( const marker& ) = delete;
      void operator=( marker&& ) = delete;

      [[nodiscard]] bool operator()( const bool result ) const noexcept
      {
         return result;
      }
   };

   template< typename Iterator >
   class marker< Iterator, rewind_mode::required >
   {
   public:
      static constexpr rewind_mode next_rewind_mode = rewind_mode::active;

      explicit marker( Iterator& i ) noexcept
         : m_saved( i ),
           m_input( &i )
      {
      }

      marker( const marker& ) = delete;
      marker( marker&& ) = delete;

      ~marker() noexcept
      {
         if( m_input != nullptr ) {
            ( *m_input ) = m_saved;
         }
      }

      void operator=( const marker& ) = delete;
      void operator=( marker&& ) = delete;

      [[nodiscard]] bool operator()( const bool result ) noexcept
      {
         if( result ) {
            m_input = nullptr;
            return true;
         }
         return false;
      }

      [[nodiscard]] const Iterator& iterator() const noexcept
      {
         return m_saved;
      }

   private:
      const Iterator m_saved;
      Iterator* m_input;
   };

}  // namespace TAO_JSON_PEGTL_NAMESPACE::internal

#endif

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
couchbase-3.0.0-universal-darwin-19 ext/third_party/json/include/tao/json/external/pegtl/internal/marker.hpp
couchbase-3.0.0 ext/third_party/json/include/tao/json/external/pegtl/internal/marker.hpp
couchbase-3.0.0.beta.1-universal-darwin-19 ext/third_party/json/include/tao/json/external/pegtl/internal/marker.hpp
couchbase-3.0.0.beta.1 ext/third_party/json/include/tao/json/external/pegtl/internal/marker.hpp
couchbase-3.0.0.alpha.5-x86_64-linux ext/third_party/json/include/tao/json/external/pegtl/internal/marker.hpp
couchbase-3.0.0.alpha.5-universal-darwin-19 ext/third_party/json/include/tao/json/external/pegtl/internal/marker.hpp
couchbase-3.0.0.alpha.5-x86_64-darwin-19 ext/third_party/json/include/tao/json/external/pegtl/internal/marker.hpp
couchbase-3.0.0.alpha.5 ext/third_party/json/include/tao/json/external/pegtl/internal/marker.hpp
couchbase-3.0.0.alpha.4-x86_64-linux ext/third_party/json/include/tao/json/external/pegtl/internal/marker.hpp
couchbase-3.0.0.alpha.4-x86_64-darwin-19 ext/third_party/json/include/tao/json/external/pegtl/internal/marker.hpp
couchbase-3.0.0.alpha.4-universal-darwin-19 ext/third_party/json/include/tao/json/external/pegtl/internal/marker.hpp
couchbase-3.0.0.alpha.4 ext/third_party/json/include/tao/json/external/pegtl/internal/marker.hpp
couchbase-3.0.0.alpha.3-x86_64-linux ext/third_party/json/include/tao/json/external/pegtl/internal/marker.hpp
couchbase-3.0.0.alpha.3-x86_64-darwin-19 ext/third_party/json/include/tao/json/external/pegtl/internal/marker.hpp
couchbase-3.0.0.alpha.3-universal-darwin-19 ext/third_party/json/include/tao/json/external/pegtl/internal/marker.hpp
couchbase-3.0.0.alpha.3 ext/third_party/json/include/tao/json/external/pegtl/internal/marker.hpp
couchbase-3.0.0.alpha.2-x86_64-linux ext/third_party/json/include/tao/json/external/pegtl/internal/marker.hpp
couchbase-3.0.0.alpha.2-x86_64-darwin-19 ext/third_party/json/include/tao/json/external/pegtl/internal/marker.hpp
couchbase-3.0.0.alpha.2-universal-darwin-19 ext/third_party/json/include/tao/json/external/pegtl/internal/marker.hpp
couchbase-3.0.0.alpha.2 ext/third_party/json/include/tao/json/external/pegtl/internal/marker.hpp