Orcus
Loading...
Searching...
No Matches
stream.hpp
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 */
7
8#ifndef INCLUDED_ORCUS_STREAM_HPP
9#define INCLUDED_ORCUS_STREAM_HPP
10
11#include "env.hpp"
12
13#include <memory>
14#include <string>
15
16namespace orcus {
17
24class ORCUS_PSR_DLLPUBLIC file_content
25{
26 struct impl;
27 std::unique_ptr<impl> mp_impl;
28public:
29 file_content(const file_content&) = delete;
30 file_content& operator= (const file_content&) = delete;
31
32 file_content();
33 file_content(file_content&& other);
34 file_content(std::string_view filepath);
35 file_content(std::u16string_view filepath);
36 ~file_content();
37
43 const char* data() const;
44
51 size_t size() const;
52
58 bool empty() const;
59
65 void swap(file_content& other);
66
73 void load(std::string_view filepath);
74
81
82 std::string_view str() const;
83};
84
91class ORCUS_PSR_DLLPUBLIC memory_content
92{
93 struct impl;
94 std::unique_ptr<impl> mp_impl;
95public:
96 memory_content(const file_content&) = delete;
97 memory_content& operator= (const file_content&) = delete;
98
99 memory_content();
100 memory_content(std::string_view s);
101 memory_content(memory_content&& other);
102 ~memory_content();
103
104 const char* data() const;
105 size_t size() const;
106 bool empty() const;
107
108 void swap(memory_content& other);
109
116
117 std::string_view str() const;
118};
119
120struct ORCUS_PSR_DLLPUBLIC line_with_offset
121{
123 std::string line;
125 std::size_t line_number;
127 std::size_t offset_on_line;
128
129 line_with_offset(std::string _line, std::size_t _line_number, std::size_t _offset_on_line);
130 line_with_offset(const line_with_offset& other);
131 line_with_offset(line_with_offset&& other);
132 ~line_with_offset();
133
134 bool operator== (const line_with_offset& other) const;
135 bool operator!= (const line_with_offset& other) const;
136};
137
147ORCUS_PSR_DLLPUBLIC std::string create_parse_error_output(std::string_view strm, std::ptrdiff_t offset);
148
162ORCUS_PSR_DLLPUBLIC line_with_offset locate_line_with_offset(std::string_view strm, std::ptrdiff_t offset);
163
175ORCUS_PSR_DLLPUBLIC std::size_t locate_first_different_char(std::string_view left, std::string_view right);
176
183ORCUS_PSR_DLLPUBLIC std::size_t calc_logical_string_length(std::string_view s);
184
185} // namespace orcus
186
187#endif
188
189/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition stream.hpp:25
size_t size() const
void swap(file_content &other)
void load(std::string_view filepath)
const char * data() const
bool empty() const
Definition stream.hpp:121
std::size_t offset_on_line
Definition stream.hpp:127
std::size_t line_number
Definition stream.hpp:125
std::string line
Definition stream.hpp:123