本文整理汇总了C++中StringPtr类的典型用法代码示例。如果您正苦于以下问题:C++ StringPtr类的具体用法?C++ StringPtr怎么用?C++ StringPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StringPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Q_ASSERT
ObjectPtr StringDialog::createNewGeneratedString(){
Q_ASSERT(_document && _document->objectStore());
QString value = _stringTab->value();
// qDebug() << "Creating new string ===>"
// << "\n\ttag:" << DataDialog::tagString()
// << "\n\tvalue:" << value
// << endl;
StringPtr string = _document->objectStore()->createObject<String>();
string->setValue(value);
string->setOrphan(true);
string->setEditable(true);
if (DataDialog::tagStringAuto()) {
string->setDescriptiveName(QString());
} else {
string->setDescriptiveName(DataDialog::tagString());
}
string->writeLock();
string->registerChange();
string->unlock();
_dataObjectName = string->Name();
//UpdateServer::self()->requestUpdateSignal();
return static_cast<ObjectPtr>(string);
}
示例2: dataSource
void DataMatrix::_resetFieldStrings() {
const QMap<QString, QString> meta_strings = dataSource()->matrix().metaStrings(_field);
QStringList fieldStringKeys = _fieldStrings.keys();
// remove field strings that no longer need to exist
readLock();
for (int i=0; i<fieldStringKeys.count(); i++) {
QString key = fieldStringKeys.at(i);
if (!meta_strings.contains(key)) {
StringPtr sp = _fieldStrings[key];
_fieldStrings.remove(key);
sp = 0L;
}
}
// find or insert strings, to set their value
QMapIterator<QString, QString> it(meta_strings);
while (it.hasNext()) {
it.next();
QString key = it.key();
StringPtr sp;
if (!_fieldStrings.contains(key)) { // insert a new one
_fieldStrings.insert(key, sp = store()->createObject<String>());
sp->setProvider(this);
sp->setSlaveName(key);
} else { // find it
sp = _fieldStrings[key];
}
sp->setValue(it.value());
}
unlock();
}
示例3: qSort
void StringSelector::fillStrings() {
if (!_store) {
return;
}
QHash<QString, StringPtr> strings;
StringList stringList = _store->getObjects<String>();
StringList::ConstIterator it = stringList.constBegin();
for (; it != stringList.constEnd(); ++it) {
StringPtr string = (*it);
string->readLock();
strings.insert(string->CleanedName(), string);
string->unlock();
}
QStringList list = strings.keys();
qSort(list);
StringPtr current = selectedString();
_string->clear();
foreach (const QString &string, list) {
StringPtr s = strings.value(string);
_string->addItem(string, qVariantFromValue(s.data()));
}
示例4: Q_ASSERT
void BasicPlugin::setOutputString(const QString &type, const QString &name) {
QString txt = !name.isEmpty() ? name : type;
Q_ASSERT(store());
StringPtr s = store()->createObject<String>();
s->setProvider(this);
s->setSlaveName(txt);
s->setOrphan(false);
_outputStrings.insert(type, s);
}
示例5: ReplaceAll
StringPtr ReplaceAll(StringPtr str, const std::string &remove, StringPtr insert)
{
std::string::size_type pos = 0;
while ((pos = str->find(remove, pos)) != std::string::npos)
{
str->replace(pos, remove.size(), *insert);
pos++;
}
return str;
}
示例6: s
LRESULT C_SpinButton::OnTextChange(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
C_STLException::install();
try {
TCHAR t[32];
m_ed.SendMessage(WM_GETTEXT, 1023, reinterpret_cast<LPARAM>(t));
String s(t);
StringPtr ptr = s.Find(_T('-'));
if (ptr.isValid()) {
if (ptr.Index() > 0) {
s = s.Left(ptr.Index());
m_ed.SendMessage(WM_SETTEXT, s.GetLength(), reinterpret_cast<LPARAM>(s.toLPCTSTR()));
m_ed.SendMessage(EM_SETSEL, s.GetLength(), s.GetLength());
return S_OK;
}
}
float f = static_cast<float>(s.toDouble());
if (m_fValue != f) {
if (m_fMinValue == m_fMaxValue || (f >= m_fMinValue && f <= m_fMaxValue)) {
InternalSetValue(f);
FireChangeMessage();
}
else {
MessageBeep(0xFFFFFFFF);
DisplayValue();
return S_OK;
}
}
if (0 == s.GetLength()) {
DisplayValue();
}
}
catch (C_STLNonStackException const &exception) {
exception.Log(_T("Exception in C_SpinButton::"));
}
return S_OK;
}
示例7: check_starr
void check_starr(int n, const char* A[], const SA& sa) {
ASSERT_EQ(n, sa.length());
for (int i = 0; i < n; ++i) {
std::string p = sa.get_str(i);
ASSERT_EQ(p, A[i]);
}
for (int i = 0; i < n; ++i) {
StringPtr pt = sa.get(i);
unsigned slen = strlen(A[i]);
ASSERT_EQ(slen, pt->length());
ASSERT_EQ(0, strncmp(A[i], pt->c_str(), slen));
}
}
示例8: testPkt
void testPkt()
{
typedef boost::shared_ptr<FreeList<net_pk> > NetPacketFLShrPtr;
NetPacketFLShrPtr pkFL(new FreeList<net_pk>(5, 10));
sPkFList.set(pkFL);
IPacketShrPtr pk = allocPacket();
pk->setMsg(M_JUMP);
pk->put("teststring", 10);
pk->put("teststr2", 8);
StringPtr ms;
pk->get(ms, pk->getSize());
printf("pk: %s\n", ms.ptr());
printf("pk size: %d\n", pk->getSize());
printf("msg: %s\n", g_msgs[pk->getMsg()].c_str());
IPacketParserShrPtr pkpr(new packet_builder);
char str[PKT_MAX_SIZE] = "001400ACTION1#nous|1&4&5&1";
std::vector<IPacketShrPtr> pks;
pkpr->parse(str, 2, pks);
pkpr->parse(str+2, 1, pks);
pkpr->parse(str+3, 1, pks);
pkpr->parse(str+4, 2, pks);
pkpr->parse(str+6, 1, pks);
pkpr->parse(str+7, 2, pks);
pkpr->parse(str+9, 17, pks);
for (uint32 i=0; i<pks.size(); ++i)
{
StringPtr msi;
pks[i]->get(msi, pks[i]->getSize());
printf("pks[i]: %s\n", msi.ptr());
printf("pks[i] size: %d\n", pks[i]->getSize());
printf("msg: %s\n", g_msgs[pks[i]->getMsg()].c_str());
Args args_list;
packet_seer psr;
pks[i]->reset();
psr.analyse_packet(pks[i], args_list, g_spts);
std::vector<Arg>& args = args_list.argList;
for (uint32 i=0; i<args.size(); ++i)
{
printf("args[%d]: arg: %s\n", i, args[i].arg.c_str());
}
}
getchar();
}
示例9: createStringConst
// Emit constants
ValueBuilder BlockBuilder::createStringConst(const String& value) {
StringPtr type = StringType::get(getNativeContext());
// get partial types for string
llvm::Type* charType = llvm::IntegerType::get(*m_context, 16);
llvm::Type* sizeType = llvm::IntegerType::get(*m_context, 32);
llvm::ArrayType* bufferType = llvm::ArrayType::get(charType, value.length());
// generate size
llvm::Constant* size = llvm::ConstantInt::get(*m_context, llvm::APInt(32, value.length(), false));
// generate buffer
llvm::Constant* buffer = 0; {
std::vector<llvm::Constant*> bufferConst;
for (int i = 0; i < value.length(); ++i) {
UChar c = value[i];
llvm::Constant* value = llvm::ConstantInt::get(*m_context, llvm::APInt(16, c, false));
bufferConst.push_back(value);
}
buffer = llvm::ConstantArray::get(bufferType, bufferConst);
}
// generate string type
std::vector<llvm::Type*> elements;
elements.push_back(sizeType);
elements.push_back(bufferType);
llvm::StructType* stringCstType = llvm::StructType::get(*m_context, elements);
// generate string
llvm::Constant* string = llvm::ConstantStruct::get(stringCstType, size, buffer, NULL);
llvm::GlobalVariable* stringCst = new llvm::GlobalVariable(
*m_module,
stringCstType,
true,
llvm::GlobalValue::PrivateLinkage,
string,
"string.cst"
);
stringCst->setUnnamedAddr(true); // Binary equal strings must be merged
llvm::Type* stringType = type->getMetadata()->getBackendVariableType();
llvm::Value* result = new llvm::BitCastInst(stringCst, stringType, "string.val", m_block);
return ValueBuilder(*this, result, type);
}
示例10: setSelectedString
void StringSelector::setSelectedString(StringPtr selectedString) {
int i=-1;
for (int j=0; j<_string->count() ; ++j) {
if (selectedString.data() == _string->itemData(j).value<String*>()) {
i=j;
break;
}
}
Q_ASSERT(i != -1);
_string->setCurrentIndex(i);
}
示例11: setSelectedString
void StringSelector::setSelectedString(StringPtr selectedString) {
int i=-1,j;
for (j=0; j<_string->count() ; j++) {
if (selectedString.data() == (qVariantValue<String*>(_string->itemData(j)))) {
i=j;
break;
}
}
Q_ASSERT(i != -1);
_string->setCurrentIndex(i);
}
示例12: jsonPtr
ParsedEntity::ParsedEntity(StringPtr content)
{
const char * cContent = content->c_str();
shared_ptr<cJSON> jsonPtr(cJSON_Parse(cContent), null_deleter());
json.swap(jsonPtr);
if(json && json->string)
{
key = MakeStringPtr(json->string);
}
else
{
key = MakeStringPtr("");
}
type = determineType();
}
示例13: getObjectValue
ParsedEntityPtr ParsedEntity::getObjectValue(StringPtr key)
{
cJSONPtr ret(cJSON_GetObjectItem(json.get(), key->c_str()), null_deleter());
return MakeParsedEntity(ret);
}
示例14: foreach
foreach (StringPtr P, _inputStrings) {
minSerial = qMin(minSerial, P->serial());
}
示例15: s
STDMETHODIMP C_Items::Retrieve(I_Archive * arc)
{
if (!arc)
return E_POINTER;
C_STLException::install();
//TODO - templatize this function and stick it in a base class.
try {
BSTR bs = NULL;
unsigned int len = 0;
if (S_OK != arc->RetrieveString(&bs)) {
return E_FAIL;
}
String s(bs);
s.toLower();
String::FreeBSTR(&bs);
static String tags[5] = {
_T("mmp:item"),
_T("mmp:text"),
_T("mmp:node"),
_T("mmp:picture"),
_T("mmp:branch")
};
typedef enum ematches {
plainitem,
text,
node,
picture,
branch
};
static String types[4] = {
_T("node"),
_T("text-block"),
_T("picture"),
_T("branch")
};
ematches match = plainitem;
CLSID clsid;
IID iid;
StringPtr ptr(s.Find(tags[plainitem]));
StringPtr ptrKill(s.Find(tags[plainitem]));
for (unsigned int test = plainitem; test <= branch; test++) {
ptr = s.Find(tags[test]);
if (ptr.isValid()) {
ptrKill = s.Find(String(_T("/")) + tags[test]);
match = static_cast<ematches>(test);
break;
}
}
switch (match) {
case node:
clsid = CLSID_Node;
iid = IID_I_Node;
break;
case text:
clsid = CLSID_TextBlock;
iid = IID_I_TextBlock;
break;
case picture:
clsid = CLSID_Picture;
iid = IID_I_Picture;
break;
case branch:
clsid = CLSID_Branch;
iid = IID_I_Branch;
break;
}
while (ptr.isValid() && !ptrKill.isValid()) {//Check this is the start of an item...
C_ItemPtr item;
/////////////////////////////////////////////////////
// In a paste operation, the object's GUID must be ignored
// - a new object is being created with its own identity.
BOOL b = FALSE;
BOOL bPreserveID = TRUE;
BSTR bs = NULL;
arc->get_PreserveIdentities(&bPreserveID);
if (bPreserveID) {
/////////////////////////////////////////////////////
//.........这里部分代码省略.........