Orcus
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 
16 namespace orcus {
17 
23 class ORCUS_PSR_DLLPUBLIC file_content
24 {
25  struct impl;
26  std::unique_ptr<impl> mp_impl;
27 public:
28  file_content(const file_content&) = delete;
29  file_content& operator= (const file_content&) = delete;
30 
31  file_content();
32  file_content(file_content&& other);
33  file_content(std::string_view filepath);
34  ~file_content();
35 
41  const char* data() const;
42 
49  size_t size() const;
50 
56  bool empty() const;
57 
63  void swap(file_content& other);
64 
71  void load(std::string_view filepath);
72 
79 
80  std::string_view str() const;
81 };
82 
89 class ORCUS_PSR_DLLPUBLIC memory_content
90 {
91  struct impl;
92  std::unique_ptr<impl> mp_impl;
93 public:
94  memory_content(const file_content&) = delete;
95  memory_content& operator= (const file_content&) = delete;
96 
98  memory_content(std::string_view s);
100  ~memory_content();
101 
102  const char* data() const;
103  size_t size() const;
104  bool empty() const;
105 
106  void swap(memory_content& other);
107 
114 
115  std::string_view str() const;
116 };
117 
118 struct ORCUS_PSR_DLLPUBLIC line_with_offset
119 {
120  std::string line;
121  size_t line_number;
122  size_t offset_on_line;
123 
124  line_with_offset(std::string _line, size_t _line_number, size_t _offset_on_line);
125  line_with_offset(const line_with_offset& other);
127  ~line_with_offset();
128 };
129 
139 ORCUS_PSR_DLLPUBLIC std::string create_parse_error_output(std::string_view strm, std::ptrdiff_t offset);
140 
151 ORCUS_PSR_DLLPUBLIC line_with_offset locate_line_with_offset(std::string_view strm, std::ptrdiff_t offset);
152 
164 ORCUS_PSR_DLLPUBLIC size_t locate_first_different_char(std::string_view left, std::string_view right);
165 
166 } // namespace orcus
167 
168 #endif
169 
170 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: stream.hpp:24
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:90
Definition: stream.hpp:119