PageRenderTime 19ms CodeModel.GetById 6ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 1ms

/indra/llmessage/llservicebuilder.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 104 lines | 26 code | 13 blank | 65 comment | 0 complexity | 3f9efc4461df72d4648c1c02157e4f50 MD5 | raw file
  1/** 
  2* @file llservicebuilder.h
  3* @brief Declaration of the LLServiceBuilder class.
  4*
  5* $LicenseInfo:firstyear=2007&license=viewerlgpl$
  6* Second Life Viewer Source Code
  7* Copyright (C) 2010, Linden Research, Inc.
  8* 
  9* This library is free software; you can redistribute it and/or
 10* modify it under the terms of the GNU Lesser General Public
 11* License as published by the Free Software Foundation;
 12* version 2.1 of the License only.
 13* 
 14* This library is distributed in the hope that it will be useful,
 15* but WITHOUT ANY WARRANTY; without even the implied warranty of
 16* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17* Lesser General Public License for more details.
 18* 
 19* You should have received a copy of the GNU Lesser General Public
 20* License along with this library; if not, write to the Free Software
 21* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 22* 
 23* Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 24* $/LicenseInfo$
 25*/
 26
 27#ifndef LLSERVICEBUILDER_H
 28#define LLSERVICEBUILDER_H
 29
 30#include <string>
 31#include <map>
 32#include "llerror.h"
 33
 34class LLSD;
 35
 36/**
 37 * @brief  Format format string according to rules for RUSS.
 38 *
 39 * This function appears alongside the service builder since the
 40 * algorithm was originally implemented there. This can eventually be
 41 * moved when someone wants to take the time.
 42 * @see https://osiris.lindenlab.com/mediawiki/index.php/Recursive_URL_Substitution_Syntax
 43 * @param format_str The input string to format.
 44 * @param context A map used for string substitutions.
 45 * @return Returns the formatted string. If no match is found for a
 46 * substitution target, the braces remain intact.
 47 */
 48std::string russ_format(const std::string& format_str, const LLSD& context);
 49
 50/** 
 51 * @class LLServiceBuilder
 52 * @brief This class builds urls for us to use when making web service calls.
 53 */
 54class LLServiceBuilder
 55{
 56	LOG_CLASS(LLServiceBuilder);
 57public:
 58	LLServiceBuilder(void) {}
 59	~LLServiceBuilder(void) {}
 60
 61	/** 
 62	 * @brief Initialize this object with the service definitions.
 63	 *
 64	 * @param service_filename The services definition files -- services.xml.
 65	 */
 66	void loadServiceDefinitionsFromFile(const std::string& service_filename);
 67
 68	/** 
 69	 * @brief Build a service url if the url needs no construction parameters.
 70	 *
 71	 * @param service_name The name of the service you want to call.
 72	 */
 73	std::string buildServiceURI(const std::string& service_name) const;
 74
 75	/** 
 76	 * @brief Build a service url if the url with construction parameters.
 77	 *
 78	 * The parameter substitution supports string substituition from RUSS:
 79	 * [[Recursive_URL_Substitution_Syntax]]
 80	 * @param service_name The name of the service you want to call.
 81	 * @param option_map The parameters in a map of name:value for the service.
 82	 */
 83	std::string buildServiceURI(
 84		const std::string& service_name,
 85		const LLSD& option_map) const;	
 86
 87public:
 88	/** 
 89	 * @brief Helper method which builds construction state for a service
 90	 *
 91	 * This method should probably be protected, but we need to test this
 92	 * method.
 93	 */
 94	void createServiceDefinition(
 95		const std::string& service_name,
 96		LLSD& service_url);
 97
 98protected:
 99	std::map<std::string, std::string> mServiceMap;
100};
101
102
103
104#endif