PageRenderTime 31ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/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
Possible License(s): LGPL-2.1
  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. #ifndef LLSERVICEBUILDER_H
  27. #define LLSERVICEBUILDER_H
  28. #include <string>
  29. #include <map>
  30. #include "llerror.h"
  31. class LLSD;
  32. /**
  33. * @brief Format format string according to rules for RUSS.
  34. *
  35. * This function appears alongside the service builder since the
  36. * algorithm was originally implemented there. This can eventually be
  37. * moved when someone wants to take the time.
  38. * @see https://osiris.lindenlab.com/mediawiki/index.php/Recursive_URL_Substitution_Syntax
  39. * @param format_str The input string to format.
  40. * @param context A map used for string substitutions.
  41. * @return Returns the formatted string. If no match is found for a
  42. * substitution target, the braces remain intact.
  43. */
  44. std::string russ_format(const std::string& format_str, const LLSD& context);
  45. /**
  46. * @class LLServiceBuilder
  47. * @brief This class builds urls for us to use when making web service calls.
  48. */
  49. class LLServiceBuilder
  50. {
  51. LOG_CLASS(LLServiceBuilder);
  52. public:
  53. LLServiceBuilder(void) {}
  54. ~LLServiceBuilder(void) {}
  55. /**
  56. * @brief Initialize this object with the service definitions.
  57. *
  58. * @param service_filename The services definition files -- services.xml.
  59. */
  60. void loadServiceDefinitionsFromFile(const std::string& service_filename);
  61. /**
  62. * @brief Build a service url if the url needs no construction parameters.
  63. *
  64. * @param service_name The name of the service you want to call.
  65. */
  66. std::string buildServiceURI(const std::string& service_name) const;
  67. /**
  68. * @brief Build a service url if the url with construction parameters.
  69. *
  70. * The parameter substitution supports string substituition from RUSS:
  71. * [[Recursive_URL_Substitution_Syntax]]
  72. * @param service_name The name of the service you want to call.
  73. * @param option_map The parameters in a map of name:value for the service.
  74. */
  75. std::string buildServiceURI(
  76. const std::string& service_name,
  77. const LLSD& option_map) const;
  78. public:
  79. /**
  80. * @brief Helper method which builds construction state for a service
  81. *
  82. * This method should probably be protected, but we need to test this
  83. * method.
  84. */
  85. void createServiceDefinition(
  86. const std::string& service_name,
  87. LLSD& service_url);
  88. protected:
  89. std::map<std::string, std::string> mServiceMap;
  90. };
  91. #endif