diff options
Diffstat (limited to 'src/mongo/db/auth/role_name.h')
-rw-r--r-- | src/mongo/db/auth/role_name.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mongo/db/auth/role_name.h b/src/mongo/db/auth/role_name.h index 81055b5ac20..1cd68bf1a62 100644 --- a/src/mongo/db/auth/role_name.h +++ b/src/mongo/db/auth/role_name.h @@ -60,6 +60,18 @@ public: BSONObj toBSON() const; /** + * Serialized length (in bytes) of object returned by toBSON(). + */ + std::size_t getBSONObjSize() const { + return 4UL + // BSONObj size + 1UL + ("role"_sd).size() + 1UL + // FieldName elem type, FieldName, NULL. + 4UL + getRole().size() + 1UL + // Length of name data, name data, NULL. + 1UL + ("db"_sd).size() + 1UL + // DB field elem type, "db", NULL. + 4UL + getDB().size() + 1UL + // DB value length, DB value, NULL. + 1UL; // EOD marker. + } + + /** * Gets the name of the role excluding the "@dbname" component. */ StringData getRole() const { |