Ejemplo n.º 1
0
listtable* parseQueries(listtable* tbl, const char* query, char equalchar, char sepchar, int* count) {

	if (tbl == NULL && (tbl = listTable(0)) == NULL) {
		return NULL;
	}

	if (query == NULL) {
		return tbl;
	}

	int cnt			= 0;
	char* newquery	= strdup(query);

	while (newquery && *newquery) {

		char* value	= makeword(newquery, sepchar);
		char* name	= strTrim(makeword(value, equalchar));

		urlDecode(name);
		urlDecode(value);

		if (tbl->putstr(tbl, name, value) == true) {
			cnt++;
		}

		free(name);
		free(value);
	}

	if (count != NULL) {
		*count = cnt;
	}

	free(newquery);

	return tbl;
}
OSG_BEGIN_NAMESPACE

/***************************************************************************\
 *                            Description                                  *
\***************************************************************************/

/***************************************************************************\
 *                           Class variables                               *
\***************************************************************************/

/***************************************************************************\
 *                           Class methods                                 *
\***************************************************************************/

/***************************************************************************\
 *                           Instance methods                              *
\***************************************************************************/

// store information about Lua value present at the 'index' inside 'v' struct
void lua_details::Value::capture(lua_State* L, int index, int recursive, size_t table_size_limit)
{
    int i= index;

    int t= lua_type(L, i);

    switch (t)
    {
    case LUA_TSTRING:
        _Type = String;
        _Value = lua_tostring(L, i);
        break;

    case LUA_TBOOLEAN:
        _Type = Bool;
        _Value = lua_toboolean(L, i) ? "true" : "false";
        break;

    case LUA_TNUMBER:
        _Type = Number;
        _Value = boost::lexical_cast<std::string>(lua_tonumber(L, i));
        break;

    case LUA_TLIGHTUSERDATA:
        _Type = LightUserData;
        _Value = "0x" + boost::lexical_cast<std::string>(lua_topointer(L, i));
        break;

    case LUA_TUSERDATA:
        _Type = UserData;
        _Value = "0x" + boost::lexical_cast<std::string>(lua_topointer(L, i));
        break;

    case LUA_TTABLE:
        _Type = Table;
        if (recursive > 0)
        {
            TableInfo t;
            listTable(L, i, t, recursive - 1);
            _Value = tableAsString(t, table_size_limit);
        }
        else
            _Value = "0x" + boost::lexical_cast<std::string>(lua_topointer(L, i));
        break;

    case LUA_TFUNCTION:
        _Type = Function;
        _Value = "0x" + boost::lexical_cast<std::string>(lua_topointer(L, i));
        break;

    case LUA_TTHREAD:
        _Type = Thread;
        _Value = "0x" + boost::lexical_cast<std::string>(lua_topointer(L, i));
        break;

    case LUA_TNIL:
        _Type = Nil;
        _Value.clear();
        break;

    default:
        _Type = None;
        _Value.clear();
        break;
    }

    _TypeName = lua_typename(L, t);
}
Ejemplo n.º 3
0
void SizPostForm::addRecordOfTablePost()
{
    QTextStream stream(&exchangeFile);
    QString line;
    while(!stream.atEnd()){
        stream.readLine();
    }
    if(checkingFill()){
        ViewListTable listTable("","post",this);
        listTable.exec();
        QString postId = listTable.returnValue();

        QSqlQuery query;
        query.prepare("SELECT * FROM post WHERE postid = :id");
        query.bindValue(":id",postId);
        query.exec();
        while(query.next()){
            int rowCount = postView->rowCount();
            bool insert = true;
            //Проверка на существование записи
            if (rowCount != 0){
                for(int kk = 0; kk < rowCount; ++kk){
                    QString yy = postView->item(kk,2)->text();
                    QString pp = query.value(1).toString();
                    if(yy == pp){
                        QString tempString = query.value(1).toString();
                        tempString += QObject::trUtf8(" is availble!");
                        QMessageBox::warning(this,QObject::trUtf8("Atention!!!"),tempString);
                        insert = false;
                        break;
                    }
                }
            }
            if(insert){
                addIntoTable = true;
                postView->insertRow(rowCount);

                NumPrefix numPrefix;
                QString idPostSizList = numPrefix.getPrefix("postsizlist");

                QTableWidgetItem *itemID = new QTableWidgetItem;
                postView->setItem(rowCount,0,itemID);
                postView->item(rowCount,0)->setText(idPostSizList);

                QTableWidgetItem *itemPostSiz = new QTableWidgetItem;
                postView->setItem(rowCount,1,itemPostSiz);
                postView->item(rowCount,1)->setText(indexTemp);

                QTableWidgetItem *itemPost = new QTableWidgetItem;
                postView->setItem(rowCount,2,itemPost);
                postView->item(rowCount,2)->setText(query.value(1).toString());

                QSqlQuery queryPSL;
                queryPSL.prepare("INSERT INTO postsizlist ("
                                 "postsizlistid, postsizid, postid"
                                 ") VALUES(:postsizlistid, :postsizid, :postid)");
                queryPSL.bindValue(":postsizlistid",idPostSizList);
                queryPSL.bindValue(":postsizid",indexTemp);
                queryPSL.bindValue(":postid",query.value(0).toString());
                queryPSL.exec();
                if(!queryPSL.isActive()){
                    QMessageBox::warning(this,QObject::trUtf8("Post SIZ List Table, INSERT ERROR!"),queryPSL.lastError().text());
                    return;
                }
                line += "INSERT INTO postsizlist (postsizlistid, postsizid, postid) VALUES('";
                line += idPostSizList.toUtf8();
                line += "', '";
                line += indexTemp.toUtf8();
                line += "', '";
                line += query.value(0).toString().toUtf8();
                line += "')";
                line += "\r\n";
                stream<<line;
            }
        }
    }
}