Skip to content

Commit

Permalink
Added flipper_format_write_empty_line(...) (#4029)
Browse files Browse the repository at this point in the history
* Added flipper_format_write_empty_line(...)
* Format sources

Co-authored-by: Aleksandr Kutuzov <[email protected]>
  • Loading branch information
janwiesemann and skotopes authored Dec 23, 2024
1 parent dc73096 commit e11a626
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ static bool test_write(const char* file_name) {
if(!flipper_format_file_open_always(file, file_name)) break;
if(!flipper_format_write_header_cstr(file, test_filetype, test_version)) break;
if(!flipper_format_write_comment_cstr(file, "This is comment")) break;
if(!flipper_format_write_empty_line(file)) break;
if(!flipper_format_write_string_cstr(file, test_string_key, test_string_data)) break;
if(!flipper_format_write_int32(file, test_int_key, test_int_data, COUNT_OF(test_int_data)))
break;
Expand Down
5 changes: 5 additions & 0 deletions lib/flipper_format/flipper_format.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,11 @@ bool flipper_format_write_comment_cstr(FlipperFormat* flipper_format, const char
return flipper_format_stream_write_comment_cstr(flipper_format->stream, data);
}

bool flipper_format_write_empty_line(FlipperFormat* flipper_format) {
furi_check(flipper_format);
return flipper_format_stream_write_eol(flipper_format->stream);
}

bool flipper_format_delete_key(FlipperFormat* flipper_format, const char* key) {
furi_check(flipper_format);
FlipperStreamWriteData write_data = {
Expand Down
8 changes: 8 additions & 0 deletions lib/flipper_format/flipper_format.h
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,14 @@ bool flipper_format_write_comment(FlipperFormat* flipper_format, FuriString* dat
*/
bool flipper_format_write_comment_cstr(FlipperFormat* flipper_format, const char* data);

/** Write empty line (Improves readability for human based parsing)
*
* @param flipper_format Pointer to a FlipperFormat instance
*
* @return True on success
*/
bool flipper_format_write_empty_line(FlipperFormat* flipper_format);

/** Removes the first matching key and its value. Sets the RW pointer to a
* position of deleted data.
*
Expand Down
3 changes: 2 additions & 1 deletion targets/f18/api_symbols.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
entry,status,name,type,params
Version,+,79.0,,
Version,+,79.1,,
Header,+,applications/services/bt/bt_service/bt.h,,
Header,+,applications/services/bt/bt_service/bt_keys_storage.h,,
Header,+,applications/services/cli/cli.h,,
Expand Down Expand Up @@ -1054,6 +1054,7 @@ Function,+,flipper_format_update_uint32,_Bool,"FlipperFormat*, const char*, cons
Function,+,flipper_format_write_bool,_Bool,"FlipperFormat*, const char*, const _Bool*, const uint16_t"
Function,+,flipper_format_write_comment,_Bool,"FlipperFormat*, FuriString*"
Function,+,flipper_format_write_comment_cstr,_Bool,"FlipperFormat*, const char*"
Function,+,flipper_format_write_empty_line,_Bool,FlipperFormat*
Function,+,flipper_format_write_float,_Bool,"FlipperFormat*, const char*, const float*, const uint16_t"
Function,+,flipper_format_write_header,_Bool,"FlipperFormat*, FuriString*, const uint32_t"
Function,+,flipper_format_write_header_cstr,_Bool,"FlipperFormat*, const char*, const uint32_t"
Expand Down
3 changes: 2 additions & 1 deletion targets/f7/api_symbols.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
entry,status,name,type,params
Version,+,79.0,,
Version,+,79.1,,
Header,+,applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h,,
Header,+,applications/services/bt/bt_service/bt.h,,
Header,+,applications/services/bt/bt_service/bt_keys_storage.h,,
Expand Down Expand Up @@ -1164,6 +1164,7 @@ Function,+,flipper_format_update_uint32,_Bool,"FlipperFormat*, const char*, cons
Function,+,flipper_format_write_bool,_Bool,"FlipperFormat*, const char*, const _Bool*, const uint16_t"
Function,+,flipper_format_write_comment,_Bool,"FlipperFormat*, FuriString*"
Function,+,flipper_format_write_comment_cstr,_Bool,"FlipperFormat*, const char*"
Function,+,flipper_format_write_empty_line,_Bool,FlipperFormat*
Function,+,flipper_format_write_float,_Bool,"FlipperFormat*, const char*, const float*, const uint16_t"
Function,+,flipper_format_write_header,_Bool,"FlipperFormat*, FuriString*, const uint32_t"
Function,+,flipper_format_write_header_cstr,_Bool,"FlipperFormat*, const char*, const uint32_t"
Expand Down

0 comments on commit e11a626

Please sign in to comment.