53 CPort::CPort(std::shared_ptr<const GenTLWrapper> _gentl,
void **_port) : gentl(_gentl)
71 size=
static_cast<size_t>(length);
72 err=
gentl->GCReadPort(*
port,
static_cast<uint64_t
>(addr), buffer, &size);
78 out <<
"CPort::Read(address=0x" << std::hex << addr <<
", length=" <<
79 std::dec << static_cast<size_t>(length) <<
")";
89 while (size <
static_cast<size_t>(length))
91 reinterpret_cast<uint8_t *
>(buffer)[size++]=0;
102 size_t size=
static_cast<size_t>(length);
106 if (
gentl->GCWritePort(*
port,
static_cast<uint64_t
>(addr), buffer, &size) !=
110 out <<
"CPort::Write(address=0x" << std::hex << addr <<
", length=" <<
111 std::dec << length <<
")";
116 if (size !=
static_cast<size_t>(length))
118 throw GenTLException(
"CPort::Write(): Returned size not as expected");
140 inline std::string toLower(
const std::string &s,
size_t start,
size_t size)
144 size_t end=std::min(s.size(), start+size);
148 out << static_cast<char>(std::tolower(s[start++]));
156 std::shared_ptr<GenApi::CNodeMapRef>
allocNodeMap(std::shared_ptr<const GenTLWrapper> gentl,
157 void *port,
CPort *cport,
const char *xml)
173 return std::shared_ptr<GenApi::CNodeMapRef>();
180 size_t size=
sizeof(tmp);
191 if (toLower(url, 0, 6) ==
"local:")
196 if (url.compare(i, 3,
"///") == 0)
201 std::stringstream in(url.substr(i));
202 std::string name, saddress, slength;
208 uint64_t address=std::stoull(saddress, 0, 16);
209 size_t length=
static_cast<size_t>(std::stoull(slength, 0, 16));
213 std::unique_ptr<char[]> buffer(
new char[length+1]);
220 buffer.get()[length]=
'\0';
231 std::ofstream out(xml, std::ios::binary);
233 out.rdbuf()->sputn(buffer.get(),
static_cast<std::streamsize
>(length));
238 if (name.size() > 4 && toLower(name, name.size()-4, 4) ==
".zip")
240 nodemap->_LoadXMLFromZIPData(buffer.get(), length);
245 nodemap->_LoadXMLFromString(sxml);
248 else if (toLower(url, 0, 5) ==
"file:")
253 if (url.compare(i, 3,
"///") == 0)
258 std::string name=url.
substr(i);
262 if (name.size() > 4 && toLower(name, name.size()-4, 4) ==
".zip")
265 nodemap->_LoadXMLFromZIPFile(file);
270 nodemap->_LoadXMLFromFile(file);
275 throw GenTLException((
"allocNodeMap(): Cannot interpret URL: "+url).c_str());
289 if (!nodemap->_Connect(cport, portname))
291 throw GenTLException((std::string(
"allocNodeMap(): Cannot connect port: ")+tmp).c_str());