Guest User

Untitled

a guest
Oct 4th, 2018
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <authorization>
  3. <user name="user1" login="login1" password="password1">
  4. <role type="rerrer"/>
  5. <role type="engineer"/>
  6. </user>
  7. <user name="user2" login="login2" password="password2" role="operator" />
  8. <user name="user3" login="login3" password="password3" role="engineer" />
  9. <user name="user4" login="login4" password="password4" role="installer" />
  10. </authorization>
  11.  
  12. #ifndef CAUTHORIZATIONDATA_H
  13. #define CAUTHORIZATIONDATA_H
  14. #include <string>
  15. #include <vector>
  16.  
  17. namespace Authorization
  18. {
  19.  
  20. struct CAuthorizationData
  21. {
  22. struct CUserData
  23. {
  24. std::string _name;
  25. std::string _login;
  26. std::string _password;
  27.  
  28. enum class RolesType
  29. {
  30. _none,
  31. _viewer,
  32. _operator,
  33. _engineer,
  34. _installer
  35. };
  36.  
  37. std::vector<RolesType> _roles;
  38. };
  39.  
  40. std::vector<CUserData> _users;
  41. };
  42.  
  43. }
  44.  
  45. #endif // CSETTINGSDATA_H
  46.  
  47. #include <iostream>
  48. #include "tinyxml2.h"
  49. #include "CAuthorization.h"
  50.  
  51. using namespace std;
  52. using namespace tinyxml2;
  53. using namespace Authorization;
  54.  
  55. int main(int argc, char *argv[])
  56. {
  57.  
  58. CAuthorization userInfo;
  59. if (userInfo.Load ("impr1_auth.xml"))
  60. {
  61. for (const auto &User: userInfo.Data()._users)
  62. {
  63. cout << "Name: " << User._name << endl;
  64. cout << "Login: " << User._login << endl;
  65. cout << "Password: " << User._password << endl << endl;
  66. }
  67.  
  68. }
  69.  
  70. return 0;
  71. }
  72.  
  73. // - бит 0=1 - viewer
  74. // - бит 1=1 - operator
  75. // - бит 2=1 - engineer
  76. // - бит 3=1 - installer
Add Comment
Please, Sign In to add comment