Path::StringType Path::Absolute() const { StringType::value_type buf[MAX_PATH*2] = PATH_LITERAL(""); StringType::value_type* pathStart = realpath(m_path.c_str(), buf); if (!pathStart) { return StringType(); } return StringType(pathStart); }
StringType NSIS::popstring() { stack_t* th; if (!s_stacktop || !*s_stacktop) return StringType(); th = (*s_stacktop); RefType< char >::Ref str(new char[s_stringsize], CharArrayDeleter); lstrcpyn(str.get(), th->text, s_stringsize); *s_stacktop = th->next; GlobalFree((HGLOBAL)th); return StringType(str.get()); }
CommandLine::StringType CommandLine::GetCommandLineString() const { StringType string(argv_[0]); string = QuoteForCommandLineToArgvW(string); // Append switches and arguments. bool parse_switches = true; for(size_t i=1; i<argv_.size(); ++i) { CommandLine::StringType arg = argv_[i]; CommandLine::StringType switch_string; CommandLine::StringType switch_value; parse_switches &= arg != kSwitchTerminator; string.append(StringType(FILE_PATH_LITERAL(" "))); if (parse_switches && IsSwitch(arg, &switch_string, &switch_value)) { string.append(switch_string); if(!switch_value.empty()) { switch_value = QuoteForCommandLineToArgvW(switch_value); string.append(kSwitchValueSeparator + switch_value); } } else { arg = QuoteForCommandLineToArgvW(arg); string.append(arg); } } return string; }
CommandLine::StringType CommandLine::GetSwitchValueNative( const std::string& switch_string) const { SwitchMap::const_iterator result = switches_.end(); result = switches_.find(LowerASCIIOnWindows(switch_string)); return result==switches_.end() ? StringType() : result->second; }
AnyType TPTScriptInterface::eval(std::deque<std::string> * words) { if(words->size() < 1) return AnyType(TypeNull, NULL); std::string word = words->front(); words->pop_front(); char * rawWord = (char *)word.c_str(); ValueType wordType = testType(word); switch(wordType) { case TypeFunction: if(word == "set") return tptS_set(words); else if(word == "create") return tptS_create(words); else if(word == "delete" || word == "kill") return tptS_delete(words); else if(word == "load") return tptS_load(words); else if(word == "reset") return tptS_reset(words); else if(word == "bubble") return tptS_bubble(words); break; case TypeNumber: return NumberType(atoi(rawWord)); case TypePoint: { int pointX, pointY; sscanf(rawWord, "%d,%d", &pointX, &pointY); return PointType(pointX, pointY); } case TypeString: return StringType(word); } }
AnyType::operator StringType() { if(type == TypeNumber) { std::stringstream numberStream; numberStream << ((NumberType*)this)->Value(); return StringType(numberStream.str()); } else if(type == TypeString && value) { return StringType(*((std::string*)value)); } else throw InvalidConversionException(type, TypeString); }
CommandLine::StringType CommandLine::GetArgumentsString() const { StringType params; // Append switches and arguments. bool parse_switches = true; for (size_t i = 1; i < argv_.size(); ++i) { StringType arg = argv_[i]; StringType switch_string; StringType switch_value; parse_switches &= arg != kSwitchTerminator; if (i > 1) params.append(StringType(FILE_PATH_LITERAL(" "))); if (parse_switches && IsSwitch(arg, &switch_string, &switch_value)) { params.append(switch_string); if (!switch_value.empty()) { #if defined(OS_WIN) switch_value = QuoteForCommandLineToArgvW(switch_value); #endif params.append(kSwitchValueSeparator + switch_value); } } else { #if defined(OS_WIN) arg = QuoteForCommandLineToArgvW(arg); #endif params.append(arg); } } return params; }
template <class StringType, class CharType> Bool ParseXmlNode(xml_node<CharType>* pNode, CXmlElement<StringType>* pElement) { if (pNode && pElement) { if (pNode->type() == rapidxml::node_element && pNode->name_size()) { //标签数据 pElement->SetTag(StringType(pNode->name(), pNode->name_size())); //属性数据 if (pNode->value_size()) pElement->SetValue(StringType(pNode->value(), pNode->value_size())); //读取属性 pElement->Attributes.reserve(rapidxml::count_children<CharType>(pNode)); xml_attribute<CharType>* pNodeAttr = pNode->first_attribute(); while (pNodeAttr) { if (pNodeAttr->name_size()) { pElement->AddAttribute(CXmlAttribute<StringType>( StringType(pNodeAttr->name(), pNodeAttr->name_size()), StringType(pNodeAttr->value(), pNodeAttr->value_size()))); } pNodeAttr = pNodeAttr->next_attribute(); } //子节点预开辟空间 pElement->Children.reserve(rapidxml::count_children<CharType>(pNode)); xml_node<CharType>* pChildNode = pNode->first_node(); while (pChildNode) { if (pChildNode->type() == rapidxml::node_element && pChildNode->name_size()) { CXmlElement<StringType>* pChildElement = pElement->AddChildren(StringType(pChildNode->name(), pChildNode->name_size())); if (!ParseXmlNode(pChildNode, pChildElement)) return false; } pChildNode = pChildNode->next_sibling(); } } return true; } return false; }
StringType FromIntegral(IntegralType val) { static_assert(std::is_integral_v<IntegralType>); ext::itoa_buffer<IntegralType> buffer; auto * last = std::end(buffer) - 1; auto * first = ext::itoa(val, buffer); return StringType(first, last - first); }
AnyType TPTScriptInterface::eval(std::deque<String> * words) { if(words->size() < 1) return AnyType(TypeNull, ValueValue()); String word = words->front(); words->pop_front(); ValueType wordType = testType(word); switch(wordType) { case TypeFunction: if(word == "set") return tptS_set(words); else if(word == "create") return tptS_create(words); else if(word == "delete" || word == "kill") return tptS_delete(words); else if(word == "load") return tptS_load(words); else if(word == "reset") return tptS_reset(words); else if(word == "bubble") return tptS_bubble(words); else if(word == "quit") return tptS_quit(words); break; case TypeNumber: return NumberType(parseNumber(word)); case TypeFloat: return FloatType(atof(word.ToUtf8().c_str())); case TypePoint: { int x, y; if(String::Split comma = word.SplitNumber(x)) if(comma.After().BeginsWith(",")) if(comma.After().Substr(1).SplitNumber(y)) return PointType(x, y); return PointType(0, 0); } case TypeString: return StringType(word); default: break; } return StringType(word); }
inline StringType trimWhitespace(const StringType& string, const StringType& whitespace) { std::size_t start = string.find_first_not_of(whitespace); if (start == StringType::npos) return StringType(); std::size_t end = string.find_last_not_of(whitespace); return substring(string, start, end + 1); }
CommandLine::StringType CommandLine::GetCommandLineString() const { StringType string(argv_[0]); #if defined(OS_WIN) string = QuoteForCommandLineToArgvW(string); #endif StringType params(GetArgumentsString()); if (!params.empty()) { string.append(StringType(FILE_PATH_LITERAL(" "))); string.append(params); } return string; }
AnyType::operator StringType() { if(type == TypeNumber) { std::stringstream numberStream; numberStream << ((NumberType *)this)->Value(); return StringType(numberStream.str()); } else if(type == TypeString && value.str) { return StringType(*(value.str)); } else if (type == TypePoint && value.pt) { ui::Point thisPoint = *(value.pt); std::stringstream pointStream; pointStream << thisPoint.X << "," << thisPoint.Y; return StringType(pointStream.str()); } else throw InvalidConversionException(type, TypeString); }
StringType operator()( const StringType & before_0, const StringType & after_0 ) const { StringType ans; const auto & source=data->source; ans.reserve(source.size()+64); typedef decltype(source.cbegin()) _i_type; typedef typename StringType::value_type _value_type; constexpr static const _value_type _0b[]={ '\\', '$','\\','{','\0',0 }; constexpr static const _value_type _0e[]={ '\\', '}','\0',0 }; std::match_results<_i_type> m; std::basic_regex<_value_type> e( StringType(_0b)+ before_0+ StringType(_0e) ); auto source_begin=source.cbegin(); auto source_end=source.cend(); while (std::regex_search(source_begin,source_end,m,e)) { auto & subs=*(m.begin()); ans+=StringType(source_begin,subs.first); ans+=after_0; source_begin=subs.second; } ans+=StringType(source_begin,source_end); return std::move(ans); }
AnyType::operator PointType() { if(type == TypePoint) { return PointType(*((ui::Point*)value)); } else if(type == TypeString) { ui::Point thisPoint = *((ui::Point*)value); std::stringstream pointStream; pointStream << thisPoint.X << "," << thisPoint.Y; return StringType(pointStream.str()); } else throw InvalidConversionException(type, TypePoint); }
typename ANTLR_Exception<ImplTraits, Ex, StreamType>::StringType ANTLR_Exception<ImplTraits, Ex, StreamType>::getName() const { const char* exArray[] = { "org.antlr.runtime.RecognitionException" , "org.antlr.runtime.MismatchedTokenException" , "org.antlr.runtime.NoViableAltException" , "org.antlr.runtime.MismatchedSetException" , "org.antlr.runtime.EarlyExitException" , "org.antlr.runtime.FailedPredicateException" , "org.antlr.runtime.MismatchedTreeNodeException" , "org.antlr.runtime.tree.RewriteEarlyExitException" , "org.antlr.runtime.UnwantedTokenException" , "org.antlr.runtime.MissingTokenException" }; return StringType(exArray[Ex]); }
LRESULT CTipWnd::OnSetText(WPARAM, LPARAM lp) { // Just display the current window string in the default colour Clear(); AddString(StringType((LPCTSTR)lp), m_text_colour, NULL, m_fmt); //CClientDC dc(this); //CRect rct; //CFont *pOldFont = (CFont*)dc.SelectStockObject(m_stock_font); //ASSERT(pOldFont != NULL); //dc.DrawText((LPCTSTR)lp, &rct, DT_CALCRECT | m_fmt); //dc.SelectObject(pOldFont); //rct.InflateRect(m_margins+CSize(1,1)); //SetWindowPos(NULL, 0, 0, rct.Width(), rct.Height(), SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); //Invalidate(); return Default(); }
void CTipWnd::AddString(LPCTSTR ss, COLORREF col /*= -1*/, CPoint * ppt /*= NULL*/, UINT fmt /*= 0*/) #endif { ASSERT(col_.size() == str_.size()); ASSERT(fmt_.size() == str_.size()); ASSERT(rct_.size() == str_.size()); str_.push_back(StringType(ss)); col_.push_back(col == -1 ? m_text_colour : col); fmt_.push_back(fmt == 0 ? m_fmt : fmt); CRect rct(0,0,0,0); // Work out how big the text is CClientDC dc(this); CFont *pOldFont = (CFont*)dc.SelectStockObject(m_stock_font); ASSERT(pOldFont != NULL); #if _MSC_VER >= 1300 ::DrawTextW(dc.m_hDC, (LPCWSTR)str_.back(), str_.back().GetLength(), &rct, DT_CALCRECT | fmt_.back()); #else dc.DrawText(str_.back(), &rct, DT_CALCRECT | fmt_.back()); #endif dc.SelectObject(pOldFont); // Work out where to put the text if (ppt != NULL) rct.MoveToXY(*ppt); // move to the specified posn else if (!rct_.empty()) rct.MoveToY(rct_all_.Height()); // put underneath the last one rct_.push_back(rct); ::UnionRect(&rct, &rct_all_, &rct_.back()); rct_all_ = rct; // Resize the window to accommodate the new string rct.InflateRect(m_margins+CSize(1,1)); SetWindowPos(NULL, 0, 0, rct.Width(), rct.Height(), SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); Invalidate(); ASSERT(col_.size() == str_.size()); ASSERT(fmt_.size() == str_.size()); ASSERT(rct_.size() == str_.size()); }
StringType v8StringToWebCoreString(v8::Handle<v8::String> v8String, ExternalMode external) { { // This portion of this function is very hot in certain Dromeao benchmarks. v8::String::Encoding encoding; v8::String::ExternalStringResourceBase* resource = v8String->GetExternalStringResourceBase(&encoding); if (LIKELY(!!resource)) { WebCoreStringResourceBase* base; if (encoding == v8::String::ONE_BYTE_ENCODING) base = static_cast<WebCoreStringResource8*>(resource); else base = static_cast<WebCoreStringResource16*>(resource); return StringTraits<StringType>::fromStringResource(base); } } int length = v8String->Length(); if (UNLIKELY(!length)) return StringType(""); bool oneByte = v8String->ContainsOnlyOneByte(); StringType result(oneByte ? StringTraits<StringType>::template fromV8String<V8StringOneByteTrait>(v8String, length) : StringTraits<StringType>::template fromV8String<V8StringTwoBytesTrait>(v8String, length)); if (external != Externalize || !v8String->CanMakeExternal()) return result; if (result.is8Bit()) { WebCoreStringResource8* stringResource = new WebCoreStringResource8(result); if (UNLIKELY(!v8String->MakeExternal(stringResource))) delete stringResource; } else { WebCoreStringResource16* stringResource = new WebCoreStringResource16(result); if (UNLIKELY(!v8String->MakeExternal(stringResource))) delete stringResource; } return result; }
static inline void SplitStringToIteratorUsing(const StringPiece& full, const char* delim, ITR& result) { // Optimize the common case where delim is a single character. if (delim[0] != '\0' && delim[1] == '\0') { char c = delim[0]; const char* p = full.data(); const char* end = p + full.size(); while (p != end) { if (*p == c) ++p; else { const char* start = p; while (++p != end && *p != c) {} *result++ = StringType(start, p - start); } } return; } std::string::size_type begin_index, end_index; begin_index = full.find_first_not_of(delim); while (begin_index != std::string::npos) { end_index = full.find_first_of(delim, begin_index); if (end_index == std::string::npos) { *result++ = full.substr(begin_index).as_string(); return; } *result++ = full.substr(begin_index, (end_index - begin_index)).as_string(); begin_index = full.find_first_not_of(delim, end_index); } }
StringType print(const CharType& c) const { return StringType(1,c); }
void CommandLine::AppendSwitch(const std::string& switch_string) { AppendSwitchNative(switch_string, StringType()); }
StringType print(CharType const &c) const { return StringType(1, c); }
const StringType* StringType::get() { static const StringType type = StringType(); return &type; }
void Gear_UnpackList::runVideo() { //std::cout << name() << "::: size:: " << _LIST_IN->type()->size() << std::endl; if (!_LIST_IN->connected() || _LIST_IN->type()->empty()) { _LIST_OUT->sleeping(true); // TODO: the sleeping mechanism just doesn't work return; } _LIST_OUT->sleeping(false); ListType *listType = _LIST_OUT->type(); const AbstractType *type = _LIST_IN->type()->front(); // XXX Maybe there's a more efficient way than clearing/populating each time but this // is safe memory-wise. clearList(); // Copy const ListType* inputList = _LIST_IN->type(); for(ListType::const_iterator it=inputList->begin() + 1; it!=inputList->end(); ++it) listType->push_back( (*it)->clone() ); //std::cout << "got something " << type->typeName() << std::endl; //for (ListType::const_iterator it = _LIST_IN->type()->begin(); it != _LIST_IN->type()->end(); ++it) //listType->assign(_LIST_IN->type()->begin(), _LIST_IN->type()->end()); if ((_STR_OUT->connected()) && type->typeName() == StringType().typeName()) { //std::cout << "sending str out: " << ((StringType*)type)->value() << std::endl; _STR_OUT->type()->copyFrom(*type); return; } else if ((_VAL_OUT->connected()) && type->typeName() == ValueType().typeName()) { //std::cout << "sending val out: " << ((ValueType*)type)->value() << std::endl; _VAL_OUT->type()->copyFrom(*type); return; } else if ((_ENUM_OUT->connected()) && type->typeName() == EnumType().typeName()) { //std::cout << "sending val out: " << ((ValueType*)type)->value() << std::endl; _ENUM_OUT->type()->copyFrom(*type); return; } else if ((_CHANNEL_OUT->connected()) && type->typeName() == VideoChannelType().typeName()) { //std::cout << "sending val out: " << ((ValueType*)type)->value() << std::endl; _CHANNEL_OUT->type()->copyFrom(*type); return; } else if ((_VIDEO_OUT->connected()) && type->typeName() == VideoRGBAType().typeName()) { //std::cout << "sending val out: " << ((ValueType*)type)->value() << std::endl; _VIDEO_OUT->type()->copyFrom(*type); return; } else if ((_AREA_OUT->connected()) && type->typeName() == AreaType().typeName()) { //std::cout << "sending val out: " << ((ValueType*)type)->value() << std::endl; _AREA_OUT->type()->copyFrom(*type); return; } }