LicenseSpring C++ SDK
Easily add Software Licensing to your application
LicenseID.h
Go to the documentation of this file.
1 #ifndef LS_LICENSE_ID_H
2 #define LS_LICENSE_ID_H
3 
4 #ifdef _MSC_VER
5 #pragma once
6 #pragma warning(push)
7 #pragma warning(disable : 4251)
8 #endif
9 
10 #include <string>
11 #include "APIDef.h"
12 
13 namespace LicenseSpring
14 {
21 {
22 public:
24  LicenseID() = default;
25 
27  LicenseID(const LicenseID &) = default;
28 
32  bool isEmpty() const;
33 
38  bool isValid() const;
39 
42  const std::string &id() const;
43 
47  const std::string &key() const;
48 
52  const std::string &user() const;
53 
57  const std::string &password() const;
58 
63  uint64_t serverId() const;
64 
67  void setPassword(const std::string &password);
68 
71  void trim();
72 
80  static LicenseID fromKey(const std::string &licenseKey, bool needTrim = true);
81 
88  static LicenseID fromKey(const char *licenseKey);
89 
98  static LicenseID fromUser(
99  const std::string &user, const std::string &password = std::string(), bool needTrim = true);
100 
108  static LicenseID fromUser(const char *user, const char *password = nullptr);
109 
119  static LicenseID fromUser(const std::string &user, uint64_t serverId,
120  const std::string &password = std::string(), bool needTrim = true);
121 
130  static LicenseID fromUser(const char *user, uint64_t serverId, const char *password = nullptr);
131 
132 private:
133  std::string m_key;
134  std::string m_user;
135  std::string m_password;
136  uint64_t m_serverId;
137 };
138 } // namespace LicenseSpring
139 
140 #ifdef _MSC_VER
141 #pragma warning(pop)
142 #endif
143 
144 #endif // LS_LICENSE_ID_H
#define LS_API
Definition: APIDef.h:23
Class that represents License identifier.
Definition: LicenseID.h:20