Why does table and tablebuilder in leveldb use struct rep?

I recently read the leveldb source code, but I'm confused about the rep structure in the table source and table_builder.

since we can directly store the member variable directly in the Table class and the TableBuilder class.

But why does the author create the Rep structure and save the member variable in the Rep structure.

I can come up for one reason, because the table and table_builder are exposed to the user, so we want to hide the implementation. It is right? or is there some other idea I'm missing, or is it some kind of design template?

thanks

+4
source share
1 answer

, table.h, table_builder.h

class Table 
{
    ...
    struct Rep;
    Rep* rep_;
    ...
};

, , , :

  • table.h table_builder.h leveldb;
  • , ;
  • , , Rep, ( ), ( );
  • , pImpl idiom ( pImpl) .

, , . , Table table.h, userdb , table.h, , .

, leveldb leveldb. , leveldb ( ) , leveldb , : leveldb.

, .

+4

Source: https://habr.com/ru/post/1613760/


All Articles