📄 apr::table.3
字号:
.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05).\".\" Standard preamble:.\" ========================================================================.de Sh \" Subsection heading.br.if t .Sp.ne 5.PP\fB\\$1\fR.PP...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" '''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 turned on, we'll generate index entries on stderr for.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index.\" entries marked with X<> in POD. Of course, you'll have to process the.\" output yourself in some meaningful fashion..ie \nF \{\. de IX. tm Index:\\$1\t\\n%\t"\\$2"... nr % 0. rr F.\}.el \{\. de IX...\}.\".\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2)..\" Fear. Run. Save yourself. No user-serviceable parts.. \" fudge factors for nroff and troff.if n \{\. ds #H 0. ds #V .8m. ds #F .3m. ds #[ \f1. ds #] \fP.\}.if t \{\. ds #H ((1u-(\\\\n(.fu%2u))*.13m). ds #V .6m. ds #F 0. ds #[ \&. ds #] \&.\}. \" simple accents for nroff and troff.if n \{\. ds ' \&. ds ` \&. ds ^ \&. ds , \&. ds ~ ~. ds /.\}.if t \{\. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u". ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'.\}. \" troff and (daisy-wheel) nroff accents.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'.ds 8 \h'\*(#H'\(*b\h'-\*(#H'.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#].ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#].ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#].ds ae a\h'-(\w'a'u*4/10)'e.ds Ae A\h'-(\w'A'u*4/10)'E. \" corrections for vroff.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'. \" for low resolution devices (crt and lpr).if \n(.H>23 .if \n(.V>19 \\{\. ds : e. ds 8 ss. ds o a. ds d- d\h'-1'\(ga. ds D- D\h'-1'\(hy. ds th \o'bp'. ds Th \o'LP'. ds ae ae. ds Ae AE.\}.rm #[ #] #H #V #F C.\" ========================================================================.\".IX Title "mod_perl-2.0.2::docs::api::APR::Table 3".TH mod_perl-2.0.2::docs::api::APR::Table 3 "2005-10-21" "perl v5.10.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"APR::Table \- Perl API for manipulating APR opaque string\-content tables.SH "Synopsis".IX Header "Synopsis".Vb 1\& use APR::Table ();\& \& $table = APR::Table::make($pool, $nelts);\& $table_copy = $table\->copy($pool);\& \& $table\->clear();\& \& $table\->set($key => $val);\& $table\->unset($key);\& $table\->add($key, $val);\& \& $val = $table\->get($key);\& @val = $table\->get($key);\& \& $table\->merge($key => $val);\& \& use APR::Const \-compile qw(:table);\& $table_overlay = $table_base\->overlay($table_overlay, $pool);\& $table_overlay\->compress(APR::Const::OVERLAP_TABLES_MERGE);\& \& $table_a\->overlap($table_b, APR::Const::OVERLAP_TABLES_SET);\& \& $table\->do(sub {print "key $_[0], value $_[1]\en"}, @valid_keys);\& \& #Tied Interface\& $value = $table\->{$key};\& $table\->{$key} = $value;\& print "got it" if exists $table\->{$key};\& \& foreach my $key (keys %{$table}) {\& print "$key = $table\->{$key}\en";\& }.Ve.SH "Description".IX Header "Description"\&\f(CW\*(C`APR::Table\*(C'\fR allows its users to manipulate opaque string-contenttables..PPOn the C level the \*(L"opaque string-content\*(R" means: you can put in\&'\e0'\-terminated strings and whatever you put in your get out..PPOn the Perl level that means that we convert scalars into strings andstore those strings. Any special information that was in the Perlscalar is not stored. So for example if a scalar was marked as utf8,tainted or tied, that information is not stored. When you get the databack as a Perl scalar you get only the string..PPThe table's structure is somewhat similar to the Perl's hashstructure, but allows multiple values for the same key. An access tothe records stored in the table always requires a key..PPThe key-value pairs are stored in the order they are added..PPThe keys are case-insensitive..PPHowever as of the current implementation if more than value for thesame key is requested, the whole table is lineary searched, which isvery inefficient unless the table is very small..PP\&\f(CW\*(C`APR::Table\*(C'\fR provides a \s-1TIE\s0 Interface..PPSee \fIapr/include/apr_tables.h\fR in \s-1ASF\s0's \fIapr\fR project for low leveldetails..SH "API".IX Header "API"\&\f(CW\*(C`APR::Table\*(C'\fR provides the following functions and/or methods:.ie n .Sh """add""".el .Sh "\f(CWadd\fP".IX Subsection "add"Add data to a table, regardless of whether there is another elementwith the same key..PP.Vb 1\& $table\->add($key, $val);.Ve.ie n .IP "obj: $table\fR ( \f(CW""APR::Table object"" )" 4.el .IP "obj: \f(CW$table\fR ( \f(CWAPR::Table object\fR )" 4.IX Item "obj: $table ( APR::Table object )"The table to add to..ie n .IP "arg1: $key ( string )" 4.el .IP "arg1: \f(CW$key\fR ( string )" 4.IX Item "arg1: $key ( string )"The key to use..ie n .IP "arg2: $val ( string )" 4.el .IP "arg2: \f(CW$val\fR ( string )" 4.IX Item "arg2: $val ( string )"The value to add..IP "ret: no return value" 4.IX Item "ret: no return value".PD 0.IP "since: 2.0.00" 4.IX Item "since: 2.0.00".PD.PPWhen adding data, this function makes a copy of both the key and thevalue..ie n .Sh """clear""".el .Sh "\f(CWclear\fP".IX Subsection "clear"Delete all of the elements from a table..PP.Vb 1\& $table\->clear();.Ve.ie n .IP "obj: $table\fR ( \f(CW""APR::Table object"" )" 4.el .IP "obj: \f(CW$table\fR ( \f(CWAPR::Table object\fR )" 4.IX Item "obj: $table ( APR::Table object )"The table to clear..IP "ret: no return value" 4.IX Item "ret: no return value".PD 0.IP "since: 2.0.00" 4.IX Item "since: 2.0.00".PD.ie n .Sh """compress""".el .Sh "\f(CWcompress\fP".IX Subsection "compress"Eliminate redundant entries in a table by either overwriting ormerging duplicates:.PP.Vb 1\& $table\->compress($flags);.Ve.ie n .IP "obj: $table\fR ( \f(CW""APR::Table object"" )" 4.el .IP "obj: \f(CW$table\fR ( \f(CWAPR::Table object\fR )" 4.IX Item "obj: $table ( APR::Table object )"The table to compress..ie n .IP "arg1: $flags\fR (\f(CW""APR::Const constant"")" 4.el .IP "arg1: \f(CW$flags\fR (\f(CWAPR::Const constant\fR)" 4.IX Item "arg1: $flags (APR::Const constant)".Vb 2\& APR::Const::OVERLAP_TABLES_MERGE \-\- to merge\& APR::Const::OVERLAP_TABLES_SET \-\- to overwrite.Ve.IP "ret: no return value" 4.IX Item "ret: no return value".PD 0.IP "since: 2.0.00" 4.IX Item "since: 2.0.00".PD.PPConverts multi-valued keys in \f(CW$table\fR into single-valued keys. Thisfunction takes duplicate table entries and flattens them into a singleentry. The flattening behavior is controlled by the (mandatory)\&\f(CW$flags\fR argument..PPWhen \f(CW$flags\fR == \f(CW\*(C`APR::Const::OVERLAP_TABLES_SET\*(C'\fR, each key will be set tothe last value seen for that key. For example, given key/value pairs\&'foo => bar' and 'foo => baz', 'foo' would have a final valueof 'baz' after compression \*(-- the 'bar' value would be lost..PPWhen \f(CW$flags\fR == \f(CW\*(C`APR::Const::OVERLAP_TABLES_MERGE\*(C'\fR, multiple values forthe same key are flattened into a comma-separated list. Givenkey/value pairs 'foo => bar' and 'foo => baz', 'foo' wouldhave a final value of 'bar, baz' after compression..PPAccess the constants via:.PP.Vb 1\& use APR::Const \-compile qw(:table);.Ve.PPor an explicit:.PP.Vb 1\& use APR::Const \-compile qw(OVERLAP_TABLES_SET OVERLAP_TABLES_MERGE);.Ve.PP\&\f(CW\*(C`compress()\*(C'\fR combined with \f(CW\*(C`overlay()\*(C'\fR does the samething as \f(CW\*(C`overlap()\*(C'\fR..PPExamples:.IP "\(bu" 4\&\f(CW\*(C`APR::Const::OVERLAP_TABLES_SET\*(C'\fR.SpStart with table \f(CW$table\fR:.Sp.Vb 4\& foo => "one"\& foo => "two"\& foo => "three"\& bar => "beer".Ve.Spwhich is done by:.Sp.Vb 2\& use APR::Const \-compile => \*(Aq:table\*(Aq;\& my $table = APR::Table::make($r\->pool, TABLE_SIZE);\& \& $table\->set(bar => \*(Aqbeer\*(Aq);\& $table\->set(foo => \*(Aqone\*(Aq);\& $table\->add(foo => \*(Aqtwo\*(Aq);\& $table\->add(foo => \*(Aqthree\*(Aq);.Ve.SpNow compress it using \f(CW\*(C`APR::Const::OVERLAP_TABLES_SET\*(C'\fR:.Sp.Vb 1\& $table\->compress(APR::Const::OVERLAP_TABLES_SET);.Ve.SpNow table \f(CW$table\fR contains:.Sp.Vb 2\& foo => "three"\& bar => "beer".Ve.SpThe value \fIthree\fR for the key \fIfoo\fR, that was added last, took overthe other values.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -