Where Online Learning is simpler!
The C and C++ Include Header Files
cat -n /usr/include/nodejs/src/string_decoder.h
1 #ifndef SRC_STRING_DECODER_H_ 2 #define SRC_STRING_DECODER_H_ 3 4 #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS 5 6 #include "node.h" 7 8 namespace node { 9 10 class StringDecoder { 11 public: 12 StringDecoder() { state_[kEncodingField] = BUFFER; } 13 inline enum encoding Encoding() const; 14 15 inline char* IncompleteCharacterBuffer(); 16 inline unsigned MissingBytes() const; 17 inline unsigned BufferedBytes() const; 18 19 // Decode a string from the specified encoding. 20 // The value pointed to by `nread` will be modified to reflect that 21 // less data may have been read because it ended on an incomplete character 22 // and more data may have been read because a previously incomplete character 23 // was finished. 24 v8::MaybeLocal<v8::String> DecodeData(v8::Isolate* isolate, 25 const char* data, 26 size_t* nread); 27 // Flush an incomplete character. For character encodings like UTF8 this 28 // means printing replacement characters, buf for e.g. Base64 the returned 29 // string contains more data. 30 v8::MaybeLocal<v8::String> FlushData(v8::Isolate* isolate); 31 32 enum Fields { 33 kIncompleteCharactersStart = 0, 34 kIncompleteCharactersEnd = 4, 35 kMissingBytes = 4, 36 kBufferedBytes = 5, 37 kEncodingField = 6, 38 kNumFields = 7 39 }; 40 41 private: 42 uint8_t state_[kNumFields] = {}; 43 }; 44 45 } // namespace node 46 47 #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS 48 49 #endif // SRC_STRING_DECODER_H_