35 using namespace basis;
38 using namespace nodes;
46 #define BASE_LOG(s) program_wide_logger::get().log(s, ALWAYS_PRINT)
48 #define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), \
49 a_sprintf("line %d: ", _categories._line_number) + s)
62 virtual int execute();
65 int write_new_marks(
const astring &output_filename);
80 This program needs two filenames as command-line parameters. The -i flag\n\
81 is used to specify the input filename, which is expected to be in the HOOPLE\n\
82 link database format. The -o flag specifies the new bookmarks file to be\n\
83 created, which will also be in the HOOPLE link format.\n\
84 The HOOPLE link format is documented here:\n\
85 http://feistymeow.org/guides/link_database/format_manifesto.txt\n\
87 program_wide_logger::get().log(to_show, ALWAYS_PRINT);
91 int marks_sorter::execute()
99 if (!cmds.get_value(
'i', input_filename,
false))
101 if (!cmds.get_value(
'o', output_filename,
false))
108 if (outname.exists()) {
110 + output_filename +
" already exists. It would be over-written if "
114 int ret = _categories.read_csv_file(input_filename);
117 ret = write_new_marks(output_filename);
123 int marks_sorter::write_new_marks(
const astring &output_filename)
129 if (!output_file.good())
132 bool just_had_return =
false;
133 bool first_line =
true;
136 tree::iterator itty = _categories.access_root().start(tree::prefix);
139 while ( (curr = itty.
next()) ) {
144 cat_list += nod->
name();
147 astring name_split, nick_split;
148 _categories.break_name(pare->
name(), name_split, nick_split);
149 if (!nick_split) cat_list += name_split;
150 else cat_list += nick_split;
157 list_parsing::create_csv_line(cat_list, tmp);
159 if (!just_had_return && !first_line) {
161 output_file.write(parser_bits::platform_eol_to_chars());
165 just_had_return =
false;
168 output_file.write(tmp);
179 int indy = descrip.
find(
'"');
181 descrip.
zap(0, indy);
182 indy = descrip.
find(
'"');
185 descrip =
astring(
" ") + descrip;
189 output_file.write(
astring(
"#") + descrip +
"\n");
190 just_had_return =
false;
195 if (!just_had_return) {
196 output_file.write(parser_bits::platform_eol_to_chars());
197 just_had_return =
true;
208 _categories.break_name(nod->
name(), name_split, nick_split);
209 if (!nick_split) lnks += nod->
name();
210 else lnks += nick_split;
212 list_parsing::create_csv_line(lnks, tmp);
214 output_file.write(tmp);
215 just_had_return =
false;
223 _categories.link_count(), _categories.category_count()));
int print_instructions(bool good, const astring &program_name)
The application_shell is a base object for console programs.
a_sprintf is a specialization of astring that provides printf style support.
Provides a dynamically resizable ASCII character string.
const char * s() const
synonym for observe. the 's' stands for "string", if that helps.
bool t() const
t() is a shortcut for the string being "true", as in non-empty.
virtual void zap(int start, int end)
Deletes the characters between "start" and "end" inclusively.
int end() const
returns the index of the last (non-null) character in the string.
int find(char to_find, int position=0, bool reverse=false) const
Locates "to_find" in "this".
bool contains(const astring &to_find) const
Returns true if "to_find" is contained in this string or false if not.
Provides file managment services using the standard I/O support.
Provides operations commonly needed on file names.
const basis::astring & raw() const
returns the astring that we're holding onto for the path.
filename basename() const
returns the base of the filename; no directory.
basis::astring _description
const basis::astring & name() const
returns the name of this node.
tree * next()
Returns a pointer to the next tree in the direction of traversal.
A dynamically linked tree with an arbitrary number of branches.
virtual tree * parent() const
Returns the tree node that is the immediate ancestor of this one.
int elements() const
the maximum number of elements currently allowed in this amorph.
contents * borrow(int field)
Returns a pointer to the information at the index "field".
An array of strings with some additional helpful methods.
#define SETUP_COMBO_LOGGER
a macro that retasks the program-wide logger as a combo_logger.
#define non_continuable_error(c, f, i)
an extra piece of information used, if available, in bounds_halt below.
#define NULL_POINTER
The value representing a pointer to nothing.
#define DEFINE_CLASS_NAME(objname)
Defines the name of a class by providing a couple standard methods.
#define FUNCDEF(func_in)
FUNCDEF sets the name of a function (and plugs it into the callstack).
Provides macros that implement the 'main' program of an application.
#define HOOPLE_MAIN(obj_name, obj_args)
options that should work for most unix and linux apps.
Implements an application lock to ensure only one is running at once.
The guards collection helps in testing preconditions and reporting errors.
const int MEGABYTE
Number of bytes in a megabyte.
bool non_negative(const type &a)
non_negative returns true if "a" is greater than or equal to zero.
A platform independent way to obtain the timestamp of a file.
A logger that sends to the console screen using the standard output device.
A dynamic container class that holds any kind of object via pointers.