xbmc
WsgiInputStream.h
1 /*
2  * Copyright (C) 2015-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "interfaces/legacy/AddonClass.h"
12 
13 #include <vector>
14 
15 struct HTTPPythonRequest;
16 
17 namespace XBMCAddon
18 {
19  namespace xbmcwsgi
20  {
21 
22  // Iterator for the wsgi.input stream.
24  {
25  public:
27  ~WsgiInputStreamIterator() override;
28 
29 #ifdef DOXYGEN_SHOULD_USE_THIS
30  read(...);
39 #else
40  String read(unsigned long size = 0) const;
41 #endif
42 
43 #ifdef DOXYGEN_SHOULD_USE_THIS
44  read(...);
54 #else
55  String readline(unsigned long size = 0) const;
56 #endif
57 
58 #ifdef DOXYGEN_SHOULD_USE_THIS
59  read(...);
69 #else
70  std::vector<String> readlines(unsigned long sizehint = 0) const;
71 #endif
72 
73 #if !defined SWIG && !defined DOXYGEN_SHOULD_SKIP_THIS
74  WsgiInputStreamIterator(const String& data, bool end = false);
75 
76  WsgiInputStreamIterator& operator++();
77  bool operator==(const WsgiInputStreamIterator& rhs);
78  bool operator!=(const WsgiInputStreamIterator& rhs);
79  String& operator*();
80  inline bool end() const { return m_remaining <= 0; }
81 
82  protected:
83  String m_data;
84  mutable unsigned long m_offset = 0;
85  mutable unsigned long m_remaining = 0;
86 
87  private:
88  String m_line;
89 #endif
90  };
91 
102  {
103  public:
104  WsgiInputStream();
105  ~WsgiInputStream() override;
106 
107 #if !defined SWIG && !defined DOXYGEN_SHOULD_SKIP_THIS
108  WsgiInputStreamIterator* begin();
110 
114  void SetRequest(HTTPPythonRequest* request);
115 
116  HTTPPythonRequest* m_request;
117 #endif
118  };
119  }
120 }
Definition: HTTPPythonRequest.h:18
Defining LOG_LIFECYCLE_EVENTS will log all instantiations, deletions and also reference countings (in...
Definition: Addon.cpp:25
Definition: WsgiInputStream.h:101
Definition: WsgiInputStream.h:23
This class is the superclass for all reference counted classes in the api.
Definition: AddonClass.h:57