[CXX-233] BSONForEach MACRO requires "using namespace::mongo" Created: 19/May/14  Updated: 13/Jun/14  Resolved: 29/May/14

Status: Closed
Project: C++ Driver
Component/s: BSON
Affects Version/s: legacy-0.0-26compat-2.6.1
Fix Version/s: legacy-0.10.0

Type: Bug Priority: Trivial - P5
Reporter: Thomas Riccardi Assignee: Andrew Morrow (Inactive)
Resolution: Done Votes: 0
Labels: legacy-cxx
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

In bson/bsonobjiterator.h included from bson/bson.h, a useful foreach macro is defined:

#define BSONForEach(e, obj)                                     \
    BSONObjIterator BOOST_PP_CAT(it_,__LINE__)(obj);            \
    for ( BSONElement e;                                        \
            (BOOST_PP_CAT(it_,__LINE__).more() ?                  \
             (e = BOOST_PP_CAT(it_,__LINE__).next(), true) :  \
             false) ;                                         \
            /*nothing*/ )

However it's not directly usable as it does not prefix BSONObjIterator and BSONElement by "mongo::"

Compilation error (clang 3.3):

error: unknown type name 'BSONObjIterator'; did you mean 'mongo::BSONObjIterator'?
    BSONForEach(e, oSentence.Obj())

It currently requires a "using namespace mongo;" around it.

Also, this macro is not documented here: https://github.com/mongodb/mongo-cxx-driver/wiki/BSON%20Helper%20Functions



 Comments   
Comment by Githook User [ 29/May/14 ]

Author:

{u'username': u'acmorrow', u'name': u'Andrew Morrow', u'email': u'acm@mongodb.com'}

Message: CXX-233 Namespace qualify names in BSONForEach macro
Branch: legacy
https://github.com/mongodb/mongo-cxx-driver/commit/c13493de0486c4cb17846bb7e58aa4a6014bcb53

Comment by Andrew Morrow (Inactive) [ 28/May/14 ]

https://github.com/mongodb/mongo-cxx-driver/pull/83

Generated at Wed Feb 07 21:58:35 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.