void LinkLabel::mouseReleaseEvent(QMouseEvent* event) { if((event->button() == Qt::LeftButton) && (isEnabled())) { if(isCheckable()) { if(isText()) { if(_down) setStyleSheet("QLabel { color : blue; }"); } else { if(_down) setPixmap(_upImg); } _down = !_down; emit toggled(_down); } else { if(isText()) setStyleSheet("QLabel { color : blue; }"); else setPixmap(_upImg); _down = false; emit clicked(); emit clicked(this); } } if (!_hyperlink) setStyleSheet(""); QLabel::mouseReleaseEvent(event); }
eFlag Tree::appendVertex(Sit S, Vertex *v) { sabassert(stackTop && isDaddy(stackTop)); sabassert(!isText(v) || !pendingTextNode); if (!isText(v)) flushPendingText(); E( cast(Daddy*,stackTop) -> newChild(S, v) ); //sets parent too if (isDaddy(v)) stackTop = v; v -> stamp = vcount++; // set the subtree information for vertex v -> setSubtreeInfo(subtrees.getCurrent()); return OK; };
size_t YamlNode::toSizeT() const { if (isText()) { const std::string& text = static_cast<TextData&>(*m_Data).text; size_t pos = std::string::npos; size_t value; if (sizeof(size_t) == sizeof(unsigned long)) value = size_t(std::stoul(text, &pos, 0)); else if (sizeof(size_t) == sizeof(unsigned long long)) value = size_t(std::stoull(text, &pos, 0)); else { static_assert( sizeof(size_t) == sizeof(unsigned long) || sizeof(size_t) == sizeof(unsigned long long), "unsupported sizeof(size_t)."); } if (pos == text.length()) return value; } return 0U; }
void XMLText::setText(QString p_text) { if(!isText()) return; data()->text = p_text; }
QString XMLText::text() const { if(!isText()) return QString(); return data()->text; }
/* static */ bool txXPathNodeUtils::isWhitespace(const txXPathNode& aNode) { NS_ASSERTION(aNode.isContent() && isText(aNode), "Wrong type!"); return aNode.Content()->TextIsOnlyWhitespace(); }
int32_t CBC_PDF417HighLevelEncoder::determineConsecutiveTextCount( CFX_WideString msg, int32_t startpos) { int32_t len = msg.GetLength(); int32_t idx = startpos; while (idx < len) { FX_WCHAR ch = msg.GetAt(idx); int32_t numericCount = 0; while (numericCount < 13 && isDigit(ch) && idx < len) { numericCount++; idx++; if (idx < len) { ch = msg.GetAt(idx); } } if (numericCount >= 13) { return idx - startpos - numericCount; } if (numericCount > 0) { continue; } ch = msg.GetAt(idx); if (!isText(ch)) { break; } idx++; } return idx - startpos; }
void RepoQuery::getText(int iCol, const char*& text) { if (!isText(iCol)) { throw RepoExc( "RepoQuery::%s(repo=%p) error: Column %d is not text in '%s'", __func__, &m_stmt.repo(), iCol, m_stmt.sql().c_str()); } text = (const char*)sqlite3_column_text(m_stmt.get(), iCol); }
int InlineTextBox::baselinePosition(FontBaseline baselineType) const { if (!isText() || !parent()) return 0; if (parent()->lineLayoutItem() == lineLayoutItem().parent()) return parent()->baselinePosition(baselineType); return LineLayoutBoxModel(lineLayoutItem().parent()).baselinePosition(baselineType, isFirstLineStyle(), isHorizontal() ? HorizontalLine : VerticalLine, PositionOnContainingLine); }
LayoutUnit InlineTextBox::lineHeight() const { if (!isText() || !lineLayoutItem().parent()) return 0; if (lineLayoutItem().isBR()) return toLayoutBR(lineLayoutItem())->lineHeight(isFirstLineStyle()); if (parent()->lineLayoutItem() == lineLayoutItem().parent()) return parent()->lineHeight(); return LineLayoutBoxModel(lineLayoutItem().parent()).lineHeight(isFirstLineStyle(), isHorizontal() ? HorizontalLine : VerticalLine, PositionOnContainingLine); }
void LinkLabel::enableHyperlinkStyle(bool enable) { _hyperlink = enable; if(isText()) { if(_hyperlink) setStyleSheet("QLabel { color : blue; text-decoration: underline }"); else setStyleSheet(""); } }
bool xbnode::getBool() { if( isBool() ) return (this->getText()=="true"); if( isNumeric() ) return getNumeric()!=0; if( isText() ) return !getText().empty(); raiseError( "getBool() cant convert", __FILE__,__LINE__); return false; }
CFileType CFileUtil:: getType(CFileBase *file) { CFileType type = file->getType(); if (type != CFILE_TYPE_INODE_REG) return type; type = getImageType(file); if (type != CFILE_TYPE_NONE) return type; type = getSoundType(file); if (type != CFILE_TYPE_NONE) return type; type = getTextType(file); if (type != CFILE_TYPE_NONE) return type; //------ std::string filename = file->getName(); type = getImageTypeFromName(filename); if (type != CFILE_TYPE_NONE) return type; type = getSoundTypeFromName(filename); if (type != CFILE_TYPE_NONE) return type; type = getTextTypeFromName(filename); if (type != CFILE_TYPE_NONE) return type; //------ type = isText(file); if (type != CFILE_TYPE_NONE) return type; return CFILE_TYPE_TEXT_BINARY; }
double YamlNode::toDouble() const { if (isText()) { const std::string& text = static_cast<TextData&>(*m_Data).text; size_t pos = std::string::npos; double value = std::stod(text, &pos); if (pos == text.length()) return value; } return 0.0; }
int YamlNode::toInt() const { if (isText()) { const std::string& text = static_cast<TextData&>(*m_Data).text; size_t pos = std::string::npos; int value = std::stoi(text, &pos, 0); if (pos == text.length()) return value; } return 0; }
/** * \todo Optimize this with a flag on Element to know if it's a whitespace or not. */ __INLINE bool ElementRef::isWhitespace () { AssertBug(isText(), "Element is not a text() !\n"); bool isWs = true; for (const char* c = getText().c_str(); *c; c++) if (!isspace(*c)) { isWs = false; break; } return isWs; }
void LinkLabel::mousePressEvent(QMouseEvent* event) { if((event->button() == Qt::LeftButton) && isEnabled()) { if(isText()) setStyleSheet("QLabel { color : blue; text-decoration: underline }"); else setPixmap(_downImg); if(!isCheckable()) _down = true; } if (!_hyperlink) setStyleSheet(""); QLabel::mousePressEvent(event); }
YamlNode::BooleanValue YamlNode::toBool() const { if (isText()) { std::string text = static_cast<TextData&>(*m_Data).text; for (auto& ch : text) ch = tolower(ch); auto it = g_StringToBoolean.find(text); if (it != g_StringToBoolean.end()) return it->second; } return Indeterminate; }
//------------------------------------------------------------------------------ std::string WebSocketFrame::toString() const { std::stringstream ss; ss << "Flags:"; ss << " CONT=" << (isContinuation() ? "Y" : "N"); ss << ", TXT=" << (isText() ? "Y" : "N"); ss << ", BIN=" << (isBinary() ? "Y" : "N"); ss << ", CLOSE=" << (isClose() ? "Y" : "N"); ss << ", PING=" << (isPing() ? "Y" : "N"); ss << ", PONG=" << (isPong() ? "Y" : "N"); ss << ", FINAL=" << (isFinal() ? "Y" : "N"); ss << ", RSV1=" << (isRSV1() ? "Y" : "N"); ss << ", RSV2=" << (isRSV2() ? "Y" : "N"); ss << ", RSV3=" << (isRSV3() ? "Y" : "N"); ss << ", nBytes=" << size(); ss << ", bytes=" << getText(); return ss.str(); }
int32_t CBC_PDF417HighLevelEncoder::determineConsecutiveBinaryCount( CFX_WideString msg, CFX_ByteArray* bytes, int32_t startpos, int32_t& e) { int32_t len = msg.GetLength(); int32_t idx = startpos; while (idx < len) { FX_WCHAR ch = msg.GetAt(idx); int32_t numericCount = 0; while (numericCount < 13 && isDigit(ch)) { numericCount++; int32_t i = idx + numericCount; if (i >= len) { break; } ch = msg.GetAt(i); } if (numericCount >= 13) { return idx - startpos; } int32_t textCount = 0; while (textCount < 5 && isText(ch)) { textCount++; int32_t i = idx + textCount; if (i >= len) { break; } ch = msg.GetAt(i); } if (textCount >= 5) { return idx - startpos; } ch = msg.GetAt(idx); if (bytes->GetAt(idx) == 63 && ch != '?') { e = BCExceptionNonEncodableCharacterDetected; return -1; } idx++; } return idx - startpos; }
/* * Textual contents setting */ __INLINE void ElementRef::setText (const char* text, DomTextSize textSize) { AssertBug(isText() || isPI() || isComment(), "Not a text element ! id=%llx, path=%s\n", getElementId(), generateVersatileXPath().c_str()); ElementSegment* me = getMe<Write>(); AssertBug(me->flags & ElementFlag_HasTextualContents, "Invalid flags %x\n", me->flags); if (me->textualContents.size > me->textualContents.shortFormatSize) { // We shall reuse a bit here... Nevermind... getDocumentAllocator().freeSegment(me->textualContents.contentsPtr, me->textualContents.size); } if (textSize <= me->textualContents.shortFormatSize) { getDocumentAllocator().alter(me); me->textualContents.size = textSize; memcpy(me->textualContents.contents, text, textSize); getDocumentAllocator().protect(me); } else { SegmentPtr contentsPtr = getDocumentAllocator().getFreeSegmentPtr(textSize, getAllocationProfile()); char* textSegment = getDocumentAllocator().getSegment<char, Write>(contentsPtr, textSize); getDocumentAllocator().alter(textSegment, textSize); memcpy(textSegment, text, textSize); getDocumentAllocator().protect(textSegment, textSize); getDocumentAllocator().alter(me); me->textualContents.size = textSize; me->textualContents.contentsPtr = contentsPtr; getDocumentAllocator().protect(me); } if ( getFather() ) { getDocument().appendJournal(*this, JournalOperation_UpdateTextNode, *this, 0); } }
api_return ViewFileApi::handleGetText(ApiRequest& aRequest) { auto file = ViewFileManager::getInstance()->getFile(Deserializer::parseTTH(aRequest.getStringParam(0))); if (!file) { aRequest.setResponseErrorStr("File not found"); return websocketpp::http::status_code::not_found; } if (!file->isText()) { aRequest.setResponseErrorStr("This method can't be used for non-text files"); return websocketpp::http::status_code::bad_request; } string content; try { File f(file->getPath(), File::READ, File::OPEN); auto encoding = Util::emptyString; bool nfo = Util::getFileExt(file->getPath()) == ".nfo"; if (nfo) { // Platform-independent encoding conversion function could be added if there is more use for it #ifdef _WIN32 encoding = "CP.437"; #else encoding = "cp437"; #endif } content = Text::toUtf8(f.read(), encoding); } catch (const FileException& e) { aRequest.setResponseErrorStr("Failed to open the file: " + e.getError() + "(" + file->getPath() + ")"); return websocketpp::http::status_code::internal_server_error; } aRequest.setResponseBody({ { "text", content }, }); return websocketpp::http::status_code::ok; }
void LinkLabel::leaveEvent(QEvent*) { if(isText() && isEnabled() && _hyperlink) setStyleSheet("QLabel { color : blue; }"); }
__INLINE void ElementRef::setWrapCData (bool wrap) { AssertBug(isText(), "ElementRef not a text !\n"); setFlag(ElementFlag_WrapCData, wrap); }
__INLINE bool ElementRef::getWrapCData () { AssertBug(isText(), "ElementRef not a text !\n"); return hasFlag(ElementFlag_WrapCData); }
__INLINE bool ElementRef::isRegularElement () { return (!isText() && !isComment() && !isPI()); }
const std::string& YamlNode::toString() const { return (isText() ? static_cast<TextData&>(*m_Data).text : g_EmptyString); }
__INLINE void ElementRef::setDisableOutputEscaping (bool escaping) { AssertBug(isText(), "ElementRef not a text !\n"); setFlag(ElementFlag_DisableOutputEscaping, escaping); }
InlineBox* LayoutListMarker::createInlineBox() { InlineBox* result = LayoutBox::createInlineBox(); result->setIsText(isText()); return result; }
__INLINE bool ElementRef::getDisableOutputEscaping () { AssertBug(isText(), "ElementRef not a text !\n"); return hasFlag(ElementFlag_DisableOutputEscaping); }