Add removeObject() method to parser

This commit is contained in:
Grégory Soutadé 2024-03-23 18:28:23 +01:00
parent c5ce75b9ee
commit 6060d12344
2 changed files with 21 additions and 1 deletions

View File

@ -81,6 +81,11 @@ namespace uPDFParser
*/
void addObject(Object* object) { _objects.push_back(object); }
/**
* @brief Remove an object from list and crefTable
*/
void removeObject(Object* object);
/**
* @brief Return trailer object
*/
@ -88,7 +93,7 @@ namespace uPDFParser
/**
* @brief Return xref table. This table is read and updated only once after parse
* Further add/delete will make it incoherent
* It's not used for write operation
*/
const std::vector<XRefValue>& xrefTable() {return _xrefTable;}

View File

@ -847,6 +847,21 @@ namespace uPDFParser
}
}
void Parser::removeObject(Object* object)
{
std::vector<Object*>::iterator it;
for(it = _objects.begin(); it != _objects.end(); it++)
{
if (**it == *object)
{
delete *it;
_objects.erase(it);
break;
}
}
}
void Parser::writeBuffer(int fd, const char* buffer, int size)
{
int ret;