VirtualBox

Changeset 74348 in vbox for trunk/include/iprt/cpp


Ignore:
Timestamp:
Sep 18, 2018 5:06:05 PM (6 years ago)
Author:
vboxsync
Message:

IPRT/rest: Trying to make the basepath stuff more flexible. However, it's not peferect yet and requires the host to be set. Sigh. bugref:9167

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/cpp/restclient.h

    r74250 r74348  
    632632{
    633633public:
    634     RTCRestClientApiBase()
    635         : m_hHttp(NIL_RTHTTP)
    636     {}
     634    RTCRestClientApiBase();
    637635    virtual ~RTCRestClientApiBase();
    638636
    639     /** @name Base path (URL) handling.
     637    /** @name Host and Base path (URL) handling.
    640638     * @{ */
    641639    /**
    642      * Gets the base path we're using.
    643      *
    644      * @returns Base URL string.  If empty, we'll be using the default one.
    645      */
    646     inline RTCString const &getBasePath(void) const
    647     {
    648         return m_strBasePath;
    649     }
     640     * Gets the default host (start of URL) as specified in the specs.
     641     *
     642     * @returns Host string (start of URL).
     643     */
     644    virtual const char *getDefaultHost() const = 0;
     645
     646    /**
     647     * Gets the host we're using.
     648     *
     649     * @returns Host URL string.
     650     */
     651    const char *getHost(void) const;
     652
     653    /**
     654     * Sets the host (URL) to use when talking to the server.
     655     *
     656     * Setting the host is only required if there is a desire to use a
     657     * different server from the one specified in the API specification, like
     658     * for instance regional one.
     659     *
     660     * @returns IPRT status code.
     661     * @param   a_pszHost   The base path to use.
     662     */
     663    virtual int setHost(const char *a_pszHost);
    650664
    651665    /**
     
    656670     * for instance regional one.
    657671     *
     672     * @returns IPRT status code.
     673     * @param   a_strHost   The base path to use.
     674     * @note    Defers to the C-string variant.
     675     */
     676    int setHost(RTCString const &a_strHost);
     677
     678
     679    /**
     680     * Gets the default base path (relative to getHost()) as specified in the specs.
     681     *
     682     * @returns Base path string.
     683     */
     684    virtual const char *getDefaultBasePath() const = 0;
     685
     686    /**
     687     * Gets the base path we're using (relative to getHost).
     688     *
     689     * @returns Base path string.
     690     */
     691    const char *getBasePath(void) const;
     692
     693    /**
     694     * Sets the base path (relative to getHost()) to use when talking to the server.
     695     *
     696     * It is assumed that the base path is at the minimum a lone slash, so an
     697     * empty (or NULL) string is understood to mean reverting to the default
     698     * (see getDefaultBasePath()).
     699     *
    658700     * @param   a_pszPath   The base path to use.
    659701     */
    660     virtual void setBasePath(const char *a_pszPath)
    661     {
    662         m_strBasePath = a_pszPath;
    663     }
    664 
    665     /**
    666      * Sets the base path (URL) to use when talking to the server.
    667      *
    668      * Setting the base path is only required if there is a desire to use a
    669      * different server from the one specified in the API specification, like
    670      * for instance regional one.
     702    virtual int setBasePath(const char *a_pszPath);
     703
     704    /**
     705     * Sets the base path (relative to getHost()) to use when talking to the server.
    671706     *
    672707     * @param   a_strPath   The base path to use.
    673708     * @note    Defers to the C-string variant.
    674709     */
    675     inline void setBasePath(RTCString const &a_strPath) { setBasePath(a_strPath.c_str()); }
    676 
    677     /**
    678      * Gets the default base path (URL) as specified in the specs.
    679      *
    680      * @returns Base path (URL) string.
    681      */
    682     virtual const char *getDefaultBasePath() = 0;
     710    int setBasePath(RTCString const &a_strPath);
     711
    683712    /** @} */
    684713
     
    692721    /** Handle to the HTTP connection object. */
    693722    RTHTTP  m_hHttp;
    694     /** The base path to use. */
     723    /** The host to use.  If empty use the default. */
     724    RTCString m_strHost;
     725    /** The base path to use.  If empty use the default. */
    695726    RTCString m_strBasePath;
    696727
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette