Im using this snippet of code to stringify a dom with rapidjson:
rapidjson::StringBuffer buffer;
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
document.Accept(writer);
But i get the error that Writer is not a member of the rapidjson namespace.
My includes are:
#include "rapidjson/document.h"
#include "rapidjson/writer.h"
#include "rapidjson/stringbuffer.h"
#include <iostream>
as mentioned in the example simpledom.cpp.
So my question is if this is a bug or does it need another writer class for this?
Did i miss any includes? I use the latest version of rapidjson.
I switched to an older version (0.11) https://code.google.com/p/rapidjson/downloads/detail?name=rapidjson-0.11.zip and the error didnt show up anymore.
The first version i have used was from github: https://github.com/miloyip/rapidjson
Im not sure if the error was related to my dev environment or a bug in rapidjson.
It is a late response but I think it would help other people who come here. In place of Writer<StringBuffer>
you code use PrettyWriter<StringBuffer>
after including prettywriter.h, of course.
Related
I develop an UMDF2.0 driver using VS2019.
Inside this driver I need to communicate with an BLE device.
I have to use BluetoothLEDevice class to do this. This is a WinRT Api.
I'm completely lost on how to call C++/WinRT from my driver.
Does anyone have experienced this situation ?
Thank a lot for your great support,
EDIT 1#
I use the following simple test code in new cpp file into umdf2 sample project:
#include <windows.devices.h>
#include <windows.devices.bluetooth.h>
#include <windows.devices.bluetooth.genericattributeprofile.h>
using namespace ABI::Windows::Devices::Bluetooth;
void testBle()
{
BluetoothLEDevice dev;
}
I have the following error :
Error C2079
'dev' uses a class of 'ABI::Windows::Devices::Bluetooth::BluetoothLEDevice' not defined
EDIT 2
I found one usefull project on GitHub that help me a lot to make all this work. Please find the link below :
https://github.com/bucienator/ble-win-cpp
Thank you again for your help
You cannot instantiate the BluetoothLEDevice with default constructor because there is no such constructor in this case.
Please use this code snippet in instantiate the BT device.
#include <winrt/windows.devices.h>
#include <winrt/Windows.Devices.Bluetooth.h>
using namespace Windows::Devices::Bluetooth;
void testBle()
{
BluetoothLEDevice btDev = NULL;
IAsyncOperation<BluetoothLEDevice> launchOp =
BluetoothLEDevice::FromIdAsync(L"test");
btDev = launchOp.GetResults();
}
I'm trying to run this repo for curiosity: https://github.com/jzeimen/PuzzleSolver/tree/master/PuzzleSolver
Eclipse throws the title error "'MSize' is not a member of cv::Mat' whenever I try to run the following line of code from PuzzleDisjointSet.cpp:
cv::Mat::MSize size_of_a = sets[rep_a].locations.size;
Where locations is defined like so:
struct forest{
cv::Mat_<int> locations;
cv::Mat_<int> rotations;
int representative;
int id;
};
and sets is a vector version of the forest structure. I'm mainly confused as to why this is occurring, when documentation clearly refutes this.
I believe the header files I am including are the correct ones (PuzzleDisjointSet.h includes the above forest structure definition as well as the sets definition.
#include "PuzzleDisjointSet.h"
#include <algorithm>
#include <opencv2/core.hpp>
#include <opencv/cv.h>
#include <opencv2/core/mat.hpp>
the struct was removed in this commit
https://github.com/Itseez/opencv/commit/d8c8339bec83b77978d2a0e1a62b764fb9d9c599#diff-bc1d784738cd852f5b1e95ce10a56d06
maybe you can checkout a version before that and use it, or i suspect it may have been moved to a different class, you can try looking for that
OpenCV version: 4.3.0
cv::MatSize size_of_a = sets[rep_a].locations.size;
How do I hit a url in C++, there are a ton of examples for Objective-C, but my application doesn't use objective-c and starts with main() and is all c/c++. I was using URLSimpleDownload but it isn't working anymore (returns -50). I don't want to open a webpage or browser, I simply need to hit a url from c/c++.
You can take several of those NSURL examples you referred to, and just use the equivalent CFURL* APIs. Note: CFURLRef is an NSURL*. So you just need to figure out the corresponding CFURL* interface which an NSURL-based implementation uses.
This relationship where a CF-type is an NS-type is named "toll-free bridged".
Note that not everything will map one-to-one, NS-APIs have a lot of conveniences/additions -- it's better to think of it as an abstraction layer above CF-APIs.
You could try downloading and installing cURLpp (code from neuro's post):
// Edit : rewritten for cURLpp 0.7.3
// Note : namespace changed, was cURLpp in 0.7.2 ...
#include <curlpp/cURLpp.hpp>
#include <curlpp/Easy.hpp>
#include <curlpp/Options.hpp>
// RAII cleanup
curlpp::Cleanup myCleanup;
// standard request object.
curlpp::Easy myRequest;
// Set the URL.
myRequest.setOpt(new curlpp::options::Url(std::string("http://example.com")));
// Send request and get a result.
// By default the result goes to standard output.
// Here I use a shortcut to get it in a string stream ...
std::ostringstream os;
os << myRequest.perform();
string asAskedInQuestion = os.str();
I'm using curlpp in an application and need to get the URL I was redirected to. Apparently there are two ways: track the Location headers (ugly) or use curlpp::InfoGetter (the c++ counterpart of curl_easy_getinfo()).
But how do I use curlpp::InfoGetter? I cant't find any examples. Does anyone have a short snippet?
Ok, just found it out by myself:
#include <curlpp/cURLpp.hpp>
#include <curlpp/Easy.hpp>
#include <curlpp/Infos.hpp>
curlpp::Easy request;
request.setOpt(new curlpp::options::Url("http://www.example.com/"));
request.perform();
std::string effective_url = curlpp::infos::EffectiveUrl::get(request);
You may use any other subclass of curl::Info found in http://bitbucket.org/jpbarrette/curlpp/src/tip/include/curlpp/Infos.hpp instead of curlpp::infos::EffectiveUrl.
This is a weird question in that I'm not sure where to start looking.
First of all, I haven't done any C++ programming for the last 10 years so it could be me thats forgotten a few things. Secondly, the IDE I'm using is Eclipse based (which I've never used) and customized for Samsung bada based mobile development (it kicks off an emulator for debugging purposes)
I'm posting my code samples as images because the StackOverflow WYSIWYG editor seems to have a problem parsing C++.
[EDIT] Due to complaints I've edited my question to remove the images. Hope that helps :)
I have the following header file...
#include <FApp.h>
#include <FBase.h>
#include <FGraphics.h>
#include <FSystem.h>
#include <FMedia.h>
using namespace Osp::Media;
using namespace Osp::Graphics;
class NineAcross :
public Osp::App::Application,
public Osp::System::IScreenEventListener
{
public:
static Osp::App::Application* CreateInstance(void);
public:
NineAcross();
~NineAcross();
public:
bool OnAppInitializing(Osp::App::AppRegistry& appRegistry);
private:
Image *_problematicDecoder;
};
...and the following cpp file...
#include "NineAcross.h"
using namespace Osp::App;
using namespace Osp::Base;
using namespace Osp::System;
using namespace Osp::Graphics;
using namespace Osp::Media;
NineAcross::NineAcross()
{
}
NineAcross::~NineAcross()
{
}
Application* NineAcross::CreateInstance(void)
{
// Create the instance through the constructor.
return new NineAcross();
}
bool NineAcross::OnAppInitializing(AppRegistry& appRegistry)
{
Image *workingDecoder;
workingDecoder->Construct();
_problematicDecoder->Construct();
return true;
}
Now, in my cpp file, if I comment out the line that reads _problematicDecoder->Construct();...I'm able to set a breakpoint and happily step over the call to Constuct() on workingDecoder. However, as soon as I uncomment the line that reads _problematicDecoder->Construct();... I end up with the IDE telling me...
"No source available for "Osp::Media::Image::Construct()"
In other words, why can I NOT debug this code when I reference Image *image from a header file?
Any ideas?
Thanks :-)
This usually means you're stepping through some code which you do not posses its source.
I assume here that Osp::Media::Image is a class supplied by Samsung or similar for which you do not have the cpp file. So this means the debugger can't show you the current code line while you're at a function of Osp::Media::Image.
Alternatively, there's a good chance you do have all of the source code for this class, but Eclipse doesn't know where it is. In this case you can add the correct directories under the Debug Configurations window.
Ok, problem solved.
The idea is to first new up an instance of Image like so...
_decoder = new Osp::Media::Image();
And then do _decoder->Construct().
Funny enough, this seems blatantly obvious to me now coming from the C# world, though why the code I posted for workingDecoder works is still somewhat mysterious to me. The fact the sample projects pre-loaded with the bada IDE don't seem to make a call to new() leads me to believe that perhaps those samples are outdated our out of synch.
Either that or I really AM wildly out of the C++ loop.
Anyway thanks so much for the effort guys.
Appreciated :)