NAME
File::ValueFile::Simple::Writer - module for reading and writing ValueFile files
VERSION
version v0.02
SYNOPSIS
use File::ValueFile::Simple::Writer;
This module provides a simple way to write ValueFile files.
METHODS
new
my $writer = File::ValueFile::Simple::Writer->new($out [, %opts]);
Opens a writer for the given output file. $out
can be an open file handle that must support seeking or a filename.
This method dies on any problem.
In addition the following options (all optional) are supported:
format
-
The format to use. Must be an ISE or an instances of Data::Identifier.
required_feature
,copy_feature
,optional_feature
-
Features that are used in the file. Required features need to be supported by the reading entity. Copy features are safe to be copied, even if not understood. Optional features do not need to be understood by the reader.
May be a single feature or a list (as array ref). Each feature is given by the ISE or an instances of Data::Identifier.
write
$writer->write(@line);
Writes a single line (record). Correctly escapes the output.
Values in @line
may be strings, numbers, or instances of Data::Identifier.
write_hash
$writer->write_hash($hashref);
Writes a hash as returned by "read_as_hash" in File::ValueFile::Simple::Reader or "read_as_hash_of_arrays" in File::ValueFile::Simple::Reader.
Values in $hashref
may be strings, numbers, or instances of Data::Identifier.
write_tag_ise
$writer->write_tag_ise(@ids);
Writes a tag-ise
line for the given identifiers. @ids can include raw ISEs or instances of Data::Identifier.
The method will write a most compatible line with a comment if the provided data allows.
write_tag_relation
$writer->write_tag_relation($tag, $relation, $related);
# or:
$writer->write_tag_relation($tag, $relation, $related, $context, $filter);
# or:
$writer->write_tag_relation(tag => $tag, relation => $relation, related => $related [, context => $context ] [, filter => ]);
# or:
$writer->write_tag_relation({tag => $tag, relation => $relation, related => $related [, context => $context ] [, filter => ]});
# or:
$writer->write_tag_relation($link);
Writes a tag-relation
line for the given relation. This function is smart and will write the most compatible line possible, including a comment.
Each of $tag
, $relation
, $related
, $context
, and $filter
must be a raw ISE or an instances of Data::Identifier. $context
, and $filter
may also be undef
.
$link
must be any object that implements the methods tag
, relation
, related
, context
, and filter
. Each method must return the corresponding value in a format as defined above. Each method must also tolerable the options default
, no_defaults
, and as
to be passed (with any value).
write_tag_metadata
$writer->write_tag_metadata($tag, $relation, $data_raw);
# or:
$writer->write_tag_metadata($tag, $relation, $type, $encoding, $data_raw);
# or:
$writer->write_tag_metadata(tag => $tag, relation => $relation, data_raw => $data_raw [, type => $type ] [, encoding => $encoding ] [, context => $context ]);
# or:
$writer->write_tag_metadata({tag => $tag, relation => $relation, data_raw => $data_raw [, type => $type ] [, encoding => $encoding ] [, context => $context ]});
# or:
$writer->write_tag_metadata($link);
Writes a tag-metadata
line for the given relation. This function is smart and will write the most compatible line possible, including a comment.
Each of $tag
, $relation
, $context
, $type
, and $encoding
must be a raw ISE or an instances of Data::Identifier. $context
, $type
, and $encoding
may also be undef
.
$raw_data
must be a value allowed by "write".
$link
must be any object that implements the methods tag
, relation
, context
, type
, and encoding
. Each method must return the corresponding value in a format as defined above. Each method must also tolerable the options default
, no_defaults
, and as
to be passed (with any value).
AUTHOR
Löwenfelsen UG (haftungsbeschränkt) <support@loewenfelsen.net>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2024 by Löwenfelsen UG (haftungsbeschränkt) <support@loewenfelsen.net>.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)