A
A
Armen2016-01-21 13:19:00
Qt
Armen, 2016-01-21 13:19:00

How to store records from the VK wall?

Good afternoon! I am making a small mobile application and it became necessary to get a list of records with all attachments from the VK wall.
Comes to mind QList <QList <QMap <QString, QString> > >.
That is:
Text, objects (music, pictures, video) are stored each in a separate QMap <QString, QString>, from this it turns out that each entry from the wall is QList <QMap <QString, QString> >, and, accordingly, the list of entries is QList <QList <QMap <QString, QString> > >.
Isn't it very cumbersome and resource-intensive in terms of performance?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Mercury13, 2016-01-21
@Mercury13

Not cumbersome and not resource-intensive (especially in C ++ 11 - by the way, Qt will soon abandon 03 altogether).
However, I would make structs from one element in such heaps. Something like

struct Comment {
  QMap<QString, QString> objects;
};

struct Post {
   QList<Comment> comments;
};

This will make the code easier to parse.
Only one thing is unclear. What are these objectsand what do you need this "string typing" for?

A
Anatoly Medvedev, 2016-01-21
@balamyt92

If to store, it is better in a DB.

A
AtomKrieg, 2016-01-21
@AtomKrieg

The performance of containers depends on the operations that are performed on them.
The List is fast to insert and quickly traverse in order, but if you need to access an element in the middle of the container, it will take a long time. In a normal Map, access complexity grows logarithmically with size - HashMap is spared this shortcoming. Mercury13 correctly tells you that data structures should be removed for class abstraction:

class VKWall {
public: 
  Add(VKWallPost&& wp);
private:
   QList<VKWallPost> m_posts;
};

If you run into performance issues (only if you do) and changing containers in wrapper classes doesn't help, then consider tabular storage:
stuct vkobj {unsigned wallpost_id, char[255] key, char[255] value};
QVector<vkobj> m_posts;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question