int PipeControlChannel::readNamedPipe() { BALL_LOG_SET_CATEGORY(LOG_CATEGORY); BSLS_ASSERT(INVALID_HANDLE_VALUE != d_impl.d_windows.d_handle); BALL_LOG_TRACE << "Accepting next pipe client connection" << BALL_LOG_END; if (!ConnectNamedPipe(d_impl.d_windows.d_handle, NULL)) { BALL_LOG_TRACE << "Connecting to named pipe '" << d_pipeName << "': " << describeWin32Error(GetLastError()) << BALL_LOG_END; DWORD lastError = GetLastError(); if (lastError != ERROR_PIPE_CONNECTED && lastError != ERROR_NO_DATA) { BALL_LOG_TRACE << "Failed to connect to named pipe '" << d_pipeName << "'" << BALL_LOG_END; return -1; } } while(1) { char buffer[MAX_PIPE_BUFFER_LEN]; DWORD bytesRead = 0; if (ReadFile(d_impl.d_windows.d_handle, buffer, MAX_PIPE_BUFFER_LEN, &bytesRead, NULL)) { if (bytesRead > 0) { if (buffer[bytesRead - 1] == '\n') { bytesRead--; } bslstl::StringRef stringRef(buffer, bytesRead); if (!stringRef.isEmpty()) { d_callback(stringRef); } } else { // reached EOF on a named pipe. break; } } else { BALL_LOG_TRACE << "Failed to read from named pipe '" << d_pipeName << "': " << describeWin32Error(GetLastError()) << BALL_LOG_END; break; } } DisconnectNamedPipe(d_impl.d_windows.d_handle); return 0; }
QString QWebPreferencesPrivate::fontFamily(QWebPreferencesPrivate::FontFamily which) const { switch (which) { case StandardFont: { WKRetainPtr<WKStringRef> stringRef(AdoptWK, WKPreferencesCopyStandardFontFamily(preferencesRef())); return WKStringCopyQString(stringRef.get()); } case FixedFont: { WKRetainPtr<WKStringRef> stringRef(AdoptWK, WKPreferencesCopyFixedFontFamily(preferencesRef())); return WKStringCopyQString(stringRef.get()); } case SerifFont: { WKRetainPtr<WKStringRef> stringRef(AdoptWK, WKPreferencesCopySerifFontFamily(preferencesRef())); return WKStringCopyQString(stringRef.get()); } case SansSerifFont: { WKRetainPtr<WKStringRef> stringRef(AdoptWK, WKPreferencesCopySansSerifFontFamily(preferencesRef())); return WKStringCopyQString(stringRef.get()); } case CursiveFont: { WKRetainPtr<WKStringRef> stringRef(AdoptWK, WKPreferencesCopyCursiveFontFamily(preferencesRef())); return WKStringCopyQString(stringRef.get()); } case FantasyFont: { WKRetainPtr<WKStringRef> stringRef(AdoptWK, WKPreferencesCopyFantasyFontFamily(preferencesRef())); return WKStringCopyQString(stringRef.get()); } default: return QString(); } }
void PipeControlChannel::dispatchMessageUpTo( const bsl::vector<char>::iterator& iter) { BALL_LOG_SET_CATEGORY(LOG_CATEGORY); bslstl::StringRef stringRef(&(*d_buffer.begin()), iter - d_buffer.begin()); BALL_LOG_TRACE << "Assembled complete message '" << (bsl::string)stringRef << "'" << BALL_LOG_END; if (!stringRef.isEmpty()) { d_callback(stringRef); } d_buffer.erase(d_buffer.begin(), iter+1); }
AnimExpression::Token AnimExpression::consumeIdentifier(const QString& str, QString::const_iterator& iter) const { assert(iter != str.end()); assert(iter->isLetter()); auto begin = iter; while ((iter->isLetter() || iter->isDigit()) && iter != str.end()) { ++iter; } int pos = (int)(begin - str.begin()); int len = (int)(iter - begin); QStringRef stringRef(const_cast<const QString*>(&str), pos, len); if (stringRef == "true") { return Token(true); } else if (stringRef == "false") { return Token(false); } else { return Token(stringRef); } }