dxflib is an open source C++ library mainly for parsing DXFTM files. QCAD, CAM Expert and vec2web all use dxflib to import DXF files. dxflib can also write DXF files, but you need to have good knowledge of the DXF format to produce valid output.
dxflib parses DXF files and calls functions in your class. In those functions you can for example add the entities to an entity container.