Tamer
C++ language extensions for event-driven programming
Loading...
Searching...
No Matches
bufferedio.hh
1#ifndef TAMER_BUFFEREDIO_HH
2#define TAMER_BUFFEREDIO_HH 1
3/* Copyright (c) 2007-2015, Eddie Kohler
4 * Copyright (c) 2007, Regents of the University of California
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, subject to the conditions
9 * listed in the Tamer LICENSE file. These conditions include: you must
10 * preserve this copyright notice, and you cannot mention the copyright
11 * holders in advertising related to the Software without their permission.
12 * The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This
13 * notice is a summary of the Tamer LICENSE file; the license in that file is
14 * legally binding.
15 */
16#include <string>
17#include <tamer/tamer.hh>
18#include <tamer/fd.hh>
19namespace tamer {
20
21class buffer {
22public:
23 buffer(size_t initial_capacity = 1024);
24 ~buffer();
25
26 std::string str() const; // debugging
27
28 void fill_until(fd f, char c, size_t max_size, size_t& out_size, event<int> done);
29 void take_until(fd f, char c, size_t max_size, std::string& str, event<int> done);
30
31private:
32 char* buf_;
33 size_t size_;
34 size_t head_ = 0;
35 size_t tail_ = 0;
36
37 ssize_t fill_more(fd f, const event<int>& done);
38
39 class closure__fill_until__2fdckRkQi_;
40 void fill_until(closure__fill_until__2fdckRkQi_&);
41 class closure__take_until__2fdckRSsQi_;
42 void take_until(closure__take_until__2fdckRSsQi_&);
43};
44
45}
46#endif /* TAMER_BUFFEREDIO_HH */
Event-based file descriptor wrapper class.
Namespace containing public Tamer classes and functions for the Tamer core.
Definition adapter.hh:17
The main Tamer header file.