Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="UTF-8"?>
- <authorization>
- <user name="user1" login="login1" password="password1">
- <role type="rerrer"/>
- <role type="engineer"/>
- </user>
- <user name="user2" login="login2" password="password2" role="operator" />
- <user name="user3" login="login3" password="password3" role="engineer" />
- <user name="user4" login="login4" password="password4" role="installer" />
- </authorization>
- #ifndef CAUTHORIZATIONDATA_H
- #define CAUTHORIZATIONDATA_H
- #include <string>
- #include <vector>
- namespace Authorization
- {
- struct CAuthorizationData
- {
- struct CUserData
- {
- std::string _name;
- std::string _login;
- std::string _password;
- enum class RolesType
- {
- _none,
- _viewer,
- _operator,
- _engineer,
- _installer
- };
- std::vector<RolesType> _roles;
- };
- std::vector<CUserData> _users;
- };
- }
- #endif // CSETTINGSDATA_H
- #include <iostream>
- #include "tinyxml2.h"
- #include "CAuthorization.h"
- using namespace std;
- using namespace tinyxml2;
- using namespace Authorization;
- int main(int argc, char *argv[])
- {
- CAuthorization userInfo;
- if (userInfo.Load ("impr1_auth.xml"))
- {
- for (const auto &User: userInfo.Data()._users)
- {
- cout << "Name: " << User._name << endl;
- cout << "Login: " << User._login << endl;
- cout << "Password: " << User._password << endl << endl;
- }
- }
- return 0;
- }
- // - бит 0=1 - viewer
- // - бит 1=1 - operator
- // - бит 2=1 - engineer
- // - бит 3=1 - installer
Add Comment
Please, Sign In to add comment