MongoDB C++ Driver legacy-1.1.2
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | List of all members
mongo::NamespaceString Class Reference

Public Types

enum  MaxNsLenValue
 Note that these values are derived from the mmap_v1 implementation and that is the only reason they are constrained as such.
 

Public Member Functions

 NamespaceString ()
 Constructs an empty NamespaceString.
 
 NamespaceString (const StringData &ns)
 Constructs a NamespaceString from the fully qualified namespace named in "ns".
 
 NamespaceString (const StringData &dbName, const StringData &collectionName)
 Constructs a NamespaceString for the given database and collection names.
 
NamespaceString getTargetNSForListIndexesGetMore () const
 Given a NamespaceString for which isListIndexesGetMore() returns true, returns the NamespaceString for the collection that the "listIndexesGetMore" targets.
 
bool isValid () const
 
std::string getSisterNS (const StringData &local) const
 ( foo.bar ).getSisterNS( "blah" ) == foo.blah
 

Static Public Member Functions

static bool normal (const StringData &ns)
 
static bool oplog (const StringData &ns)
 
static bool validDBName (const StringData &dbin)
 samples: good foo bar foo-bar bad: foo bar foo.bar foo"bar
 
static bool validCollectionComponent (const StringData &ns)
 Takes a fully qualified namespace (ie dbname.collectionName), and returns true if the collection name component of the namespace is valid.
 
static bool validCollectionName (const StringData &coll)
 Takes a collection name and returns true if it is a valid collection name.
 

Constructor & Destructor Documentation

◆ NamespaceString()

mongo::NamespaceString::NamespaceString ( const StringData dbName,
const StringData collectionName 
)
inline

Constructs a NamespaceString for the given database and collection names.

"dbName" must not contain a ".", and "collectionName" must not start with one.

Member Function Documentation

◆ isValid()

bool mongo::NamespaceString::isValid ( ) const
inline
Returns
true if the namespace is valid. Special namespaces for internal use are considered as valid.

◆ normal()

bool mongo::NamespaceString::normal ( const StringData ns)
inlinestatic
Returns
true if ns is 'normal'. A "$" is used for namespaces holding index data, which do not contain BSON objects in their records. ("oplog.$main" is the exception)

◆ oplog()

bool mongo::NamespaceString::oplog ( const StringData ns)
inlinestatic
Returns
true if the ns is an oplog one, otherwise false.

◆ validCollectionComponent()

bool mongo::NamespaceString::validCollectionComponent ( const StringData ns)
inlinestatic

Takes a fully qualified namespace (ie dbname.collectionName), and returns true if the collection name component of the namespace is valid.

samples: good: foo.bar bad: foo.

Parameters
ns- a full namespace (a.b)
Returns
if db.coll is an allowed collection name

◆ validCollectionName()

bool mongo::NamespaceString::validCollectionName ( const StringData coll)
inlinestatic

Takes a collection name and returns true if it is a valid collection name.

samples: good: foo system.indexes bad: $foo

Parameters
coll- a collection name component of a namespace
Returns
if the input is a valid collection name

◆ validDBName()

bool mongo::NamespaceString::validDBName ( const StringData dbin)
inlinestatic

samples: good foo bar foo-bar bad: foo bar foo.bar foo"bar

Parameters
db- a possible database name
Returns
if db is an allowed database name

The documentation for this class was generated from the following files: