Base class to manipulate the RISC OS boot options files in Choices.
More...
#include <boot_options_file.h>
|
class | commit_error |
| An exception class for reporting failure to commit a boot options file. More...
|
|
|
| boot_options_file (const char *file_name, const char *section_prefix, const char *section_version, const char *section_suffix, const char *command, const char *command2=0) |
| Construct boot_options_file object by setting parameters for the options file it will edit. More...
|
|
virtual | ~boot_options_file () |
|
void | rollback () |
| Discard any changes and reload the file. More...
|
|
void | commit () |
| Commit any changes to the file. More...
|
|
bool | contains (const std::string &app) const |
| Check if application is contained in the look ups. More...
|
|
bool | add (const std::string &app) |
| Add application to up section. More...
|
|
bool | remove (const std::string &app) |
| Remove application from section. More...
|
|
bool | replace (const std::string &was_app, const std::string &app) |
| Replace an application. More...
|
|
const std::string & | read_pathname () const |
| The path name to the location of the PreDesk file that contains the look at declarations for reading. More...
|
|
const std::string & | write_pathname () const |
| The path name to the location of the PreDesk file that any changes to the look at declarations will be written to. More...
|
|
void | use_test_pathname (const std::string &pathname) |
| Change the path name for read or write. More...
|
|
bool | has_section () const |
| See if file has the section defined. More...
|
|
bool | modified () const |
|
bool | contains_raw (const std::string &app) const |
| Check if exact name is contained in the look ups. More...
|
|
void | dump_apps () const |
| Dump apps array to cout - debugging helper. More...
|
|
Base class to manipulate the RISC OS boot options files in Choices.
pkg::boot_options_file::boot_options_file |
( |
const char * |
file_name, |
|
|
const char * |
section_prefix, |
|
|
const char * |
section_version, |
|
|
const char * |
section_suffix, |
|
|
const char * |
command, |
|
|
const char * |
command2 = 0 |
|
) |
| |
Construct boot_options_file object by setting parameters for the options file it will edit.
- Parameters
-
file_name | Choices file name to be updated |
section_prefix | prefix for section title |
section_version | section version |
section_suffix | suffix for section title |
command | command to write to section |
command2 | optional second command for section |
References rollback().
pkg::boot_options_file::~boot_options_file |
( |
| ) |
|
|
virtual |
void pkg::boot_options_file::rollback |
( |
| ) |
|
void pkg::boot_options_file::commit |
( |
| ) |
|
bool pkg::boot_options_file::contains |
( |
const std::string & |
app | ) |
const |
Check if application is contained in the look ups.
- Parameters
-
- Returns
- true if application is contained in the look ups
References name_in_section().
bool pkg::boot_options_file::add |
( |
const std::string & |
app | ) |
|
Add application to up section.
- Parameters
-
app | name of application to add |
- Returns
- true if app was added, false if it's already there.
References name_in_section().
Referenced by pkg::commit::poll().
bool pkg::boot_options_file::remove |
( |
const std::string & |
app | ) |
|
Remove application from section.
- Parameters
-
app | name of application to remove |
- Returns
- true if application was found and removed
References name_in_section().
Referenced by pkg::commit::poll().
bool pkg::boot_options_file::replace |
( |
const std::string & |
was_app, |
|
|
const std::string & |
app |
|
) |
| |
Replace an application.
- Parameters
-
was_app | application to replace |
app | application to replace it with |
- Returns
- true if the replace was done
References name_in_section().
const std::string& pkg::boot_options_file::read_pathname |
( |
| ) |
const |
|
inline |
The path name to the location of the PreDesk file that contains the look at declarations for reading.
const std::string& pkg::boot_options_file::write_pathname |
( |
| ) |
const |
|
inline |
The path name to the location of the PreDesk file that any changes to the look at declarations will be written to.
void pkg::boot_options_file::use_test_pathname |
( |
const std::string & |
pathname | ) |
|
Change the path name for read or write.
This method is for unit testing and would not normally be used. call rollback() to read the test file after this method.
bool pkg::boot_options_file::has_section |
( |
| ) |
const |
See if file has the section defined.
bool pkg::boot_options_file::modified |
( |
| ) |
const |
|
inline |
bool pkg::boot_options_file::contains_raw |
( |
const std::string & |
app | ) |
const |
Check if exact name is contained in the look ups.
Used for Unit testing to check that entries of format "Boot:^..."
- Parameters
-
app | application to check (is not standardized) |
- Returns
- true if application is contained in the look ups
void pkg::boot_options_file::dump_apps |
( |
| ) |
const |
Dump apps array to cout - debugging helper.
virtual char* pkg::boot_options_file::find_insert_section |
( |
| ) |
|
|
protectedpure virtual |
char * pkg::boot_options_file::find_section |
( |
const char * |
name, |
|
|
const char * |
suffix |
|
) |
| |
|
protected |
void pkg::boot_options_file::parse_section |
( |
| ) |
|
|
protected |
bool pkg::boot_options_file::parse_word |
( |
char *& |
pos, |
|
|
std::string & |
word |
|
) |
| const |
|
protected |
Parse a single word from the given location.
Skips spaces, then a word is defined until the next space, char 0 or line feed.
- Parameters
-
pos | location to start parsing - updated to position of character after word |
word | parsed out (empty if at end of line) |
- Returns
- true if a word is found.
Referenced by parse_section().
char * pkg::boot_options_file::find_section_end |
( |
char * |
section | ) |
const |
|
protected |
Find the end of the section.
- Parameters
-
section | location in section to find |
- Returns
- section end or 0 if not found
Referenced by commit().
char * pkg::boot_options_file::next_line |
( |
char * |
line | ) |
const |
|
protected |
Return adress of start of next line.
- Parameters
-
line | line to find next line for |
- Returns
- start of next line
Referenced by commit().
std::string pkg::boot_options_file::name_in_section |
( |
const std::string & |
app | ) |
const |
|
protected |
Generate the name used in the file.
This usually involves replacing the start with Boot:^ if it's on the boot drive
- Parameters
-
- Returns
- name that will be stored in the file
References pkg::canonicalise().
Referenced by add(), contains(), remove(), and replace().
The documentation for this class was generated from the following files: