43      std::function<
void(
const char* entry, 
ProtocolRole role)> cb) {
 
   44    if ( !cb) 
return false;
 
   46    enum CollectState { LOOKING, IN_SOURCE, IN_SINK } state = LOOKING;
 
   48    const char* endSource = 
"</Source>";
 
   49    const char* endSink = 
"</Sink>";
 
   54      int len = in.readBytes(buf, 
sizeof(buf));
 
   56      for (
int i = 0; i < len; ++i) {
 
   57        char c = (char)buf[i];
 
   58        if (state == LOOKING) {
 
   59          static Str openBuf(16);
 
   64          if (openBuf.
indexOf(
"<Source") >= 0) {
 
   71          if (openBuf.
indexOf(
"<Sink") >= 0) {
 
   78        } 
else if (state == IN_SOURCE) {
 
   79          if (c == endSource[matchPos]) {
 
   81            if (endSource[matchPos] == 
'\0') {
 
   93              for (
int k = 0; k < matchPos; ++k) token.
add(endSource[k]);
 
  105        } 
else if (state == IN_SINK) {
 
  106          if (c == endSink[matchPos]) {
 
  108            if (endSink[matchPos] == 
'\0') {
 
  120              for (
int k = 0; k < matchPos; ++k) token.
add(endSink[k]);
 
  136    if (state == IN_SOURCE) {
 
  140    } 
else if (state == IN_SINK) {
 
virtual void add(int value)
adds a int value
Definition: StrView.h:128
 
virtual bool isEmpty()
checks if the string is empty
Definition: StrView.h:383
 
virtual int indexOf(const char c, int start=0)
Definition: StrView.h:274
 
virtual int length()
Definition: StrView.h:380
 
virtual void trim()
remove leading and traling spaces
Definition: StrView.h:532
 
String implementation which keeps the data on the heap. We grow the allocated memory only if the copy...
Definition: Str.h:22
 
void clear() override
clears the string by setting the terminating 0 at the beginning
Definition: Str.h:161
 
Str substring(int start, int end)
copies a substring into the current string
Definition: Str.h:211
 
const char * c_str() const
Definition: Str.h:186
 
Streaming parser for ConnectionManager::GetProtocolInfo results.
Definition: XMLProtocolInfoParser.h:28
 
static bool parse(Stream &in, std::function< void(const char *entry, ProtocolRole role)> cb)
Definition: XMLProtocolInfoParser.h:41
 
Definition: AllocationTracker.h:9
 
ProtocolRole
Role to indicate whether a protocolInfo entry is a Source or a Sink.
Definition: DLNACommon.h:26