Browse Source

Added Jupiter::remove() functions for removing sections.

release/0.19
JustinAJ 10 years ago
parent
commit
2ec8cc41a1
  1. 25
      Jupiter/INIFile.cpp
  2. 10
      Jupiter/INIFile.h
  3. BIN
      Release/Jupiter.lib

25
Jupiter/INIFile.cpp

@ -459,6 +459,31 @@ bool Jupiter::INIFile::remove(const Jupiter::ReadableString &section, const Jupi
return false;
}
bool Jupiter::INIFile::remove(size_t section_index)
{
delete Jupiter::INIFile::data_->data.remove(section_index);
return true;
}
bool Jupiter::INIFile::remove(const Jupiter::INIFile::Section *section)
{
size_t i = Jupiter::INIFile::data_->data.size();
while (i != 0)
if (Jupiter::INIFile::data_->data.get(--i) == section)
return Jupiter::INIFile::remove(i);
return false;
}
bool Jupiter::INIFile::remove(const Jupiter::ReadableString &section)
{
unsigned int nameSum = section.calcChecksumi();
size_t i = Jupiter::INIFile::data_->data.size();
while (i != 0)
if (Jupiter::INIFile::data_->data.get(--i)->getNameChecksum() == nameSum && Jupiter::INIFile::data_->data.get(i)->getName().equalsi(section))
return Jupiter::INIFile::remove(i);
return false;
}
size_t Jupiter::INIFile::getSections() const
{
return Jupiter::INIFile::data_->data.size();

10
Jupiter/INIFile.h

@ -339,6 +339,16 @@ namespace Jupiter
*/
bool remove(const Jupiter::ReadableString &section, const Jupiter::ReadableString &keyName);
/**
* @brief Removes a section. Does not modify any files.
*
* @param section Section to remove.
* @return True if a section was removed, false otherwise.
*/
bool remove(size_t section_index);
bool remove(const Jupiter::INIFile::Section *section);
bool remove(const Jupiter::ReadableString &section);
/**
* @brief Returns the number of sections in memory.
*

BIN
Release/Jupiter.lib

Binary file not shown.
Loading…
Cancel
Save