.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Arch::Name 3pm" .TH Arch::Name 3pm "2022-06-08" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Arch::Name \- parse, store and construct an arch name .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Arch::Name; \& \& my $version_spec = \*(Aqsome@hacker.org\-\-pub/bugzilla\-\-main\-\-1.2\*(Aq; \& my $name = Arch::Name\->new($version_spec); \& die unless $name eq $version; \& die unless $name \- 2 eq \*(Aqsome@hacker.org\-\-pub/bugzilla\*(Aq; \& die unless $name\->branch eq \*(Aqmain\*(Aq; \& \& \& # list other branches (latest versions) in the tree archive \& my $category = Arch::Name\->new($tree\->get_version)\->go_up(2); \& \& foreach my $branch_str ($session\->branches($category)) { \& my $branch = $category\->child($branch_str); \& my $latest_version = ($session\->versions($branch))[\-1]; \& \& print $branch\->go_down($latest_version)\->to_string, "\en"; \& } \& \& \& # another way to manipulate it \& my $category = Arch::Name\->new($tree\->get_version); \& $category\->apply([undef, undef]); \& print $category\->fqn, "\en", $category\->parent\->to_hash, "\en"; \& \& \& # validate arch name from the user input \& # suppose we write a tool that accepts 3 command line args: \& # * tree directory or branch+ (to get tree) \& # * fully qualified revision (to get changeset) \& # * archive+ (fully qualified category is ok too) \& my ($name_or_dir, $rvsn, $archv) = @ARGV; \& \& my $tree = Arch::Name\->is_valid($name_or_dir, "branch+")? \& Arch::Session\->new\->get_tree($name_or_dir): \& Arch::Tree\->new($name_or_dir); \& my $cset = $session\->get_revision_changeset($rvsn) \& if Arch::Name\->is_valid($rvsn, \*(Aqrevision\*(Aq); \& my $possibly_archive = Arch::Name\->new($archv); \& die "No archive" unless $possibly_archive\->is_valid; \& my $archive = $possibly_archive\->cast(\*(Aqarchive\*(Aq); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This class represents the Arch name concept and provides useful methods to manipulate it. .PP The fully qualified Arch name looks like \&\fIarchive\fR/\fIcategory\fR\-\-\fIbranch\fR\-\-\fIversion\fR\-\-\fIrevision\fR for revisions and some prefix of it for other hierarchy citizens. The branchless names have "\-\-\fIbranch\fR" part removed. .SH "METHODS" .IX Header "METHODS" The following class methods are available: .PP \&\fBnew\fR, \&\fBset\fR, \&\fBclone\fR, \&\fBapply\fR, \&\fBgo_up\fR, \&\fBgo_down\fR, \&\fBparent\fR, \&\fBchild\fR, \&\fBto_string\fR, \&\fBto_nonarch_string\fR, \&\fBto_array\fR, \&\fBto_hash\fR, \&\fBfqn\fR, \&\fBnan\fR, \&\fBget\fR, \&\fBarchive\fR, \&\fBcategory\fR, \&\fBbranch\fR, \&\fBversion\fR, \&\fBrevision\fR, \&\fBerror\fR, \&\fBlevel\fR, \&\fBcast\fR, \&\fBis_valid\fR. .IP "\fBnew\fR" 4 .IX Item "new" .PD 0 .IP "\fBnew\fR \fIinit\fR [\fIon_error\fR=0]" 4 .IX Item "new init [on_error=0]" .PD Construct the \f(CW\*(C`Arch::Name\*(C'\fR instanse. If the optional \fIinit\fR parameter is given, then \fBset\fR method is called with this parameter on the newly created instanse. .Sp By default (without \fIinit\fR), the empty name is created that does not pass \&\fBis_valid\fR check. .Sp If \fIon_error\fR is set and positive, then die on any initialization error, i.e. when only a partial name is parsed or no name components are given. By default an object representing a partial name is returning, and \fBerror\fR may be used. If \fIon_error\fR is set and is negative, then don't set any error. .Sp Please note, that passing \f(CW\*(C`Arch::Name\*(C'\fR object as the parameter does not construct a new instance, but returns this passed object. Use \fBclone\fR instead if you want to clone the passed object. Or explicitly call \fBset\fR. .IP "\fBset\fR \fIobject\fR" 4 .IX Item "set object" .PD 0 .IP "\fBset\fR \fIstring\fR" 4 .IX Item "set string" .IP "\fBset\fR \fIarrayref\fR" 4 .IX Item "set arrayref" .IP "\fBset\fR \fIhashref\fR" 4 .IX Item "set hashref" .PD Store the new content. Multiple argument types supported. \fIobject\fR is another reference object of type \f(CW\*(C`Arch::Name\*(C'\fR. \fIstring\fR is fully qualified name. \&\fIarrayref\fR contains subnames, like the ones returned by \fBto_array\fR method. \&\fIhashref\fR is hash with some or all keys \fIarchive\fR, \fIcategory\fR, \fIbranch\fR, \&\fIversion\fR and \fIrevision\fR, like the ones returned by \fBto_hash\fR method. .IP "\fBclone\fR [\fIinit\fR ..]" 4 .IX Item "clone [init ..]" Create and return a new \f(CW\*(C`Arch::Name\*(C'\fR instanse that stores the same logical arch name. If the optional \fIinit\fR parameter(s) given, then \fBapply\fR method is called with these parameters on the newly created instanse. .IP "\fBapply\fR \fIhashref\fR" 4 .IX Item "apply hashref" .PD 0 .IP "\fBapply\fR [\fIreversed_arrayref\fR] [\fIsubname\fR ..]" 4 .IX Item "apply [reversed_arrayref] [subname ..]" .PD Similar to \fBset\fR, but enables to apply a partial change. For example: .Sp .Vb 1 \& my $name = Arch::Name\->new("user@host\-\-arch/cat\-\-felix\-\-1.2.3"); \& \& $name\->apply([ \*(Aq1.2.4\*(Aq, \*(Aqleo\*(Aq ]); # ok, new branch\-version \&or: \& $name\->apply({ branch => \*(Aqleo\*(Aq, version => \*(Aq1.2.4\*(Aq }); # ditto \&or: \& $name\->apply([ \*(Aqpanther\*(Aq ]); # error, invalid version \&or: \& $name\->apply([ undef, \*(Aqpanther\*(Aq ]); # ok, it is branch now \&or: \& $name\->apply({ category => \*(Aqdog\*(Aq }); # ok, it is category now \&or: \& $name\->apply({ branch => \*(Aqleo\*(Aq }); # ok, == [undef, \*(Aqleo\*(Aq] \&or: \& $name\->apply({ version => undef }); # ok, it is branch now \&or: \& $name\->apply({ revision => \*(Aqpatch\-6\*(Aq }); # ok, it is revision now \&or: \& $name\->apply([], \*(Aqpatch\-6\*(Aq); # ditto \&or: \& $name\->apply([ \*(Aq1.2.4\*(Aq ], \*(Aqpatch\-6\*(Aq); # ditto with new version \&or: \& $branch\->apply([], \*(Aq0\*(Aq, \*(Aqbase\-0\*(Aq); # ok, go import revision \&or: \& $branch\->apply(\*(Aq0\*(Aq, \*(Aqbase\-0\*(Aq) ; # ditto .Ve .IP "\fBgo_up\fR [\fIlevel\fR=1]" 4 .IX Item "go_up [level=1]" Remove one dimension (i.e. the last component) from the name, or more than one dimension if \fIlevel\fR is given. This is effectivelly just a convenient shortcut for \f(CW\*(C`apply([ (undef) x \f(CIlevel\f(CW ])\*(C'\fR. .IP "\fBgo_down\fR \fIstring\fR .." 4 .IX Item "go_down string .." Add one more dimension (i.e. new component \fIstring\fR) to the name. Multiple new dimentions are supported. This is effectivelly just an alias for \f(CW\*(C`apply(\f(CIstring\f(CW, .. )\*(C'\fR. .IP "\fBparent\fR [\fIlevel\fR=1]" 4 .IX Item "parent [level=1]" Return object representing the parent arch name. This is just a shortcut for \&\f(CW\*(C`clone\->go_up(\f(CIlevel\f(CW)\*(C'\fR. .IP "\fBchild\fR \fIstring\fR .." 4 .IX Item "child string .." Return object representing the child arch name. This is just a shortcut for \&\f(CW\*(C`clone\->go_down(\f(CIstring\f(CW)\*(C'\fR. .IP "\fBto_string\fR" 4 .IX Item "to_string" Return the fully qualified name. .IP "\fBto_nonarch_string\fR" 4 .IX Item "to_nonarch_string" Return the nonarch name (that is the fully qualified name without \&\fIarchive/\fR part). .IP "\fBto_array\fR" 4 .IX Item "to_array" Return the components of the name starting from archive to revision. The returned array may contain 0 to 5 strings; the branch in branchless names is represented by empty string. .Sp Returns array or arrayref depending on context. .IP "\fBto_hash\fR" 4 .IX Item "to_hash" Return the hash containing the components of the name with keys: \&\fIarchive\fR, \fIcategory\fR, \fIbranch\fR, \fIversion\fR and \fIrevision\fR. .Sp Returns hash or hashref depending on context. .IP "\fBfqn\fR" 4 .IX Item "fqn" This is an alias for \fBto_string\fR. .IP "\fBnan\fR" 4 .IX Item "nan" This is an alias for \fBto_nonarch_string\fR. .IP "\fBget\fR" 4 .IX Item "get" This is an alias for \fBto_array\fR. .IP "\fBarchive\fR [\fIarchive\fR]" 4 .IX Item "archive [archive]" Get or set the archive component only (the string). See also, \&\fBto_array\fR (getter) and \fBapply\fR (setter). .IP "\fBcategory\fR [\fIcategory\fR]" 4 .IX Item "category [category]" Get or set the category component only (the string). See also, \&\fBto_array\fR (getter) and \fBapply\fR (setter). .IP "\fBbranch\fR [\fIbranch\fR]" 4 .IX Item "branch [branch]" Get or set the branch component only (the string). See also, \&\fBto_array\fR (getter) and \fBapply\fR (setter). .IP "\fBversion\fR [\fIversion\fR]" 4 .IX Item "version [version]" Get or set the version component only (the string). See also, \&\fBto_array\fR (getter) and \fBapply\fR (setter). .IP "\fBrevision\fR [\fIrevision\fR]" 4 .IX Item "revision [revision]" Get or set the revision component only (the string). See also, \&\fBto_array\fR (getter) and \fBapply\fR (setter). .IP "\fBerror\fR" 4 .IX Item "error" Return the last error string or undef. Some errors are fatal (like passing unexiting [\fIelem\fR] parameter to \fBis_valid\fR), then the module dies. Some errors are however not fatal (like setting malformed fully qualified name, or setting revision part when no version part is set). In this case the name is set to something adequate (usually empty name), and this method may be used to get the error message. .Sp This last error string is class global and it is (un)set on every \fBset\fR or \&\fBapply\fR method. .IP "\fBlevel\fR [\fIstringify-flag\fR]" 4 .IX Item "level [stringify-flag]" Return 0 if the name is not valid (empty). Return integer [1 .. 5] if the name is \fIarchive\fR, \fIcategory\fR, \&\fIbranch\fR, \fIversion\fR and \fIrevision\fR correspondingly. .Sp If \fIstringify-flag\fR is set, then return the same as a text, i.e. one of the values: \*(L"none\*(R", \*(L"archive\*(R", \*(L"category\*(R", \*(L"branch\*(R", \*(L"version\*(R", \*(L"revision\*(R". .IP "\fBcast\fR \fIelem\fR" 4 .IX Item "cast elem" Similar to \fBparent\fR or \fBclone\fR, but requires argument that is one of the values that \fBlevel\fR returns (i.e. either integers 0 .. 5 or strings \&\*(L"none\*(R" .. \*(L"revision\*(R"). The returned cloned object contains only the number of components specified by \fIelem\fR. .Sp If the original object contains less components than requested, then undef if returned. .IP "\fBis_valid\fR [\fIelem\fR]" 4 .IX Item "is_valid [elem]" Return true if the object contains the valid arch name (i.e. at least one component). .Sp If \fIelem\fR is given that is one of the strings \*(L"archive\*(R", \*(L"category\*(R", \&\*(L"branch\*(R", \*(L"version\*(R" and \*(L"revision\*(R", then return true if the object represents the given element (for example, category), and false otherwise. .Sp If \fIelem\fR is given that is one of the strings \*(L"archive+\*(R", \*(L"category+\*(R", \&\*(L"branch+\*(R", \*(L"version+\*(R" and \*(L"revision+\*(R", then return true if the object represents at least the given element, and false otherwise. .IP "Arch::Name\->\fBis_valid\fR \fIname\fR [\fIelem\fR]" 4 .IX Item "Arch::Name->is_valid name [elem]" This class method does two things, first constructs the \f(CW\*(C`Arch::Name\*(C'\fR object with \fIname\fR as the constructor parameter, and then calls the \&\fBis_valid\fR method on this created object with optional \fIelem\fR passed. .SH "OVERLOADED OPERATORS" .IX Header "OVERLOADED OPERATORS" The following operators are overloaded: .PP .Vb 8 \& "" # to_string \& 0+ # level \& bool # is_valid \& = # clone \& + # child \& \- # parent \& += # go_down \& \-= # go_up .Ve .SH "BUGS" .IX Header "BUGS" No known bugs. .PP \&\f(CW\*(C`man perl | grep more\*(C'\fR .SH "AUTHORS" .IX Header "AUTHORS" Mikhael Goikhman (migo@homemail.com\*(--Perl\-GPL/arch\-perl\*(--devel). .SH "SEE ALSO" .IX Header "SEE ALSO" For more information, see tla, Arch::Session, Arch::Library, Arch::Tree.