=encoding utf8

=head1 NAME

Math::Formula::Config - load/save formulas to file

=head1 INHERITANCE

 Math::Formula::Config is extended by
   Math::Formula::Config::INI
   Math::Formula::Config::JSON
   Math::Formula::Config::YAML

=head1 SYNOPSIS

  my $saver = Math::Formula::Config::YAML->new(directory => $dir);
  $saver->save($context);

=head1 DESCRIPTION

The extensions of this module can be used to export and import
sets of expressions to and from a program.

The following serialization formats are supported:

=over 4

=item * JSON L<Math::Formula::Config::JSON|Math::Formula::Config::JSON>

=item * YAML L<Math::Formula::Config::YAML|Math::Formula::Config::YAML>

=item * INI  L<Math::Formula::Config::INI|Math::Formula::Config::INI>

=back

=head1 METHODS

=head2 Constructors

=over 4

=item $class-E<gt>B<new>(%options)

Z<>

 -Option   --Default
  directory  <required>

=over 2

=item directory => DIRECTORY

In this directory, the output files will be made.  For each context (fragment),
a separate file is made.

=back

=back

=head2 Attributes

=over 4

=item $obj-E<gt>B<directory>()

When the configuration files will be written, and are read.

=item $obj-E<gt>B<path_for>($file)

Constructs a filename, based on the configured L<directory()|Math::Formula::Config/"Attributes">, the context's name,
and the usual filename extensions.

=back

=head2 Actions

=over 4

=item $obj-E<gt>B<load>($name, %options)

Load a L<Math::Formula::Context|Math::Formula::Context> for an INI file.

 -Option  --Default
  filename  <directory/$name.ini>

=over 2

=item filename => FILENAME

=back

=item $obj-E<gt>B<save>($context, %options)

Serialize the C<$context> into a file as storage or to be edited by hand.
This is a useful method when default configuration templates need to
be generated.

=back

=head1 DIAGNOSTICS

=over 4

=item Error: Save directory '$dir' does not exist

Z<>

=item Error: Save directory required

Z<>

=back

=head1 SEE ALSO

This module is part of Math-Formula version 0.17,
built on August 17, 2025. Website: F<http://perl.overmeer.net/CPAN/>

=head1 LICENSE

For contributors see file ChangeLog.

This software is copyright (c) 2023-2025 by Mark Overmeer.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

