ReadHelper.cti
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
14 /** \file
15  \brief ReadHelper inline template implementation */
16 
17 #include "ReadHelper.ih"
18 
19 // Custom includes
20 #include <senf/Utils/Exception.hh>
21 
22 #define prefix_ inline
23 //-/////////////////////////////////////////////////////////////////////////////////////////////////
24 
25 template <class Handle>
26 prefix_ typename senf::ReadHelper<Handle>::ptr
27 senf::ReadHelper<Handle>::dispatch(Handle handle, std::string::size_type maxSize,
28  Callback callback)
29 {
30  return ptr(new ReadHelper(handle, maxSize, 0, callback));
31 }
32 
33 template <class Handle>
34 template <class Predicate>
35 prefix_ typename senf::ReadHelper<Handle>::ptr
36 senf::ReadHelper<Handle>::dispatch(Handle handle, std::string::size_type maxSize,
37  Predicate const & predicate, Callback callback)
38 {
39  return ptr(new ReadHelper(handle, maxSize,
40  new typename InternalPredicate::template Dispatcher<Predicate>(predicate),
41  callback));
42 }
43 
44 template <class Handle>
45 prefix_ Handle senf::ReadHelper<Handle>::handle()
46  const
47 {
48  return handle_;
49 }
50 
51 template <class Handle>
52 prefix_ std::string::size_type senf::ReadHelper<Handle>::maxSize()
53  const
54 {
55  return maxSize_;
56 }
57 
58 template <class Handle>
59 prefix_ std::string const & senf::ReadHelper<Handle>::data()
60  const
61 {
62  return data_;
63 }
64 
65 template <class Handle>
66 prefix_ std::string const & senf::ReadHelper<Handle>::tail()
67  const
68 {
69  return tail_;
70 }
71 
72 template <class Handle>
73 prefix_ bool senf::ReadHelper<Handle>::complete()
74  const
75 {
76  return complete_;
77 }
78 
79 template <class Handle>
80 prefix_ bool senf::ReadHelper<Handle>::error()
81  const
82 {
83  return errno_ != 0;
84 }
85 
86 template <class Handle>
87 prefix_ void senf::ReadHelper<Handle>::throw_error()
88  const
89 {
90  if (errno_ != 0) throw SystemException(errno_ SENF_EXC_DEBUGINFO);
91 }
92 
93 //-/////////////////////////////////////////////////////////////////////////////////////////////////
94 #undef prefix_
95 
96 
97 // Local Variables:
98 // mode: c++
99 // fill-column: 100
100 // c-file-style: "senf"
101 // indent-tabs-mode: nil
102 // ispell-local-dictionary: "american"
103 // compile-command: "scons -u test"
104 // comment-column: 40
105 // End: