/indra/newview/llversioninfo.cpp

https://bitbucket.org/lindenlab/viewer-beta/ · C++ · 136 lines · 72 code · 19 blank · 45 comment · 3 complexity · 2fe5cffbbf88e74276693039874671c2 MD5 · raw file

  1. /**
  2. * @file llversioninfo.cpp
  3. * @brief Routines to access the viewer version and build information
  4. * @author Martin Reddy
  5. *
  6. * $LicenseInfo:firstyear=2009&license=viewerlgpl$
  7. * Second Life Viewer Source Code
  8. * Copyright (C) 2010, Linden Research, Inc.
  9. *
  10. * This library is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU Lesser General Public
  12. * License as published by the Free Software Foundation;
  13. * version 2.1 of the License only.
  14. *
  15. * This library is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * Lesser General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Lesser General Public
  21. * License along with this library; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. *
  24. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  25. * $/LicenseInfo$
  26. */
  27. #include "llviewerprecompiledheaders.h"
  28. #include "llversioninfo.h"
  29. #include "llversionviewer.h"
  30. //
  31. // Set the version numbers in indra/llcommon/llversionviewer.h
  32. //
  33. //static
  34. S32 LLVersionInfo::getMajor()
  35. {
  36. return LL_VERSION_MAJOR;
  37. }
  38. //static
  39. S32 LLVersionInfo::getMinor()
  40. {
  41. return LL_VERSION_MINOR;
  42. }
  43. //static
  44. S32 LLVersionInfo::getPatch()
  45. {
  46. return LL_VERSION_PATCH;
  47. }
  48. //static
  49. S32 LLVersionInfo::getBuild()
  50. {
  51. return LL_VERSION_BUILD;
  52. }
  53. //static
  54. const std::string &LLVersionInfo::getVersion()
  55. {
  56. static std::string version("");
  57. if (version.empty())
  58. {
  59. // cache the version string
  60. std::ostringstream stream;
  61. stream << LL_VERSION_MAJOR << "."
  62. << LL_VERSION_MINOR << "."
  63. << LL_VERSION_PATCH << "."
  64. << LL_VERSION_BUILD;
  65. version = stream.str();
  66. }
  67. return version;
  68. }
  69. //static
  70. const std::string &LLVersionInfo::getShortVersion()
  71. {
  72. static std::string version("");
  73. if (version.empty())
  74. {
  75. // cache the version string
  76. std::ostringstream stream;
  77. stream << LL_VERSION_MAJOR << "."
  78. << LL_VERSION_MINOR << "."
  79. << LL_VERSION_PATCH;
  80. version = stream.str();
  81. }
  82. return version;
  83. }
  84. namespace
  85. {
  86. /// Storage of the channel name the viewer is using.
  87. // The channel name is set by hardcoded constant,
  88. // or by calling LLVersionInfo::resetChannel()
  89. std::string sWorkingChannelName(LL_CHANNEL);
  90. // Storage for the "version and channel" string.
  91. // This will get reset too.
  92. std::string sVersionChannel("");
  93. }
  94. //static
  95. const std::string &LLVersionInfo::getChannelAndVersion()
  96. {
  97. if (sVersionChannel.empty())
  98. {
  99. // cache the version string
  100. std::ostringstream stream;
  101. stream << LLVersionInfo::getChannel()
  102. << " "
  103. << LLVersionInfo::getVersion();
  104. sVersionChannel = stream.str();
  105. }
  106. return sVersionChannel;
  107. }
  108. //static
  109. const std::string &LLVersionInfo::getChannel()
  110. {
  111. return sWorkingChannelName;
  112. }
  113. void LLVersionInfo::resetChannel(const std::string& channel)
  114. {
  115. sWorkingChannelName = channel;
  116. sVersionChannel.clear(); // Reset version and channel string til next use.
  117. }