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#include "orcus/pstring.hpp"
13
14#include <memory>
15
16namespace orcus {
17
23class ORCUS_PSR_DLLPUBLIC file_content
24{
25 struct impl;
26 std::unique_ptr<impl> mp_impl;
27public:
28 file_content(const file_content&) = delete;
29 file_content& operator= (const file_content&) = delete;
30
33 file_content(const char* filepath);
35
36 const char* data() const;
37 size_t size() const;
38 bool empty() const;
39
40 void swap(file_content& other);
41
48 void load(const char* filepath);
49
56
57 pstring str() const;
58};
59
67class ORCUS_PSR_DLLPUBLIC memory_content
68{
69 struct impl;
70 std::unique_ptr<impl> mp_impl;
71public:
72 memory_content(const file_content&) = delete;
73 memory_content& operator= (const file_content&) = delete;
74
76 memory_content(const char* p, size_t n);
79
80 const char* data() const;
81 size_t size() const;
82 bool empty() const;
83
84 void swap(memory_content& other);
85
92
93 pstring str() const;
94};
95
105ORCUS_PSR_DLLPUBLIC std::string create_parse_error_output(
106 const pstring& strm, std::ptrdiff_t offset);
107
119ORCUS_PSR_DLLPUBLIC size_t locate_first_different_char(
120 const pstring& left, const pstring& right);
121
122} // namespace orcus
123
124#endif
125
126/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: stream.hpp:24
void load(const char *filepath)
Definition: stream.hpp:68
Definition: pstring.hpp:28