[CXX-87] bsondemo.cpp won't build standalone anymore Created: 24/Sep/13  Updated: 18/Feb/15  Resolved: 12/Mar/14

Status: Closed
Project: C++ Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Dwight Merriman Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: cxxmove, legacy-cxx, neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

comments in the source file indicate you can do a one-line g++ statement. however

1) the include requires (-I) are now broader and as specified wrong;
2) you need to do
cd src/mongo/base
python generate_error_codes.py error_codes.err error_codes.h error_codes.cpp
cd -
cd src/mongo/bson/bsondemo
or something now and that isn't specified;
3) there are then undefined simple msgasserted() or something like that
4) i suspect the vcxproj doesn't work anymore either
5) separately, scons . should probably verify that bsondemo.cpp will build period

i suppose if there are more grandiose plans for c++ client & bson lib cleanups and such in the meantime the build instruction comment could be eliminated, #3 resolved, and #5 done, and vcxproj files deleted? as it wouldn't make sense to release it broken. but fixing would be easy too.



 Comments   
Comment by Andrew Morrow (Inactive) [ 12/Mar/14 ]

A standalone BSON library is not a current goal of the project.

Comment by Andrew Morrow (Inactive) [ 10/Mar/14 ]

dwight_10gen It is not clear right now whether we are aiming to support header only use of BSON with the driver as currently constructed or not, so I'm putting this in 'features we aren't sure of' for now.

However, the independent repo does build and run the bsondemo example, so we are at least now confirming that it builds and runs.

Comment by Dwight Merriman [ 25/Feb/14 ]

it doesn't look like it would throw:

    void BSONObj::vals(std::vector<T>& v) const {
        BSONObjIterator i(*this);
        while( i.more() ) {
            try {
                T t;
                i.next().Val(t);
                v.push_back(t);
            }
            catch(...) { }
        }
    }

Comment by Tyler Brock [ 08/Oct/13 ]

I got this to compile using:

g++ -I ../../../ -lboost_system-mt -lboost_thread-mt -lmongoclient -o bsondemo bsondemo.cpp

It throws a "wrong type for field" exception that I wouldn't expect given the comments in the code:

/* grab all the string values from x.  if the field isn't of string type, just skip it --
 * lowercase v on vals() indicates skip don't throw.
 */

Perhaps we changed how lower case vals() works?

Either way, I think its probably bad that the BSON demo needs dbclient.h to compile. Shouldn't this be self contained to simply requiring bson.h?

I would be happy to explore further with sverch if others feel the same way.

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