哦,这个时候提及国际法了啊!难道你老人家忘记前不久的至理名言了吗?“不要拿法律当挡箭牌”啊!
看完内容就得看评论嘛!到目前为止,有850人参与,跟贴218条,却仅仅显示了四条回复。这个嘛,这个,这个,这个......
Keep logging what I am interested in
我们已经在17个省全部取消了政府还贷的二级公路收费站点,撤销站点1723个,总里程9万公里,这其中解决了40万人过去收费和征稽人员的分流安置工作算一算,光是这么些个二级公路,每个收费站养活了232个人,每公里更是养活了4.4个人,厉害啊!
struct Data {
QBasicAtomicInt ref; // reference count, the operation on it is atomic
int alloc; // allocated space for the data
int size; // actual size of the data, not counting the ending '\0' added by QByteArray
char *data; // point to the data
char array[1]; // where the data is stored, and the data always end with '\0'
};QByteArray &QByteArray::operator=(const QByteArray & other)
{
// increase the reference count of the shared data it's supposed to be used
other.d->ref.ref();
// decrease the reference count of the share data currently used, and free it if no one else is using
if (!d->ref.deref())
qFree(d);
// point to the shared data
d = other.d;
return *this;
}void QByteArray::resize(int size)
{
if (size <= 0) {
// if the target is no bigger than 0, points to an empty data block
Data *x = &shared_empty;
x->ref.ref();
if (!d->ref.deref())
qFree(d);
d = x;
} else if (d == &shared_null) {
// if currently a null array, just create a new data block
Data *x = static_cast<data *>(qMalloc(sizeof(Data)+size));
Q_CHECK_PTR(x);
x->ref = 1;
x->alloc = x->size = size;
x->data = x->array;
x->array[size] = '\0';
(void) d->ref.deref();
d = x;
} else {
// if any other object uses this data block, or the current memory is too small or too big
// reallocate space, and copy the data for it
// note that this operation might consume some time if the data is huge
if (d->ref != 1 || size > d->alloc || (size < d->size && size < d->alloc >> 1))
realloc(qAllocMore(size, sizeof(Data)));
if (d->alloc >= size) {
d->size = size;
if (d->data == d->array) {
d->array[size] = '\0';
}
}
}
}// first implement your data object inheriting from QSharedData, which provides the reference count
class SharedData: public QSharedData
{
public:
SharedData()
: QSharedData()
, var(0)
{}
SharedData(const SharedData &other)
: QSharedData(other)
, var(other.var)
{}
int var;
};
// then the data owner
class DataOwner
{
public:
DataOwner()
: d(new SharedData)
{}
DataOwner(int var)
: d(new SharedData)
{
// for write access, the -> operator will automatically copy the shared data if needed
d->var = var;
}
private:
// this template class hides all the details for implicit sharing
// therefore, no need to provide copy constructor or assignment operator
QSharedDataPointer<SharedData> d;
};
QObject obj;
const QMetaObject *metaObj = obj.metaObject();
qDebug() << "class name: " << metaObj->className();
qDebug() << "class info count: " << metaObj->classInfoCount();
qDebug() << "methods: ";
// starting from QMetaObject::methodOffset() so it won't display the methods inherited
for (int i = metaObj->methodOffset(); i < metaObj->methodCount(); ++i)
qDebug() << metaObj->method(i).methodType() << " " << metaObj->method(i).signature();class MyObject : public QObject
{
Q_OBJECT
public:
explicit MyObject(QObject *parent = 0);
void myFunc();
public slots:
void mySlot(int myParam);
signals:
void mySignal(int myParam);
};// pointed by QMetaObject::d.data, the beginning stored "as" a QMetaObjectPrivate struct
static const uint qt_meta_data_MyObject[] = {
5, // revision, the internals have been changed several times
0, // classname, offset of qt_meta_stringdata_MyObject
// the following are defined as (number, index) pair
0, 0, // classinfo
2, 14, // we have two methods, starting at index 14 (i.e. the signal)
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
1, // signal counts
// for signals slots, and properties, the signatures and parameters are offset of qt_meta_stringdata_MyObject
// signals: signature, parameters, type, tag, flags
18, 10, 9, 9, 0x05,
// slots: signature, parameters, type, tag, flags
32, 10, 9, 9, 0x0a,
0 // eod
};
// pointed by QMetaObject::d.stringdata
static const char qt_meta_stringdata_MyObject[] = {
"MyObject\0\0myParam\0mySignal(int)\0"
"mySlot(int)\0"
};const QMetaObject MyObject::staticMetaObject = {
{ &QObject::staticMetaObject, // pointer to its base class, stored at QMetaObject::d.superdata
qt_meta_stringdata_MyObject, qt_meta_data_MyObject, 0 }
};template <class T> inline T qobject_cast(QObject *object)
{
#if !defined(QT_NO_QOBJECT_CHECK)
reinterpret_cast(0)->qt_check_for_QOBJECT_macro(*reinterpret_cast(object));
#endif
return static_cast(reinterpret_cast(0)->staticMetaObject.cast(object));
} const QObject *QMetaObject::cast(const QObject *obj) const
{
if (obj) {
const QMetaObject *m = obj->metaObject();
do {
if (m == this)
return obj;
} while ((m = m->d.superdata));
}
return 0;
}void MyObject::mySignal(int _t1)
{
void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
// it checks all the connected slots, and call each of them based on the connection type
QMetaObject::activate(this, &staticMetaObject, 0, _a);
}int MyObject::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
// if this function is called by the super class, just return
_id = QObject::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
// call the function based on its ID
if (_c == QMetaObject::InvokeMetaMethod) {
switch (_id) {
case 0: mySignal((*reinterpret_cast< int(*)>(_a[1]))); break;
case 1: mySlot((*reinterpret_cast< int(*)>(_a[1]))); break;
default: ;
}
// remove the IDs "consumed" by this class so that in its subclass the ID always starts with 0, and the return value of -1 means already consumed
_id -= 2;
}
return _id;
}