diff options
author | Spencer T Brody <spencer@10gen.com> | 2013-05-07 19:51:11 -0400 |
---|---|---|
committer | Spencer T Brody <spencer@10gen.com> | 2013-05-22 14:08:54 -0400 |
commit | 0467aeb4416f82ff18927f3f887cd181073e1db6 (patch) | |
tree | ce2f3704fec533241898d9d8571f428ae7b461fc /src/mongo/db/auth/role_name.cpp | |
parent | 59c64b943afa52b4d837949b1094be1d895bf062 (diff) | |
download | mongo-0467aeb4416f82ff18927f3f887cd181073e1db6.tar.gz |
SERVER-9518 Initial implementation of RoleGraph data structures
Diffstat (limited to 'src/mongo/db/auth/role_name.cpp')
-rw-r--r-- | src/mongo/db/auth/role_name.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/mongo/db/auth/role_name.cpp b/src/mongo/db/auth/role_name.cpp new file mode 100644 index 00000000000..d691e826f77 --- /dev/null +++ b/src/mongo/db/auth/role_name.cpp @@ -0,0 +1,39 @@ +/** + * Copyright (C) 2013 10gen Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "mongo/db/auth/role_name.h" + +#include <algorithm> +#include <string> + +#include "mongo/base/string_data.h" +#include "mongo/util/assert_util.h" + +namespace mongo { + + RoleName::RoleName(const StringData& role, const StringData& dbname) { + _fullName.resize(role.size() + dbname.size() + 1); + std::string::iterator iter = std::copy(role.rawData(), + role.rawData() + role.size(), + _fullName.begin()); + *iter = '@'; + ++iter; + iter = std::copy(dbname.rawData(), dbname.rawData() + dbname.size(), iter); + dassert(iter == _fullName.end()); + _splitPoint = role.size(); + } + +} // namespace mongo |