MCPcopy Create free account
hub / github.com/apache/nifi-minifi-cpp / read

Method read

extensions/script/lua/LuaBaseStream.cpp:36–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34}
35
36std::string LuaBaseStream::read(size_t len) {
37 if (len == 0) {
38 len = stream_->size();
39 }
40
41 if (len <= 0) {
42 return nullptr;
43 }
44
45 std::string buffer;
46 buffer.resize(len);
47
48 // Here, we write directly to the string data, which is safe starting in C++ 11:
49 //
50 // The char-like objects in a basic_string object shall be stored contiguously. That is, for any basic_string
51 // object s, the identity &*(s.begin() + n) == &*s.begin() + n shall hold for all values of n such that
52 // 0 <= n < s.size()."
53 //
54 // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3337.pdf
55 auto read = stream_->read(reinterpret_cast<uint8_t *>(&buffer[0]), static_cast<int>(len));
56
57 if (read != len) {
58 buffer.resize(static_cast<size_t >(read));
59 }
60
61 return std::move(buffer);
62}
63
64size_t LuaBaseStream::write(std::string buf) {
65 return static_cast<size_t>(stream_->write(reinterpret_cast<uint8_t *>(const_cast<char *>(buf.data())),

Callers 15

serializeMethod · 0.45
processMethod · 0.45
onTriggerMethod · 0.45
onTriggerMethod · 0.45
onTriggerMethod · 0.45
writeFetchedBodyMethod · 0.45
onTriggerMethod · 0.45
processMethod · 0.45
processMethod · 0.45
onTriggerFunction · 0.45
processMethod · 0.45

Calls 1

sizeMethod · 0.45

Tested by 3

testFileMethod · 0.36
testFileMethod · 0.36
testFileMethod · 0.36