mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Demos: Convey proper ownership semantics
This commit is contained in:
parent
4abffb1f11
commit
5af01b9b16
20 changed files with 77 additions and 76 deletions
|
|
@ -655,21 +655,21 @@ private:
|
|||
#endif
|
||||
|
||||
//==============================================================================
|
||||
InputStream* URL::createInputStream (bool usePostCommand,
|
||||
OpenStreamProgressCallback* progressCallback,
|
||||
void* progressCallbackContext,
|
||||
String headers,
|
||||
int timeOutMs,
|
||||
StringPairArray* responseHeaders,
|
||||
int* statusCode,
|
||||
int numRedirectsToFollow,
|
||||
String httpRequestCmd) const
|
||||
std::unique_ptr<InputStream> URL::createInputStream (bool usePostCommand,
|
||||
OpenStreamProgressCallback* progressCallback,
|
||||
void* progressCallbackContext,
|
||||
String headers,
|
||||
int timeOutMs,
|
||||
StringPairArray* responseHeaders,
|
||||
int* statusCode,
|
||||
int numRedirectsToFollow,
|
||||
String httpRequestCmd) const
|
||||
{
|
||||
if (isLocalFile())
|
||||
{
|
||||
#if JUCE_IOS
|
||||
// We may need to refresh the embedded bookmark.
|
||||
return new iOSFileStreamWrapper<FileInputStream> (const_cast<URL&>(*this));
|
||||
return std::make_unique<iOSFileStreamWrapper<FileInputStream>> (const_cast<URL&>(*this));
|
||||
#else
|
||||
return getLocalFile().createInputStream();
|
||||
#endif
|
||||
|
|
@ -717,27 +717,29 @@ InputStream* URL::createInputStream (bool usePostCommand,
|
|||
if (! success || wi->isError())
|
||||
return nullptr;
|
||||
|
||||
return wi.release();
|
||||
// Older GCCs complain about binding unique_ptr<WebInputStream>&& to unique_ptr<InputStream>
|
||||
// if we just `return wi` here.
|
||||
return std::unique_ptr<InputStream> (std::move (wi));
|
||||
}
|
||||
|
||||
#if JUCE_ANDROID
|
||||
OutputStream* juce_CreateContentURIOutputStream (const URL&);
|
||||
#endif
|
||||
|
||||
OutputStream* URL::createOutputStream() const
|
||||
std::unique_ptr<OutputStream> URL::createOutputStream() const
|
||||
{
|
||||
if (isLocalFile())
|
||||
{
|
||||
#if JUCE_IOS
|
||||
// We may need to refresh the embedded bookmark.
|
||||
return new iOSFileStreamWrapper<FileOutputStream> (const_cast<URL&> (*this));
|
||||
return std::make_unique<iOSFileStreamWrapper<FileOutputStream>> (const_cast<URL&> (*this));
|
||||
#else
|
||||
return new FileOutputStream (getLocalFile());
|
||||
return std::make_unique<FileOutputStream> (getLocalFile());
|
||||
#endif
|
||||
}
|
||||
|
||||
#if JUCE_ANDROID
|
||||
return juce_CreateContentURIOutputStream (*this);
|
||||
return std::unique_ptr<OutputStream> (juce_CreateContentURIOutputStream (*this));
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -340,22 +340,22 @@ public:
|
|||
@returns an input stream that the caller must delete, or a null pointer if there was an
|
||||
error trying to open it.
|
||||
*/
|
||||
InputStream* createInputStream (bool doPostLikeRequest,
|
||||
OpenStreamProgressCallback* progressCallback = nullptr,
|
||||
void* progressCallbackContext = nullptr,
|
||||
String extraHeaders = {},
|
||||
int connectionTimeOutMs = 0,
|
||||
StringPairArray* responseHeaders = nullptr,
|
||||
int* statusCode = nullptr,
|
||||
int numRedirectsToFollow = 5,
|
||||
String httpRequestCmd = {}) const;
|
||||
std::unique_ptr<InputStream> createInputStream (bool doPostLikeRequest,
|
||||
OpenStreamProgressCallback* progressCallback = nullptr,
|
||||
void* progressCallbackContext = nullptr,
|
||||
String extraHeaders = {},
|
||||
int connectionTimeOutMs = 0,
|
||||
StringPairArray* responseHeaders = nullptr,
|
||||
int* statusCode = nullptr,
|
||||
int numRedirectsToFollow = 5,
|
||||
String httpRequestCmd = {}) const;
|
||||
|
||||
/** Attempts to open an output stream to a URL for writing
|
||||
|
||||
This method can only be used for certain scheme types such as local files
|
||||
and content:// URIs on Android.
|
||||
*/
|
||||
OutputStream* createOutputStream() const;
|
||||
std::unique_ptr<OutputStream> createOutputStream() const;
|
||||
|
||||
//==============================================================================
|
||||
/** Represents a download task.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue