FTSelection *FTDistance::optimize(FTContext *ftcontext, bool execute) const { XPath2MemoryManager *mm = ftcontext->context->getMemoryManager(); if(execute || range_.arg1->isConstant()) { Result rangeResult = range_.arg1->createResult(ftcontext->context); Numeric::Ptr num = (Numeric::Ptr)rangeResult->next(ftcontext->context); long distance = ::atol(UTF8(num->asString(ftcontext->context))); switch(range_.type) { case FTRange::EXACTLY: { FTSelection *result = new (mm) FTDistanceLiteral(arg_, FTRange::EXACTLY, distance, 0, unit_, mm); result->setLocationInfo(this); return result->optimize(ftcontext, execute); } case FTRange::AT_LEAST: { FTSelection *result = new (mm) FTDistanceLiteral(arg_, FTRange::AT_LEAST, distance, 0, unit_, mm); result->setLocationInfo(this); return result->optimize(ftcontext, execute); } case FTRange::AT_MOST: { FTSelection *result = new (mm) FTDistanceLiteral(arg_, FTRange::AT_MOST, distance, 0, unit_, mm); result->setLocationInfo(this); return result->optimize(ftcontext, execute); } case FTRange::FROM_TO: { Result rangeResult2 = range_.arg2->createResult(ftcontext->context); Numeric::Ptr num2 = (Numeric::Ptr)rangeResult2->next(ftcontext->context); long distance2 = ::atol(UTF8(num->asString(ftcontext->context))); FTSelection *result = new (mm) FTDistanceLiteral(arg_, FTRange::FROM_TO, distance, distance2, unit_, mm); result->setLocationInfo(this); return result->optimize(ftcontext, execute); } } } FTSelection *newarg = arg_->optimize(ftcontext, execute); if(newarg == 0) return 0; if(newarg->getType() == WORD) { return newarg; } newarg = new (mm) FTDistance(range_, unit_, newarg, mm); newarg->setLocationInfo(this); return newarg; }
BitSet64 XmlUtil::get_bitset64_value(const xmlNodePtr node) { if (node == 0) { EL_THROW_EXCEPTION(InvalidParameterException() << errinfo_message(UTF8("parameter is zero")) << errinfo_parameter_name(UTF8("node"))); } if (node->children == 0) { return 0; } return boost::lexical_cast<BitSet64>(node->children->content); }
static cxInt cxJsonLuaMake(lua_State *L) { cxConstChars json = luaL_checkstring(L, 1); cxJson ret = cxJsonCreate(UTF8(json)); CX_LUA_PUSH_OBJECT(ret); return 1; }
static int RemoveLockingFile(ConstUnicode lockDir, // IN: ConstUnicode fileName) // IN: { int err; Unicode path; ASSERT(lockDir); ASSERT(fileName); path = Unicode_Join(lockDir, DIRSEPS, fileName, NULL); err = FileDeletionRobust(path, FALSE); if (err != 0) { if (err == ENOENT) { /* Not there anymore; locker unlocked or timed out */ err = 0; } else { Warning(LGPFX" %s of '%s' failed: %s\n", __FUNCTION__, UTF8(path), strerror(err)); } } Unicode_Free(path); return err; }
static HANDLE GetContact(TCHAR *arg, TCHAR **pemail, CMsnProto *proto) { TCHAR* email = NULL; do { TCHAR *tok = _tcschr(arg, '&'); /* next token */ if (tok != NULL) *tok++ = '\0'; if (_tcsnicmp(arg, _T("contact="), 8) == 0) { arg += 8; UrlDecode(arg); email = arg; } arg = tok; } while(arg != NULL); if (email == NULL || email[0] == '\0') { if (pemail) *pemail = NULL; return NULL; } if (pemail) *pemail = email; HANDLE hContact = proto->MSN_HContactFromEmail(UTF8(email), NULL, true, true); return hContact; }
// Helper to process texts static char * HtmlEncodeUTF8T(const TCHAR *src) { if (src == NULL) return mir_strdup(""); return HtmlEncode(UTF8(src)); }
static Vector<String> get_strings (const Vector<Byte> & buffer) { // Decode auto str=UTF8().Decode(buffer.begin(),buffer.end()); // Separate on NULL character Vector<String> retr; for (auto cp : str.CodePoints()) { if (retr.Count()==0) retr.EmplaceBack(); if (cp=='\0') { retr.EmplaceBack(); continue; } retr[retr.Count()-1] << cp; } return retr; }
int main(int argc, char *argv[]) { // Initialise Xerces-C and XQilla by creating the factory object XQilla xqilla; // Parse an XQuery expression // (AutoDelete deletes the object at the end of the scope) AutoDelete<XQQuery> query(xqilla.parse(X("foo/bar/@baz"))); // Create a context object AutoDelete<DynamicContext> context(query->createDynamicContext()); // Parse a document, and set it as the context item Sequence seq = context->resolveDocument(X("foo.xml")); if(!seq.isEmpty() && seq.first()->isNode()) { context->setContextItem(seq.first()); context->setContextPosition(1); context->setContextSize(1); } // Execute the query, using the context Result result = query->execute(context); // Iterate over the results, printing them Item::Ptr item; while(item = result->next(context)) { std::cout << UTF8(item->asString(context)) << std::endl; } return 0; }
FileIOResult FileIO_Unlock(FileIODescriptor *file) // IN/OUT: { FileIOResult ret = FILEIO_SUCCESS; ASSERT(file); #if !defined(__FreeBSD__) && !defined(sun) if (file->lockToken != NULL) { int err = 0; if (!FileLock_Unlock(file->lockToken, &err, NULL)) { Warning(LGPFX" %s on '%s' failed: %s\n", __FUNCTION__, UTF8(file->fileName), strerror(err)); ret = FILEIO_ERROR; } file->lockToken = NULL; } #else ASSERT(file->lockToken == NULL); #endif // !__FreeBSD__ && !sun return ret; }
String XmlUtil::get_string_value(const xmlNodePtr node) { if (node == 0) { EL_THROW_EXCEPTION(InvalidParameterException() << errinfo_message(UTF8("parameter is zero")) << errinfo_parameter_name(UTF8("node"))); } if (node->children == 0) { return String(); } return String((char*)node->children->content); }
void registerViewController::loadDisButton(CCSize _size, int _lineHeight){ CAButton* button1 = CAButton::createWithFrame(CCRect(-1, 10 + _lineHeight, _size.width / 5, _px(50)), CAButtonTypeCustom); button1->setAllowsSelected(false); CAScale9ImageView* imageView = CAScale9ImageView::createWithImage(CAImage::create("image/bg.png")); button1->setBackGroundViewForState(CAControlStateAll, imageView); this->getView()->addSubview(button1); CAView* view1 = CAView::createWithFrame(CCRect(-1, 11 + _lineHeight, _size.width / 5 - 1, _px(48))); view1->setColor(ccc4(220, 220, 220, 250)); this->getView()->addSubview(view1); CALabel* label = CALabel::createWithCenter(view1->getCenter()); label->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter); label->setTextAlignment(CATextAlignmentCenter); label->setFontSize(_px(20)); if (_lineHeight==0) { label->setText("+86"); } else{ label->setText(UTF8("邀请码")); } this->getView()->addSubview(label); }
FileIOResult FileIO_Lock(FileIODescriptor *file, // IN/OUT: int access) // IN: { FileIOResult ret = FILEIO_SUCCESS; /* * Lock the file if necessary. */ ASSERT(file); ASSERT(file->lockToken == NULL); FileIOResolveLockBits(&access); ASSERT((access & FILEIO_OPEN_LOCKED) == 0); #if !defined(__FreeBSD__) && !defined(sun) if ((access & FILEIO_OPEN_LOCK_MANDATORY) != 0) { /* Mandatory file locks are available only when opening a file */ ret = FILEIO_LOCK_FAILED; } else if ((access & FILEIO_OPEN_LOCK_ADVISORY) != 0) { int err = 0; file->lockToken = FileLock_Lock(file->fileName, (access & FILEIO_OPEN_ACCESS_WRITE) == 0, FILELOCK_DEFAULT_WAIT, &err, NULL); if (file->lockToken == NULL) { /* Describe the lock not acquired situation in detail */ Warning(LGPFX" %s on '%s' failed: %s\n", __FUNCTION__, UTF8(file->fileName), (err == 0) ? "Lock timed out" : strerror(err)); /* Return a serious failure status if the locking code did */ switch (err) { case 0: // File is currently locked case EROFS: // Attempt to lock for write on RO FS ret = FILEIO_LOCK_FAILED; break; case ENAMETOOLONG: // Path is too long ret = FILEIO_FILE_NAME_TOO_LONG; break; case ENOENT: // No such file or directory ret = FILEIO_FILE_NOT_FOUND; break; case EACCES: // Permissions issues ret = FILEIO_NO_PERMISSION; break; default: // Some sort of locking error ret = FILEIO_ERROR; } } } #endif // !__FreeBSD__ && !sun return ret; }
void JSONObject::generate(Error& error, const HOutputStream& out) const { out->twrite(error, Chr8('{')); if (error) return; if (size() > 0) { bool bFirst = true; TreeMap<UTF16, JSON>::Iterator it(m_core->m_tree); UTF16 sKey; JSON value; while (it(sKey, value)) { if (bFirst) bFirst = false; else { out->twrite(error, UTF8(", ")); if (error) return; } JSON(sKey).generate(error, out); if (error) return; out->twrite(error, UTF8(": ")); if (error) return; value.generate(error, out); if (error) return; } } out->twrite(error, Chr8('}')); if (error) return; }
//***************************************************************************** Kwave::MenuItem::MenuItem(Kwave::MenuNode *parent, const QString &name, const QString &command, const QKeySequence &shortcut, const QString &uid) :Kwave::MenuNode(parent, name, command, shortcut, uid), m_exclusive_group(), m_action(0) { Q_ASSERT(parent); if (!parent) return; m_action.setText(i18nc(UTF8(_("menu: ") + path()), UTF8(name))); if (!shortcut.isEmpty()) m_action.setShortcut(shortcut); connect(&m_action, SIGNAL(triggered(bool)), this, SLOT(actionTriggered(bool))); }
void registerViewController::loadTextField(CCSize _size){ textFieldNum = CATextField::createWithFrame(CADipRect(_size.width / 5-1 , _px(10), (_size.width-_size.width / 5), _px(50))); textFieldNum->setBackgroundView(CAScale9ImageView::createWithImage(CAImage::create("image/bg1.png"))); textFieldNum->setPlaceHolder(UTF8("输入11位手机号")); textFieldNum->setFontSize(_px(20)); textFieldNum->setKeyboardType(KEY_BOARD_TYPE_NUMBER); this->getView()->addSubview(textFieldNum); textFieldCod = CATextField::createWithFrame(CADipRect(_size.width / 5-1, _px(59), (_size.width - _size.width / 5), _px(50))); textFieldCod->setBackgroundView(CAScale9ImageView::createWithImage(CAImage::create("image/bg1.png"))); textFieldCod->setPlaceHolder(UTF8("请输入验证码")); textFieldCod->setFontSize(_px(20)); textFieldCod->setKeyboardType(KEY_BOARD_TYPE_NUMBER); this->getView()->addSubview(textFieldCod); }
UTF8 JSON::generate(Error& error) const { Buffer buf(0); HOutputStream out = NewObject(MemoryOutputStream, buf); generate(error, out); out->twrite(error,'\0'); return UTF8(Blob(buf)); }
void XmlUtil::forece_next(xmlNodePtr &node, const bool elements_only) { if (!next(node, elements_only)) { EL_THROW_EXCEPTION(InvalidParameterException() << errinfo_message(UTF8("no next xml node"))); } }
bool CATextSelectView::ccTouchBegan(CATouch *pTouch, CAEvent *pEvent) { CCPoint cTouchPoint = this->convertTouchToNodeSpace(pTouch); CCRect newRectL = m_pCursorMarkL->getFrame(); newRectL.InflateRect(8); CCRect newRectR = m_pCursorMarkR->getFrame(); newRectR.InflateRect(8); m_iSelViewTouchPos = 0; if (newRectL.containsPoint(cTouchPoint)) { m_iSelViewTouchPos = 1; return true; } if (newRectR.containsPoint(cTouchPoint)) { m_iSelViewTouchPos = 2; return true; } CCPoint point = this->convertTouchToNodeSpace(pTouch); CCRect ccTextRect = m_pTextViewMask->getFrame(); if (ccTextRect.containsPoint(point)) { CATextToolBarView *pToolBar = CATextToolBarView::create(); pToolBar->addButton(UTF8("\u526a\u5207"), this, callfunc_selector(CATextSelectView::ccCutToClipboard)); pToolBar->addButton(UTF8("\u590d\u5236"), this, callfunc_selector(CATextSelectView::ccCopyToClipboard)); pToolBar->addButton(UTF8("\u7c98\u8d34"), this, callfunc_selector(CATextSelectView::ccPasteFromClipboard)); pToolBar->show(); } else { if (resignFirstResponder()) { hideTextSelView(); } else { becomeFirstResponder(); } } return true; }
void printTypes(const char *label, const DOMNode *node, int indent = 0) { if(indent == 0) std::cerr << "\n"; if(node->getNodeType() == DOMNode::ELEMENT_NODE) { const XMLCh *typeURI, *typeName; XercesNodeImpl::typeUriAndName(node, typeURI, typeName); std::cerr << label << ":" << std::string(indent * 2, ' ') << "name: {" << UTF8(node->getNamespaceURI()) << "}" << UTF8(Axis::getLocalName(node)) << ", type: {" << UTF8(typeURI) << "}" << UTF8(typeName) << "\n"; DOMNode *child = node->getFirstChild(); while(child) { printTypes(label, child, indent + 1); child = child->getNextSibling(); } } }
void CATextView::ccTouchPress(CATouch *pTouch, CAEvent *pEvent) { if (m_pTextSelView->isTextViewShow()) return; CATextToolBarView *pToolBar = CATextToolBarView::create(); if (m_szText.empty()) { pToolBar->addButton(UTF8("\u7c98\u8d34"), this, callfunc_selector(CATextView::ccPasteFromClipboard)); } else { pToolBar->addButton(UTF8("\u7c98\u8d34"), this, callfunc_selector(CATextView::ccPasteFromClipboard)); pToolBar->addButton(UTF8("\u5168\u9009"), this, callfunc_selector(CATextView::ccSelectAll)); pToolBar->addButton(UTF8("\u9009\u62e9"), this, callfunc_selector(CATextView::ccStartSelect)); } pToolBar->show(); }
void CALabel::ccTouchPress(CATouch *pTouch, CAEvent *pEvent) { if (m_bEnableCopy) { CATextToolBarView *pToolBar = CATextToolBarView::create(); pToolBar->addButton(UTF8("\u590d\u5236"), this, callfunc_selector(CALabel::copySelectText)); pToolBar->show(); } }
void EffectParameter::write(const Uint16StringMap &array_layers, const ShaderVersionType version, const EffectQualityType quality, const EffectChangeType change, StringUint16Map ¶meters, ShaderSourceParameterVector &vertex_parameters, ShaderSourceParameterVector &fragment_parameters, OutStream &vertex_str, OutStream &fragment_str, UuidSet &vertex_written, UuidSet &fragment_written) const { ShaderSourceParameterVector &shader_parameters = change == ect_fragment ? fragment_parameters : vertex_parameters; switch (get_type()) { case ept_position: ShaderSourceParameterBuilder::add_parameter( String(UTF8("EffectParameter")), cpt_world_position, pqt_in, shader_parameters); break; case ept_normal: ShaderSourceParameterBuilder::add_parameter( String(UTF8("EffectParameter")), cpt_world_normal, pqt_in, shader_parameters); break; case ept_tangent: ShaderSourceParameterBuilder::add_parameter( String(UTF8("EffectParameter")), cpt_world_tangent, pqt_in, shader_parameters); break; case ept_view_direction: ShaderSourceParameterBuilder::add_parameter( String(UTF8("EffectParameter")), cpt_world_view_direction, pqt_in, fragment_parameters); break; case ept_uv: ShaderSourceParameterBuilder::add_parameter( String(UTF8("EffectParameter")), cpt_world_uv, pqt_in, shader_parameters); break; case ept_fragment_coordinate: break; case ept_time: ShaderSourceParameterBuilder::add_parameter( String(UTF8("EffectParameter")), apt_time, shader_parameters); break; case ept_camera: ShaderSourceParameterBuilder::add_parameter( String(UTF8("EffectParameter")), apt_camera, shader_parameters); break; } }
int FPID::Parse( const UTF8& aId ) { clear(); const char* buffer = aId.c_str(); const char* rev = EndsWithRev( buffer, buffer+aId.length(), '/' ); size_t revNdx; size_t partNdx; int offset; //=====<revision>========================================= // in a FPID like discret:R3/rev4 if( rev ) { revNdx = rev - buffer; // no need to check revision, EndsWithRev did that. revision = aId.substr( revNdx ); --revNdx; // back up to omit the '/' which precedes the rev } else { revNdx = aId.size(); } //=====<nickname>========================================== if( ( partNdx = aId.find( ':' ) ) != aId.npos ) { offset = SetLibNickname( aId.substr( 0, partNdx ) ); if( offset > -1 ) { return offset; } ++partNdx; // skip ':' } else { partNdx = 0; } //=====<footprint name>==================================== if( partNdx >= revNdx ) return partNdx; // Error: no footprint name. // Be sure the footprint name is valid. // Some chars can be found in board file (in old board files // or converted files from an other EDA tool std::string fpname = aId.substr( partNdx, revNdx-partNdx ); ReplaceIllegalFileNameChars( &fpname, '_' ); SetFootprintName( UTF8( fpname ) ); return -1; }
bool XmlUtil::get_bool_property(const xmlNodePtr node, const String &property) { const xmlAttr *attr; if (node == 0) { EL_THROW_EXCEPTION(InvalidParameterException() << errinfo_message(UTF8("parameter is zero")) << errinfo_parameter_name(UTF8("node"))); } for (attr = node->properties; attr; attr = attr->next) { if ((attr->type == XML_ATTRIBUTE_NODE) && (xmlStrcasecmp(attr->name, BAD_CAST property.get().c_str()) == 0)) { if (attr->children == 0) { return false; } if (xmlStrcmp(attr->children->content, BAD_CAST UTF8("true")) == 0) { return true; } if (xmlStrcmp(attr->children->content, BAD_CAST UTF8("yes")) == 0) { return true; } if (xmlStrcmp(attr->children->content, BAD_CAST UTF8("false")) == 0) { return false; } if (xmlStrcmp(attr->children->content, BAD_CAST UTF8("no")) == 0) { return false; } return boost::lexical_cast<bool>( attr->children->content); } } EL_THROW_EXCEPTION(ItemNotFoundException() << errinfo_message(UTF8("Property not found")) << errinfo_item_name(property) << errinfo_parameter_name((char*)node->name)); }
static __forceinline String^ HEX(const byte *bytes, int count) { char result[41]; result[40] = '\0'; char *current = result; for(int i = 0; i < count; i++) { sprintf(current, "%02X", bytes[i]); current += 2; } return UTF8(result); }
int sceCccStrlenUTF8(u32 strAddr) { const auto str = PSPConstCharPointer::Create(strAddr); if (!str.IsValid()) { ERROR_LOG(HLE, "sceCccStrlenUTF8(%08x): invalid pointer", strAddr); return 0; } DEBUG_LOG(HLE, "sceCccStrlenUTF8(%08x): invalid pointer", strAddr); return UTF8(str).length(); }
void registerViewController::loadTopBar(){ CABarButtonItem* leftItem = CABarButtonItem::create("", CAImage::create("image/btn_left.png"), CAImage::create("image/btn_left.png")); leftItem->setTarget(this, CAControl_selector(registerViewController::backButton)); CANavigationBarItem* barItem = CANavigationBarItem::create(""); barItem->addLeftButtonItem(leftItem); barItem->setTitle(UTF8("注册")); this->setNavigationBarItem(barItem); this->getNavigationController()->setNavigationBarBackGroundColor(CAColor_black); }
int CMsnProto::OnDbSettingChanged(WPARAM hContact, LPARAM lParam) { DBCONTACTWRITESETTING* cws = (DBCONTACTWRITESETTING*)lParam; if (!msnLoggedIn || MyOptions.netId != NETID_MSN) return 0; if (hContact == NULL) { if (MyOptions.SlowSend && strcmp(cws->szSetting, "MessageTimeout") == 0 && (strcmp(cws->szModule, "SRMM") == 0 || strcmp(cws->szModule, "SRMsg") == 0)) { if (cws->value.dVal < 60000) MessageBox(NULL, TranslateT("MSN requires message send timeout in your Message window plugin to be not less then 60 sec. Please correct the timeout value."), TranslateT("MSN Protocol"), MB_OK | MB_ICONINFORMATION); } return 0; } if (!strcmp(cws->szSetting, "ApparentMode")) { char tEmail[MSN_MAX_EMAIL_LEN]; if (!db_get_static(hContact, m_szModuleName, "wlid", tEmail, sizeof(tEmail)) || !db_get_static(hContact, m_szModuleName, "e-mail", tEmail, sizeof(tEmail))) { bool isBlocked = Lists_IsInList(LIST_BL, tEmail); if (isBlocked && (cws->value.type == DBVT_DELETED || cws->value.wVal == 0)) { MSN_AddUser(hContact, tEmail, 0, LIST_BL + LIST_REMOVE); MSN_AddUser(hContact, tEmail, 0, LIST_AL); } else if (!isBlocked && cws->value.wVal == ID_STATUS_OFFLINE) { MSN_AddUser(hContact, tEmail, 0, LIST_AL + LIST_REMOVE); MSN_AddUser(hContact, tEmail, 0, LIST_BL); } } } if (!strcmp(cws->szSetting, "MyHandle") && !strcmp(cws->szModule, "CList")) { bool isMe = MSN_IsMeByContact(hContact); if (!isMe || !nickChg) { char szContactID[100]; if (!db_get_static(hContact, m_szModuleName, "ID", szContactID, sizeof(szContactID))) { if (cws->value.type != DBVT_DELETED) { if (cws->value.type == DBVT_UTF8) MSN_ABUpdateNick(cws->value.pszVal, szContactID); else MSN_ABUpdateNick(UTF8(cws->value.pszVal), szContactID); } else MSN_ABUpdateNick(NULL, szContactID); } if (isMe) displayEmailCount(hContact); } } return 0; }
FloatVector XmlUtil::get_float_vector(const xmlNodePtr node) { FloatVector result; StringStream values_str; String string; std::vector<std::string> values; if (node == 0) { EL_THROW_EXCEPTION(InvalidParameterException() << errinfo_message(UTF8("parameter is zero")) << errinfo_parameter_name(UTF8("node"))); } if (node->children == 0) { return result; } values_str << node->children->content; string = String(values_str.str()); boost::split(values, string.get(), boost::is_any_of(UTF8("\n\t ")), boost::token_compress_on); BOOST_FOREACH(const std::string &value, values) { StringStream str; float tmp; if (value.empty()) { continue; } str << value; str >> tmp; result.push_back(tmp); }
/** * Converts to unsigned rg 16 bit image */ ImageSharedPtr UvTool::convert(glm::vec4 &dudv_scale_offset) const { ImageSharedPtr dudv_map; dudv_map = boost::make_shared<Image>(String(UTF8("Dudv map")), false, tft_rg16, glm::uvec3(m_width, m_height, 0), 0, false); convert(dudv_map, dudv_scale_offset); return dudv_map; }