How do I make MongoDB to C++ connection for multiple programs uniquely?

62 views
Skip to first unread message

Govardhan Veer

unread,
Jun 1, 2017, 12:42:26 PM6/1/17
to BSON
As I am new to c++11 and followed a documentation provided by mongoDB. I am able make a connection to mongo and able to insert and fetch content to/from it.
But uri's scope is limited to my main(), it can not pass to other functions which are defined in other .cpp files.
So I wanted to make a connection which will creates a unique instance of mongo cxx::uri params for my each program, so that I won't need to specify the connection params like IP,Port,User,Password etc every time. In short a config file should have these params and which would be read by a .cpp program, which results into instance of mongo cxx::uri
So please let me know how do I go ahead with C++ in detail steps.

Evan Wies

unread,
Jun 1, 2017, 1:00:36 PM6/1/17
to bs...@googlegroups.com
This is not a MongoDB or BSON issue.  Here’s a Stack Overflow page that covers this [1].

I like to use Boost.ProgramOptions [2].  It can be a little confusing at first, but is quite powerful and typesafe.  I often feed the results into a  Boost.PropertyTree [3] to have both CLI options and JSON configuration files (but it also supports INI and XML formats).

-Evan

[3] http://www.boost.org/doc/libs/1_64_0/doc/html/property_tree.html
--
You received this message because you are subscribed to the Google Groups "BSON" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bson+uns...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages