Cinder  0.8.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
UrlImplWinInet.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2010, The Cinder Project (http://libcinder.org)
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without modification, are permitted provided that
6  the following conditions are met:
7 
8  * Redistributions of source code must retain the above copyright notice, this list of conditions and
9  the following disclaimer.
10  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
11  the following disclaimer in the documentation and/or other materials provided with the distribution.
12 
13  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
14  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
15  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
16  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
17  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
18  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
19  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
20  POSSIBILITY OF SUCH DAMAGE.
21 */
22 
23 #pragma once
24 
25 #include "cinder/Url.h"
26 
27 namespace cinder {
28 
29 class IStreamUrlImplWinInet : public IStreamUrlImpl {
30  public:
31  IStreamUrlImplWinInet( const std::string &url, const std::string &user, const std::string &password, const UrlOptions &options );
33 
34  virtual size_t readDataAvailable( void *dest, size_t maxSize );
35  virtual void seekAbsolute( off_t absoluteOffset );
36  virtual void seekRelative( off_t relativeOffset );
37  virtual off_t tell() const;
38  virtual off_t size() const;
39 
40  virtual bool isEof() const;
41  virtual void IORead( void *t, size_t size );
42 
43  private:
44  int bufferDataRemaining() const { return mBufferedBytes - mBufferOffset; }
45  void fillBuffer( int wantBytes ) const;
46 
47  std::shared_ptr<void> mSession, mConnection, mRequest;
48 
49  mutable bool mIsFinished;
50  mutable uint8_t *mBuffer; // todo - consider an exception-safe version of this
51  mutable int mBufferSize;
52  mutable int mBufferOffset, mBufferedBytes;
53  mutable off_t mBufferFileOffset; // where in the file the buffer starts
54  static const int DEFAULT_BUFFER_SIZE = 4096;
55 };
56 
57 } // namespace cinder
virtual void seekRelative(off_t relativeOffset)
Definition: UrlImplWinInet.cpp:166
GLsizei const GLchar ** string
Definition: GLee.h:2427
virtual bool isEof() const
Definition: UrlImplWinInet.cpp:161
virtual void IORead(void *t, size_t size)
Definition: UrlImplWinInet.cpp:247
IStreamUrlImplWinInet(const std::string &url, const std::string &user, const std::string &password, const UrlOptions &options)
Definition: UrlImplWinInet.cpp:54
virtual size_t readDataAvailable(void *dest, size_t maxSize)
Definition: UrlImplWinInet.cpp:259
virtual off_t size() const
Definition: UrlImplWinInet.cpp:191
Options for loadUrl() to dictate caching and timeout behavior.
Definition: Url.h:64
~IStreamUrlImplWinInet()
Definition: UrlImplWinInet.cpp:155
GLdouble GLdouble t
Definition: GLee.h:1426
Definition: UrlImplWinInet.h:29
virtual off_t tell() const
Definition: UrlImplWinInet.cpp:186
virtual void seekAbsolute(off_t absoluteOffset)
Definition: UrlImplWinInet.cpp:181