1/*
2 * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25#ifndef SHARE_JFR_WRITERS_JFRPOSITION_INLINE_HPP
26#define SHARE_JFR_WRITERS_JFRPOSITION_INLINE_HPP
27
28#include "jfr/writers/jfrPosition.hpp"
29
30template <typename AP>
31inline const u1* Position<AP>::start_pos() const {
32 return _start_pos;
33}
34
35template <typename AP>
36inline void Position<AP>::set_start_pos(const u1* position) {
37 _start_pos = position;
38}
39
40template <typename AP>
41inline u1* Position<AP>::current_pos() {
42 return _current_pos;
43}
44
45template <typename AP>
46inline void Position<AP>::set_current_pos(const u1* new_position) {
47 _current_pos = const_cast<u1*>(new_position);
48}
49
50template <typename AP>
51inline void Position<AP>::set_current_pos(size_t size) {
52 _current_pos += size;
53}
54
55template <typename AP>
56inline const u1* Position<AP>::end_pos() const {
57 return _end_pos;
58}
59
60template <typename AP>
61inline void Position<AP>::set_end_pos(const u1* position) {
62 _end_pos = position;
63}
64
65template <typename AP>
66inline Position<AP>::Position(const u1* start_pos, size_t size) :
67 AP(),
68 _start_pos(start_pos),
69 _current_pos(const_cast<u1*>(start_pos)),
70 _end_pos(start_pos + size) {
71}
72
73template <typename AP>
74inline Position<AP>::Position() : _start_pos(NULL), _current_pos(NULL), _end_pos(NULL) {
75}
76
77template <typename AP>
78inline size_t Position<AP>::available_size() const {
79 return _end_pos - _current_pos;
80}
81
82template <typename AP>
83inline int64_t Position<AP>::used_offset() const {
84 return _current_pos - _start_pos;
85}
86
87template <typename AP>
88inline int64_t Position<AP>::current_offset() const {
89 return this->used_offset();
90}
91
92template <typename AP>
93inline size_t Position<AP>::used_size() const {
94 return (size_t)used_offset();
95}
96
97template <typename AP>
98inline void Position<AP>::reset() {
99 set_current_pos(_start_pos);
100}
101
102#endif // SHARE_JFR_WRITERS_JFRPOSITION_INLINE_HPP
103