MongoDB C++ Driver  legacy-1.1.2
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. More...
 
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 More...
 
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. More...
 
static bool validCollectionName (const StringData &coll)
 Takes a collection name and returns true if it is a valid collection name. More...
 

Constructor & Destructor Documentation

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

bool mongo::NamespaceString::isValid ( ) const
inline
Returns
true if the namespace is valid. Special namespaces for internal use are considered as valid.
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)
bool mongo::NamespaceString::oplog ( const StringData ns)
inlinestatic
Returns
true if the ns is an oplog one, otherwise false.
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
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
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: