53 CPort::CPort(std::shared_ptr<const GenTLWrapper> _gentl,
void **_port) : gentl(_gentl)
60 size_t size=
static_cast<size_t>(length);
64 if (
gentl->GCReadPort(*
port, static_cast<uint64_t>(addr), buffer, &size) !=
70 if (size != static_cast<size_t>(length))
72 throw GenTLException(
"CPort::Read(): Returned size not as expected");
83 size_t size=
static_cast<size_t>(length);
87 if (
gentl->GCWritePort(*
port, static_cast<uint64_t>(addr), buffer, &size) !=
93 if (size != static_cast<size_t>(length))
95 throw GenTLException(
"CPort::Write(): Returned size not as expected");
117 inline std::string toLower(
const std::string &s,
size_t start,
size_t size)
121 size_t end=std::min(s.size(), start+size);
125 out << static_cast<char>(std::tolower(s[start++]));
134 void *
port,
CPort *cport,
const char *xml)
150 return std::shared_ptr<GenApi::CNodeMapRef>();
157 size_t size=
sizeof(tmp);
168 if (toLower(url, 0, 6) ==
"local:")
173 if (url.compare(i, 3,
"///") == 0)
178 std::stringstream in(url.substr(i));
179 std::string name, saddress, slength;
185 uint64_t address=std::stoull(saddress, 0, 16);
186 size_t length=
static_cast<size_t>(std::stoull(slength, 0, 16));
190 std::unique_ptr<char[]> buffer(
new char[length+1]);
197 buffer.get()[length]=
'\0';
203 std::ofstream out(xml, std::ios::binary);
205 out.rdbuf()->sputn(buffer.get(),
static_cast<std::streamsize
>(length));
210 if (name.size() > 4 && toLower(name, name.size()-4, 4) ==
".zip")
212 nodemap->_LoadXMLFromZIPData(buffer.get(), length);
217 nodemap->_LoadXMLFromString(sxml);
220 else if (toLower(url, 0, 5) ==
"file:")
225 if (url.compare(i, 3,
"///") == 0)
230 std::string name=url.
substr(i);
234 if (name.size() > 4 && toLower(name, name.size()-4, 4) ==
".zip")
237 nodemap->_LoadXMLFromZIPFile(file);
242 nodemap->_LoadXMLFromFile(file);
247 throw GenTLException((
"allocNodeMap(): Cannot interpret URL: "+url).c_str());
261 if (!nodemap->_Connect(cport, portname))
263 throw GenTLException((std::string(
"allocNodeMap(): Cannot connect port: ")+tmp).c_str());
void Read(void *buffer, int64_t addr, int64_t length)
This is the port definition that connects GenAPI to GenTL.
std::istream & getline(std::istream &is, GENICAM_NAMESPACE::gcstring &str)
STL getline.
virtual gcstring substr(size_t offset=0, size_t count=GCSTRING_NPOS) const
void Write(const void *buffer, int64_t addr, int64_t length)
CPort(std::shared_ptr< const GenTLWrapper > gentl, void **port)
std::shared_ptr< const GenTLWrapper > gentl
GenApi::EAccessMode GetAccessMode() const
std::shared_ptr< GenApi::CNodeMapRef > allocNodeMap(std::shared_ptr< const GenTLWrapper > gentl, void *port, CPort *cport, const char *xml)
Convenience function that returns a GenICam node map from the given port.
A string class which is a clone of std::string.
enum GENAPI_NAMESPACE::_EAccessMode EAccessMode
access mode of a node
GenICam's exception class.
virtual const char * c_str(void) const
Smartpointer for NodeMaps with create function.
virtual const char * what() const
Get error description (overwrite from std:exception)