openshot-audio  0.1.4
juce_URL.h
Go to the documentation of this file.
1 /*
2  ==============================================================================
3 
4  This file is part of the juce_core module of the JUCE library.
5  Copyright (c) 2015 - ROLI Ltd.
6 
7  Permission to use, copy, modify, and/or distribute this software for any purpose with
8  or without fee is hereby granted, provided that the above copyright notice and this
9  permission notice appear in all copies.
10 
11  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
12  TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
13  NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
15  IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
16  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 
18  ------------------------------------------------------------------------------
19 
20  NOTE! This permissive ISC license applies ONLY to files within the juce_core module!
21  All other JUCE modules are covered by a dual GPL/commercial license, so if you are
22  using any other modules, be sure to check that you also comply with their license.
23 
24  For more details, visit www.juce.com
25 
26  ==============================================================================
27 */
28 
29 #ifndef JUCE_URL_H_INCLUDED
30 #define JUCE_URL_H_INCLUDED
31 
32 
33 //==============================================================================
41 {
42 public:
43  //==============================================================================
45  URL();
46 
52  URL (const String& url);
53 
55  URL (const URL& other);
56 
58  ~URL();
59 
61  URL& operator= (const URL& other);
62 
67  bool operator== (const URL&) const;
68  bool operator!= (const URL&) const;
69 
70  //==============================================================================
77  String toString (bool includeGetParameters) const;
78 
80  bool isEmpty() const noexcept;
81 
83  bool isWellFormed() const;
84 
89  String getDomain() const;
90 
95  String getSubPath() const;
96 
102  String getScheme() const;
103 
107  int getPort() const;
108 
114  URL withNewSubPath (const String& newPath) const;
115 
127  URL getChildURL (const String& subPath) const;
128 
129  //==============================================================================
140  URL withParameter (const String& parameterName,
141  const String& parameterValue) const;
142 
147  URL withParameters (const StringPairArray& parametersToAdd) const;
148 
160  URL withFileToUpload (const String& parameterName,
161  const File& fileToUpload,
162  const String& mimeType) const;
163 
173  URL withDataToUpload (const String& parameterName,
174  const String& filename,
175  const MemoryBlock& fileContentToUpload,
176  const String& mimeType) const;
177 
188  const StringArray& getParameterNames() const noexcept { return parameterNames; }
189 
202  const StringArray& getParameterValues() const noexcept { return parameterValues; }
203 
216  URL withPOSTData (const String& postData) const;
217 
219  const String& getPostData() const noexcept { return postData; }
220 
221  //==============================================================================
226  bool launchInDefaultBrowser() const;
227 
228  //==============================================================================
233  static bool isProbablyAWebsiteURL (const String& possibleURL);
234 
239  static bool isProbablyAnEmailAddress (const String& possibleEmailAddress);
240 
241  //==============================================================================
247  typedef bool (OpenStreamProgressCallback) (void* context, int bytesSent, int totalBytes);
248 
277  InputStream* createInputStream (bool usePostCommand,
278  OpenStreamProgressCallback* progressCallback = nullptr,
279  void* progressCallbackContext = nullptr,
280  String extraHeaders = String(),
281  int connectionTimeOutMs = 0,
282  StringPairArray* responseHeaders = nullptr,
283  int* statusCode = nullptr,
284  int numRedirectsToFollow = 5) const;
285 
286 
287  //==============================================================================
301  bool readEntireBinaryStream (MemoryBlock& destData,
302  bool usePostCommand = false) const;
303 
318  String readEntireTextStream (bool usePostCommand = false) const;
319 
336  XmlElement* readEntireXmlStream (bool usePostCommand = false) const;
337 
338  //==============================================================================
352  static String addEscapeChars (const String& stringToAddEscapeCharsTo,
353  bool isParameter);
354 
364  static String removeEscapeChars (const String& stringToRemoveEscapeCharsFrom);
365 
370  static URL createWithoutParsing (const String& url);
371 
372 private:
373  //==============================================================================
374  String url, postData;
375  StringArray parameterNames, parameterValues;
376 
377  struct Upload : public ReferenceCountedObject
378  {
379  Upload (const String&, const String&, const String&, const File&, MemoryBlock*);
380  String parameterName, filename, mimeType;
381  File file;
383 
385  };
386 
387  friend struct ContainerDeletePolicy<Upload>;
388  ReferenceCountedArray<Upload> filesToUpload;
389 
390  URL (const String&, int);
391  void addParameter (const String&, const String&);
392  void createHeadersAndPostData (String&, MemoryBlock&) const;
393  URL withUpload (Upload*) const;
394 
396 };
397 
398 
399 #endif // JUCE_URL_H_INCLUDED
const StringArray & getParameterNames() const noexcept
Definition: juce_URL.h:188
Definition: juce_StringPairArray.h:39
#define noexcept
Definition: juce_CompilerSupport.h:141
Definition: juce_MemoryBlock.h:38
Definition: juce_InputStream.h:41
Definition: juce_String.h:43
const StringArray & getParameterValues() const noexcept
Definition: juce_URL.h:202
#define JUCE_API
Definition: juce_StandardHeader.h:139
Definition: juce_ReferenceCountedArray.h:55
Definition: juce_ReferenceCountedObject.h:65
Definition: juce_XmlElement.h:142
Definition: juce_URL.h:40
Definition: juce_StringArray.h:39
bool operator==(const var &v1, const var &v2) noexcept
Definition: juce_Variant.cpp:565
Definition: juce_ContainerDeletePolicy.h:44
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Definition: juce_PlatformDefs.h:198
#define JUCE_LEAK_DETECTOR(OwnerClass)
Definition: juce_LeakedObjectDetector.h:141
bool operator!=(const var &v1, const var &v2) noexcept
Definition: juce_Variant.cpp:566
Definition: juce_File.h:45
const String & getPostData() const noexcept
Definition: juce_URL.h:219