C++ REST SDK server implementation URI giving errors - c++

I am trying to write my own implementation of REST server using C++ REST SDK.
the class used is http_listener.
Almost all of it compiles properly but when i try to buld a URI using class web::http::URI it gives me error, also if pass the URI to http_listener class it giving error.
below us the code that gives error.
void CPPRESTSERVER::Start()
{
//building the URI//
utility::string_t address = "http://";
address.append(m_IP);
address.append(":");
address.append(std::to_string(m_port));
address.append("/");
m_Uri(U(address)); //m_Uri class member of type web::http::uri
//m_CustUri(m_Uri);
//m_CustUri.append_path(m_pathIP);
//m_CustUri.set_port(m_port);
//*******************
m_rstServer(U(m_Uri.to_string())); //m_rstserver class member of type http_listener
m_rstServer.support(web::http::methods::GET, std::bind(&CPPRESTSERVER::handle_GET, this, std::placeholders::_1));
}
i have tried the below
1) m_Uri(U(address)); also as m_Uri(address); but still giving errors.
2) m_rstServer(U(m_Uri.to_string())); also as m_rstServer(m_Uri.to_string()); also as m_rstServer(m_Uri); also as m_rstServer(U(m_Uri));
but still they give errors eventhough they have respective cusntructors of functions accepting argumets of required type
CPPRESTSERVER.cpp:57:21: error: no match for call to ‘(web::uri) (utility::string_t&)’
m_Uri(U(address));
^
CPPRESTSERVER.cpp:62:25: error: no match for call to ‘(web::http::experimental::listener::http_listener) (web::uri&)’
m_rstServer(U(m_Uri.to_string()));
any suggestions?????? i have stuck due these two errors. also i am compiling in ubuntu with C++11 standard.

Related

I'm trying to get a bacic example of AWS transfer manager use working, but their example fails to compile

I'm trying to get the basic C++ TransferManager example provided by AWS at:
https://aws.amazon.com/blogs/aws/aws-sdk-for-c-now-ready-for-production-use/
to build. If fails to compile because it reports that
Aws::Transfer::TransferManager transferManager(transferConfig);
is an inacessable private function, yet everything I can find on the web uses some variant of this.
The header provides this constructor:
static std::shared_ptr Create(const TransferManagerConfiguration& config);
and even an explicit call to Create() has the same private scope error message.
Can anyone help me with whatever I'm overlooking?

Why I am getting errors from TableGen-generated *.inc files (LLVM)?

I am trying to write an LLVM backend, when I am trying to build it, I get the following error message:
AbcGenRegisterInfo.inc: In static member function 'static const llvm::AbcFrameLowering* llvm::AbcGenRegisterInfo::getFrameLowering(const llvm::MachineFunction&)':
AbcGenRegisterInfo.inc:322:43: error: invalid static_cast from type 'const llvm::TargetFrameLowering*' to type 'const llvm::AbcFrameLowering*'
MF.getSubtarget().getFrameLowering());
^
Here is my AbcRegisterInfo.td (I copied it from here):
class AbcReg<string n> : Register<n> {
let namespace = "Abc";
}
def DUMMY_REG : AbcReg<"R0">;
def RegI64 : RegisterClass<"Abc", [i64], 64, (add DUMMY_REG)>;
I also overrided AbcSubtarget::getFrameLowering() method:
class AbcSubTarget : public AbcGenSubtargetInfo {
AbcFrameLowering *frameLowering;
// more fields and methods
const AbcFrameLowering *getFrameLowering() const override {
return frameLowering;
}
};
but the error message did not change.
I don't understand what to do - I can't just edit AbcGenRegisterInfo.inc, because it will be re-generated every time I will build LLVM, and I don't understand what's wrong in my TableGen files.
I also tried to remove AbcGenRegisterInfo.inc file from my build directory before compiling, but it had no effect.
Does AbcFrameLowering inherit from TargetFrameLowering? It looks like the static cast is complaining because the types are unrelated.
Also make sure the header with the definition of AbcFrameLowering is included before the .inc file is included otherwise the static cast will fail as well.
I have the same exact error, and while I cannot answer your question in full, I believe I can address one part of the issue. You said
I also tried to remove AbcGenRegisterInfo.inc file from my build directory before compiling, but it had no effect.
Unless you mean that AbcGenRegisterInfo.inc was regenerated (and therefore deleting it had no effect), the fact that its absence has no effect should be due to the fact that TableGen has the .inc.tmp file to rely on as a backup. I noticed that when I make with VERBOSE=1, there is a statement that suggests tablegen uses the .tmp files in this way.
Again, not a specific answer to your main question, but just to hopefully help address that issue when trying to debug.

Add a header to a cppnet-lib response object

I would like to add a header to a cppnet-lib basic_response object. However, I am getting compilation errors.
I can add a header to a basic_request as follows which compiles ok:
boost::network::http::basic_request<boost::network::http::tags::http_server> request;
request << header("test", "test");
However, doing the same for a response object as follows receives a compilation error:
boost::network::http::basic_response<boost::network::http::tags::http_server> response;
response << header("test", "test");
Compilation error:
'headers_container_type': the symbol to the left of a '::' must be a type (header.hpp)
'value_type': is not a member of boost::network::http::basic_response<boost::network::http::tags::http_server> (header.hpp)
syntax error: missing ';' before identifier 'value_type' (header.hpp)
This would suggest that this isn't possible on a response object, but following the following page seems to suggest it is. I'm obviously going wrong somewhere!
Documentation: http://cpp-netlib.org/0.8/reference_http_response.html
My environment is:
Visual Studio 2013 (building as Release)
Boost 1.55
cppnet-lib: 0.11.0
Any help would be very much appreciated! Thanks.
First, I think you're using the wrong documentation since you're using version 0.11.0 (I suggest you use 0.11.1, which has a lot of bug fixes on top of 0.11.0). Here's the link you actually want for the 0.11.0 documentation:
http://cpp-netlib.org/0.11.0/reference/http_server.html#response-object
Second, you'd want to add headers directly to the response object's headers member. No need to use functions to do this:
struct my_server {
void operator(server::request const& req, server::response & res) {
// do something with the request and/or response
res.headers.push_back(server::response::header("Name", "value"));
// do more things
}
// ...
};

Directory.members().insert is not working using the Java client library

I'm using the Java client library for the Directory API from here: https://developers.google.com/api-client-library/java/apis/admin/directory_v1
I have insert user and insert group working fine, but for some reason when I try to insert a member, it doesn't work. There is no exception thrown. Here is the code:
Member member = new Member();
member.setEmail("someemail#mydomain.com");
member.setRole("MEMBER");
//member.setKind("admin#directory#member"); not sure if I need this. tried with and without
member.setType("USER"); // docs say "MEMBER" but doesn't seem true. Tried both
client.members().insert(myGroupId, member);
You don't need to set kind nor type.
After "client.members().insert(myGroupId, member);" do you call execute ?

How can I access the root namespace by name - instead of simply `::`?

I am working on a c++ project (and I'm a complete c++ n00b) that uses the root namespace to access the ::tolower method in the following lines of code, but I have changed some build settings and am getting an error.
CCString * CCBReader::toLowerCase(CCString * pString) {
std::string copy(pString->getCString());
std::transform(copy.begin(), copy.end(), copy.begin(), ::tolower);
return CCString::create(copy.c_str());
}
The build changes are essential for most of the project, and changing these is not an option. So as a workaround, I would like to try prefixing this with the root namespace. For example:
std::transform(copy.begin(), copy.end(), copy.begin(), rootns::tolower);
Is this possible? If so, how?
Since many of you have already disregarded my ideal solution as impossible, and have asked what the error is to see if you can solve it your own way, here is the relevant portion of the error:
error: '::tolower' has not been declared
The root namespace does not have a name, so there is no other way to address it.
Instead, you're going to have to re-examine your build changes, and maybe consider what exactly the error you get says. The error might not really be about namespaces. It could have been triggered by some other problem earlier in your code.