initial commit
parent
6bcbfbe572
commit
0cf338bfd9
@ -0,0 +1,64 @@
|
||||
License
|
||||
|
||||
THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
|
||||
|
||||
BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.
|
||||
|
||||
1. Definitions
|
||||
|
||||
1. "Adaptation" means a work based upon the Work, or upon the Work and other pre-existing works, such as a translation, adaptation, derivative work, arrangement of music or other alterations of a literary or artistic work, or phonogram or performance and includes cinematographic adaptations or any other form in which the Work may be recast, transformed, or adapted including in any form recognizably derived from the original, except that a work that constitutes a Collection will not be considered an Adaptation for the purpose of this License. For the avoidance of doubt, where the Work is a musical work, performance or phonogram, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered an Adaptation for the purpose of this License.
|
||||
2. "Collection" means a collection of literary or artistic works, such as encyclopedias and anthologies, or performances, phonograms or broadcasts, or other works or subject matter other than works listed in Section 1(g) below, which, by reason of the selection and arrangement of their contents, constitute intellectual creations, in which the Work is included in its entirety in unmodified form along with one or more other contributions, each constituting separate and independent works in themselves, which together are assembled into a collective whole. A work that constitutes a Collection will not be considered an Adaptation (as defined above) for the purposes of this License.
|
||||
3. "Distribute" means to make available to the public the original and copies of the Work or Adaptation, as appropriate, through sale or other transfer of ownership.
|
||||
4. "License Elements" means the following high-level license attributes as selected by Licensor and indicated in the title of this License: Attribution, Noncommercial, ShareAlike.
|
||||
5. "Licensor" means the individual, individuals, entity or entities that offer(s) the Work under the terms of this License.
|
||||
6. "Original Author" means, in the case of a literary or artistic work, the individual, individuals, entity or entities who created the Work or if no individual or entity can be identified, the publisher; and in addition (i) in the case of a performance the actors, singers, musicians, dancers, and other persons who act, sing, deliver, declaim, play in, interpret or otherwise perform literary or artistic works or expressions of folklore; (ii) in the case of a phonogram the producer being the person or legal entity who first fixes the sounds of a performance or other sounds; and, (iii) in the case of broadcasts, the organization that transmits the broadcast.
|
||||
7. "Work" means the literary and/or artistic work offered under the terms of this License including without limitation any production in the literary, scientific and artistic domain, whatever may be the mode or form of its expression including digital form, such as a book, pamphlet and other writing; a lecture, address, sermon or other work of the same nature; a dramatic or dramatico-musical work; a choreographic work or entertainment in dumb show; a musical composition with or without words; a cinematographic work to which are assimilated works expressed by a process analogous to cinematography; a work of drawing, painting, architecture, sculpture, engraving or lithography; a photographic work to which are assimilated works expressed by a process analogous to photography; a work of applied art; an illustration, map, plan, sketch or three-dimensional work relative to geography, topography, architecture or science; a performance; a broadcast; a phonogram; a compilation of data to the extent it is protected as a copyrightable work; or a work performed by a variety or circus performer to the extent it is not otherwise considered a literary or artistic work.
|
||||
8. "You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation.
|
||||
9. "Publicly Perform" means to perform public recitations of the Work and to communicate to the public those public recitations, by any means or process, including by wire or wireless means or public digital performances; to make available to the public Works in such a way that members of the public may access these Works from a place and at a place individually chosen by them; to perform the Work to the public by any means or process and the communication to the public of the performances of the Work, including by public digital performance; to broadcast and rebroadcast the Work by any means including signs, sounds or images.
|
||||
10. "Reproduce" means to make copies of the Work by any means including without limitation by sound or visual recordings and the right of fixation and reproducing fixations of the Work, including storage of a protected performance or phonogram in digital form or other electronic medium.
|
||||
|
||||
2. Fair Dealing Rights. Nothing in this License is intended to reduce, limit, or restrict any uses free from copyright or rights arising from limitations or exceptions that are provided for in connection with the copyright protection under copyright law or other applicable laws.
|
||||
|
||||
3. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below:
|
||||
|
||||
1. to Reproduce the Work, to incorporate the Work into one or more Collections, and to Reproduce the Work as incorporated in the Collections;
|
||||
2. to create and Reproduce Adaptations provided that any such Adaptation, including any translation in any medium, takes reasonable steps to clearly label, demarcate or otherwise identify that changes were made to the original Work. For example, a translation could be marked "The original work was translated from English to Spanish," or a modification could indicate "The original work has been modified.";
|
||||
3. to Distribute and Publicly Perform the Work including as incorporated in Collections; and,
|
||||
4. to Distribute and Publicly Perform Adaptations.
|
||||
|
||||
The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats. Subject to Section 8(f), all rights not expressly granted by Licensor are hereby reserved, including but not limited to the rights described in Section 4(e).
|
||||
|
||||
4. Restrictions. The license granted in Section 3 above is expressly made subject to and limited by the following restrictions:
|
||||
|
||||
1. You may Distribute or Publicly Perform the Work only under the terms of this License. You must include a copy of, or the Uniform Resource Identifier (URI) for, this License with every copy of the Work You Distribute or Publicly Perform. You may not offer or impose any terms on the Work that restrict the terms of this License or the ability of the recipient of the Work to exercise the rights granted to that recipient under the terms of the License. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties with every copy of the Work You Distribute or Publicly Perform. When You Distribute or Publicly Perform the Work, You may not impose any effective technological measures on the Work that restrict the ability of a recipient of the Work from You to exercise the rights granted to that recipient under the terms of the License. This Section 4(a) applies to the Work as incorporated in a Collection, but this does not require the Collection apart from the Work itself to be made subject to the terms of this License. If You create a Collection, upon notice from any Licensor You must, to the extent practicable, remove from the Collection any credit as required by Section 4(d), as requested. If You create an Adaptation, upon notice from any Licensor You must, to the extent practicable, remove from the Adaptation any credit as required by Section 4(d), as requested.
|
||||
2. You may Distribute or Publicly Perform an Adaptation only under: (i) the terms of this License; (ii) a later version of this License with the same License Elements as this License; (iii) a Creative Commons jurisdiction license (either this or a later license version) that contains the same License Elements as this License (e.g., Attribution-NonCommercial-ShareAlike 3.0 US) ("Applicable License"). You must include a copy of, or the URI, for Applicable License with every copy of each Adaptation You Distribute or Publicly Perform. You may not offer or impose any terms on the Adaptation that restrict the terms of the Applicable License or the ability of the recipient of the Adaptation to exercise the rights granted to that recipient under the terms of the Applicable License. You must keep intact all notices that refer to the Applicable License and to the disclaimer of warranties with every copy of the Work as included in the Adaptation You Distribute or Publicly Perform. When You Distribute or Publicly Perform the Adaptation, You may not impose any effective technological measures on the Adaptation that restrict the ability of a recipient of the Adaptation from You to exercise the rights granted to that recipient under the terms of the Applicable License. This Section 4(b) applies to the Adaptation as incorporated in a Collection, but this does not require the Collection apart from the Adaptation itself to be made subject to the terms of the Applicable License.
|
||||
3. You may not exercise any of the rights granted to You in Section 3 above in any manner that is primarily intended for or directed toward commercial advantage or private monetary compensation. The exchange of the Work for other copyrighted works by means of digital file-sharing or otherwise shall not be considered to be intended for or directed toward commercial advantage or private monetary compensation, provided there is no payment of any monetary compensation in con-nection with the exchange of copyrighted works.
|
||||
4. If You Distribute, or Publicly Perform the Work or any Adaptations or Collections, You must, unless a request has been made pursuant to Section 4(a), keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or if the Original Author and/or Licensor designate another party or parties (e.g., a sponsor institute, publishing entity, journal) for attribution ("Attribution Parties") in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; (ii) the title of the Work if supplied; (iii) to the extent reasonably practicable, the URI, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work; and, (iv) consistent with Section 3(b), in the case of an Adaptation, a credit identifying the use of the Work in the Adaptation (e.g., "French translation of the Work by Original Author," or "Screenplay based on original Work by Original Author"). The credit required by this Section 4(d) may be implemented in any reasonable manner; provided, however, that in the case of a Adaptation or Collection, at a minimum such credit will appear, if a credit for all contributing authors of the Adaptation or Collection appears, then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors. For the avoidance of doubt, You may only use the credit required by this Section for the purpose of attribution in the manner set out above and, by exercising Your rights under this License, You may not implicitly or explicitly assert or imply any connection with, sponsorship or endorsement by the Original Author, Licensor and/or Attribution Parties, as appropriate, of You or Your use of the Work, without the separate, express prior written permission of the Original Author, Licensor and/or Attribution Parties.
|
||||
5.
|
||||
|
||||
For the avoidance of doubt:
|
||||
1. Non-waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme cannot be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License;
|
||||
2. Waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme can be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License if Your exercise of such rights is for a purpose or use which is otherwise than noncommercial as permitted under Section 4(c) and otherwise waives the right to collect royalties through any statutory or compulsory licensing scheme; and,
|
||||
3. Voluntary License Schemes. The Licensor reserves the right to collect royalties, whether individually or, in the event that the Licensor is a member of a collecting society that administers voluntary licensing schemes, via that society, from any exercise by You of the rights granted under this License that is for a purpose or use which is otherwise than noncommercial as permitted under Section 4(c).
|
||||
6. Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable law, if You Reproduce, Distribute or Publicly Perform the Work either by itself or as part of any Adaptations or Collections, You must not distort, mutilate, modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author's honor or reputation. Licensor agrees that in those jurisdictions (e.g. Japan), in which any exercise of the right granted in Section 3(b) of this License (the right to make Adaptations) would be deemed to be a distortion, mutilation, modification or other derogatory action prejudicial to the Original Author's honor and reputation, the Licensor will waive or not assert, as appropriate, this Section, to the fullest extent permitted by the applicable national law, to enable You to reasonably exercise Your right under Section 3(b) of this License (right to make Adaptations) but not otherwise.
|
||||
|
||||
5. Representations, Warranties and Disclaimer
|
||||
|
||||
UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING AND TO THE FULLEST EXTENT PERMITTED BY APPLICABLE LAW, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO THIS EXCLUSION MAY NOT APPLY TO YOU.
|
||||
|
||||
6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
7. Termination
|
||||
|
||||
1. This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Adaptations or Collections from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License.
|
||||
2. Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above.
|
||||
|
||||
8. Miscellaneous
|
||||
|
||||
1. Each time You Distribute or Publicly Perform the Work or a Collection, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License.
|
||||
2. Each time You Distribute or Publicly Perform an Adaptation, Licensor offers to the recipient a license to the original Work on the same terms and conditions as the license granted to You under this License.
|
||||
3. If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
|
||||
4. No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent.
|
||||
5. This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You.
|
||||
6. The rights granted under, and the subject matter referenced, in this License were drafted utilizing the terminology of the Berne Convention for the Protection of Literary and Artistic Works (as amended on September 28, 1979), the Rome Convention of 1961, the WIPO Copyright Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 and the Universal Copyright Convention (as revised on July 24, 1971). These rights and subject matter take effect in the relevant jurisdiction in which the License terms are sought to be enforced according to the corresponding provisions of the implementation of those treaty provisions in the applicable national law. If the standard suite of rights granted under applicable copyright law includes additional rights not granted under this License, such additional rights are deemed to be included in the License; this License is not intended to restrict the license of any rights under applicable law.
|
||||
|
@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
@ -0,0 +1,15 @@
|
||||
Library requirements for building Stupidfilter:
|
||||
flex
|
||||
libboost-serialization-dev
|
||||
|
||||
On Ubuntu 8.04, you should be able to just run
|
||||
sudo apt-get install build-essential flex libboost-serialization-dev
|
||||
make
|
||||
make install
|
||||
|
||||
The Makefile may require a little bit of tweaking, specifically the path to your Boost serialization library, which in the test environment was /usr/lib/libboost_serialization-gcc42-mt-1_34_1.a
|
||||
|
||||
To run the StupidFilter directly just type bin/stupidfilter data/c_rbf
|
||||
It will take data from standard in followed by a EOF and return a 0.000000 classification for stupid text and a 1.000000 for nonstupid text. Once we have regression working more accurately, this number will be actually be a floating point that describes how sure we are of the classification, so it's worth keeping it as a float in your implementations.
|
||||
|
||||
We have provided an example bash implementation in classify.sh. Note that we're normalizing whitespace with a call to sed. It's a good idea to strip HTML and normalize whitespace to avoid false positives.
|
@ -0,0 +1,8 @@
|
||||
The StupidFilter is copyrighted by Rarefied Technologies, Inc. All rights not explicitly declared are reserved by the copyright holder. This software is distributed without warranty. Use it at your own risk.
|
||||
|
||||
All source code files (.cpp and .h files in root directory) are open source and licenced under The GPL version 2.0, as defined in the included GPL text file. Data files (everything in the data/ directory) are licensed as Creative Commons Attribution-NonCommercial-ShareAlike 3.0 unported, as defined in the included CC text file. More lax license terms may be applied by Rarefied Technologies, Inc. at a later date, pending legal review.
|
||||
|
||||
For more specific questions regarding licensing, please email project@stupidfilter.org.
|
||||
|
||||
Thanks,
|
||||
The StupidFilter Team
|
@ -0,0 +1,32 @@
|
||||
# Thirdparty directory
|
||||
TP = thirdparty
|
||||
LIBSVM = $(TP)/libsvm/
|
||||
# Location of boost library headers
|
||||
BOOST = -I$(TP)
|
||||
# Path to binary boost serialization library must be defined here
|
||||
BOOSTLIB = "/usr/lib64/"
|
||||
|
||||
all : stupidfilter
|
||||
|
||||
stupidfilter : stupidfilter.o svm.o SVMUtil.o parametersearch.o
|
||||
cd bin && \
|
||||
g++ -L$(BOOSTLIB) -o"stupidfilter" stupidfilter.o svm.o SVMUtil.o parametersearch.o /usr/lib64/libboost_serialization.a -lfl
|
||||
|
||||
stupidfilter.o : stupidfilter.cpp SVMUtil.cpp SVMUtil.h $(LIBSVM)svm.cpp $(LIBSVM)svm.h
|
||||
g++ -c $(BOOST) -o"bin/stupidfilter.o" stupidfilter.cpp
|
||||
|
||||
SVMUtil.o : SVMUtil.cpp SVMUtil.h parametersearch.cpp parametersearch.h parameterresult.h $(LIBSVM)svm.cpp $(LIBSVM)svm.h
|
||||
g++ -c $(BOOST) -o"bin/SVMUtil.o" SVMUtil.cpp
|
||||
|
||||
parametersearch.o : parametersearch.cpp parametersearch.h parameterresult.h $(LIBSVM)svm.cpp $(LIBSVM)svm.h
|
||||
g++ -c $(BOOST) -o"bin/parametersearch.o" parametersearch.cpp
|
||||
|
||||
svm.o : $(LIBSVM)svm.cpp $(LIBSVM)svm.h
|
||||
g++ -c -o"bin/svm.o" $(LIBSVM)svm.cpp
|
||||
|
||||
|
||||
clean:
|
||||
rm -f bin/*.o
|
||||
|
||||
install:
|
||||
cp bin/stupidfilter /usr/bin/.
|
@ -0,0 +1,377 @@
|
||||
// Copyright 2008 Rarefied Technologies, Inc.
|
||||
// Distributed under the GPL v2 please see
|
||||
// LICENSE file for more information.
|
||||
|
||||
#include "SVMUtil.h"
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <algorithm>
|
||||
#include <cfloat>
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include "parametersearch.h"
|
||||
#include "parameterresult.h"
|
||||
#include "../thirdparty/libsvm/svm.h"
|
||||
#include "../thirdparty/boost/serialization/set.hpp"
|
||||
|
||||
void myfunction(int);
|
||||
|
||||
//#define SCALED_MAX 1
|
||||
//#define SCALED_MIN 0 //assume features > 0
|
||||
//#define SCALED_MIN -1 // if features can be < 0
|
||||
|
||||
//svm_problem ParseTrainingFile(string strFilename);
|
||||
|
||||
#define MAX_LINE_LENGTH 1024
|
||||
|
||||
SVMUtil::SVMUtil()
|
||||
{
|
||||
m_pProblem = NULL;
|
||||
m_pScaleFactors = NULL;
|
||||
m_nParams = 0;
|
||||
m_pModel = NULL;
|
||||
}
|
||||
|
||||
SVMUtil::~SVMUtil()
|
||||
{
|
||||
// problem destroyed when the model is
|
||||
//delete m_pProblem;
|
||||
//m_pProblem = NULL;
|
||||
if(m_pModel)
|
||||
svm_destroy_model(m_pModel);
|
||||
}
|
||||
|
||||
// borrowed from read_problem in svm-train.c
|
||||
svm_problem* SVMUtil::ParseTrainingFile(std::string strFilename)
|
||||
{
|
||||
m_pProblem = new svm_problem;
|
||||
svm_node *x_space;
|
||||
svm_parameter param;
|
||||
|
||||
const char* filename = strFilename.c_str();
|
||||
|
||||
int elements, i, j;
|
||||
FILE *fp = fopen(filename,"r");
|
||||
|
||||
if(fp == NULL)
|
||||
{
|
||||
fprintf(stderr,"can't open input file %s\n",filename);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
m_pProblem->l = 0;
|
||||
elements = 0;
|
||||
while(1)
|
||||
{
|
||||
int c = fgetc(fp);
|
||||
switch(c)
|
||||
{
|
||||
case '\n':
|
||||
++m_pProblem->l;
|
||||
// fall through,
|
||||
// count the '-1' element
|
||||
case ':':
|
||||
++elements;
|
||||
break;
|
||||
case EOF:
|
||||
goto out;
|
||||
default:
|
||||
;
|
||||
}
|
||||
}
|
||||
out:
|
||||
rewind(fp);
|
||||
|
||||
m_pProblem->y = Malloc(double,m_pProblem->l);
|
||||
m_pProblem->x = Malloc(struct svm_node *,m_pProblem->l);
|
||||
|
||||
int nParamCountGuess = elements / m_pProblem->l;
|
||||
|
||||
m_nParams = 0;
|
||||
|
||||
for(i=0;i<m_pProblem->l;i++)
|
||||
{
|
||||
double label;
|
||||
x_space = Malloc(struct svm_node, nParamCountGuess+1);
|
||||
m_pProblem->x[i] = x_space;
|
||||
fscanf(fp,"%lf",&label);
|
||||
m_pProblem->y[i] = label;
|
||||
|
||||
j=0;
|
||||
|
||||
while(1)
|
||||
{
|
||||
int c;
|
||||
do {
|
||||
c = getc(fp);
|
||||
if(c=='\n') goto out2;
|
||||
} while(isspace(c));
|
||||
ungetc(c,fp);
|
||||
|
||||
int nIndex;
|
||||
double dValue;
|
||||
|
||||
if (fscanf(fp,"%d:%lf", &nIndex, &dValue) < 2)
|
||||
{
|
||||
fprintf(stderr,"Wrong input format at line %d\n", i+1);
|
||||
exit(1);
|
||||
}
|
||||
if(dValue!=0)
|
||||
{
|
||||
x_space[j].index = nIndex;
|
||||
x_space[j].value = dValue;
|
||||
|
||||
++j;
|
||||
}
|
||||
}
|
||||
out2:
|
||||
if(j>=1 && x_space[j-1].index > m_nParams)
|
||||
m_nParams = x_space[j-1].index;
|
||||
x_space[j++].index = -1;
|
||||
}
|
||||
|
||||
if(param.gamma == 0)
|
||||
param.gamma = 1.0/m_nParams;
|
||||
|
||||
if(param.kernel_type == PRECOMPUTED)
|
||||
for(i=0;i<m_pProblem->l;i++)
|
||||
{
|
||||
if (m_pProblem->x[i][0].index != 0)
|
||||
{
|
||||
fprintf(stderr,"Wrong input format: first column must be 0:sample_serial_number\n");
|
||||
exit(1);
|
||||
}
|
||||
if ((int)m_pProblem->x[i][0].value <= 0 || (int)m_pProblem->x[i][0].value > m_nParams)
|
||||
{
|
||||
fprintf(stderr,"Wrong input format: sample_serial_number out of range\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
|
||||
ScaleTrainingData();
|
||||
SaveScaleFactors(strFilename + ".sf");
|
||||
|
||||
return m_pProblem;
|
||||
}
|
||||
|
||||
bool SVMUtil::ScaleTrainingData()
|
||||
{
|
||||
if(!m_pProblem)
|
||||
{
|
||||
assert(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!DetermineScaleFactors())
|
||||
return false;
|
||||
|
||||
svm_node* pNode = NULL;
|
||||
|
||||
for(int i=0; i < m_pProblem->l; i++)
|
||||
{
|
||||
pNode = m_pProblem->x[i];
|
||||
ScaleNode(pNode);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SVMUtil::DetermineScaleFactors()
|
||||
{
|
||||
if(!m_pProblem)
|
||||
return false;
|
||||
|
||||
svm_node* pNode = NULL;
|
||||
double* pMaxValue = Malloc(double, m_nParams);
|
||||
m_pScaleFactors = Malloc(double, m_nParams);
|
||||
|
||||
for(int j=0; j < m_nParams; j++)
|
||||
{
|
||||
pMaxValue[j] = 0; // assumes values should be scaled between 0 and 1
|
||||
}
|
||||
|
||||
for(int i=0; i < m_pProblem->l; i++)
|
||||
{
|
||||
pNode = m_pProblem->x[i];
|
||||
int nindex = 0;
|
||||
int j=0;
|
||||
while(pNode)
|
||||
{
|
||||
nindex = pNode[j].index;
|
||||
if(nindex==-1)
|
||||
break;
|
||||
|
||||
pMaxValue[nindex-1] = max(pMaxValue[nindex-1], pNode[j].value); // assume values are positive
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
for(int j=0; j < m_nParams; j++)
|
||||
{
|
||||
if(pMaxValue[j] > 0)
|
||||
m_pScaleFactors[j] = (double)1./pMaxValue[j];
|
||||
else
|
||||
m_pScaleFactors[j] = 1;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SVMUtil::ScaleNode(svm_node* pNode)
|
||||
{
|
||||
if(!pNode)
|
||||
{
|
||||
cerr << "error scaling" << endl;
|
||||
assert(0);
|
||||
return false;
|
||||
}
|
||||
if(!m_pScaleFactors)
|
||||
{
|
||||
if(m_pProblem)
|
||||
DetermineScaleFactors();
|
||||
else
|
||||
{
|
||||
assert(0);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
|
||||
while(pNode[i].index != -1)
|
||||
{
|
||||
pNode[i].value *= m_pScaleFactors[pNode[i].index-1];
|
||||
i++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SVMUtil::ParameterSearch(svm_parameter* pSvmParam, string strFilename)
|
||||
{
|
||||
if(!m_pProblem || !pSvmParam)
|
||||
return false;
|
||||
|
||||
//struct sigaction sa;
|
||||
//sa.sa_handler = &myfunction;
|
||||
//sigaction(SIGINT, &sa, NULL);
|
||||
|
||||
CParameterSearch* paramSearch = new CParameterSearch(m_pProblem, pSvmParam, strFilename);
|
||||
|
||||
//SaveSearch(paramSearch);
|
||||
|
||||
delete paramSearch;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SVMUtil::SaveSearch(const CParameterSearch* p_Search)
|
||||
{
|
||||
std::ofstream ofs("searchResults.txt");
|
||||
boost::archive::text_oarchive oa(ofs);
|
||||
oa << *p_Search;
|
||||
return true;
|
||||
}
|
||||
|
||||
void myfunction(int number)
|
||||
{
|
||||
int ten;
|
||||
int five = number;
|
||||
|
||||
ten = five + five;
|
||||
|
||||
}
|
||||
|
||||
bool SVMUtil::Load(string filename)
|
||||
{
|
||||
if(m_pModel)
|
||||
svm_destroy_model(m_pModel);
|
||||
|
||||
string modelname = filename + ".mod";
|
||||
string scalename = filename + ".sf";
|
||||
m_pModel = svm_load_model(modelname.c_str());
|
||||
LoadScaleFactors(scalename);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SVMUtil::Save(string filename)
|
||||
{
|
||||
string modelname = filename + ".mod";
|
||||
string scalename = filename + ".sf";
|
||||
svm_save_model(modelname.c_str(), m_pModel);
|
||||
SaveScaleFactors(scalename);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SVMUtil::SaveScaleFactors(string filename)
|
||||
{
|
||||
ofstream fout;
|
||||
fout.open(filename.c_str());
|
||||
fout << m_nParams << endl;
|
||||
for(int i=0; i<m_nParams; i++)
|
||||
{
|
||||
fout << m_pScaleFactors[i] << endl;
|
||||
}
|
||||
fout.close();
|
||||
}
|
||||
|
||||
|
||||
bool SVMUtil::LoadScaleFactors(string filename)
|
||||
{
|
||||
ifstream fin;
|
||||
fin.open(filename.c_str());
|
||||
fin >> m_nParams;
|
||||
|
||||
if(m_pScaleFactors)
|
||||
delete m_pScaleFactors;
|
||||
m_pScaleFactors = new double[m_nParams];
|
||||
|
||||
for(int i=0; i<m_nParams; i++)
|
||||
{
|
||||
fin >> m_pScaleFactors[i];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SVMUtil::CrossValidate(int nFolds, svm_parameter* pParam)
|
||||
{
|
||||
double* target = new double[m_pProblem->l];
|
||||
if(nFolds>0)
|
||||
svm_cross_validation(m_pProblem, pParam, nFolds, target);
|
||||
else
|
||||
{
|
||||
if(!m_pModel)
|
||||
m_pModel = svm_train(m_pProblem, pParam);
|
||||
for(int i=0; i<m_pProblem->l; i++)
|
||||
{
|
||||
target[i] = svm_predict(m_pModel, m_pProblem->x[i]);
|
||||
}
|
||||
}
|
||||
|
||||
float fError = 0;
|
||||
float fWrong = 0;
|
||||
for(int i=0; i<m_pProblem->l; i++)
|
||||
{
|
||||
fError += abs(m_pProblem->y[i] - target[i]) ;
|
||||
if( m_pProblem->y[i] >= 0.5 && target[i] < 0.5)
|
||||
fWrong++;
|
||||
else if( m_pProblem->y[i] < 0.5 && target[i] >= 0.5)
|
||||
fWrong++;
|
||||
|
||||
}
|
||||
fError = (float)fError/m_pProblem->l;
|
||||
fWrong = (float) fWrong/m_pProblem->l;
|
||||
|
||||
float fStdDev = 0;
|
||||
for(int i=0; i<m_pProblem->l; i++)
|
||||
{
|
||||
fStdDev += pow(fError - abs(m_pProblem->y[i] - target[i]), 2) ;
|
||||
}
|
||||
fStdDev = pow(fStdDev, (float)0.5) / m_pProblem->l;
|
||||
|
||||
std::cout << "Percent wrong: " << fWrong << " Avg Error: " << fError << " Std Dev: " << fStdDev << std::endl;
|
||||
return true;
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
struct svm_problem;
|
||||
struct svm_node;
|
||||
struct svm_parameter;
|
||||
struct svm_model;
|
||||
|
||||
class CParameterSearch;
|
||||
|
||||
#include <string>
|
||||
|
||||
#define Malloc(type,n) (type *)malloc((n)*sizeof(type))
|
||||
|
||||
class SVMUtil
|
||||
{
|
||||
public:
|
||||
SVMUtil();
|
||||
|
||||
~SVMUtil();
|
||||
|
||||
svm_problem* ParseTrainingFile(std::string strFilename);
|
||||
bool ParameterSearch( svm_parameter* pSvmParam, std::string strFilename);
|
||||
bool ScaleNode(svm_node*);
|
||||
bool CrossValidate(int nFolds, svm_parameter*);
|
||||
bool Load(std::string);
|
||||
bool Save(std::string);
|
||||
|
||||
svm_model* m_pModel;
|
||||
|
||||
private:
|
||||
|
||||
bool ScaleTrainingData();
|
||||
bool DetermineScaleFactors();
|
||||
bool SaveSearch(const CParameterSearch* p_Search);
|
||||
void SaveScaleFactors(std::string);
|
||||
bool LoadScaleFactors(std::string);
|
||||
|
||||
svm_problem* m_pProblem;
|
||||
|
||||
double* m_pScaleFactors;
|
||||
int m_nParams;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,13 @@
|
||||
echo "Enter text to be classified, hit return to run classification."
|
||||
read text
|
||||
|
||||
if [ `echo "$text" | sed -r 's/ +/ /g' | bin/stupidfilter data/c_rbf` = "1.000000" ]
|
||||
then
|
||||
echo "Text is not likely to be stupid."
|
||||
fi
|
||||
|
||||
if [ `echo "$text" | sed -r 's/ +/ /g' | bin/stupidfilter data/c_rbf` = "0.000000" ]
|
||||
then
|
||||
echo "Text is likely to be stupid."
|
||||
fi
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,9 @@
|
||||
8
|
||||
1
|
||||
1
|
||||
1
|
||||
0.0369004
|
||||
7.45456
|
||||
3
|
||||
0.00609756
|
||||
0.238095
|
@ -0,0 +1,70 @@
|
||||
// Copyright 2008 Rarefied Technologies, Inc.
|
||||
// Distributed under the GPL v2 please see
|
||||
// LICENSE file for more information.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <boost/archive/text_oarchive.hpp>
|
||||
#include <boost/archive/text_iarchive.hpp>
|
||||
|
||||
|
||||
class ParameterResult
|
||||
{
|
||||
public:
|
||||
ParameterResult() { bRefined = false; fError=0; nLevel=0; };
|
||||
|
||||
float fError;
|
||||
float fStdDev;
|
||||
float fWrong; // percent of predictions that would yield the wrong class
|
||||
float fParam1;
|
||||
float fParam2;
|
||||
bool bRefined; // indicates if a refinement search has been spawned from this result
|
||||
int nLevel; // which level of refinement this result is from
|
||||
|
||||
private:
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int version)
|
||||
{
|
||||
ar & fWrong;
|
||||
ar & fError;
|
||||
ar & fStdDev;
|
||||
ar & fParam1;
|
||||
ar & fParam2;
|
||||
ar & bRefined;
|
||||
ar & nLevel;
|
||||
}
|
||||
friend std::ostream& operator<<(std::ostream &os, const ParameterResult &pr)
|
||||
{
|
||||
os << pr.fWrong << '\t';
|
||||
os << pr.fError << '\t';
|
||||
os << pr.fStdDev << '\t';
|
||||
os << pr.fParam1 << '\t';
|
||||
os << pr.fParam2 << '\t';
|
||||
os << pr.bRefined << '\t';
|
||||
os << pr.nLevel;
|
||||
|
||||
return os;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class lessthan
|
||||
{
|
||||
public:
|
||||
bool operator()(const ParameterResult* left, const ParameterResult* right) const
|
||||
{
|
||||
bool bRet = (left->fWrong < right->fWrong);
|
||||
if(!bRet && (left->fWrong == right->fWrong ))
|
||||
{
|
||||
bRet = left->fError < right->fError;
|
||||
|
||||
}
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -0,0 +1,217 @@
|
||||
// Copyright 2008 Rarefied Technologies, Inc.
|
||||
// Distributed under the GPL v2 please see
|
||||
// LICENSE file for more information.
|
||||
|
||||
#include "parametersearch.h"
|
||||
#include "parameterresult.h"
|
||||
#include "../thirdparty/libsvm/svm.h"
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#define REFINED_RANGE 1.33
|
||||
|
||||
CParameterSearch::CParameterSearch(svm_problem* pProb, svm_parameter* pSvmParam, string strFilename)
|
||||
{
|
||||
if(!pProb || !pSvmParam)
|
||||
return;
|
||||
|
||||
m_pOA = NULL;
|
||||
m_pofs = NULL;
|
||||
m_strFilename = strFilename;
|
||||
|
||||
ResetSerialization();
|
||||
|
||||
m_pProblem = pProb;
|
||||
m_pSvmParam = pSvmParam;
|
||||
|
||||
m_rangeParameters.fParam1Min = -15;
|
||||
//m_rangeParameters.fParam1Max = -1;
|
||||
m_rangeParameters.fParam1Max = 3;
|
||||
m_rangeParameters.fParam1Step = 4;
|
||||
m_rangeParameters.bParam1UseLog = true;
|
||||
m_rangeParameters.fParam1RefinementFactor = 2;
|
||||
m_rangeParameters.fParam2Min = -13;
|
||||
//m_rangeParameters.fParam2Max = -1;
|
||||
m_rangeParameters.fParam2Max = -5;
|
||||
m_rangeParameters.fParam2Step = 4;
|
||||
m_rangeParameters.bParam2UseLog = true;
|
||||
m_rangeParameters.fParam2RefinementFactor = 2;
|
||||
|
||||
ParameterResult* pResult = new ParameterResult;
|
||||
|
||||
const RangeParameters tempRP = m_rangeParameters;
|
||||
*m_pOA << tempRP;
|
||||
m_pofs->flush();
|
||||
|
||||
SearchRange( pResult, m_rangeParameters);
|
||||
|
||||
// semi-infinite, breakable loop
|
||||
while( pResult = GetNextResult())
|
||||
{
|
||||
RangeParameters Params;
|
||||
GetRefinedParameters(pResult->nLevel, pResult->fParam1, pResult->fParam2, Params);
|
||||
if(!SearchRange( pResult, Params))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CParameterSearch::~CParameterSearch()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ParameterResult* CParameterSearch::GetNextResult()
|
||||
{
|
||||
ParameterResult* pResult = NULL;
|
||||
ResultsSet::iterator it = m_searchResults.begin();
|
||||
while(it != m_searchResults.end())
|
||||
{
|
||||
pResult = *it;
|
||||
if(!pResult->bRefined)
|
||||
return pResult;
|
||||
++it;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool CParameterSearch::SearchRange(ParameterResult* pResult, RangeParameters& Params)
|
||||
{
|
||||
if(!m_pProblem || !m_pSvmParam || !pResult)
|
||||
return false;
|
||||
|
||||
float fParam1 = 0;
|
||||
float fParam2 = 0;
|
||||
|
||||
double* target = new double[m_pProblem->l];
|
||||
/* for(int i=0; i<m_pProblem->l; i++)
|
||||
{
|
||||
target[i] = 0;
|
||||
}*/
|
||||
|
||||
for(fParam1=Params.fParam1Min; fParam1<=Params.fParam1Max; fParam1+=Params.fParam1Step)
|
||||
{
|
||||
if(Params.bParam1UseLog)
|
||||
m_pSvmParam->p = ::pow(2,fParam1);
|
||||
else
|
||||
m_pSvmParam->p = fParam1;
|
||||
|
||||
for(fParam2=Params.fParam2Min; fParam2<=Params.fParam2Max; fParam2+=Params.fParam2Step)
|
||||
{
|
||||
if(Params.bParam2UseLog)
|
||||
m_pSvmParam->C = ::pow(2,fParam2);
|
||||
else
|
||||
m_pSvmParam->C = fParam2;
|
||||
|
||||
int nFolds = 2;
|
||||
svm_cross_validation(m_pProblem, m_pSvmParam, nFolds, target);
|
||||
float fError = 0;
|
||||
float fWrong = 0;
|
||||
for(int i=0; i<m_pProblem->l; i++)
|
||||
{
|
||||
fError += abs(m_pProblem->y[i] - target[i]);
|
||||
if( m_pProblem->y[i] >= 0.5 && target[i] < 0.5)
|
||||
fWrong++;
|
||||
else if( m_pProblem->y[i] < 0.5 && target[i] >= 0.5)
|
||||
fWrong++;
|
||||
}
|
||||
fError = (float)fError/m_pProblem->l;
|
||||
fWrong = (float) fWrong/m_pProblem->l;
|
||||
|
||||
float fStdDev = 0;
|
||||
for(int i=0; i<m_pProblem->l; i++)
|
||||
{
|
||||
fStdDev += pow(fError - abs(m_pProblem->y[i] - target[i]), 2) ;
|
||||
}
|
||||
fStdDev = pow(fStdDev, (float)0.5) / m_pProblem->l;
|
||||
|
||||
std::cout << "\n****************" << std::endl;
|
||||
std::cout << "C = 2^" << fParam2 << ", epsilon = 2^" << fParam1 << std::endl;
|
||||
std::cout << "Avg Error: " << fError << " Std Dev: " << fStdDev << std::endl;
|
||||
std::cout << "Percent wrong: " << fWrong << std::endl;
|
||||
|
||||
ParameterResult* pNewResult = new ParameterResult;
|
||||
pNewResult->fError = fError;
|
||||
pNewResult->fStdDev = fStdDev;
|
||||
pNewResult->fWrong = fWrong;
|
||||
pNewResult->fParam1 = fParam1;
|
||||
pNewResult->fParam2 = fParam2;
|
||||
pNewResult->nLevel = pResult->nLevel + 1;
|
||||
m_searchResults.insert(pNewResult);
|
||||
|
||||
const ParameterResult* pConstResult = pNewResult;
|
||||
|
||||
*m_pOA << *pConstResult;
|
||||
m_pofs->flush();
|
||||
|
||||
//SaveTextResults();
|
||||
}
|
||||
}
|
||||
pResult->bRefined = true;
|
||||
|
||||
SerializeData();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// nLevel is desired level, not current level
|
||||
bool CParameterSearch::GetRefinedParameters(int nLevel, float fParam1, float fParam2, RangeParameters& paramsOut)
|
||||
{
|
||||
paramsOut.bParam1UseLog = m_rangeParameters.bParam1UseLog;
|
||||
float fParam1StepPrev = m_rangeParameters.fParam1Step / pow(m_rangeParameters.fParam1RefinementFactor, nLevel-1);
|
||||
paramsOut.fParam1Min = max( m_rangeParameters.fParam1Min, fParam1 - (float)REFINED_RANGE * fParam1StepPrev );
|
||||
paramsOut.fParam1Max = min( m_rangeParameters.fParam1Max, fParam1 + (float)REFINED_RANGE * fParam1StepPrev );
|
||||
paramsOut.fParam1Step = m_rangeParameters.fParam1Step / pow(m_rangeParameters.fParam1RefinementFactor, nLevel);
|
||||
|
||||
paramsOut.bParam2UseLog = m_rangeParameters.bParam2UseLog;
|
||||
float fParam2StepPrev = m_rangeParameters.fParam2Step / pow(m_rangeParameters.fParam2RefinementFactor, nLevel-1);
|
||||
paramsOut.fParam2Min = max( m_rangeParameters.fParam2Min, fParam2 - (float)REFINED_RANGE * fParam2StepPrev );
|
||||
paramsOut.fParam2Max = min( m_rangeParameters.fParam2Max, fParam2 + (float)REFINED_RANGE * fParam2StepPrev );
|
||||
paramsOut.fParam2Step = m_rangeParameters.fParam2Step / pow(m_rangeParameters.fParam2RefinementFactor, nLevel);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CParameterSearch::ResetSerialization()
|
||||
{
|
||||
delete m_pOA;
|
||||
delete m_pofs;
|
||||
|
||||
m_pofs = new std::ofstream(m_strFilename.c_str());
|
||||
m_pOA = new boost::archive::text_oarchive(*m_pofs);
|
||||
}
|
||||
|
||||
void CParameterSearch::SerializeData()
|
||||
{
|
||||
ResetSerialization();
|
||||
|
||||
const CParameterSearch* pSearch = this;
|
||||
|
||||
*m_pOA << *pSearch;
|
||||
|
||||
m_pofs->flush();
|
||||
}
|
||||
|
||||
void CParameterSearch::SaveTextResults()
|
||||
{
|
||||
std::ofstream ofs("SearchResults.txt");
|
||||
ofs << *this;
|
||||
}
|
||||
|
||||
std::ostream & operator<<(std::ostream &os, const CParameterSearch &ps)
|
||||
{
|
||||
os << ps.m_rangeParameters << std::endl << std::endl;
|
||||
ResultsSet::iterator it = ps.m_searchResults.begin();
|
||||
while(it != ps.m_searchResults.end())
|
||||
{
|
||||
const ParameterResult* pResult = *it;
|
||||
|
||||
os << *pResult << '\n';
|
||||
|
||||
++it;
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
|
@ -0,0 +1,119 @@
|
||||
#include <set>
|
||||
#include "../thirdparty/boost/archive/text_oarchive.hpp"
|
||||
#include "../thirdparty/boost/archive/text_iarchive.hpp"
|
||||
#include "../thirdparty/boost/serialization/set.hpp"
|
||||
#include <ostream>
|
||||
#include "parameterresult.h"
|
||||
#include <string>
|
||||
|
||||
struct svm_problem;
|
||||
struct svm_parameter;
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
typedef multiset<ParameterResult*, lessthan> ResultsSet;
|
||||
|
||||
struct RangeParameters
|
||||
{
|
||||
float fParam1Min;
|
||||
float fParam1Max;
|
||||
float fParam1Step;
|
||||
bool bParam1UseLog;
|
||||
|
||||
float fParam2Min;
|
||||
float fParam2Max;
|
||||
float fParam2Step;
|
||||
bool bParam2UseLog;
|
||||
|
||||
// members below could be moved to a derived class
|
||||
float fParam1RefinementFactor;
|
||||
float fParam2RefinementFactor;
|
||||
int nLevels; // alternatively have a minimum refined step for each param
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int version)
|
||||
{
|
||||
ar & fParam1Min;
|
||||
ar & fParam1Max;
|
||||
ar & fParam1Step;
|
||||
ar & bParam1UseLog;
|
||||
ar & fParam2Min;
|
||||
ar & fParam2Max;
|
||||
ar & fParam2Step;
|
||||
ar & bParam2UseLog;
|
||||
ar & fParam1RefinementFactor;
|
||||
ar & fParam2RefinementFactor;
|
||||
}
|
||||
|
||||
// friend ostream& operator<<(ostream &os, const RangeParameters &rp);
|
||||
friend ostream& operator<<(ostream &os, const RangeParameters &rp)
|
||||
{
|
||||
os << rp.fParam1Min << endl;
|
||||
os << rp.fParam1Max << endl;
|
||||
os << rp.fParam1Step << endl;
|
||||
os << rp.bParam1UseLog << endl;
|
||||
os << rp.fParam2Min << endl;
|
||||
os << rp.fParam2Max << endl;
|
||||
os << rp.fParam2Step << endl;
|
||||
os << rp.bParam2UseLog << endl;
|
||||
os << rp.fParam1RefinementFactor << endl;
|
||||
os << rp.fParam2RefinementFactor << endl;
|
||||
return os;
|
||||
/* return os << rp.fParam1Min
|
||||
<< rp.fParam1Max
|
||||
<< rp.fParam1Step
|
||||
<< rp.bParam1UseLog
|
||||
<< rp.fParam2Min
|
||||
<< rp.fParam2Max
|
||||
<< rp.fParam2Step
|
||||
<< rp.bParam2UseLog
|
||||
<< rp.fParam1RefinementFactor
|
||||
<< rp.fParam2RefinementFactor;*/
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/*class SearchParameters : class RangeParameters
|
||||
{
|
||||
public:
|
||||
float fRefinementFactor;
|
||||
};*/
|
||||
|
||||
class CParameterSearch
|
||||
{
|
||||
public:
|
||||
|
||||
CParameterSearch(svm_problem* pProb, svm_parameter* pSvmParam, std::string);
|
||||
~CParameterSearch();
|
||||
|
||||
bool SearchRange(ParameterResult* pResult, RangeParameters&);
|
||||
bool GetRefinedParameters(int nLevel, float fParam1, float fParam2, RangeParameters& paramsOut);
|
||||
ParameterResult* GetNextResult();
|
||||
|
||||
svm_problem* m_pProblem;
|
||||
svm_parameter* m_pSvmParam;
|
||||
ResultsSet m_searchResults;
|
||||
RangeParameters m_rangeParameters;
|
||||
|
||||
|
||||
private:
|
||||
friend class boost::serialization::access;
|
||||
friend std::ostream & operator<<(std::ostream &os, const CParameterSearch &ps);
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int version)
|
||||
{
|
||||
ar.register_type(static_cast<ParameterResult *>(NULL));
|
||||
ar & m_rangeParameters;
|
||||
ar & m_searchResults;
|
||||
}
|
||||
|
||||
void ResetSerialization();
|
||||
void SerializeData();
|
||||
void SaveTextResults();
|
||||
|
||||
std::ofstream* m_pofs;
|
||||
boost::archive::text_oarchive* m_pOA;
|
||||
std::string m_strFilename;
|
||||
};
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,23 @@
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by
|
||||
this license (the "Software") to use, reproduce, display, distribute,
|
||||
execute, and transmit the Software, and to prepare derivative works of the
|
||||
Software, and to permit third-parties to whom the Software is furnished to
|
||||
do so, all subject to the following:
|
||||
|
||||
The copyright notices in the Software and this entire statement, including
|
||||
the above license grant, this restriction and the following disclaimer,
|
||||
must be included in all copies of the Software, in whole or in part, and
|
||||
all derivative works of the Software, unless such copies or derivative
|
||||
works are solely in the form of machine-executable object code generated by
|
||||
a source language processor.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
@ -0,0 +1,47 @@
|
||||
// (C) Copyright Herve Bronnimann 2004.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
/*
|
||||
Revision history:
|
||||
1 July 2004
|
||||
Split the code into two headers to lessen dependence on
|
||||
Boost.tuple. (Herve)
|
||||
26 June 2004
|
||||
Added the code for the boost minmax library. (Herve)
|
||||
*/
|
||||
|
||||
#ifndef BOOST_ALGORITHM_MINMAX_HPP
|
||||
#define BOOST_ALGORITHM_MINMAX_HPP
|
||||
|
||||
/* PROPOSED STANDARD EXTENSIONS:
|
||||
*
|
||||
* minmax(a, b)
|
||||
* Effect: (b<a) ? std::make_pair(b,a) : std::make_pair(a,b);
|
||||
*
|
||||
* minmax(a, b, comp)
|
||||
* Effect: comp(b,a) ? std::make_pair(b,a) : std::make_pair(a,b);
|
||||
*
|
||||
*/
|
||||
|
||||
#include <boost/tuple/tuple.hpp> // for using pairs with boost::cref
|
||||
#include <boost/ref.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
template <typename T>
|
||||
tuple< T const&, T const& >
|
||||
minmax(T const& a, T const& b) {
|
||||
return (b<a) ? make_tuple(cref(b),cref(a)) : make_tuple(cref(a),cref(b));
|
||||
}
|
||||
|
||||
template <typename T, class BinaryPredicate>
|
||||
tuple< T const&, T const& >
|
||||
minmax(T const& a, T const& b, BinaryPredicate comp) {
|
||||
return comp(b,a) ? make_tuple(cref(b),cref(a)) : make_tuple(cref(a),cref(b));
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_ALGORITHM_MINMAX_HPP
|
@ -0,0 +1,551 @@
|
||||
// (C) Copyright Herve Bronnimann 2004.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
/*
|
||||
Revision history:
|
||||
1 July 2004
|
||||
Split the code into two headers to lessen dependence on
|
||||
Boost.tuple. (Herve)
|
||||
26 June 2004
|
||||
Added the code for the boost minmax library. (Herve)
|
||||
*/
|
||||
|
||||
#ifndef BOOST_ALGORITHM_MINMAX_ELEMENT_HPP
|
||||
#define BOOST_ALGORITHM_MINMAX_ELEMENT_HPP
|
||||
|
||||
/* PROPOSED STANDARD EXTENSIONS:
|
||||
*
|
||||
* minmax_element(first, last)
|
||||
* Effect: std::make_pair( std::min_element(first, last),
|
||||
* std::max_element(first, last) );
|
||||
*
|
||||
* minmax_element(first, last, comp)
|
||||
* Effect: std::make_pair( std::min_element(first, last, comp),
|
||||
* std::max_element(first, last, comp) );
|
||||
*/
|
||||
|
||||
#include <utility> // for std::pair and std::make_pair
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace detail { // for obtaining a uniform version of minmax_element
|
||||
// that compiles with VC++ 6.0 -- avoid the iterator_traits by
|
||||
// having comparison object over iterator, not over dereferenced value
|
||||
|
||||
template <typename Iterator>
|
||||
struct less_over_iter {
|
||||
bool operator()(Iterator const& it1,
|
||||
Iterator const& it2) const { return *it1 < *it2; }
|
||||
};
|
||||
|
||||
template <typename Iterator, class BinaryPredicate>
|
||||
struct binary_pred_over_iter {
|
||||
explicit binary_pred_over_iter(BinaryPredicate const& p ) : m_p( p ) {}
|
||||
bool operator()(Iterator const& it1,
|
||||
Iterator const& it2) const { return m_p(*it1, *it2); }
|
||||
private:
|
||||
BinaryPredicate m_p;
|
||||
};
|
||||
|
||||
// common base for the two minmax_element overloads
|
||||
|
||||
template <typename ForwardIter, class Compare >
|
||||
std::pair<ForwardIter,ForwardIter>
|
||||
basic_minmax_element(ForwardIter first, ForwardIter last, Compare comp)
|
||||
{
|
||||
if (first == last)
|
||||
return std::make_pair(last,last);
|
||||
|
||||
ForwardIter min_result = first;
|
||||
ForwardIter max_result = first;
|
||||
|
||||
// if only one element
|
||||
ForwardIter second = first; ++second;
|
||||
if (second == last)
|
||||
return std::make_pair(min_result, max_result);
|
||||
|
||||
// treat first pair separately (only one comparison for first two elements)
|
||||
ForwardIter potential_min_result = last;
|
||||
if (comp(first, second))
|
||||
max_result = second;
|
||||
else {
|
||||
min_result = second;
|
||||
potential_min_result = first;
|
||||
}
|
||||
|
||||
// then each element by pairs, with at most 3 comparisons per pair
|
||||
first = ++second; if (first != last) ++second;
|
||||
while (second != last) {
|
||||
if (comp(first, second)) {
|
||||
if (comp(first, min_result)) {
|
||||
min_result = first;
|
||||
potential_min_result = last;
|
||||
}
|
||||
if (comp(max_result, second))
|
||||
max_result = second;
|
||||
} else {
|
||||
if (comp(second, min_result)) {
|
||||
min_result = second;
|
||||
potential_min_result = first;
|
||||
}
|
||||
if (comp(max_result, first))
|
||||
max_result = first;
|
||||
}
|
||||
first = ++second;
|
||||
if (first != last) ++second;
|
||||
}
|
||||
|
||||
// if odd number of elements, treat last element
|
||||
if (first != last) { // odd number of elements
|
||||
if (comp(first, min_result))
|
||||
min_result = first, potential_min_result = last;
|
||||
else if (comp(max_result, first))
|
||||
max_result = first;
|
||||
}
|
||||
|
||||
// resolve min_result being incorrect with one extra comparison
|
||||
// (in which case potential_min_result is necessarily the correct result)
|
||||
if (potential_min_result != last
|
||||
&& !comp(min_result, potential_min_result))
|
||||
min_result = potential_min_result;
|
||||
|
||||
return std::make_pair(min_result,max_result);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <typename ForwardIter>
|
||||
std::pair<ForwardIter,ForwardIter>
|
||||
minmax_element(ForwardIter first, ForwardIter last)
|
||||
{
|
||||
return detail::basic_minmax_element(first, last,
|
||||
detail::less_over_iter<ForwardIter>() );
|
||||
}
|
||||
|
||||
template <typename ForwardIter, class BinaryPredicate>
|
||||
std::pair<ForwardIter,ForwardIter>
|
||||
minmax_element(ForwardIter first, ForwardIter last, BinaryPredicate comp)
|
||||
{
|
||||
return detail::basic_minmax_element(first, last,
|
||||
detail::binary_pred_over_iter<ForwardIter,BinaryPredicate>(comp) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* PROPOSED BOOST EXTENSIONS
|
||||
* In the description below, [rfirst,rlast) denotes the reversed range
|
||||
* of [first,last). Even though the iterator type of first and last may
|
||||
* be only a Forward Iterator, it is possible to explain the semantics
|
||||
* by assuming that it is a Bidirectional Iterator. In the sequel,
|
||||
* reverse(ForwardIterator&) returns the reverse_iterator adaptor.
|
||||
* This is not how the functions would be implemented!
|
||||
*
|
||||
* first_min_element(first, last)
|
||||
* Effect: std::min_element(first, last);
|
||||
*
|
||||
* first_min_element(first, last, comp)
|
||||
* Effect: std::min_element(first, last, comp);
|
||||
*
|
||||
* last_min_element(first, last)
|
||||
* Effect: reverse( std::min_element(reverse(last), reverse(first)) );
|
||||
*
|
||||
* last_min_element(first, last, comp)
|
||||
* Effect: reverse( std::min_element(reverse(last), reverse(first), comp) );
|
||||
*
|
||||
* first_max_element(first, last)
|
||||
* Effect: std::max_element(first, last);
|
||||
*
|
||||
* first_max_element(first, last, comp)
|
||||
* Effect: max_element(first, last);
|
||||
*
|
||||
* last_max_element(first, last)
|
||||
* Effect: reverse( std::max_element(reverse(last), reverse(first)) );
|
||||
*
|
||||
* last_max_element(first, last, comp)
|
||||
* Effect: reverse( std::max_element(reverse(last), reverse(first), comp) );
|
||||
*
|
||||
* first_min_first_max_element(first, last)
|
||||
* Effect: std::make_pair( first_min_element(first, last),
|
||||
* first_max_element(first, last) );
|
||||
*
|
||||
* first_min_first_max_element(first, last, comp)
|
||||
* Effect: std::make_pair( first_min_element(first, last, comp),
|
||||
* first_max_element(first, last, comp) );
|
||||
*
|
||||
* first_min_last_max_element(first, last)
|
||||
* Effect: std::make_pair( first_min_element(first, last),
|
||||
* last_max_element(first, last) );
|
||||
*
|
||||
* first_min_last_max_element(first, last, comp)
|
||||
* Effect: std::make_pair( first_min_element(first, last, comp),
|
||||
* last_max_element(first, last, comp) );
|
||||
*
|
||||
* last_min_first_max_element(first, last)
|
||||
* Effect: std::make_pair( last_min_element(first, last),
|
||||
* first_max_element(first, last) );
|
||||
*
|
||||
* last_min_first_max_element(first, last, comp)
|
||||
* Effect: std::make_pair( last_min_element(first, last, comp),
|
||||
* first_max_element(first, last, comp) );
|
||||
*
|
||||
* last_min_last_max_element(first, last)
|
||||
* Effect: std::make_pair( last_min_element(first, last),
|
||||
* last_max_element(first, last) );
|
||||
*
|
||||
* last_min_last_max_element(first, last, comp)
|
||||
* Effect: std::make_pair( last_min_element(first, last, comp),
|
||||
* last_max_element(first, last, comp) );
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
|
||||
// Min_element and max_element variants
|
||||
|
||||
namespace detail { // common base for the overloads
|
||||
|
||||
template <typename ForwardIter, class BinaryPredicate>
|
||||
ForwardIter
|
||||
basic_first_min_element(ForwardIter first, ForwardIter last,
|
||||
BinaryPredicate comp)
|
||||
{
|
||||
if (first == last) return last;
|
||||
ForwardIter min_result = first;
|
||||
while (++first != last)
|
||||
if (comp(first, min_result))
|
||||
min_result = first;
|
||||
return min_result;
|
||||
}
|
||||
|
||||
template <typename ForwardIter, class BinaryPredicate>
|
||||
ForwardIter
|
||||
basic_last_min_element(ForwardIter first, ForwardIter last,
|
||||
BinaryPredicate comp)
|
||||
{
|
||||
if (first == last) return last;
|
||||
ForwardIter min_result = first;
|
||||
while (++first != last)
|
||||
if (!comp(min_result, first))
|
||||
min_result = first;
|
||||
return min_result;
|
||||
}
|
||||
|
||||
template <typename ForwardIter, class BinaryPredicate>
|
||||
ForwardIter
|
||||
basic_first_max_element(ForwardIter first, ForwardIter last,
|
||||
BinaryPredicate comp)
|
||||
{
|
||||
if (first == last) return last;
|
||||
ForwardIter max_result = first;
|
||||
while (++first != last)
|
||||
if (comp(max_result, first))
|
||||
max_result = first;
|
||||
return max_result;
|
||||
}
|
||||
|
||||
template <typename ForwardIter, class BinaryPredicate>
|
||||
ForwardIter
|
||||
basic_last_max_element(ForwardIter first, ForwardIter last,
|
||||
BinaryPredicate comp)
|
||||
{
|
||||
if (first == last) return last;
|
||||
ForwardIter max_result = first;
|
||||
while (++first != last)
|
||||
if (!comp(first, max_result))
|
||||
max_result = first;
|
||||
return max_result;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <typename ForwardIter>
|
||||
ForwardIter
|
||||
first_min_element(ForwardIter first, ForwardIter last)
|
||||
{
|
||||
return detail::basic_first_min_element(first, last,
|
||||
detail::less_over_iter<ForwardIter>() );
|
||||
}
|
||||
|
||||
template <typename ForwardIter, class BinaryPredicate>
|
||||
ForwardIter
|
||||
first_min_element(ForwardIter first, ForwardIter last, BinaryPredicate comp)
|
||||
{
|
||||
return detail::basic_first_min_element(first, last,
|
||||
detail::binary_pred_over_iter<ForwardIter,BinaryPredicate>(comp) );
|
||||
}
|
||||
|
||||
template <typename ForwardIter>
|
||||
ForwardIter
|
||||
last_min_element(ForwardIter first, ForwardIter last)
|
||||
{
|
||||
return detail::basic_last_min_element(first, last,
|
||||
detail::less_over_iter<ForwardIter>() );
|
||||
}
|
||||
|
||||
template <typename ForwardIter, class BinaryPredicate>
|
||||
ForwardIter
|
||||
last_min_element(ForwardIter first, ForwardIter last, BinaryPredicate comp)
|
||||
{
|
||||
return detail::basic_last_min_element(first, last,
|
||||
detail::binary_pred_over_iter<ForwardIter,BinaryPredicate>(comp) );
|
||||
}
|
||||
|
||||
template <typename ForwardIter>
|
||||
ForwardIter
|
||||
first_max_element(ForwardIter first, ForwardIter last)
|
||||
{
|
||||
return detail::basic_first_max_element(first, last,
|
||||
detail::less_over_iter<ForwardIter>() );
|
||||
}
|
||||
|
||||
template <typename ForwardIter, class BinaryPredicate>
|
||||
ForwardIter
|
||||
first_max_element(ForwardIter first, ForwardIter last, BinaryPredicate comp)
|
||||
{
|
||||
return detail::basic_first_max_element(first, last,
|
||||
detail::binary_pred_over_iter<ForwardIter,BinaryPredicate>(comp) );
|
||||
}
|
||||
|
||||
template <typename ForwardIter>
|
||||
ForwardIter
|
||||
last_max_element(ForwardIter first, ForwardIter last)
|
||||
{
|
||||
return detail::basic_last_max_element(first, last,
|
||||
detail::less_over_iter<ForwardIter>() );
|
||||
}
|
||||
|
||||
template <typename ForwardIter, class BinaryPredicate>
|
||||
ForwardIter
|
||||
last_max_element(ForwardIter first, ForwardIter last, BinaryPredicate comp)
|
||||
{
|
||||
return detail::basic_last_max_element(first, last,
|
||||
detail::binary_pred_over_iter<ForwardIter,BinaryPredicate>(comp) );
|
||||
}
|
||||
|
||||
|
||||
// Minmax_element variants -- comments removed
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename ForwardIter, class BinaryPredicate>
|
||||
std::pair<ForwardIter,ForwardIter>
|
||||
basic_first_min_last_max_element(ForwardIter first, ForwardIter last,
|
||||
BinaryPredicate comp)
|
||||
{
|
||||
if (first == last)
|
||||
return std::make_pair(last,last);
|
||||
|
||||
ForwardIter min_result = first;
|
||||
ForwardIter max_result = first;
|
||||
|
||||
ForwardIter second = ++first;
|
||||
if (second == last)
|
||||
return std::make_pair(min_result, max_result);
|
||||
|
||||
if (comp(second, min_result))
|
||||
min_result = second;
|
||||
else
|
||||
max_result = second;
|
||||
|
||||
first = ++second; if (first != last) ++second;
|
||||
while (second != last) {
|
||||
if (!comp(second, first)) {
|
||||
if (comp(first, min_result))
|
||||
min_result = first;
|
||||
if (!comp(second, max_result))
|
||||
max_result = second;
|
||||
} else {
|
||||
if (comp(second, min_result))
|
||||
min_result = second;
|
||||
if (!comp(first, max_result))
|
||||
max_result = first;
|
||||
}
|
||||
first = ++second; if (first != last) ++second;
|
||||
}
|
||||
|
||||
if (first != last) {
|
||||
if (comp(first, min_result))
|
||||
min_result = first;
|
||||
else if (!comp(first, max_result))
|
||||
max_result = first;
|
||||
}
|
||||
|
||||
return std::make_pair(min_result, max_result);
|
||||
}
|
||||
|
||||
template <typename ForwardIter, class BinaryPredicate>
|
||||
std::pair<ForwardIter,ForwardIter>
|
||||
basic_last_min_first_max_element(ForwardIter first, ForwardIter last,
|
||||
BinaryPredicate comp)
|
||||
{
|
||||
if (first == last) return std::make_pair(last,last);
|
||||
|
||||
ForwardIter min_result = first;
|
||||
ForwardIter max_result = first;
|
||||
|
||||
ForwardIter second = ++first;
|
||||
if (second == last)
|
||||
return std::make_pair(min_result, max_result);
|
||||
|
||||
if (comp(max_result, second))
|
||||
max_result = second;
|
||||
else
|
||||
min_result = second;
|
||||
|
||||
first = ++second; if (first != last) ++second;
|
||||
while (second != last) {
|
||||
if (comp(first, second)) {
|
||||
if (!comp(min_result, first))
|
||||
min_result = first;
|
||||
if (comp(max_result, second))
|
||||
max_result = second;
|
||||
} else {
|
||||
if (!comp(min_result, second))
|
||||
min_result = second;
|
||||
if (comp(max_result, first))
|
||||
max_result = first;
|
||||
}
|
||||
first = ++second; if (first != last) ++second;
|
||||
}
|
||||
|
||||
if (first != last) {
|
||||
if (!comp(min_result, first))
|
||||
min_result = first;
|
||||
else if (comp(max_result, first))
|
||||
max_result = first;
|
||||
}
|
||||
|
||||
return std::make_pair(min_result, max_result);
|
||||
}
|
||||
|
||||
template <typename ForwardIter, class BinaryPredicate>
|
||||
std::pair<ForwardIter,ForwardIter>
|
||||
basic_last_min_last_max_element(ForwardIter first, ForwardIter last,
|
||||
BinaryPredicate comp)
|
||||
{
|
||||
if (first == last) return std::make_pair(last,last);
|
||||
|
||||
ForwardIter min_result = first;
|
||||
ForwardIter max_result = first;
|
||||
|
||||
ForwardIter second = first; ++second;
|
||||
if (second == last)
|
||||
return std::make_pair(min_result,max_result);
|
||||
|
||||
ForwardIter potential_max_result = last;
|
||||
if (comp(first, second))
|
||||
max_result = second;
|
||||
else {
|
||||
min_result = second;
|
||||
potential_max_result = second;
|
||||
}
|
||||
|
||||
first = ++second; if (first != last) ++second;
|
||||
while (second != last) {
|
||||
if (comp(first, second)) {
|
||||
if (!comp(min_result, first))
|
||||
min_result = first;
|
||||
if (!comp(second, max_result)) {
|
||||
max_result = second;
|
||||
potential_max_result = last;
|
||||
}
|
||||
} else {
|
||||
if (!comp(min_result, second))
|
||||
min_result = second;
|
||||
if (!comp(first, max_result)) {
|
||||
max_result = first;
|
||||
potential_max_result = second;
|
||||
}
|
||||
}
|
||||
first = ++second;
|
||||
if (first != last) ++second;
|
||||
}
|
||||
|
||||
if (first != last) {
|
||||
if (!comp(min_result, first))
|
||||
min_result = first;
|
||||
if (!comp(first, max_result)) {
|
||||
max_result = first;
|
||||
potential_max_result = last;
|
||||
}
|
||||
}
|
||||
|
||||
if (potential_max_result != last
|
||||
&& !comp(potential_max_result, max_result))
|
||||
max_result = potential_max_result;
|
||||
|
||||
return std::make_pair(min_result,max_result);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <typename ForwardIter>
|
||||
inline std::pair<ForwardIter,ForwardIter>
|
||||
first_min_first_max_element(ForwardIter first, ForwardIter last)
|
||||
{
|
||||
return minmax_element(first, last);
|
||||
}
|
||||
|
||||
template <typename ForwardIter, class BinaryPredicate>
|
||||
inline std::pair<ForwardIter,ForwardIter>
|
||||
first_min_first_max_element(ForwardIter first, ForwardIter last,
|
||||
BinaryPredicate comp)
|
||||
{
|
||||
return minmax_element(first, last, comp);
|
||||
}
|
||||
|
||||
template <typename ForwardIter>
|
||||
std::pair<ForwardIter,ForwardIter>
|
||||
first_min_last_max_element(ForwardIter first, ForwardIter last)
|
||||
{
|
||||
return detail::basic_first_min_last_max_element(first, last,
|
||||
detail::less_over_iter<ForwardIter>() );
|
||||
}
|
||||
|
||||
template <typename ForwardIter, class BinaryPredicate>
|
||||
inline std::pair<ForwardIter,ForwardIter>
|
||||
first_min_last_max_element(ForwardIter first, ForwardIter last,
|
||||
BinaryPredicate comp)
|
||||
{
|
||||
return detail::basic_first_min_last_max_element(first, last,
|
||||
detail::binary_pred_over_iter<ForwardIter,BinaryPredicate>(comp) );
|
||||
}
|
||||
|
||||
template <typename ForwardIter>
|
||||
std::pair<ForwardIter,ForwardIter>
|
||||
last_min_first_max_element(ForwardIter first, ForwardIter last)
|
||||
{
|
||||
return detail::basic_last_min_first_max_element(first, last,
|
||||
detail::less_over_iter<ForwardIter>() );
|
||||
}
|
||||
|
||||
template <typename ForwardIter, class BinaryPredicate>
|
||||
inline std::pair<ForwardIter,ForwardIter>
|
||||
last_min_first_max_element(ForwardIter first, ForwardIter last,
|
||||
BinaryPredicate comp)
|
||||
{
|
||||
return detail::basic_last_min_first_max_element(first, last,
|
||||
detail::binary_pred_over_iter<ForwardIter,BinaryPredicate>(comp) );
|
||||
}
|
||||
|
||||
template <typename ForwardIter>
|
||||
std::pair<ForwardIter,ForwardIter>
|
||||
last_min_last_max_element(ForwardIter first, ForwardIter last)
|
||||
{
|
||||
return detail::basic_last_min_last_max_element(first, last,
|
||||
detail::less_over_iter<ForwardIter>() );
|
||||
}
|
||||
|
||||
template <typename ForwardIter, class BinaryPredicate>
|
||||
inline std::pair<ForwardIter,ForwardIter>
|
||||
last_min_last_max_element(ForwardIter first, ForwardIter last,
|
||||
BinaryPredicate comp)
|
||||
{
|
||||
return detail::basic_last_min_last_max_element(first, last,
|
||||
detail::binary_pred_over_iter<ForwardIter,BinaryPredicate>(comp) );
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_ALGORITHM_MINMAX_ELEMENT_HPP
|
@ -0,0 +1,30 @@
|
||||
// Boost string_algo library string_algo.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2004.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_ALGO_HPP
|
||||
#define BOOST_STRING_ALGO_HPP
|
||||
|
||||
/*! \file
|
||||
Cumulative include for string_algo library
|
||||
*/
|
||||
|
||||
#include <boost/algorithm/string/std_containers_traits.hpp>
|
||||
#include <boost/algorithm/string/trim.hpp>
|
||||
#include <boost/algorithm/string/case_conv.hpp>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/algorithm/string/find.hpp>
|
||||
#include <boost/algorithm/string/split.hpp>
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/algorithm/string/erase.hpp>
|
||||
#include <boost/algorithm/string/classification.hpp>
|
||||
#include <boost/algorithm/string/find_iterator.hpp>
|
||||
|
||||
|
||||
#endif // BOOST_STRING_ALGO_HPP
|
@ -0,0 +1,176 @@
|
||||
// Boost string_algo library case_conv.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_CASE_CONV_HPP
|
||||
#define BOOST_STRING_CASE_CONV_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <algorithm>
|
||||
#include <locale>
|
||||
#include <boost/iterator/transform_iterator.hpp>
|
||||
|
||||
#include <boost/range/as_literal.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/value_type.hpp>
|
||||
|
||||
#include <boost/algorithm/string/detail/case_conv.hpp>
|
||||
|
||||
/*! \file
|
||||
Defines sequence case-conversion algorithms.
|
||||
Algorithms convert each element in the input sequence to the
|
||||
desired case using provided locales.
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// to_lower -----------------------------------------------//
|
||||
|
||||
//! Convert to lower case
|
||||
/*!
|
||||
Each element of the input sequence is converted to lower
|
||||
case. The result is a copy of the input converted to lower case.
|
||||
It is returned as a sequence or copied to the output iterator.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input range
|
||||
\param Loc A locale used for conversion
|
||||
\return
|
||||
An output iterator pointing just after the last inserted character or
|
||||
a copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
|
||||
*/
|
||||
template<typename OutputIteratorT, typename RangeT>
|
||||
inline OutputIteratorT
|
||||
to_lower_copy(
|
||||
OutputIteratorT Output,
|
||||
const RangeT& Input,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return ::boost::algorithm::detail::transform_range_copy(
|
||||
Output,
|
||||
as_literal(Input),
|
||||
::boost::algorithm::detail::to_lowerF<
|
||||
typename range_value<RangeT>::type >(Loc));
|
||||
}
|
||||
|
||||
//! Convert to lower case
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT>
|
||||
inline SequenceT to_lower_copy(
|
||||
const SequenceT& Input,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return ::boost::algorithm::detail::transform_range_copy<SequenceT>(
|
||||
Input,
|
||||
::boost::algorithm::detail::to_lowerF<
|
||||
typename range_value<SequenceT>::type >(Loc));
|
||||
}
|
||||
|
||||
//! Convert to lower case
|
||||
/*!
|
||||
Each element of the input sequence is converted to lower
|
||||
case. The input sequence is modified in-place.
|
||||
|
||||
\param Input A range
|
||||
\param Loc a locale used for conversion
|
||||
*/
|
||||
template<typename WritableRangeT>
|
||||
inline void to_lower(
|
||||
WritableRangeT& Input,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
::boost::algorithm::detail::transform_range(
|
||||
as_literal(Input),
|
||||
::boost::algorithm::detail::to_lowerF<
|
||||
typename range_value<WritableRangeT>::type >(Loc));
|
||||
}
|
||||
|
||||
// to_upper -----------------------------------------------//
|
||||
|
||||
//! Convert to upper case
|
||||
/*!
|
||||
Each element of the input sequence is converted to upper
|
||||
case. The result is a copy of the input converted to upper case.
|
||||
It is returned as a sequence or copied to the output iterator
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input range
|
||||
\param Loc A locale used for conversion
|
||||
\return
|
||||
An output iterator pointing just after the last inserted character or
|
||||
a copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename OutputIteratorT, typename RangeT>
|
||||
inline OutputIteratorT
|
||||
to_upper_copy(
|
||||
OutputIteratorT Output,
|
||||
const RangeT& Input,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return ::boost::algorithm::detail::transform_range_copy(
|
||||
Output,
|
||||
as_literal(Input),
|
||||
::boost::algorithm::detail::to_upperF<
|
||||
typename range_value<RangeT>::type >(Loc));
|
||||
}
|
||||
|
||||
//! Convert to upper case
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT>
|
||||
inline SequenceT to_upper_copy(
|
||||
const SequenceT& Input,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return ::boost::algorithm::detail::transform_range_copy<SequenceT>(
|
||||
Input,
|
||||
::boost::algorithm::detail::to_upperF<
|
||||
typename range_value<SequenceT>::type >(Loc));
|
||||
}
|
||||
|
||||
//! Convert to upper case
|
||||
/*!
|
||||
Each element of the input sequence is converted to upper
|
||||
case. The input sequence is modified in-place.
|
||||
|
||||
\param Input An input range
|
||||
\param Loc a locale used for conversion
|
||||
*/
|
||||
template<typename WritableRangeT>
|
||||
inline void to_upper(
|
||||
WritableRangeT& Input,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
::boost::algorithm::detail::transform_range(
|
||||
as_literal(Input),
|
||||
::boost::algorithm::detail::to_upperF<
|
||||
typename range_value<WritableRangeT>::type >(Loc));
|
||||
}
|
||||
|
||||
} // namespace algorithm
|
||||
|
||||
// pull names to the boost namespace
|
||||
using algorithm::to_lower;
|
||||
using algorithm::to_lower_copy;
|
||||
using algorithm::to_upper;
|
||||
using algorithm::to_upper_copy;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_STRING_CASE_CONV_HPP
|
@ -0,0 +1,312 @@
|
||||
// Boost string_algo library classification.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_CLASSIFICATION_HPP
|
||||
#define BOOST_STRING_CLASSIFICATION_HPP
|
||||
|
||||
#include <algorithm>
|
||||
#include <locale>
|
||||
#include <boost/range/value_type.hpp>
|
||||
#include <boost/range/as_literal.hpp>
|
||||
#include <boost/algorithm/string/detail/classification.hpp>
|
||||
#include <boost/algorithm/string/predicate_facade.hpp>
|
||||
|
||||
|
||||
/*! \file
|
||||
Classification predicates are included in the library to give
|
||||
some more convenience when using algorithms like \c trim() and \c all().
|
||||
They wrap functionality of STL classification functions ( e.g. \c std::isspace() )
|
||||
into generic functors.
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// classification functor generator -------------------------------------//
|
||||
|
||||
//! is_classified predicate
|
||||
/*!
|
||||
Construct the \c is_classified predicate. This predicate holds if the input is
|
||||
of specified \c std::ctype category.
|
||||
|
||||
\param Type A \c std::ctype category
|
||||
\param Loc A locale used for classification
|
||||
\return An instance of the \c is_classified predicate
|
||||
*/
|
||||
inline detail::is_classifiedF
|
||||
is_classified(std::ctype_base::mask Type, const std::locale& Loc=std::locale())
|
||||
{
|
||||
return detail::is_classifiedF(Type, Loc);
|
||||
}
|
||||
|
||||
//! is_space predicate
|
||||
/*!
|
||||
Construct the \c is_classified predicate for the \c ctype_base::space category.
|
||||
|
||||
\param Loc A locale used for classification
|
||||
\return An instance of the \c is_classified predicate
|
||||
*/
|
||||
inline detail::is_classifiedF
|
||||
is_space(const std::locale& Loc=std::locale())
|
||||
{
|
||||
return detail::is_classifiedF(std::ctype_base::space, Loc);
|
||||
}
|
||||
|
||||
//! is_alnum predicate
|
||||
/*!
|
||||
Construct the \c is_classified predicate for the \c ctype_base::alnum category.
|
||||
|
||||
\param Loc A locale used for classification
|
||||
\return An instance of the \c is_classified predicate
|
||||
*/
|
||||
inline detail::is_classifiedF
|
||||
is_alnum(const std::locale& Loc=std::locale())
|
||||
{
|
||||
return detail::is_classifiedF(std::ctype_base::alnum, Loc);
|
||||
}
|
||||
|
||||
//! is_alpha predicate
|
||||
/*!
|
||||
Construct the \c is_classified predicate for the \c ctype_base::alpha category.
|
||||
|
||||
\param Loc A locale used for classification
|
||||
\return An instance of the \c is_classified predicate
|
||||
*/
|
||||
inline detail::is_classifiedF
|
||||
is_alpha(const std::locale& Loc=std::locale())
|
||||
{
|
||||
return detail::is_classifiedF(std::ctype_base::alpha, Loc);
|
||||
}
|
||||
|
||||
//! is_cntrl predicate
|
||||
/*!
|
||||
Construct the \c is_classified predicate for the \c ctype_base::cntrl category.
|
||||
|
||||
\param Loc A locale used for classification
|
||||
\return An instance of the \c is_classified predicate
|
||||
*/
|
||||
inline detail::is_classifiedF
|
||||
is_cntrl(const std::locale& Loc=std::locale())
|
||||
{
|
||||
return detail::is_classifiedF(std::ctype_base::cntrl, Loc);
|
||||
}
|
||||
|
||||
//! is_digit predicate
|
||||
/*!
|
||||
Construct the \c is_classified predicate for the \c ctype_base::digit category.
|
||||
|
||||
\param Loc A locale used for classification
|
||||
\return An instance of the \c is_classified predicate
|
||||
*/
|
||||
inline detail::is_classifiedF
|
||||
is_digit(const std::locale& Loc=std::locale())
|
||||
{
|
||||
return detail::is_classifiedF(std::ctype_base::digit, Loc);
|
||||
}
|
||||
|
||||
//! is_graph predicate
|
||||
/*!
|
||||
Construct the \c is_classified predicate for the \c ctype_base::graph category.
|
||||
|
||||
\param Loc A locale used for classification
|
||||
\return An instance of the \c is_classified predicate
|
||||
*/
|
||||
inline detail::is_classifiedF
|
||||
is_graph(const std::locale& Loc=std::locale())
|
||||
{
|
||||
return detail::is_classifiedF(std::ctype_base::graph, Loc);
|
||||
}
|
||||
|
||||
//! is_lower predicate
|
||||
/*!
|
||||
Construct the \c is_classified predicate for the \c ctype_base::lower category.
|
||||
|
||||
\param Loc A locale used for classification
|
||||
\return An instance of \c is_classified predicate
|
||||
*/
|
||||
inline detail::is_classifiedF
|
||||
is_lower(const std::locale& Loc=std::locale())
|
||||
{
|
||||
return detail::is_classifiedF(std::ctype_base::lower, Loc);
|
||||
}
|
||||
|
||||
//! is_print predicate
|
||||
/*!
|
||||
Construct the \c is_classified predicate for the \c ctype_base::print category.
|
||||
|
||||
\param Loc A locale used for classification
|
||||
\return An instance of the \c is_classified predicate
|
||||
*/
|
||||
inline detail::is_classifiedF
|
||||
is_print(const std::locale& Loc=std::locale())
|
||||
{
|
||||
return detail::is_classifiedF(std::ctype_base::print, Loc);
|
||||
}
|
||||
|
||||
//! is_punct predicate
|
||||
/*!
|
||||
Construct the \c is_classified predicate for the \c ctype_base::punct category.
|
||||
|
||||
\param Loc A locale used for classification
|
||||
\return An instance of the \c is_classified predicate
|
||||
*/
|
||||
inline detail::is_classifiedF
|
||||
is_punct(const std::locale& Loc=std::locale())
|
||||
{
|
||||
return detail::is_classifiedF(std::ctype_base::punct, Loc);
|
||||
}
|
||||
|
||||
//! is_upper predicate
|
||||
/*!
|
||||
Construct the \c is_classified predicate for the \c ctype_base::upper category.
|
||||
|
||||
\param Loc A locale used for classification
|
||||
\return An instance of the \c is_classified predicate
|
||||
*/
|
||||
inline detail::is_classifiedF
|
||||
is_upper(const std::locale& Loc=std::locale())
|
||||
{
|
||||
return detail::is_classifiedF(std::ctype_base::upper, Loc);
|
||||
}
|
||||
|
||||
//! is_xdigit predicate
|
||||
/*!
|
||||
Construct the \c is_classified predicate for the \c ctype_base::xdigit category.
|
||||
|
||||
\param Loc A locale used for classification
|
||||
\return An instance of the \c is_classified predicate
|
||||
*/
|
||||
inline detail::is_classifiedF
|
||||
is_xdigit(const std::locale& Loc=std::locale())
|
||||
{
|
||||
return detail::is_classifiedF(std::ctype_base::xdigit, Loc);
|
||||
}
|
||||
|
||||
//! is_any_of predicate
|
||||
/*!
|
||||
Construct the \c is_any_of predicate. The predicate holds if the input
|
||||
is included in the specified set of characters.
|
||||
|
||||
\param Set A set of characters to be recognized
|
||||
\return An instance of the \c is_any_of predicate
|
||||
*/
|
||||
template<typename RangeT>
|
||||
inline detail::is_any_ofF<
|
||||
BOOST_STRING_TYPENAME range_value<RangeT>::type>
|
||||
is_any_of( const RangeT& Set )
|
||||
{
|
||||
return detail::is_any_ofF<
|
||||
BOOST_STRING_TYPENAME range_value<RangeT>::type>(as_literal(Set));
|
||||
}
|
||||
|
||||
//! is_from_range predicate
|
||||
/*!
|
||||
Construct the \c is_from_range predicate. The predicate holds if the input
|
||||
is included in the specified range. (i.e. From <= Ch <= To )
|
||||
|
||||
\param From The start of the range
|
||||
\param To The end of the range
|
||||
\return An instance of the \c is_from_range predicate
|
||||
*/
|
||||
template<typename CharT>
|
||||
inline detail::is_from_rangeF<CharT> is_from_range(CharT From, CharT To)
|
||||
{
|
||||
return detail::is_from_rangeF<CharT>(From,To);
|
||||
}
|
||||
|
||||
// predicate combinators ---------------------------------------------------//
|
||||
|
||||
//! predicate 'and' composition predicate
|
||||
/*!
|
||||
Construct the \c class_and predicate. This predicate can be used
|
||||
to logically combine two classification predicates. \c class_and holds,
|
||||
if both predicates return true.
|
||||
|
||||
\param Pred1 The first predicate
|
||||
\param Pred2 The second predicate
|
||||
\return An instance of the \c class_and predicate
|
||||
*/
|
||||
template<typename Pred1T, typename Pred2T>
|
||||
inline detail::pred_andF<Pred1T, Pred2T>
|
||||
operator&&(
|
||||
const predicate_facade<Pred1T>& Pred1,
|
||||
const predicate_facade<Pred2T>& Pred2 )
|
||||
{
|
||||
// Doing the static_cast with the pointer instead of the reference
|
||||
// is a workaround for some compilers which have problems with
|
||||
// static_cast's of template references, i.e. CW8. /grafik/
|
||||
return detail::pred_andF<Pred1T,Pred2T>(
|
||||
*static_cast<const Pred1T*>(&Pred1),
|
||||
*static_cast<const Pred2T*>(&Pred2) );
|
||||
}
|
||||
|
||||
//! predicate 'or' composition predicate
|
||||
/*!
|
||||
Construct the \c class_or predicate. This predicate can be used
|
||||
to logically combine two classification predicates. \c class_or holds,
|
||||
if one of the predicates return true.
|
||||
|
||||
\param Pred1 The first predicate
|
||||
\param Pred2 The second predicate
|
||||
\return An instance of the \c class_or predicate
|
||||
*/
|
||||
template<typename Pred1T, typename Pred2T>
|
||||
inline detail::pred_orF<Pred1T, Pred2T>
|
||||
operator||(
|
||||
const predicate_facade<Pred1T>& Pred1,
|
||||
const predicate_facade<Pred2T>& Pred2 )
|
||||
{
|
||||
// Doing the static_cast with the pointer instead of the reference
|
||||
// is a workaround for some compilers which have problems with
|
||||
// static_cast's of template references, i.e. CW8. /grafik/
|
||||
return detail::pred_orF<Pred1T,Pred2T>(
|
||||
*static_cast<const Pred1T*>(&Pred1),
|
||||
*static_cast<const Pred2T*>(&Pred2));
|
||||
}
|
||||
|
||||
//! predicate negation operator
|
||||
/*!
|
||||
Construct the \c class_not predicate. This predicate represents a negation.
|
||||
\c class_or holds if of the predicates return false.
|
||||
|
||||
\param Pred The predicate to be negated
|
||||
\return An instance of the \c class_not predicate
|
||||
*/
|
||||
template<typename PredT>
|
||||
inline detail::pred_notF<PredT>
|
||||
operator!( const predicate_facade<PredT>& Pred )
|
||||
{
|
||||
// Doing the static_cast with the pointer instead of the reference
|
||||
// is a workaround for some compilers which have problems with
|
||||
// static_cast's of template references, i.e. CW8. /grafik/
|
||||
return detail::pred_notF<PredT>(*static_cast<const PredT*>(&Pred));
|
||||
}
|
||||
|
||||
} // namespace algorithm
|
||||
|
||||
// pull names to the boost namespace
|
||||
using algorithm::is_classified;
|
||||
using algorithm::is_space;
|
||||
using algorithm::is_alnum;
|
||||
using algorithm::is_alpha;
|
||||
using algorithm::is_cntrl;
|
||||
using algorithm::is_digit;
|
||||
using algorithm::is_graph;
|
||||
using algorithm::is_lower;
|
||||
using algorithm::is_upper;
|
||||
using algorithm::is_print;
|
||||
using algorithm::is_punct;
|
||||
using algorithm::is_xdigit;
|
||||
using algorithm::is_any_of;
|
||||
using algorithm::is_from_range;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_STRING_PREDICATE_HPP
|
@ -0,0 +1,199 @@
|
||||
// Boost string_algo library compare.hpp header file -------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2006.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_COMPARE_HPP
|
||||
#define BOOST_STRING_COMPARE_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <locale>
|
||||
|
||||
/*! \file
|
||||
Defines element comparison predicates. Many algorithms in this library can
|
||||
take an additional argument with a predicate used to compare elements.
|
||||
This makes it possible, for instance, to have case insensitive versions
|
||||
of the algorithms.
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// is_equal functor -----------------------------------------------//
|
||||
|
||||
//! is_equal functor
|
||||
/*!
|
||||
Standard STL equal_to only handle comparison between arguments
|
||||
of the same type. This is a less restrictive version which wraps operator ==.
|
||||
*/
|
||||
struct is_equal
|
||||
{
|
||||
//! Function operator
|
||||
/*!
|
||||
Compare two operands for equality
|
||||
*/
|
||||
template< typename T1, typename T2 >
|
||||
bool operator()( const T1& Arg1, const T2& Arg2 ) const
|
||||
{
|
||||
return Arg1==Arg2;
|
||||
}
|
||||
};
|
||||
|
||||
//! case insensitive version of is_equal
|
||||
/*!
|
||||
Case insensitive comparison predicate. Comparison is done using
|
||||
specified locales.
|
||||
*/
|
||||
struct is_iequal
|
||||
{
|
||||
//! Constructor
|
||||
/*!
|
||||
\param Loc locales used for comparison
|
||||
*/
|
||||
is_iequal( const std::locale& Loc=std::locale() ) :
|
||||
m_Loc( Loc ) {}
|
||||
|
||||
//! Function operator
|
||||
/*!
|
||||
Compare two operands. Case is ignored.
|
||||
*/
|
||||
template< typename T1, typename T2 >
|
||||
bool operator()( const T1& Arg1, const T2& Arg2 ) const
|
||||
{
|
||||
#if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL)
|
||||
return std::toupper(Arg1)==std::toupper(Arg2);
|
||||
#else
|
||||
return std::toupper<T1>(Arg1,m_Loc)==std::toupper<T2>(Arg2,m_Loc);
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
std::locale m_Loc;
|
||||
};
|
||||
|
||||
// is_less functor -----------------------------------------------//
|
||||
|
||||
//! is_less functor
|
||||
/*!
|
||||
Convenient version of standard std::less. Operation is templated, therefore it is
|
||||
not required to specify the exact types upon the construction
|
||||
*/
|
||||
struct is_less
|
||||
{
|
||||
//! Functor operation
|
||||
/*!
|
||||
Compare two operands using > operator
|
||||
*/
|
||||
template< typename T1, typename T2 >
|
||||
bool operator()( const T1& Arg1, const T2& Arg2 ) const
|
||||
{
|
||||
return Arg1<Arg2;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//! case insensitive version of is_less
|
||||
/*!
|
||||
Case insensitive comparison predicate. Comparison is done using
|
||||
specified locales.
|
||||
*/
|
||||
struct is_iless
|
||||
{
|
||||
//! Constructor
|
||||
/*!
|
||||
\param Loc locales used for comparison
|
||||
*/
|
||||
is_iless( const std::locale& Loc=std::locale() ) :
|
||||
m_Loc( Loc ) {}
|
||||
|
||||
//! Function operator
|
||||
/*!
|
||||
Compare two operands. Case is ignored.
|
||||
*/
|
||||
template< typename T1, typename T2 >
|
||||
bool operator()( const T1& Arg1, const T2& Arg2 ) const
|
||||
{
|
||||
#if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL)
|
||||
return std::toupper(Arg1)<std::toupper(Arg2);
|
||||
#else
|
||||
return std::toupper<T1>(Arg1,m_Loc)<std::toupper<T2>(Arg2,m_Loc);
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
std::locale m_Loc;
|
||||
};
|
||||
|
||||
// is_not_greater functor -----------------------------------------------//
|
||||
|
||||
//! is_not_greater functor
|
||||
/*!
|
||||
Convenient version of standard std::not_greater_to. Operation is templated, therefore it is
|
||||
not required to specify the exact types upon the construction
|
||||
*/
|
||||
struct is_not_greater
|
||||
{
|
||||
//! Functor operation
|
||||
/*!
|
||||
Compare two operands using > operator
|
||||
*/
|
||||
template< typename T1, typename T2 >
|
||||
bool operator()( const T1& Arg1, const T2& Arg2 ) const
|
||||
{
|
||||
return Arg1<=Arg2;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//! case insensitive version of is_not_greater
|
||||
/*!
|
||||
Case insensitive comparison predicate. Comparison is done using
|
||||
specified locales.
|
||||
*/
|
||||
struct is_not_igreater
|
||||
{
|
||||
//! Constructor
|
||||
/*!
|
||||
\param Loc locales used for comparison
|
||||
*/
|
||||
is_not_igreater( const std::locale& Loc=std::locale() ) :
|
||||
m_Loc( Loc ) {}
|
||||
|
||||
//! Function operator
|
||||
/*!
|
||||
Compare two operands. Case is ignored.
|
||||
*/
|
||||
template< typename T1, typename T2 >
|
||||
bool operator()( const T1& Arg1, const T2& Arg2 ) const
|
||||
{
|
||||
#if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL)
|
||||
return std::toupper(Arg1)<=std::toupper(Arg2);
|
||||
#else
|
||||
return std::toupper<T1>(Arg1,m_Loc)<=std::toupper<T2>(Arg2,m_Loc);
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
std::locale m_Loc;
|
||||
};
|
||||
|
||||
|
||||
} // namespace algorithm
|
||||
|
||||
// pull names to the boost namespace
|
||||
using algorithm::is_equal;
|
||||
using algorithm::is_iequal;
|
||||
using algorithm::is_less;
|
||||
using algorithm::is_iless;
|
||||
using algorithm::is_not_greater;
|
||||
using algorithm::is_not_igreater;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_COMPARE_HPP
|
@ -0,0 +1,83 @@
|
||||
// Boost string_algo library concept.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_CONCEPT_HPP
|
||||
#define BOOST_STRING_CONCEPT_HPP
|
||||
|
||||
#include <boost/concept_check.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
|
||||
/*! \file
|
||||
Defines concepts used in string_algo library
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
//! Finder concept
|
||||
/*!
|
||||
Defines the Finder concept. Finder is a functor which selects
|
||||
an arbitrary part of a string. Search is performed on
|
||||
the range specified by starting and ending iterators.
|
||||
|
||||
Result of the find operation must be convertible to iterator_range.
|
||||
*/
|
||||
template<typename FinderT, typename IteratorT>
|
||||
struct FinderConcept
|
||||
{
|
||||
private:
|
||||
typedef iterator_range<IteratorT> range;
|
||||
public:
|
||||
void constraints()
|
||||
{
|
||||
// Operation
|
||||
r=(*pF)(i,i);
|
||||
}
|
||||
private:
|
||||
range r;
|
||||
IteratorT i;
|
||||
FinderT* pF;
|
||||
}; // Finder_concept
|
||||
|
||||
|
||||
//! Formatter concept
|
||||
/*!
|
||||
Defines the Formatter concept. Formatter is a functor, which
|
||||
takes a result from a finder operation and transforms it
|
||||
in a specific way.
|
||||
|
||||
Result must be a container supported by container_traits,
|
||||
or a reference to it.
|
||||
*/
|
||||
template<typename FormatterT, typename FinderT, typename IteratorT>
|
||||
struct FormatterConcept
|
||||
{
|
||||
public:
|
||||
void constraints()
|
||||
{
|
||||
// Operation
|
||||
begin((*pFo)( (*pF)(i,i) ));
|
||||
end((*pFo)( (*pF)(i,i) ));
|
||||
}
|
||||
private:
|
||||
IteratorT i;
|
||||
FinderT* pF;
|
||||
FormatterT *pFo;
|
||||
}; // FormatterConcept;
|
||||
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // BOOST_STRING_CONCEPT_HPP
|
@ -0,0 +1,28 @@
|
||||
// Boost string_algo library config.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_CONFIG_HPP
|
||||
#define BOOST_STRING_CONFIG_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#ifdef BOOST_STRING_DEDUCED_TYPENAME
|
||||
# error "macro already defined!"
|
||||
#endif
|
||||
|
||||
#define BOOST_STRING_TYPENAME BOOST_DEDUCED_TYPENAME
|
||||
|
||||
// Metrowerks workaround
|
||||
#if BOOST_WORKAROUND(__MWERKS__, <= 0x3003) // 8.x
|
||||
#pragma parse_func_templ off
|
||||
#endif
|
||||
|
||||
#endif // BOOST_STRING_CONFIG_HPP
|
@ -0,0 +1,36 @@
|
||||
// Boost string_algo library constants.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_CONSTANTS_HPP
|
||||
#define BOOST_STRING_CONSTANTS_HPP
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
//! Token compression mode
|
||||
/*!
|
||||
Specifies token compression mode for the token_finder.
|
||||
*/
|
||||
enum token_compress_mode_type
|
||||
{
|
||||
token_compress_on, //!< Compress adjacent tokens
|
||||
token_compress_off //!< Do not compress adjacent tokens
|
||||
};
|
||||
|
||||
} // namespace algorithm
|
||||
|
||||
// pull the names to the boost namespace
|
||||
using algorithm::token_compress_on;
|
||||
using algorithm::token_compress_off;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_STRING_CONSTANTS_HPP
|
||||
|
@ -0,0 +1,112 @@
|
||||
// Boost string_algo library string_funct.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_CASE_CONV_DETAIL_HPP
|
||||
#define BOOST_STRING_CASE_CONV_DETAIL_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <locale>
|
||||
#include <functional>
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
namespace detail {
|
||||
|
||||
// case conversion functors -----------------------------------------------//
|
||||
|
||||
// a tolower functor
|
||||
template<typename CharT>
|
||||
struct to_lowerF : public std::unary_function<CharT, CharT>
|
||||
{
|
||||
// Constructor
|
||||
to_lowerF( const std::locale& Loc ) : m_Loc( Loc ) {}
|
||||
|
||||
// Operation
|
||||
CharT operator ()( CharT Ch ) const
|
||||
{
|
||||
#if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL)
|
||||
return std::tolower( Ch);
|
||||
#else
|
||||
return std::tolower<CharT>( Ch, m_Loc );
|
||||
#endif
|
||||
}
|
||||
private:
|
||||
const std::locale& m_Loc;
|
||||
};
|
||||
|
||||
// a toupper functor
|
||||
template<typename CharT>
|
||||
struct to_upperF : public std::unary_function<CharT, CharT>
|
||||
{
|
||||
// Constructor
|
||||
to_upperF( const std::locale& Loc ) : m_Loc( Loc ) {}
|
||||
|
||||
// Operation
|
||||
CharT operator ()( CharT Ch ) const
|
||||
{
|
||||
#if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL)
|
||||
return std::toupper( Ch);
|
||||
#else
|
||||
return std::toupper<CharT>( Ch, m_Loc );
|
||||
#endif
|
||||
}
|
||||
private:
|
||||
const std::locale& m_Loc;
|
||||
};
|
||||
|
||||
// algorithm implementation -------------------------------------------------------------------------
|
||||
|
||||
// Transform a range
|
||||
template<typename OutputIteratorT, typename RangeT, typename FunctorT>
|
||||
OutputIteratorT transform_range_copy(
|
||||
OutputIteratorT Output,
|
||||
const RangeT& Input,
|
||||
FunctorT Functor)
|
||||
{
|
||||
return std::transform(
|
||||
begin(Input),
|
||||
end(Input),
|
||||
Output,
|
||||
Functor);
|
||||
}
|
||||
|
||||
// Transform a range (in-place)
|
||||
template<typename RangeT, typename FunctorT>
|
||||
void transform_range(
|
||||
const RangeT& Input,
|
||||
FunctorT Functor)
|
||||
{
|
||||
std::transform(
|
||||
begin(Input),
|
||||
end(Input),
|
||||
begin(Input),
|
||||
Functor);
|
||||
}
|
||||
|
||||
template<typename SequenceT, typename RangeT, typename FunctorT>
|
||||
inline SequenceT transform_range_copy(
|
||||
const RangeT& Input,
|
||||
FunctorT Functor)
|
||||
{
|
||||
return SequenceT(
|
||||
make_transform_iterator(
|
||||
begin(Input),
|
||||
Functor),
|
||||
make_transform_iterator(
|
||||
end(Input),
|
||||
Functor));
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_CASE_CONV_DETAIL_HPP
|
@ -0,0 +1,198 @@
|
||||
// Boost string_algo library classification.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_CLASSIFICATION_DETAIL_HPP
|
||||
#define BOOST_STRING_CLASSIFICATION_DETAIL_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <locale>
|
||||
#include <set>
|
||||
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
|
||||
#include <boost/algorithm/string/predicate_facade.hpp>
|
||||
#include <boost/type_traits/remove_const.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
namespace detail {
|
||||
|
||||
// classification functors -----------------------------------------------//
|
||||
|
||||
// is_classified functor
|
||||
struct is_classifiedF :
|
||||
public predicate_facade<is_classifiedF>
|
||||
{
|
||||
// Boost.Lambda support
|
||||
template <class Args> struct sig { typedef bool type; };
|
||||
|
||||
// Constructor from a locale
|
||||
is_classifiedF(std::ctype_base::mask Type, std::locale const & Loc = std::locale()) :
|
||||
m_Type(Type), m_Locale(Loc) {}
|
||||
|
||||
// Operation
|
||||
template<typename CharT>
|
||||
bool operator()( CharT Ch ) const
|
||||
{
|
||||
return std::use_facet< std::ctype<CharT> >(m_Locale).is( m_Type, Ch );
|
||||
}
|
||||
|
||||
#if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x582) && !defined(_USE_OLD_RW_STL)
|
||||
template<>
|
||||
bool operator()( char const Ch ) const
|
||||
{
|
||||
return std::use_facet< std::ctype<char> >(m_Locale).is( m_Type, Ch );
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
const std::ctype_base::mask m_Type;
|
||||
const std::locale m_Locale;
|
||||
};
|
||||
|
||||
// is_any_of functor
|
||||
/*
|
||||
returns true if the value is from the specified set
|
||||
*/
|
||||
template<typename CharT>
|
||||
struct is_any_ofF :
|
||||
public predicate_facade<is_any_ofF<CharT> >
|
||||
{
|
||||
// Boost.Lambda support
|
||||
template <class Args> struct sig { typedef bool type; };
|
||||
|
||||
// Constructor
|
||||
template<typename RangeT>
|
||||
is_any_ofF( const RangeT& Range ) :
|
||||
m_Set( begin(Range), end(Range) ) {}
|
||||
|
||||
// Operation
|
||||
template<typename Char2T>
|
||||
bool operator()( Char2T Ch ) const
|
||||
{
|
||||
return m_Set.find(Ch)!=m_Set.end();
|
||||
}
|
||||
|
||||
private:
|
||||
// set cannot operate on const value-type
|
||||
typedef typename remove_const<CharT>::type set_value_type;
|
||||
std::set<set_value_type> m_Set;
|
||||
};
|
||||
|
||||
// is_from_range functor
|
||||
/*
|
||||
returns true if the value is from the specified range.
|
||||
(i.e. x>=From && x>=To)
|
||||
*/
|
||||
template<typename CharT>
|
||||
struct is_from_rangeF :
|
||||
public predicate_facade< is_from_rangeF<CharT> >
|
||||
{
|
||||
// Boost.Lambda support
|
||||
template <class Args> struct sig { typedef bool type; };
|
||||
|
||||
// Constructor
|
||||
is_from_rangeF( CharT From, CharT To ) : m_From(From), m_To(To) {}
|
||||
|
||||
// Operation
|
||||
template<typename Char2T>
|
||||
bool operator()( Char2T Ch ) const
|
||||
{
|
||||
return ( m_From <= Ch ) && ( Ch <= m_To );
|
||||
}
|
||||
|
||||
private:
|
||||
CharT m_From;
|
||||
CharT m_To;
|
||||
};
|
||||
|
||||
// class_and composition predicate
|
||||
template<typename Pred1T, typename Pred2T>
|
||||
struct pred_andF :
|
||||
public predicate_facade< pred_andF<Pred1T,Pred2T> >
|
||||
{
|
||||
public:
|
||||
|
||||
// Boost.Lambda support
|
||||
template <class Args> struct sig { typedef bool type; };
|
||||
|
||||
// Constructor
|
||||
pred_andF( Pred1T Pred1, Pred2T Pred2 ) :
|
||||
m_Pred1(Pred1), m_Pred2(Pred2) {}
|
||||
|
||||
// Operation
|
||||
template<typename CharT>
|
||||
bool operator()( CharT Ch ) const
|
||||
{
|
||||
return m_Pred1(Ch) && m_Pred2(Ch);
|
||||
}
|
||||
|
||||
private:
|
||||
Pred1T m_Pred1;
|
||||
Pred2T m_Pred2;
|
||||
};
|
||||
|
||||
// class_or composition predicate
|
||||
template<typename Pred1T, typename Pred2T>
|
||||
struct pred_orF :
|
||||
public predicate_facade< pred_orF<Pred1T,Pred2T> >
|
||||
{
|
||||
public:
|
||||
// Boost.Lambda support
|
||||
template <class Args> struct sig { typedef bool type; };
|
||||
|
||||
// Constructor
|
||||
pred_orF( Pred1T Pred1, Pred2T Pred2 ) :
|
||||
m_Pred1(Pred1), m_Pred2(Pred2) {}
|
||||
|
||||
// Operation
|
||||
template<typename CharT>
|
||||
bool operator()( CharT Ch ) const
|
||||
{
|
||||
return m_Pred1(Ch) || m_Pred2(Ch);
|
||||
}
|
||||
|
||||
private:
|
||||
Pred1T m_Pred1;
|
||||
Pred2T m_Pred2;
|
||||
};
|
||||
|
||||
// class_not composition predicate
|
||||
template< typename PredT >
|
||||
struct pred_notF :
|
||||
public predicate_facade< pred_notF<PredT> >
|
||||
{
|
||||
public:
|
||||
// Boost.Lambda support
|
||||
template <class Args> struct sig { typedef bool type; };
|
||||
|
||||
// Constructor
|
||||
pred_notF( PredT Pred ) : m_Pred(Pred) {}
|
||||
|
||||
// Operation
|
||||
template<typename CharT>
|
||||
bool operator()( CharT Ch ) const
|
||||
{
|
||||
return !m_Pred(Ch);
|
||||
}
|
||||
|
||||
private:
|
||||
PredT m_Pred;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_CLASSIFICATION_DETAIL_HPP
|
@ -0,0 +1,193 @@
|
||||
// Boost string_algo library find_format.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_FIND_FORMAT_DETAIL_HPP
|
||||
#define BOOST_STRING_FIND_FORMAT_DETAIL_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/algorithm/string/detail/find_format_store.hpp>
|
||||
#include <boost/algorithm/string/detail/replace_storage.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
namespace detail {
|
||||
|
||||
// find_format_copy (iterator variant) implementation -------------------------------//
|
||||
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename InputT,
|
||||
typename FormatterT,
|
||||
typename FindResultT >
|
||||
inline OutputIteratorT find_format_copy_impl(
|
||||
OutputIteratorT Output,
|
||||
const InputT& Input,
|
||||
FormatterT Formatter,
|
||||
const FindResultT& FindResult )
|
||||
{
|
||||
return find_format_copy_impl2(
|
||||
Output,
|
||||
Input,
|
||||
Formatter,
|
||||
FindResult,
|
||||
Formatter(FindResult) );
|
||||
}
|
||||
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename InputT,
|
||||
typename FormatterT,
|
||||
typename FindResultT,
|
||||
typename FormatResultT >
|
||||
inline OutputIteratorT find_format_copy_impl2(
|
||||
OutputIteratorT Output,
|
||||
const InputT& Input,
|
||||
FormatterT Formatter,
|
||||
const FindResultT& FindResult,
|
||||
const FormatResultT& FormatResult )
|
||||
{
|
||||
typedef find_format_store<
|
||||
BOOST_STRING_TYPENAME
|
||||
range_const_iterator<InputT>::type,
|
||||
FormatterT,
|
||||
FormatResultT > store_type;
|
||||
|
||||
// Create store for the find result
|
||||
store_type M( FindResult, FormatResult, Formatter );
|
||||
|
||||
if ( !M )
|
||||
{
|
||||
// Match not found - return original sequence
|
||||
std::copy( begin(Input), end(Input), Output );
|
||||
return Output;
|
||||
}
|
||||
|
||||
// Copy the beginning of the sequence
|
||||
std::copy( begin(Input), begin(M), Output );
|
||||
// Format find result
|
||||
// Copy formated result
|
||||
std::copy( begin(M.format_result()), end(M.format_result()), Output );
|
||||
// Copy the rest of the sequence
|
||||
std::copy( M.end(), end(Input), Output );
|
||||
|
||||
return Output;
|
||||
}
|
||||
|
||||
// find_format_copy implementation --------------------------------------------------//
|
||||
|
||||
template<
|
||||
typename InputT,
|
||||
typename FormatterT,
|
||||
typename FindResultT >
|
||||
inline InputT find_format_copy_impl(
|
||||
const InputT& Input,
|
||||
FormatterT Formatter,
|
||||
const FindResultT& FindResult)
|
||||
{
|
||||
return find_format_copy_impl2(
|
||||
Input,
|
||||
Formatter,
|
||||
FindResult,
|
||||
Formatter(FindResult) );
|
||||
}
|
||||
|
||||
template<
|
||||
typename InputT,
|
||||
typename FormatterT,
|
||||
typename FindResultT,
|
||||
typename FormatResultT >
|
||||
inline InputT find_format_copy_impl2(
|
||||
const InputT& Input,
|
||||
FormatterT Formatter,
|
||||
const FindResultT& FindResult,
|
||||
const FormatResultT& FormatResult)
|
||||
{
|
||||
typedef find_format_store<
|
||||
BOOST_STRING_TYPENAME
|
||||
range_const_iterator<InputT>::type,
|
||||
FormatterT,
|
||||
FormatResultT > store_type;
|
||||
|
||||
// Create store for the find result
|
||||
store_type M( FindResult, FormatResult, Formatter );
|
||||
|
||||
if ( !M )
|
||||
{
|
||||
// Match not found - return original sequence
|
||||
return InputT( Input );
|
||||
}
|
||||
|
||||
InputT Output;
|
||||
// Copy the beginning of the sequence
|
||||
insert( Output, end(Output), begin(Input), M.begin() );
|
||||
// Copy formated result
|
||||
insert( Output, end(Output), M.format_result() );
|
||||
// Copy the rest of the sequence
|
||||
insert( Output, end(Output), M.end(), end(Input) );
|
||||
|
||||
return Output;
|
||||
}
|
||||
|
||||
// replace implementation ----------------------------------------------------//
|
||||
|
||||
template<
|
||||
typename InputT,
|
||||
typename FormatterT,
|
||||
typename FindResultT >
|
||||
inline void find_format_impl(
|
||||
InputT& Input,
|
||||
FormatterT Formatter,
|
||||
const FindResultT& FindResult)
|
||||
{
|
||||
find_format_impl2(
|
||||
Input,
|
||||
Formatter,
|
||||
FindResult,
|
||||
Formatter(FindResult) );
|
||||
}
|
||||
|
||||
template<
|
||||
typename InputT,
|
||||
typename FormatterT,
|
||||
typename FindResultT,
|
||||
typename FormatResultT >
|
||||
inline void find_format_impl2(
|
||||
InputT& Input,
|
||||
FormatterT Formatter,
|
||||
const FindResultT& FindResult,
|
||||
const FormatResultT& FormatResult)
|
||||
{
|
||||
typedef find_format_store<
|
||||
BOOST_STRING_TYPENAME
|
||||
range_iterator<InputT>::type,
|
||||
FormatterT,
|
||||
FormatResultT > store_type;
|
||||
|
||||
// Create store for the find result
|
||||
store_type M( FindResult, FormatResult, Formatter );
|
||||
|
||||
if ( !M )
|
||||
{
|
||||
// Search not found - return original sequence
|
||||
return;
|
||||
}
|
||||
|
||||
// Replace match
|
||||
replace( Input, M.begin(), M.end(), M.format_result() );
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_STRING_FIND_FORMAT_DETAIL_HPP
|
@ -0,0 +1,263 @@
|
||||
// Boost string_algo library find_format_all.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_FIND_FORMAT_ALL_DETAIL_HPP
|
||||
#define BOOST_STRING_FIND_FORMAT_ALL_DETAIL_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
#include <boost/range/value_type.hpp>
|
||||
#include <boost/algorithm/string/detail/find_format_store.hpp>
|
||||
#include <boost/algorithm/string/detail/replace_storage.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
namespace detail {
|
||||
|
||||
// find_format_all_copy (iterator variant) implementation ---------------------------//
|
||||
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename InputT,
|
||||
typename FinderT,
|
||||
typename FormatterT,
|
||||
typename FindResultT >
|
||||
inline OutputIteratorT find_format_all_copy_impl(
|
||||
OutputIteratorT Output,
|
||||
const InputT& Input,
|
||||
FinderT Finder,
|
||||
FormatterT Formatter,
|
||||
const FindResultT& FindResult )
|
||||
{
|
||||
return find_format_all_copy_impl2(
|
||||
Output,
|
||||
Input,
|
||||
Finder,
|
||||
Formatter,
|
||||
FindResult,
|
||||
Formatter(FindResult) );
|
||||
}
|
||||
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename InputT,
|
||||
typename FinderT,
|
||||
typename FormatterT,
|
||||
typename FindResultT,
|
||||
typename FormatResultT >
|
||||
inline OutputIteratorT find_format_all_copy_impl2(
|
||||
OutputIteratorT Output,
|
||||
const InputT& Input,
|
||||
FinderT Finder,
|
||||
FormatterT Formatter,
|
||||
const FindResultT& FindResult,
|
||||
const FormatResultT& FormatResult )
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
range_const_iterator<InputT>::type input_iterator_type;
|
||||
|
||||
typedef find_format_store<
|
||||
input_iterator_type,
|
||||
FormatterT,
|
||||
FormatResultT > store_type;
|
||||
|
||||
// Create store for the find result
|
||||
store_type M( FindResult, FormatResult, Formatter );
|
||||
|
||||
// Initialize last match
|
||||
input_iterator_type LastMatch=begin(Input);
|
||||
|
||||
// Iterate through all matches
|
||||
while( M )
|
||||
{
|
||||
// Copy the beginning of the sequence
|
||||
std::copy( LastMatch, M.begin(), Output );
|
||||
// Copy formated result
|
||||
std::copy( begin(M.format_result()), end(M.format_result()), Output );
|
||||
|
||||
// Proceed to the next match
|
||||
LastMatch=M.end();
|
||||
M=Finder( LastMatch, end(Input) );
|
||||
}
|
||||
|
||||
// Copy the rest of the sequence
|
||||
std::copy( LastMatch, end(Input), Output );
|
||||
|
||||
return Output;
|
||||
}
|
||||
|
||||
// find_format_all_copy implementation ----------------------------------------------//
|
||||
|
||||
template<
|
||||
typename InputT,
|
||||
typename FinderT,
|
||||
typename FormatterT,
|
||||
typename FindResultT >
|
||||
inline InputT find_format_all_copy_impl(
|
||||
const InputT& Input,
|
||||
FinderT Finder,
|
||||
FormatterT Formatter,
|
||||
const FindResultT& FindResult)
|
||||
{
|
||||
return find_format_all_copy_impl2(
|
||||
Input,
|
||||
Finder,
|
||||
Formatter,
|
||||
FindResult,
|
||||
Formatter(FindResult) );
|
||||
}
|
||||
|
||||
template<
|
||||
typename InputT,
|
||||
typename FinderT,
|
||||
typename FormatterT,
|
||||
typename FindResultT,
|
||||
typename FormatResultT >
|
||||
inline InputT find_format_all_copy_impl2(
|
||||
const InputT& Input,
|
||||
FinderT Finder,
|
||||
FormatterT Formatter,
|
||||
const FindResultT& FindResult,
|
||||
const FormatResultT& FormatResult)
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
range_const_iterator<InputT>::type input_iterator_type;
|
||||
|
||||
typedef find_format_store<
|
||||
input_iterator_type,
|
||||
FormatterT,
|
||||
FormatResultT > store_type;
|
||||
|
||||
// Create store for the find result
|
||||
store_type M( FindResult, FormatResult, Formatter );
|
||||
|
||||
// Initialize last match
|
||||
input_iterator_type LastMatch=begin(Input);
|
||||
|
||||
// Output temporary
|
||||
InputT Output;
|
||||
|
||||
// Iterate through all matches
|
||||
while( M )
|
||||
{
|
||||
// Copy the beginning of the sequence
|
||||
insert( Output, end(Output), LastMatch, M.begin() );
|
||||
// Copy formated result
|
||||
insert( Output, end(Output), M.format_result() );
|
||||
|
||||
// Proceed to the next match
|
||||
LastMatch=M.end();
|
||||
M=Finder( LastMatch, end(Input) );
|
||||
}
|
||||
|
||||
// Copy the rest of the sequence
|
||||
insert( Output, end(Output), LastMatch, end(Input) );
|
||||
|
||||
return Output;
|
||||
}
|
||||
|
||||
// find_format_all implementation ------------------------------------------------//
|
||||
|
||||
template<
|
||||
typename InputT,
|
||||
typename FinderT,
|
||||
typename FormatterT,
|
||||
typename FindResultT >
|
||||
inline void find_format_all_impl(
|
||||
InputT& Input,
|
||||
FinderT Finder,
|
||||
FormatterT Formatter,
|
||||
FindResultT FindResult)
|
||||
{
|
||||
find_format_all_impl2(
|
||||
Input,
|
||||
Finder,
|
||||
Formatter,
|
||||
FindResult,
|
||||
Formatter(FindResult) );
|
||||
}
|
||||
|
||||
template<
|
||||
typename InputT,
|
||||
typename FinderT,
|
||||
typename FormatterT,
|
||||
typename FindResultT,
|
||||
typename FormatResultT >
|
||||
inline void find_format_all_impl2(
|
||||
InputT& Input,
|
||||
FinderT Finder,
|
||||
FormatterT Formatter,
|
||||
FindResultT FindResult,
|
||||
FormatResultT FormatResult)
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
range_iterator<InputT>::type input_iterator_type;
|
||||
typedef find_format_store<
|
||||
input_iterator_type,
|
||||
FormatterT,
|
||||
FormatResultT > store_type;
|
||||
|
||||
// Create store for the find result
|
||||
store_type M( FindResult, FormatResult, Formatter );
|
||||
|
||||
// Instantiate replacement storage
|
||||
std::deque<
|
||||
BOOST_STRING_TYPENAME range_value<InputT>::type> Storage;
|
||||
|
||||
// Initialize replacement iterators
|
||||
input_iterator_type InsertIt=begin(Input);
|
||||
input_iterator_type SearchIt=begin(Input);
|
||||
|
||||
while( M )
|
||||
{
|
||||
// process the segment
|
||||
InsertIt=process_segment(
|
||||
Storage,
|
||||
Input,
|
||||
InsertIt,
|
||||
SearchIt,
|
||||
M.begin() );
|
||||
|
||||
// Adjust search iterator
|
||||
SearchIt=M.end();
|
||||
|
||||
// Copy formated replace to the storage
|
||||
copy_to_storage( Storage, M.format_result() );
|
||||
|
||||
// Find range for a next match
|
||||
M=Finder( SearchIt, end(Input) );
|
||||
}
|
||||
|
||||
// process the last segment
|
||||
InsertIt=process_segment(
|
||||
Storage,
|
||||
Input,
|
||||
InsertIt,
|
||||
SearchIt,
|
||||
end(Input) );
|
||||
|
||||
if ( Storage.empty() )
|
||||
{
|
||||
// Truncate input
|
||||
erase( Input, InsertIt, end(Input) );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Copy remaining data to the end of input
|
||||
insert( Input, end(Input), Storage.begin(), Storage.end() );
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_STRING_FIND_FORMAT_ALL_DETAIL_HPP
|
@ -0,0 +1,71 @@
|
||||
// Boost string_algo library find_format_store.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_FIND_FORMAT_STORE_DETAIL_HPP
|
||||
#define BOOST_STRING_FIND_FORMAT_STORE_DETAIL_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
namespace detail {
|
||||
|
||||
// temporary format and find result storage --------------------------------//
|
||||
|
||||
template<
|
||||
typename ForwardIteratorT,
|
||||
typename FormatterT,
|
||||
typename FormatResultT >
|
||||
class find_format_store :
|
||||
public iterator_range<ForwardIteratorT>
|
||||
{
|
||||
public:
|
||||
// typedefs
|
||||
typedef iterator_range<ForwardIteratorT> base_type;
|
||||
typedef FormatterT formatter_type;
|
||||
typedef FormatResultT format_result_type;
|
||||
|
||||
public:
|
||||
// Construction
|
||||
find_format_store(
|
||||
const base_type& FindResult,
|
||||
const format_result_type& FormatResult,
|
||||
const formatter_type& Formatter ) :
|
||||
base_type(FindResult),
|
||||
m_FormatResult(FormatResult),
|
||||
m_Formatter(Formatter) {}
|
||||
|
||||
// Assignment
|
||||
template< typename FindResultT >
|
||||
find_format_store& operator=( FindResultT FindResult )
|
||||
{
|
||||
iterator_range<ForwardIteratorT>::operator=(FindResult);
|
||||
m_FormatResult=m_Formatter(FindResult);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Retrieve format result
|
||||
const format_result_type& format_result()
|
||||
{
|
||||
return m_FormatResult;
|
||||
}
|
||||
|
||||
private:
|
||||
format_result_type m_FormatResult;
|
||||
const formatter_type& m_Formatter;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_STRING_FIND_FORMAT_STORE_DETAIL_HPP
|
@ -0,0 +1,87 @@
|
||||
// Boost string_algo library find_iterator.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_FIND_ITERATOR_DETAIL_HPP
|
||||
#define BOOST_STRING_FIND_ITERATOR_DETAIL_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/iterator/iterator_facade.hpp>
|
||||
#include <boost/iterator/iterator_categories.hpp>
|
||||
#include <boost/function.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
namespace detail {
|
||||
|
||||
// find_iterator base -----------------------------------------------//
|
||||
|
||||
// Find iterator base
|
||||
template<typename IteratorT>
|
||||
class find_iterator_base
|
||||
{
|
||||
protected:
|
||||
// typedefs
|
||||
typedef IteratorT input_iterator_type;
|
||||
typedef iterator_range<IteratorT> match_type;
|
||||
typedef function2<
|
||||
match_type,
|
||||
input_iterator_type,
|
||||
input_iterator_type> finder_type;
|
||||
|
||||
protected:
|
||||
// Protected construction/destruction
|
||||
|
||||
// Default constructor
|
||||
find_iterator_base() {};
|
||||
// Copy construction
|
||||
find_iterator_base( const find_iterator_base& Other ) :
|
||||
m_Finder(Other.m_Finder) {}
|
||||
|
||||
// Constructor
|
||||
template<typename FinderT>
|
||||
find_iterator_base( FinderT Finder, int ) :
|
||||
m_Finder(Finder) {}
|
||||
|
||||
// Destructor
|
||||
~find_iterator_base() {}
|
||||
|
||||
// Find operation
|
||||
match_type do_find(
|
||||
input_iterator_type Begin,
|
||||
input_iterator_type End ) const
|
||||
{
|
||||
if (!m_Finder.empty())
|
||||
{
|
||||
return m_Finder(Begin,End);
|
||||
}
|
||||
else
|
||||
{
|
||||
return match_type(End,End);
|
||||
}
|
||||
}
|
||||
|
||||
// Check
|
||||
bool is_null() const
|
||||
{
|
||||
return m_Finder.empty();
|
||||
}
|
||||
|
||||
private:
|
||||
// Finder
|
||||
finder_type m_Finder;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_FIND_ITERATOR_DETAIL_HPP
|
@ -0,0 +1,646 @@
|
||||
// Boost string_algo library finder.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2006.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_FINDER_DETAIL_HPP
|
||||
#define BOOST_STRING_FINDER_DETAIL_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/algorithm/string/constants.hpp>
|
||||
#include <boost/detail/iterator.hpp>
|
||||
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/empty.hpp>
|
||||
#include <boost/range/as_literal.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
namespace detail {
|
||||
|
||||
|
||||
// find first functor -----------------------------------------------//
|
||||
|
||||
// find a subsequence in the sequence ( functor )
|
||||
/*
|
||||
Returns a pair <begin,end> marking the subsequence in the sequence.
|
||||
If the find fails, functor returns <End,End>
|
||||
*/
|
||||
template<typename SearchIteratorT,typename PredicateT>
|
||||
struct first_finderF
|
||||
{
|
||||
typedef SearchIteratorT search_iterator_type;
|
||||
|
||||
// Construction
|
||||
template< typename SearchT >
|
||||
first_finderF( const SearchT& Search, PredicateT Comp ) :
|
||||
m_Search(begin(Search), end(Search)), m_Comp(Comp) {}
|
||||
first_finderF(
|
||||
search_iterator_type SearchBegin,
|
||||
search_iterator_type SearchEnd,
|
||||
PredicateT Comp ) :
|
||||
m_Search(SearchBegin, SearchEnd), m_Comp(Comp) {}
|
||||
|
||||
// Operation
|
||||
template< typename ForwardIteratorT >
|
||||
iterator_range<ForwardIteratorT>
|
||||
operator()(
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End ) const
|
||||
{
|
||||
typedef iterator_range<ForwardIteratorT> result_type;
|
||||
typedef ForwardIteratorT input_iterator_type;
|
||||
|
||||
// Outer loop
|
||||
for(input_iterator_type OuterIt=Begin;
|
||||
OuterIt!=End;
|
||||
++OuterIt)
|
||||
{
|
||||
// Sanity check
|
||||
if( boost::empty(m_Search) )
|
||||
return result_type( End, End );
|
||||
|
||||
input_iterator_type InnerIt=OuterIt;
|
||||
search_iterator_type SubstrIt=m_Search.begin();
|
||||
for(;
|
||||
InnerIt!=End && SubstrIt!=m_Search.end();
|
||||
++InnerIt,++SubstrIt)
|
||||
{
|
||||
if( !( m_Comp(*InnerIt,*SubstrIt) ) )
|
||||
break;
|
||||
}
|
||||
|
||||
// Substring matching succeeded
|
||||
if ( SubstrIt==m_Search.end() )
|
||||
return result_type( OuterIt, InnerIt );
|
||||
}
|
||||
|
||||
return result_type( End, End );
|
||||
}
|
||||
|
||||
private:
|
||||
iterator_range<search_iterator_type> m_Search;
|
||||
PredicateT m_Comp;
|
||||
};
|
||||
|
||||
// find last functor -----------------------------------------------//
|
||||
|
||||
// find the last match a subseqeunce in the sequence ( functor )
|
||||
/*
|
||||
Returns a pair <begin,end> marking the subsequence in the sequence.
|
||||
If the find fails, returns <End,End>
|
||||
*/
|
||||
template<typename SearchIteratorT, typename PredicateT>
|
||||
struct last_finderF
|
||||
{
|
||||
typedef SearchIteratorT search_iterator_type;
|
||||
typedef first_finderF<
|
||||
search_iterator_type,
|
||||
PredicateT> first_finder_type;
|
||||
|
||||
// Construction
|
||||
template< typename SearchT >
|
||||
last_finderF( const SearchT& Search, PredicateT Comp ) :
|
||||
m_Search(begin(Search), end(Search)), m_Comp(Comp) {}
|
||||
last_finderF(
|
||||
search_iterator_type SearchBegin,
|
||||
search_iterator_type SearchEnd,
|
||||
PredicateT Comp ) :
|
||||
m_Search(SearchBegin, SearchEnd), m_Comp(Comp) {}
|
||||
|
||||
// Operation
|
||||
template< typename ForwardIteratorT >
|
||||
iterator_range<ForwardIteratorT>
|
||||
operator()(
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End ) const
|
||||
{
|
||||
typedef iterator_range<ForwardIteratorT> result_type;
|
||||
|
||||
if( boost::empty(m_Search) )
|
||||
return result_type( End, End );
|
||||
|
||||
typedef BOOST_STRING_TYPENAME boost::detail::
|
||||
iterator_traits<ForwardIteratorT>::iterator_category category;
|
||||
|
||||
return findit( Begin, End, category() );
|
||||
}
|
||||
|
||||
private:
|
||||
// forward iterator
|
||||
template< typename ForwardIteratorT >
|
||||
iterator_range<ForwardIteratorT>
|
||||
findit(
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End,
|
||||
std::forward_iterator_tag ) const
|
||||
{
|
||||
typedef ForwardIteratorT input_iterator_type;
|
||||
typedef iterator_range<ForwardIteratorT> result_type;
|
||||
|
||||
first_finder_type first_finder(
|
||||
m_Search.begin(), m_Search.end(), m_Comp );
|
||||
|
||||
result_type M=first_finder( Begin, End );
|
||||
result_type Last=M;
|
||||
|
||||
while( M )
|
||||
{
|
||||
Last=M;
|
||||
M=first_finder( end(M), End );
|
||||
}
|
||||
|
||||
return Last;
|
||||
}
|
||||
|
||||
// bidirectional iterator
|
||||
template< typename ForwardIteratorT >
|
||||
iterator_range<ForwardIteratorT>
|
||||
findit(
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End,
|
||||
std::bidirectional_iterator_tag ) const
|
||||
{
|
||||
typedef iterator_range<ForwardIteratorT> result_type;
|
||||
typedef ForwardIteratorT input_iterator_type;
|
||||
|
||||
// Outer loop
|
||||
for(input_iterator_type OuterIt=End;
|
||||
OuterIt!=Begin; )
|
||||
{
|
||||
input_iterator_type OuterIt2=--OuterIt;
|
||||
|
||||
input_iterator_type InnerIt=OuterIt2;
|
||||
search_iterator_type SubstrIt=m_Search.begin();
|
||||
for(;
|
||||
InnerIt!=End && SubstrIt!=m_Search.end();
|
||||
++InnerIt,++SubstrIt)
|
||||
{
|
||||
if( !( m_Comp(*InnerIt,*SubstrIt) ) )
|
||||
break;
|
||||
}
|
||||
|
||||
// Substring matching succeeded
|
||||
if( SubstrIt==m_Search.end() )
|
||||
return result_type( OuterIt2, InnerIt );
|
||||
}
|
||||
|
||||
return result_type( End, End );
|
||||
}
|
||||
|
||||
private:
|
||||
iterator_range<search_iterator_type> m_Search;
|
||||
PredicateT m_Comp;
|
||||
};
|
||||
|
||||
// find n-th functor -----------------------------------------------//
|
||||
|
||||
// find the n-th match of a subsequence in the sequence ( functor )
|
||||
/*
|
||||
Returns a pair <begin,end> marking the subsequence in the sequence.
|
||||
If the find fails, returns <End,End>
|
||||
*/
|
||||
template<typename SearchIteratorT, typename PredicateT>
|
||||
struct nth_finderF
|
||||
{
|
||||
typedef SearchIteratorT search_iterator_type;
|
||||
typedef first_finderF<
|
||||
search_iterator_type,
|
||||
PredicateT> first_finder_type;
|
||||
typedef last_finderF<
|
||||
search_iterator_type,
|
||||
PredicateT> last_finder_type;
|
||||
|
||||
// Construction
|
||||
template< typename SearchT >
|
||||
nth_finderF(
|
||||
const SearchT& Search,
|
||||
int Nth,
|
||||
PredicateT Comp) :
|
||||
m_Search(begin(Search), end(Search)),
|
||||
m_Nth(Nth),
|
||||
m_Comp(Comp) {}
|
||||
nth_finderF(
|
||||
search_iterator_type SearchBegin,
|
||||
search_iterator_type SearchEnd,
|
||||
int Nth,
|
||||
PredicateT Comp) :
|
||||
m_Search(SearchBegin, SearchEnd),
|
||||
m_Nth(Nth),
|
||||
m_Comp(Comp) {}
|
||||
|
||||
// Operation
|
||||
template< typename ForwardIteratorT >
|
||||
iterator_range<ForwardIteratorT>
|
||||
operator()(
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End ) const
|
||||
{
|
||||
if(m_Nth>=0)
|
||||
{
|
||||
return find_forward(Begin, End, m_Nth);
|
||||
}
|
||||
else
|
||||
{
|
||||
return find_backward(Begin, End, -m_Nth);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
// Implementation helpers
|
||||
template< typename ForwardIteratorT >
|
||||
iterator_range<ForwardIteratorT>
|
||||
find_forward(
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End,
|
||||
unsigned int N) const
|
||||
{
|
||||
typedef ForwardIteratorT input_iterator_type;
|
||||
typedef iterator_range<ForwardIteratorT> result_type;
|
||||
|
||||
// Sanity check
|
||||
if( boost::empty(m_Search) )
|
||||
return result_type( End, End );
|
||||
|
||||
// Instantiate find functor
|
||||
first_finder_type first_finder(
|
||||
m_Search.begin(), m_Search.end(), m_Comp );
|
||||
|
||||
result_type M( Begin, Begin );
|
||||
|
||||
for( unsigned int n=0; n<=N; ++n )
|
||||
{
|
||||
// find next match
|
||||
M=first_finder( end(M), End );
|
||||
|
||||
if ( !M )
|
||||
{
|
||||
// Subsequence not found, return
|
||||
return M;
|
||||
}
|
||||
}
|
||||
|
||||
return M;
|
||||
}
|
||||
|
||||
template< typename ForwardIteratorT >
|
||||
iterator_range<ForwardIteratorT>
|
||||
find_backward(
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End,
|
||||
unsigned int N) const
|
||||
{
|
||||
typedef ForwardIteratorT input_iterator_type;
|
||||
typedef iterator_range<ForwardIteratorT> result_type;
|
||||
|
||||
// Sanity check
|
||||
if( boost::empty(m_Search) )
|
||||
return result_type( End, End );
|
||||
|
||||
// Instantiate find functor
|
||||
last_finder_type last_finder(
|
||||
m_Search.begin(), m_Search.end(), m_Comp );
|
||||
|
||||
result_type M( End, End );
|
||||
|
||||
for( unsigned int n=1; n<=N; ++n )
|
||||
{
|
||||
// find next match
|
||||
M=last_finder( Begin, begin(M) );
|
||||
|
||||
if ( !M )
|
||||
{
|
||||
// Subsequence not found, return
|
||||
return M;
|
||||
}
|
||||
}
|
||||
|
||||
return M;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
iterator_range<search_iterator_type> m_Search;
|
||||
int m_Nth;
|
||||
PredicateT m_Comp;
|
||||
};
|
||||
|
||||
// find head/tail implementation helpers ---------------------------//
|
||||
|
||||
template<typename ForwardIteratorT>
|
||||
iterator_range<ForwardIteratorT>
|
||||
find_head_impl(
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End,
|
||||
unsigned int N,
|
||||
std::forward_iterator_tag )
|
||||
{
|
||||
typedef ForwardIteratorT input_iterator_type;
|
||||
typedef iterator_range<ForwardIteratorT> result_type;
|
||||
|
||||
input_iterator_type It=Begin;
|
||||
for(
|
||||
unsigned int Index=0;
|
||||
Index<N && It!=End; ++Index,++It ) {};
|
||||
|
||||
return result_type( Begin, It );
|
||||
}
|
||||
|
||||
template< typename ForwardIteratorT >
|
||||
iterator_range<ForwardIteratorT>
|
||||
find_head_impl(
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End,
|
||||
unsigned int N,
|
||||
std::random_access_iterator_tag )
|
||||
{
|
||||
typedef ForwardIteratorT input_iterator_type;
|
||||
typedef iterator_range<ForwardIteratorT> result_type;
|
||||
|
||||
if ( (End<=Begin) || ( static_cast<unsigned int>(End-Begin) < N ) )
|
||||
return result_type( Begin, End );
|
||||
|
||||
return result_type(Begin,Begin+N);
|
||||
}
|
||||
|
||||
// Find head implementation
|
||||
template<typename ForwardIteratorT>
|
||||
iterator_range<ForwardIteratorT>
|
||||
find_head_impl(
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End,
|
||||
unsigned int N )
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME boost::detail::
|
||||
iterator_traits<ForwardIteratorT>::iterator_category category;
|
||||
|
||||
return find_head_impl( Begin, End, N, category() );
|
||||
}
|
||||
|
||||
template< typename ForwardIteratorT >
|
||||
iterator_range<ForwardIteratorT>
|
||||
find_tail_impl(
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End,
|
||||
unsigned int N,
|
||||
std::forward_iterator_tag )
|
||||
{
|
||||
typedef ForwardIteratorT input_iterator_type;
|
||||
typedef iterator_range<ForwardIteratorT> result_type;
|
||||
|
||||
unsigned int Index=0;
|
||||
input_iterator_type It=Begin;
|
||||
input_iterator_type It2=Begin;
|
||||
|
||||
// Advance It2 by N increments
|
||||
for( Index=0; Index<N && It2!=End; ++Index,++It2 ) {};
|
||||
|
||||
// Advance It, It2 to the end
|
||||
for(; It2!=End; ++It,++It2 ) {};
|
||||
|
||||
return result_type( It, It2 );
|
||||
}
|
||||
|
||||
template< typename ForwardIteratorT >
|
||||
iterator_range<ForwardIteratorT>
|
||||
find_tail_impl(
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End,
|
||||
unsigned int N,
|
||||
std::bidirectional_iterator_tag )
|
||||
{
|
||||
typedef ForwardIteratorT input_iterator_type;
|
||||
typedef iterator_range<ForwardIteratorT> result_type;
|
||||
|
||||
input_iterator_type It=End;
|
||||
for(
|
||||
unsigned int Index=0;
|
||||
Index<N && It!=Begin; ++Index,--It ) {};
|
||||
|
||||
return result_type( It, End );
|
||||
}
|
||||
|
||||
template< typename ForwardIteratorT >
|
||||
iterator_range<ForwardIteratorT>
|
||||
find_tail_impl(
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End,
|
||||
unsigned int N,
|
||||
std::random_access_iterator_tag )
|
||||
{
|
||||
typedef ForwardIteratorT input_iterator_type;
|
||||
typedef iterator_range<ForwardIteratorT> result_type;
|
||||
|
||||
if ( (End<=Begin) || ( static_cast<unsigned int>(End-Begin) < N ) )
|
||||
return result_type( Begin, End );
|
||||
|
||||
return result_type( End-N, End );
|
||||
}
|
||||
|
||||
// Operation
|
||||
template< typename ForwardIteratorT >
|
||||
iterator_range<ForwardIteratorT>
|
||||
find_tail_impl(
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End,
|
||||
unsigned int N )
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME boost::detail::
|
||||
iterator_traits<ForwardIteratorT>::iterator_category category;
|
||||
|
||||
return find_tail_impl( Begin, End, N, category() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
// find head functor -----------------------------------------------//
|
||||
|
||||
|
||||
// find a head in the sequence ( functor )
|
||||
/*
|
||||
This functor find a head of the specified range. For
|
||||
a specified N, the head is a subsequence of N starting
|
||||
elements of the range.
|
||||
*/
|
||||
struct head_finderF
|
||||
{
|
||||
// Construction
|
||||
head_finderF( int N ) : m_N(N) {}
|
||||
|
||||
// Operation
|
||||
template< typename ForwardIteratorT >
|
||||
iterator_range<ForwardIteratorT>
|
||||
operator()(
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End ) const
|
||||
{
|
||||
if(m_N>=0)
|
||||
{
|
||||
return find_head_impl( Begin, End, m_N );
|
||||
}
|
||||
else
|
||||
{
|
||||
iterator_range<ForwardIteratorT> Res=
|
||||
find_tail_impl( Begin, End, -m_N );
|
||||
|
||||
return make_iterator_range(Begin, Res.begin());
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
int m_N;
|
||||
};
|
||||
|
||||
// find tail functor -----------------------------------------------//
|
||||
|
||||
|
||||
// find a tail in the sequence ( functor )
|
||||
/*
|
||||
This functor find a tail of the specified range. For
|
||||
a specified N, the head is a subsequence of N starting
|
||||
elements of the range.
|
||||
*/
|
||||
struct tail_finderF
|
||||
{
|
||||
// Construction
|
||||
tail_finderF( int N ) : m_N(N) {}
|
||||
|
||||
// Operation
|
||||
template< typename ForwardIteratorT >
|
||||
iterator_range<ForwardIteratorT>
|
||||
operator()(
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End ) const
|
||||
{
|
||||
if(m_N>=0)
|
||||
{
|
||||
return find_tail_impl( Begin, End, m_N );
|
||||
}
|
||||
else
|
||||
{
|
||||
iterator_range<ForwardIteratorT> Res=
|
||||
find_head_impl( Begin, End, -m_N );
|
||||
|
||||
return make_iterator_range(Res.end(), End);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
int m_N;
|
||||
};
|
||||
|
||||
// find token functor -----------------------------------------------//
|
||||
|
||||
// find a token in a sequence ( functor )
|
||||
/*
|
||||
This find functor finds a token specified be a predicate
|
||||
in a sequence. It is equivalent of std::find algorithm,
|
||||
with an exception that it return range instead of a single
|
||||
iterator.
|
||||
|
||||
If bCompress is set to true, adjacent matching tokens are
|
||||
concatenated into one match.
|
||||
*/
|
||||
template< typename PredicateT >
|
||||
struct token_finderF
|
||||
{
|
||||
// Construction
|
||||
token_finderF(
|
||||
PredicateT Pred,
|
||||
token_compress_mode_type eCompress=token_compress_off ) :
|
||||
m_Pred(Pred), m_eCompress(eCompress) {}
|
||||
|
||||
// Operation
|
||||
template< typename ForwardIteratorT >
|
||||
iterator_range<ForwardIteratorT>
|
||||
operator()(
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End ) const
|
||||
{
|
||||
typedef iterator_range<ForwardIteratorT> result_type;
|
||||
|
||||
ForwardIteratorT It=std::find_if( Begin, End, m_Pred );
|
||||
|
||||
if( It==End )
|
||||
{
|
||||
return result_type( End, End );
|
||||
}
|
||||
else
|
||||
{
|
||||
ForwardIteratorT It2=It;
|
||||
|
||||
if( m_eCompress==token_compress_on )
|
||||
{
|
||||
// Find first non-matching character
|
||||
while( It2!=End && m_Pred(*It2) ) ++It2;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Advance by one position
|
||||
++It2;
|
||||
}
|
||||
|
||||
return result_type( It, It2 );
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
PredicateT m_Pred;
|
||||
token_compress_mode_type m_eCompress;
|
||||
};
|
||||
|
||||
// find range functor -----------------------------------------------//
|
||||
|
||||
// find a range in the sequence ( functor )
|
||||
/*
|
||||
This functor actually does not perform any find operation.
|
||||
It always returns given iterator range as a result.
|
||||
*/
|
||||
template<typename ForwardIterator1T>
|
||||
struct range_finderF
|
||||
{
|
||||
typedef ForwardIterator1T input_iterator_type;
|
||||
typedef iterator_range<input_iterator_type> result_type;
|
||||
|
||||
// Construction
|
||||
range_finderF(
|
||||
input_iterator_type Begin,
|
||||
input_iterator_type End ) : m_Range(Begin, End) {}
|
||||
|
||||
range_finderF(const iterator_range<input_iterator_type>& Range) :
|
||||
m_Range(Range) {}
|
||||
|
||||
// Operation
|
||||
template< typename ForwardIterator2T >
|
||||
iterator_range<ForwardIterator2T>
|
||||
operator()(
|
||||
ForwardIterator2T,
|
||||
ForwardIterator2T ) const
|
||||
{
|
||||
#if BOOST_WORKAROUND( __MWERKS__, <= 0x3003 )
|
||||
return iterator_range<const ForwardIterator2T>(this->m_Range);
|
||||
#elif BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
return iterator_range<ForwardIterator2T>(m_Range.begin(), m_Range.end());
|
||||
#else
|
||||
return m_Range;
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
iterator_range<input_iterator_type> m_Range;
|
||||
};
|
||||
|
||||
|
||||
} // namespace detail
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_STRING_FINDER_DETAIL_HPP
|
@ -0,0 +1,122 @@
|
||||
// Boost string_algo library find_regex.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_FINDER_REGEX_DETAIL_HPP
|
||||
#define BOOST_STRING_FINDER_REGEX_DETAIL_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
namespace detail {
|
||||
|
||||
// regex find functor -----------------------------------------------//
|
||||
|
||||
// regex search result
|
||||
template<typename IteratorT>
|
||||
struct regex_search_result :
|
||||
public iterator_range<IteratorT>
|
||||
{
|
||||
typedef regex_search_result<IteratorT> type;
|
||||
typedef iterator_range<IteratorT> base_type;
|
||||
typedef BOOST_STRING_TYPENAME base_type::value_type value_type;
|
||||
typedef BOOST_STRING_TYPENAME base_type::difference_type difference_type;
|
||||
typedef BOOST_STRING_TYPENAME base_type::const_iterator const_iterator;
|
||||
typedef BOOST_STRING_TYPENAME base_type::iterator iterator;
|
||||
typedef boost::match_results<iterator> match_results_type;
|
||||
|
||||
// Construction
|
||||
|
||||
// Construction from the match result
|
||||
regex_search_result( const match_results_type& MatchResults ) :
|
||||
base_type( MatchResults[0].first, MatchResults[0].second ),
|
||||
m_MatchResults( MatchResults ) {}
|
||||
|
||||
// Construction of empty match. End iterator has to be specified
|
||||
regex_search_result( IteratorT End ) :
|
||||
base_type( End, End ) {}
|
||||
|
||||
regex_search_result( const regex_search_result& Other ) :
|
||||
base_type( Other.begin(), Other.end() ),
|
||||
m_MatchResults( Other.m_MatchResults ) {}
|
||||
|
||||
// Assignment
|
||||
regex_search_result& operator=( const regex_search_result& Other )
|
||||
{
|
||||
base_type::operator=( Other );
|
||||
m_MatchResults=Other.m_MatchResults;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Match result retrival
|
||||
const match_results_type& match_results() const
|
||||
{
|
||||
return m_MatchResults;
|
||||
}
|
||||
|
||||
private:
|
||||
// Saved matchresult
|
||||
match_results_type m_MatchResults;
|
||||
};
|
||||
|
||||
// find_regex
|
||||
/*
|
||||
Regex based search functor
|
||||
*/
|
||||
template<typename RegExT>
|
||||
struct find_regexF
|
||||
{
|
||||
typedef RegExT regex_type;
|
||||
typedef const RegExT& regex_reference_type;
|
||||
|
||||
// Construction
|
||||
find_regexF( regex_reference_type Rx, match_flag_type MatchFlags = match_default ) :
|
||||
m_Rx(Rx), m_MatchFlags(MatchFlags) {}
|
||||
|
||||
// Operation
|
||||
template< typename ForwardIteratorT >
|
||||
regex_search_result<ForwardIteratorT>
|
||||
operator()(
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End ) const
|
||||
{
|
||||
typedef ForwardIteratorT input_iterator_type;
|
||||
typedef regex_search_result<ForwardIteratorT> result_type;
|
||||
|
||||
// instantiate match result
|
||||
match_results<input_iterator_type> result;
|
||||
// search for a match
|
||||
if ( regex_search( Begin, End, result, m_Rx, m_MatchFlags ) )
|
||||
{
|
||||
// construct a result
|
||||
return result_type( result );
|
||||
}
|
||||
else
|
||||
{
|
||||
// empty result
|
||||
return result_type( End );
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
regex_reference_type m_Rx; // Regexp
|
||||
match_flag_type m_MatchFlags; // match flags
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_STRING_FIND_DETAIL_HPP
|
@ -0,0 +1,94 @@
|
||||
// Boost string_algo library formatter.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_FORMATTER_DETAIL_HPP
|
||||
#define BOOST_STRING_FORMATTER_DETAIL_HPP
|
||||
|
||||
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
|
||||
#include <boost/algorithm/string/detail/util.hpp>
|
||||
|
||||
// generic replace functors -----------------------------------------------//
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
namespace detail {
|
||||
|
||||
// const format functor ----------------------------------------------------//
|
||||
|
||||
// constant format functor
|
||||
template<typename RangeT>
|
||||
struct const_formatF
|
||||
{
|
||||
private:
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
range_const_iterator<RangeT>::type format_iterator;
|
||||
typedef iterator_range<format_iterator> result_type;
|
||||
|
||||
public:
|
||||
// Construction
|
||||
const_formatF(const RangeT& Format) :
|
||||
m_Format(begin(Format), end(Format)) {}
|
||||
|
||||
// Operation
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
template<typename Range2T>
|
||||
result_type& operator()(const Range2T&)
|
||||
{
|
||||
return m_Format;
|
||||
}
|
||||
#endif
|
||||
|
||||
template<typename Range2T>
|
||||
const result_type& operator()(const Range2T&) const
|
||||
{
|
||||
return m_Format;
|
||||
}
|
||||
|
||||
private:
|
||||
result_type m_Format;
|
||||
};
|
||||
|
||||
// identity format functor ----------------------------------------------------//
|
||||
|
||||
// identity format functor
|
||||
template<typename RangeT>
|
||||
struct identity_formatF
|
||||
{
|
||||
// Operation
|
||||
template< typename Range2T >
|
||||
const RangeT& operator()(const Range2T& Replace) const
|
||||
{
|
||||
return RangeT(begin(Replace), end(Replace));
|
||||
}
|
||||
};
|
||||
|
||||
// empty format functor ( used by erase ) ------------------------------------//
|
||||
|
||||
// empty format functor
|
||||
template< typename CharT >
|
||||
struct empty_formatF
|
||||
{
|
||||
template< typename ReplaceT >
|
||||
empty_container<CharT> operator()(const ReplaceT&) const
|
||||
{
|
||||
return empty_container<CharT>();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_STRING_FORMATTER_DETAIL_HPP
|
@ -0,0 +1,61 @@
|
||||
// Boost string_algo library formatter_regex.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_FORMATTER_REGEX_DETAIL_HPP
|
||||
#define BOOST_STRING_FORMATTER_REGEX_DETAIL_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <string>
|
||||
#include <boost/regex.hpp>
|
||||
#include <boost/algorithm/string/detail/finder_regex.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
namespace detail {
|
||||
|
||||
// regex format functor -----------------------------------------//
|
||||
|
||||
// regex format functor
|
||||
template<typename StringT>
|
||||
struct regex_formatF
|
||||
{
|
||||
private:
|
||||
typedef StringT result_type;
|
||||
typedef BOOST_STRING_TYPENAME StringT::value_type char_type;
|
||||
|
||||
public:
|
||||
// Construction
|
||||
regex_formatF( const StringT& Fmt, match_flag_type Flags=format_default ) :
|
||||
m_Fmt(Fmt), m_Flags( Flags ) {}
|
||||
|
||||
template<typename InputIteratorT>
|
||||
result_type operator()(
|
||||
const regex_search_result<InputIteratorT>& Replace ) const
|
||||
{
|
||||
if ( Replace.empty() )
|
||||
{
|
||||
return result_type();
|
||||
}
|
||||
else
|
||||
{
|
||||
return Replace.match_results().format( m_Fmt, m_Flags );
|
||||
}
|
||||
}
|
||||
private:
|
||||
const StringT& m_Fmt;
|
||||
match_flag_type m_Flags;
|
||||
};
|
||||
|
||||
|
||||
} // namespace detail
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_STRING_FORMATTER_DETAIL_HPP
|
@ -0,0 +1,77 @@
|
||||
// Boost string_algo library predicate.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_PREDICATE_DETAIL_HPP
|
||||
#define BOOST_STRING_PREDICATE_DETAIL_HPP
|
||||
|
||||
#include <iterator>
|
||||
#include <boost/algorithm/string/find.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
namespace detail {
|
||||
|
||||
// ends_with predicate implementation ----------------------------------//
|
||||
|
||||
template<
|
||||
typename ForwardIterator1T,
|
||||
typename ForwardIterator2T,
|
||||
typename PredicateT>
|
||||
inline bool ends_with_iter_select(
|
||||
ForwardIterator1T Begin,
|
||||
ForwardIterator1T End,
|
||||
ForwardIterator2T SubBegin,
|
||||
ForwardIterator2T SubEnd,
|
||||
PredicateT Comp,
|
||||
std::bidirectional_iterator_tag)
|
||||
{
|
||||
ForwardIterator1T it=End;
|
||||
ForwardIterator2T pit=SubEnd;
|
||||
for(;it!=Begin && pit!=SubBegin;)
|
||||
{
|
||||
if( !(Comp(*(--it),*(--pit))) )
|
||||
return false;
|
||||
}
|
||||
|
||||
return pit==SubBegin;
|
||||
}
|
||||
|
||||
template<
|
||||
typename ForwardIterator1T,
|
||||
typename ForwardIterator2T,
|
||||
typename PredicateT>
|
||||
inline bool ends_with_iter_select(
|
||||
ForwardIterator1T Begin,
|
||||
ForwardIterator1T End,
|
||||
ForwardIterator2T SubBegin,
|
||||
ForwardIterator2T SubEnd,
|
||||
PredicateT Comp,
|
||||
std::forward_iterator_tag)
|
||||
{
|
||||
if ( SubBegin==SubEnd )
|
||||
{
|
||||
// empty subsequence check
|
||||
return true;
|
||||
}
|
||||
|
||||
iterator_range<ForwardIterator1T> Result
|
||||
=last_finder(
|
||||
make_iterator_range(SubBegin, SubEnd),
|
||||
Comp)(Begin, End);
|
||||
|
||||
return !Result.empty() && Result.end()==End;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_PREDICATE_DETAIL_HPP
|
@ -0,0 +1,159 @@
|
||||
// Boost string_algo library replace_storage.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_REPLACE_STORAGE_DETAIL_HPP
|
||||
#define BOOST_STRING_REPLACE_STORAGE_DETAIL_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <algorithm>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/algorithm/string/sequence_traits.hpp>
|
||||
#include <boost/algorithm/string/detail/sequence.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
namespace detail {
|
||||
|
||||
// storage handling routines -----------------------------------------------//
|
||||
|
||||
template< typename StorageT, typename OutputIteratorT >
|
||||
inline OutputIteratorT move_from_storage(
|
||||
StorageT& Storage,
|
||||
OutputIteratorT DestBegin,
|
||||
OutputIteratorT DestEnd )
|
||||
{
|
||||
OutputIteratorT OutputIt=DestBegin;
|
||||
|
||||
while( !Storage.empty() && OutputIt!=DestEnd )
|
||||
{
|
||||
*OutputIt=Storage.front();
|
||||
Storage.pop_front();
|
||||
++OutputIt;
|
||||
}
|
||||
|
||||
return OutputIt;
|
||||
}
|
||||
|
||||
template< typename StorageT, typename WhatT >
|
||||
inline void copy_to_storage(
|
||||
StorageT& Storage,
|
||||
const WhatT& What )
|
||||
{
|
||||
Storage.insert( Storage.end(), begin(What), end(What) );
|
||||
}
|
||||
|
||||
|
||||
// process segment routine -----------------------------------------------//
|
||||
|
||||
template< bool HasStableIterators >
|
||||
struct process_segment_helper
|
||||
{
|
||||
// Optimized version of process_segment for generic sequence
|
||||
template<
|
||||
typename StorageT,
|
||||
typename InputT,
|
||||
typename ForwardIteratorT >
|
||||
ForwardIteratorT operator()(
|
||||
StorageT& Storage,
|
||||
InputT& /*Input*/,
|
||||
ForwardIteratorT InsertIt,
|
||||
ForwardIteratorT SegmentBegin,
|
||||
ForwardIteratorT SegmentEnd )
|
||||
{
|
||||
// Copy data from the storage until the beginning of the segment
|
||||
ForwardIteratorT It=move_from_storage( Storage, InsertIt, SegmentBegin );
|
||||
|
||||
// 3 cases are possible :
|
||||
// a) Storage is empty, It==SegmentBegin
|
||||
// b) Storage is empty, It!=SegmentBegin
|
||||
// c) Storage is not empty
|
||||
|
||||
if( Storage.empty() )
|
||||
{
|
||||
if( It==SegmentBegin )
|
||||
{
|
||||
// Case a) everything is grand, just return end of segment
|
||||
return SegmentEnd;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Case b) move the segment backwards
|
||||
return std::copy( SegmentBegin, SegmentEnd, It );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Case c) -> shift the segment to the left and keep the overlap in the storage
|
||||
while( It!=SegmentEnd )
|
||||
{
|
||||
// Store value into storage
|
||||
Storage.push_back( *It );
|
||||
// Get the top from the storage and put it here
|
||||
*It=Storage.front();
|
||||
Storage.pop_front();
|
||||
|
||||
// Advance
|
||||
++It;
|
||||
}
|
||||
|
||||
return It;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct process_segment_helper< true >
|
||||
{
|
||||
// Optimized version of process_segment for list-like sequence
|
||||
template<
|
||||
typename StorageT,
|
||||
typename InputT,
|
||||
typename ForwardIteratorT >
|
||||
ForwardIteratorT operator()(
|
||||
StorageT& Storage,
|
||||
InputT& Input,
|
||||
ForwardIteratorT InsertIt,
|
||||
ForwardIteratorT SegmentBegin,
|
||||
ForwardIteratorT SegmentEnd )
|
||||
|
||||
{
|
||||
// Call replace to do the job
|
||||
replace( Input, InsertIt, SegmentBegin, Storage );
|
||||
// Empty the storage
|
||||
Storage.clear();
|
||||
// Iterators were not changed, simply return the end of segment
|
||||
return SegmentEnd;
|
||||
}
|
||||
};
|
||||
|
||||
// Process one segment in the replace_all algorithm
|
||||
template<
|
||||
typename StorageT,
|
||||
typename InputT,
|
||||
typename ForwardIteratorT >
|
||||
inline ForwardIteratorT process_segment(
|
||||
StorageT& Storage,
|
||||
InputT& Input,
|
||||
ForwardIteratorT InsertIt,
|
||||
ForwardIteratorT SegmentBegin,
|
||||
ForwardIteratorT SegmentEnd )
|
||||
{
|
||||
return
|
||||
process_segment_helper<
|
||||
has_stable_iterators<InputT>::value>()(
|
||||
Storage, Input, InsertIt, SegmentBegin, SegmentEnd );
|
||||
}
|
||||
|
||||
|
||||
} // namespace detail
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_STRING_REPLACE_STORAGE_DETAIL_HPP
|
@ -0,0 +1,200 @@
|
||||
// Boost string_algo library sequence.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_DETAIL_SEQUENCE_HPP
|
||||
#define BOOST_STRING_DETAIL_SEQUENCE_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/logical.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
|
||||
#include <boost/algorithm/string/sequence_traits.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
namespace detail {
|
||||
|
||||
// insert helpers -------------------------------------------------//
|
||||
|
||||
template< typename InputT, typename ForwardIteratorT >
|
||||
inline void insert(
|
||||
InputT& Input,
|
||||
BOOST_STRING_TYPENAME InputT::iterator At,
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End )
|
||||
{
|
||||
Input.insert( At, Begin, End );
|
||||
}
|
||||
|
||||
template< typename InputT, typename InsertT >
|
||||
inline void insert(
|
||||
InputT& Input,
|
||||
BOOST_STRING_TYPENAME InputT::iterator At,
|
||||
const InsertT& Insert )
|
||||
{
|
||||
insert( Input, At, begin(Insert), end(Insert) );
|
||||
}
|
||||
|
||||
// erase helper ---------------------------------------------------//
|
||||
|
||||
// Erase a range in the sequence
|
||||
/*
|
||||
Returns the iterator pointing just after the erase subrange
|
||||
*/
|
||||
template< typename InputT >
|
||||
inline typename InputT::iterator erase(
|
||||
InputT& Input,
|
||||
BOOST_STRING_TYPENAME InputT::iterator From,
|
||||
BOOST_STRING_TYPENAME InputT::iterator To )
|
||||
{
|
||||
return Input.erase( From, To );
|
||||
}
|
||||
|
||||
// replace helper implementation ----------------------------------//
|
||||
|
||||
// Optimized version of replace for generic sequence containers
|
||||
// Assumption: insert and erase are expensive
|
||||
template< bool HasConstTimeOperations >
|
||||
struct replace_const_time_helper
|
||||
{
|
||||
template< typename InputT, typename ForwardIteratorT >
|
||||
void operator()(
|
||||
InputT& Input,
|
||||
BOOST_STRING_TYPENAME InputT::iterator From,
|
||||
BOOST_STRING_TYPENAME InputT::iterator To,
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End )
|
||||
{
|
||||
// Copy data to the container ( as much as possible )
|
||||
ForwardIteratorT InsertIt=Begin;
|
||||
BOOST_STRING_TYPENAME InputT::iterator InputIt=From;
|
||||
for(; InsertIt!=End && InputIt!=To; InsertIt++, InputIt++ )
|
||||
{
|
||||
*InputIt=*InsertIt;
|
||||
}
|
||||
|
||||
if ( InsertIt!=End )
|
||||
{
|
||||
// Replace sequence is longer, insert it
|
||||
Input.insert( InputIt, InsertIt, End );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( InputIt!=To )
|
||||
{
|
||||
// Replace sequence is shorter, erase the rest
|
||||
Input.erase( InputIt, To );
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct replace_const_time_helper< true >
|
||||
{
|
||||
// Const-time erase and insert methods -> use them
|
||||
template< typename InputT, typename ForwardIteratorT >
|
||||
void operator()(
|
||||
InputT& Input,
|
||||
BOOST_STRING_TYPENAME InputT::iterator From,
|
||||
BOOST_STRING_TYPENAME InputT::iterator To,
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End )
|
||||
{
|
||||
BOOST_STRING_TYPENAME InputT::iterator At=Input.erase( From, To );
|
||||
if ( Begin!=End )
|
||||
{
|
||||
if(!Input.empty())
|
||||
{
|
||||
Input.insert( At, Begin, End );
|
||||
}
|
||||
else
|
||||
{
|
||||
Input.insert( Input.begin(), Begin, End );
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// No native replace method
|
||||
template< bool HasNative >
|
||||
struct replace_native_helper
|
||||
{
|
||||
template< typename InputT, typename ForwardIteratorT >
|
||||
void operator()(
|
||||
InputT& Input,
|
||||
BOOST_STRING_TYPENAME InputT::iterator From,
|
||||
BOOST_STRING_TYPENAME InputT::iterator To,
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End )
|
||||
{
|
||||
replace_const_time_helper<
|
||||
boost::mpl::and_<
|
||||
has_const_time_insert<InputT>,
|
||||
has_const_time_erase<InputT> >::value >()(
|
||||
Input, From, To, Begin, End );
|
||||
}
|
||||
};
|
||||
|
||||
// Container has native replace method
|
||||
template<>
|
||||
struct replace_native_helper< true >
|
||||
{
|
||||
template< typename InputT, typename ForwardIteratorT >
|
||||
void operator()(
|
||||
InputT& Input,
|
||||
BOOST_STRING_TYPENAME InputT::iterator From,
|
||||
BOOST_STRING_TYPENAME InputT::iterator To,
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End )
|
||||
{
|
||||
Input.replace( From, To, Begin, End );
|
||||
}
|
||||
};
|
||||
|
||||
// replace helper -------------------------------------------------//
|
||||
|
||||
template< typename InputT, typename ForwardIteratorT >
|
||||
inline void replace(
|
||||
InputT& Input,
|
||||
BOOST_STRING_TYPENAME InputT::iterator From,
|
||||
BOOST_STRING_TYPENAME InputT::iterator To,
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End )
|
||||
{
|
||||
replace_native_helper< has_native_replace<InputT>::value >()(
|
||||
Input, From, To, Begin, End );
|
||||
}
|
||||
|
||||
template< typename InputT, typename InsertT >
|
||||
inline void replace(
|
||||
InputT& Input,
|
||||
BOOST_STRING_TYPENAME InputT::iterator From,
|
||||
BOOST_STRING_TYPENAME InputT::iterator To,
|
||||
const InsertT& Insert )
|
||||
{
|
||||
if(From!=To)
|
||||
{
|
||||
replace( Input, From, To, begin(Insert), end(Insert) );
|
||||
}
|
||||
else
|
||||
{
|
||||
insert( Input, From, begin(Insert), end(Insert) );
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_DETAIL_SEQUENCE_HPP
|
@ -0,0 +1,95 @@
|
||||
// Boost string_algo library trim.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_TRIM_DETAIL_HPP
|
||||
#define BOOST_STRING_TRIM_DETAIL_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/detail/iterator.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
namespace detail {
|
||||
|
||||
// trim iterator helper -----------------------------------------------//
|
||||
|
||||
// Search for first non matching character from the beginning of the sequence
|
||||
template< typename ForwardIteratorT, typename PredicateT >
|
||||
inline ForwardIteratorT trim_begin(
|
||||
ForwardIteratorT InBegin,
|
||||
ForwardIteratorT InEnd,
|
||||
PredicateT IsSpace )
|
||||
{
|
||||
ForwardIteratorT It=InBegin;
|
||||
for(; It!=InEnd; ++It )
|
||||
{
|
||||
if (!IsSpace(*It))
|
||||
return It;
|
||||
}
|
||||
|
||||
return It;
|
||||
}
|
||||
|
||||
// Search for first non matching character from the end of the sequence
|
||||
template< typename ForwardIteratorT, typename PredicateT >
|
||||
inline ForwardIteratorT trim_end(
|
||||
ForwardIteratorT InBegin,
|
||||
ForwardIteratorT InEnd,
|
||||
PredicateT IsSpace )
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME boost::detail::
|
||||
iterator_traits<ForwardIteratorT>::iterator_category category;
|
||||
|
||||
return trim_end_iter_select( InBegin, InEnd, IsSpace, category() );
|
||||
}
|
||||
|
||||
template< typename ForwardIteratorT, typename PredicateT >
|
||||
inline ForwardIteratorT trim_end_iter_select(
|
||||
ForwardIteratorT InBegin,
|
||||
ForwardIteratorT InEnd,
|
||||
PredicateT IsSpace,
|
||||
std::forward_iterator_tag )
|
||||
{
|
||||
ForwardIteratorT TrimIt=InBegin;
|
||||
|
||||
for( ForwardIteratorT It=InBegin; It!=InEnd; ++It )
|
||||
{
|
||||
if ( !IsSpace(*It) )
|
||||
{
|
||||
TrimIt=It;
|
||||
++TrimIt;
|
||||
}
|
||||
}
|
||||
|
||||
return TrimIt;
|
||||
}
|
||||
|
||||
template< typename ForwardIteratorT, typename PredicateT >
|
||||
inline ForwardIteratorT trim_end_iter_select(
|
||||
ForwardIteratorT InBegin,
|
||||
ForwardIteratorT InEnd,
|
||||
PredicateT IsSpace,
|
||||
std::bidirectional_iterator_tag )
|
||||
{
|
||||
for( ForwardIteratorT It=InEnd; It!=InBegin; )
|
||||
{
|
||||
if ( !IsSpace(*(--It)) )
|
||||
return ++It;
|
||||
}
|
||||
|
||||
return InBegin;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_TRIM_DETAIL_HPP
|
@ -0,0 +1,106 @@
|
||||
// Boost string_algo library util.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_UTIL_DETAIL_HPP
|
||||
#define BOOST_STRING_UTIL_DETAIL_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <functional>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
namespace detail {
|
||||
|
||||
// empty container -----------------------------------------------//
|
||||
|
||||
// empty_container
|
||||
/*
|
||||
This class represents always empty container,
|
||||
containing elements of type CharT.
|
||||
|
||||
It is supposed to be used in a const version only
|
||||
*/
|
||||
template< typename CharT >
|
||||
struct empty_container
|
||||
{
|
||||
typedef empty_container<CharT> type;
|
||||
typedef CharT value_type;
|
||||
typedef std::size_t size_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef const value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef const value_type* iterator;
|
||||
typedef const value_type* const_iterator;
|
||||
|
||||
|
||||
// Operations
|
||||
const_iterator begin() const
|
||||
{
|
||||
return reinterpret_cast<const_iterator>(0);
|
||||
}
|
||||
|
||||
const_iterator end() const
|
||||
{
|
||||
return reinterpret_cast<const_iterator>(0);
|
||||
}
|
||||
|
||||
bool empty() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
size_type size() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
// bounded copy algorithm -----------------------------------------------//
|
||||
|
||||
// Bounded version of the std::copy algorithm
|
||||
template<typename InputIteratorT, typename OutputIteratorT>
|
||||
inline OutputIteratorT bounded_copy(
|
||||
InputIteratorT First,
|
||||
InputIteratorT Last,
|
||||
OutputIteratorT DestFirst,
|
||||
OutputIteratorT DestLast )
|
||||
{
|
||||
InputIteratorT InputIt=First;
|
||||
OutputIteratorT OutputIt=DestFirst;
|
||||
for(; InputIt!=Last && OutputIt!=DestLast; InputIt++, OutputIt++ )
|
||||
{
|
||||
*OutputIt=*InputIt;
|
||||
}
|
||||
|
||||
return OutputIt;
|
||||
}
|
||||
|
||||
// iterator range utilities -----------------------------------------//
|
||||
|
||||
// copy range functor
|
||||
template<
|
||||
typename SeqT,
|
||||
typename IteratorT=BOOST_STRING_TYPENAME SeqT::const_iterator >
|
||||
struct copy_iterator_rangeF :
|
||||
public std::unary_function< iterator_range<IteratorT>, SeqT >
|
||||
{
|
||||
SeqT operator()( const iterator_range<IteratorT>& Range ) const
|
||||
{
|
||||
return copy_range<SeqT>(Range);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_UTIL_DETAIL_HPP
|
@ -0,0 +1,844 @@
|
||||
// Boost string_algo library erase.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2006.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_ERASE_HPP
|
||||
#define BOOST_STRING_ERASE_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
|
||||
#include <boost/algorithm/string/find_format.hpp>
|
||||
#include <boost/algorithm/string/finder.hpp>
|
||||
#include <boost/algorithm/string/formatter.hpp>
|
||||
|
||||
/*! \file
|
||||
Defines various erase algorithms. Each algorithm removes
|
||||
part(s) of the input according to a searching criteria.
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// erase_range -------------------------------------------------------//
|
||||
|
||||
//! Erase range algorithm
|
||||
/*!
|
||||
Remove the given range from the input. The result is a modified copy of
|
||||
the input. It is returned as a sequence or copied to the output iterator.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input sequence
|
||||
\param SearchRange A range in the input to be removed
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename OutputIteratorT, typename RangeT>
|
||||
inline OutputIteratorT erase_range_copy(
|
||||
OutputIteratorT Output,
|
||||
const RangeT& Input,
|
||||
const iterator_range<
|
||||
BOOST_STRING_TYPENAME
|
||||
range_const_iterator<RangeT>::type>& SearchRange )
|
||||
{
|
||||
return find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
range_finder(SearchRange),
|
||||
empty_formatter(Input) );
|
||||
}
|
||||
|
||||
//! Erase range algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT>
|
||||
inline SequenceT erase_range_copy(
|
||||
const SequenceT& Input,
|
||||
const iterator_range<
|
||||
BOOST_STRING_TYPENAME
|
||||
range_const_iterator<SequenceT>::type>& SearchRange )
|
||||
{
|
||||
return find_format_copy(
|
||||
Input,
|
||||
range_finder(SearchRange),
|
||||
empty_formatter(Input) );
|
||||
}
|
||||
|
||||
//! Erase range algorithm
|
||||
/*!
|
||||
Remove the given range from the input.
|
||||
The input sequence is modified in-place.
|
||||
|
||||
\param Input An input sequence
|
||||
\param SearchRange A range in the input to be removed
|
||||
*/
|
||||
template<typename SequenceT>
|
||||
inline void erase_range(
|
||||
SequenceT& Input,
|
||||
const iterator_range<
|
||||
BOOST_STRING_TYPENAME
|
||||
range_iterator<SequenceT>::type>& SearchRange )
|
||||
{
|
||||
find_format(
|
||||
Input,
|
||||
range_finder(SearchRange),
|
||||
empty_formatter(Input) );
|
||||
}
|
||||
|
||||
// erase_first --------------------------------------------------------//
|
||||
|
||||
//! Erase first algorithm
|
||||
/*!
|
||||
Remove the first occurrence of the substring from the input.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T>
|
||||
inline OutputIteratorT erase_first_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search )
|
||||
{
|
||||
return find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
first_finder(Search),
|
||||
empty_formatter(Input) );
|
||||
}
|
||||
|
||||
//! Erase first algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline SequenceT erase_first_copy(
|
||||
const SequenceT& Input,
|
||||
const RangeT& Search )
|
||||
{
|
||||
return find_format_copy(
|
||||
Input,
|
||||
first_finder(Search),
|
||||
empty_formatter(Input) );
|
||||
}
|
||||
|
||||
//! Erase first algorithm
|
||||
/*!
|
||||
Remove the first occurrence of the substring from the input.
|
||||
The input sequence is modified in-place.
|
||||
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for.
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline void erase_first(
|
||||
SequenceT& Input,
|
||||
const RangeT& Search )
|
||||
{
|
||||
find_format(
|
||||
Input,
|
||||
first_finder(Search),
|
||||
empty_formatter(Input) );
|
||||
}
|
||||
|
||||
// erase_first ( case insensitive ) ------------------------------------//
|
||||
|
||||
//! Erase first algorithm ( case insensitive )
|
||||
/*!
|
||||
Remove the first occurrence of the substring from the input.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
Searching is case insensitive.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T>
|
||||
inline OutputIteratorT ierase_first_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
first_finder(Search, is_iequal(Loc)),
|
||||
empty_formatter(Input) );
|
||||
}
|
||||
|
||||
//! Erase first algorithm ( case insensitive )
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline SequenceT ierase_first_copy(
|
||||
const SequenceT& Input,
|
||||
const RangeT& Search,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return find_format_copy(
|
||||
Input,
|
||||
first_finder(Search, is_iequal(Loc)),
|
||||
empty_formatter(Input) );
|
||||
}
|
||||
|
||||
//! Erase first algorithm ( case insensitive )
|
||||
/*!
|
||||
Remove the first occurrence of the substring from the input.
|
||||
The input sequence is modified in-place. Searching is case insensitive.
|
||||
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline void ierase_first(
|
||||
SequenceT& Input,
|
||||
const RangeT& Search,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
find_format(
|
||||
Input,
|
||||
first_finder(Search, is_iequal(Loc)),
|
||||
empty_formatter(Input) );
|
||||
}
|
||||
|
||||
// erase_last --------------------------------------------------------//
|
||||
|
||||
//! Erase last algorithm
|
||||
/*!
|
||||
Remove the last occurrence of the substring from the input.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for.
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T>
|
||||
inline OutputIteratorT erase_last_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search )
|
||||
{
|
||||
return find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
last_finder(Search),
|
||||
empty_formatter(Input) );
|
||||
}
|
||||
|
||||
//! Erase last algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline SequenceT erase_last_copy(
|
||||
const SequenceT& Input,
|
||||
const RangeT& Search )
|
||||
{
|
||||
return find_format_copy(
|
||||
Input,
|
||||
last_finder(Search),
|
||||
empty_formatter(Input) );
|
||||
}
|
||||
|
||||
//! Erase last algorithm
|
||||
/*!
|
||||
Remove the last occurrence of the substring from the input.
|
||||
The input sequence is modified in-place.
|
||||
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline void erase_last(
|
||||
SequenceT& Input,
|
||||
const RangeT& Search )
|
||||
{
|
||||
find_format(
|
||||
Input,
|
||||
last_finder(Search),
|
||||
empty_formatter(Input) );
|
||||
}
|
||||
|
||||
// erase_last ( case insensitive ) ------------------------------------//
|
||||
|
||||
//! Erase last algorithm ( case insensitive )
|
||||
/*!
|
||||
Remove the last occurrence of the substring from the input.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
Searching is case insensitive.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T>
|
||||
inline OutputIteratorT ierase_last_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
last_finder(Search, is_iequal(Loc)),
|
||||
empty_formatter(Input) );
|
||||
}
|
||||
|
||||
//! Erase last algorithm ( case insensitive )
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline SequenceT ierase_last_copy(
|
||||
const SequenceT& Input,
|
||||
const RangeT& Search,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return find_format_copy(
|
||||
Input,
|
||||
last_finder(Search, is_iequal(Loc)),
|
||||
empty_formatter(Input) );
|
||||
}
|
||||
|
||||
//! Erase last algorithm ( case insensitive )
|
||||
/*!
|
||||
Remove the last occurrence of the substring from the input.
|
||||
The input sequence is modified in-place. Searching is case insensitive.
|
||||
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline void ierase_last(
|
||||
SequenceT& Input,
|
||||
const RangeT& Search,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
find_format(
|
||||
Input,
|
||||
last_finder(Search, is_iequal(Loc)),
|
||||
empty_formatter(Input) );
|
||||
}
|
||||
|
||||
// erase_nth --------------------------------------------------------------------//
|
||||
|
||||
//! Erase nth algorithm
|
||||
/*!
|
||||
Remove the Nth occurrence of the substring in the input.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Nth An index of the match to be replaced. The index is 0-based.
|
||||
For negative N, matches are counted from the end of string.
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T>
|
||||
inline OutputIteratorT erase_nth_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
int Nth )
|
||||
{
|
||||
return find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
nth_finder(Search, Nth),
|
||||
empty_formatter(Input) );
|
||||
}
|
||||
|
||||
//! Erase nth algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline SequenceT erase_nth_copy(
|
||||
const SequenceT& Input,
|
||||
const RangeT& Search,
|
||||
int Nth )
|
||||
{
|
||||
return find_format_copy(
|
||||
Input,
|
||||
nth_finder(Search, Nth),
|
||||
empty_formatter(Input) );
|
||||
}
|
||||
|
||||
//! Erase nth algorithm
|
||||
/*!
|
||||
Remove the Nth occurrence of the substring in the input.
|
||||
The input sequence is modified in-place.
|
||||
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for.
|
||||
\param Nth An index of the match to be replaced. The index is 0-based.
|
||||
For negative N, matches are counted from the end of string.
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline void erase_nth(
|
||||
SequenceT& Input,
|
||||
const RangeT& Search,
|
||||
int Nth )
|
||||
{
|
||||
find_format(
|
||||
Input,
|
||||
nth_finder(Search, Nth),
|
||||
empty_formatter(Input) );
|
||||
}
|
||||
|
||||
// erase_nth ( case insensitive ) ---------------------------------------------//
|
||||
|
||||
//! Erase nth algorithm ( case insensitive )
|
||||
/*!
|
||||
Remove the Nth occurrence of the substring in the input.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
Searching is case insensitive.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for.
|
||||
\param Nth An index of the match to be replaced. The index is 0-based.
|
||||
For negative N, matches are counted from the end of string.
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T>
|
||||
inline OutputIteratorT ierase_nth_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
int Nth,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
nth_finder(Search, Nth, is_iequal(Loc)),
|
||||
empty_formatter(Input) );
|
||||
}
|
||||
|
||||
//! Erase nth algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline SequenceT ierase_nth_copy(
|
||||
const SequenceT& Input,
|
||||
const RangeT& Search,
|
||||
int Nth,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return find_format_copy(
|
||||
Input,
|
||||
nth_finder(Search, Nth, is_iequal(Loc)),
|
||||
empty_formatter(Input) );
|
||||
}
|
||||
|
||||
//! Erase nth algorithm
|
||||
/*!
|
||||
Remove the Nth occurrence of the substring in the input.
|
||||
The input sequence is modified in-place. Searching is case insensitive.
|
||||
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for.
|
||||
\param Nth An index of the match to be replaced. The index is 0-based.
|
||||
For negative N, matches are counted from the end of string.
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline void ierase_nth(
|
||||
SequenceT& Input,
|
||||
const RangeT& Search,
|
||||
int Nth,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
find_format(
|
||||
Input,
|
||||
nth_finder(Search, Nth, is_iequal(Loc)),
|
||||
empty_formatter(Input) );
|
||||
}
|
||||
|
||||
|
||||
// erase_all --------------------------------------------------------//
|
||||
|
||||
//! Erase all algorithm
|
||||
/*!
|
||||
Remove all the occurrences of the string from the input.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input sequence
|
||||
\param Search A substring to be searched for.
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T>
|
||||
inline OutputIteratorT erase_all_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search )
|
||||
{
|
||||
return find_format_all_copy(
|
||||
Output,
|
||||
Input,
|
||||
first_finder(Search),
|
||||
empty_formatter(Input) );
|
||||
}
|
||||
|
||||
//! Erase all algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline SequenceT erase_all_copy(
|
||||
const SequenceT& Input,
|
||||
const RangeT& Search )
|
||||
{
|
||||
return find_format_all_copy(
|
||||
Input,
|
||||
first_finder(Search),
|
||||
empty_formatter(Input) );
|
||||
}
|
||||
|
||||
//! Erase all algorithm
|
||||
/*!
|
||||
Remove all the occurrences of the string from the input.
|
||||
The input sequence is modified in-place.
|
||||
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for.
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline void erase_all(
|
||||
SequenceT& Input,
|
||||
const RangeT& Search )
|
||||
{
|
||||
find_format_all(
|
||||
Input,
|
||||
first_finder(Search),
|
||||
empty_formatter(Input) );
|
||||
}
|
||||
|
||||
// erase_all ( case insensitive ) ------------------------------------//
|
||||
|
||||
//! Erase all algorithm ( case insensitive )
|
||||
/*!
|
||||
Remove all the occurrences of the string from the input.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
Searching is case insensitive.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T>
|
||||
inline OutputIteratorT ierase_all_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return find_format_all_copy(
|
||||
Output,
|
||||
Input,
|
||||
first_finder(Search, is_iequal(Loc)),
|
||||
empty_formatter(Input) );
|
||||
}
|
||||
|
||||
//! Erase all algorithm ( case insensitive )
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline SequenceT ierase_all_copy(
|
||||
const SequenceT& Input,
|
||||
const RangeT& Search,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return find_format_all_copy(
|
||||
Input,
|
||||
first_finder(Search, is_iequal(Loc)),
|
||||
empty_formatter(Input) );
|
||||
}
|
||||
|
||||
//! Erase all algorithm ( case insensitive )
|
||||
/*!
|
||||
Remove all the occurrences of the string from the input.
|
||||
The input sequence is modified in-place. Searching is case insensitive.
|
||||
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for.
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline void ierase_all(
|
||||
SequenceT& Input,
|
||||
const RangeT& Search,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
find_format_all(
|
||||
Input,
|
||||
first_finder(Search, is_iequal(Loc)),
|
||||
empty_formatter(Input) );
|
||||
}
|
||||
|
||||
// erase_head --------------------------------------------------------------------//
|
||||
|
||||
//! Erase head algorithm
|
||||
/*!
|
||||
Remove the head from the input. The head is a prefix of a sequence of given size.
|
||||
If the sequence is shorter then required, the whole string is
|
||||
considered to be the head. The result is a modified copy of the input.
|
||||
It is returned as a sequence or copied to the output iterator.
|
||||
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param N Length of the head.
|
||||
For N>=0, at most N characters are extracted.
|
||||
For N<0, size(Input)-|N| characters are extracted.
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename RangeT>
|
||||
inline OutputIteratorT erase_head_copy(
|
||||
OutputIteratorT Output,
|
||||
const RangeT& Input,
|
||||
int N )
|
||||
{
|
||||
return find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
head_finder(N),
|
||||
empty_formatter( Input ) );
|
||||
}
|
||||
|
||||
//! Erase head algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT>
|
||||
inline SequenceT erase_head_copy(
|
||||
const SequenceT& Input,
|
||||
int N )
|
||||
{
|
||||
return find_format_copy(
|
||||
Input,
|
||||
head_finder(N),
|
||||
empty_formatter( Input ) );
|
||||
}
|
||||
|
||||
//! Erase head algorithm
|
||||
/*!
|
||||
Remove the head from the input. The head is a prefix of a sequence of given size.
|
||||
If the sequence is shorter then required, the whole string is
|
||||
considered to be the head. The input sequence is modified in-place.
|
||||
|
||||
\param Input An input string
|
||||
\param N Length of the head
|
||||
For N>=0, at most N characters are extracted.
|
||||
For N<0, size(Input)-|N| characters are extracted.
|
||||
*/
|
||||
template<typename SequenceT>
|
||||
inline void erase_head(
|
||||
SequenceT& Input,
|
||||
int N )
|
||||
{
|
||||
find_format(
|
||||
Input,
|
||||
head_finder(N),
|
||||
empty_formatter( Input ) );
|
||||
}
|
||||
|
||||
// erase_tail --------------------------------------------------------------------//
|
||||
|
||||
//! Erase tail algorithm
|
||||
/*!
|
||||
Remove the tail from the input. The tail is a suffix of a sequence of given size.
|
||||
If the sequence is shorter then required, the whole string is
|
||||
considered to be the tail.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param N Length of the head.
|
||||
For N>=0, at most N characters are extracted.
|
||||
For N<0, size(Input)-|N| characters are extracted.
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename RangeT>
|
||||
inline OutputIteratorT erase_tail_copy(
|
||||
OutputIteratorT Output,
|
||||
const RangeT& Input,
|
||||
int N )
|
||||
{
|
||||
return find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
tail_finder(N),
|
||||
empty_formatter( Input ) );
|
||||
}
|
||||
|
||||
//! Erase tail algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT>
|
||||
inline SequenceT erase_tail_copy(
|
||||
const SequenceT& Input,
|
||||
int N )
|
||||
{
|
||||
return find_format_copy(
|
||||
Input,
|
||||
tail_finder(N),
|
||||
empty_formatter( Input ) );
|
||||
}
|
||||
|
||||
//! Erase tail algorithm
|
||||
/*!
|
||||
Remove the tail from the input. The tail is a suffix of a sequence of given size.
|
||||
If the sequence is shorter then required, the whole string is
|
||||
considered to be the tail. The input sequence is modified in-place.
|
||||
|
||||
\param Input An input string
|
||||
\param N Length of the head
|
||||
For N>=0, at most N characters are extracted.
|
||||
For N<0, size(Input)-|N| characters are extracted.
|
||||
*/
|
||||
template<typename SequenceT>
|
||||
inline void erase_tail(
|
||||
SequenceT& Input,
|
||||
int N )
|
||||
{
|
||||
find_format(
|
||||
Input,
|
||||
tail_finder(N),
|
||||
empty_formatter( Input ) );
|
||||
}
|
||||
|
||||
} // namespace algorithm
|
||||
|
||||
// pull names into the boost namespace
|
||||
using algorithm::erase_range_copy;
|
||||
using algorithm::erase_range;
|
||||
using algorithm::erase_first_copy;
|
||||
using algorithm::erase_first;
|
||||
using algorithm::ierase_first_copy;
|
||||
using algorithm::ierase_first;
|
||||
using algorithm::erase_last_copy;
|
||||
using algorithm::erase_last;
|
||||
using algorithm::ierase_last_copy;
|
||||
using algorithm::ierase_last;
|
||||
using algorithm::erase_nth_copy;
|
||||
using algorithm::erase_nth;
|
||||
using algorithm::ierase_nth_copy;
|
||||
using algorithm::ierase_nth;
|
||||
using algorithm::erase_all_copy;
|
||||
using algorithm::erase_all;
|
||||
using algorithm::ierase_all_copy;
|
||||
using algorithm::ierase_all;
|
||||
using algorithm::erase_head_copy;
|
||||
using algorithm::erase_head;
|
||||
using algorithm::erase_tail_copy;
|
||||
using algorithm::erase_tail;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_ERASE_HPP
|
@ -0,0 +1,334 @@
|
||||
// Boost string_algo library find.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_FIND_HPP
|
||||
#define BOOST_STRING_FIND_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/range/as_literal.hpp>
|
||||
|
||||
#include <boost/algorithm/string/finder.hpp>
|
||||
#include <boost/algorithm/string/compare.hpp>
|
||||
#include <boost/algorithm/string/constants.hpp>
|
||||
|
||||
/*! \file
|
||||
Defines a set of find algorithms. The algorithms are searching
|
||||
for a substring of the input. The result is given as an \c iterator_range
|
||||
delimiting the substring.
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// Generic find -----------------------------------------------//
|
||||
|
||||
//! Generic find algorithm
|
||||
/*!
|
||||
Search the input using the given finder.
|
||||
|
||||
\param Input A string which will be searched.
|
||||
\param Finder Finder object used for searching.
|
||||
\return
|
||||
An \c iterator_range delimiting the match.
|
||||
Returned iterator is either \c RangeT::iterator or
|
||||
\c RangeT::const_iterator, depending on the constness of
|
||||
the input parameter.
|
||||
*/
|
||||
template<typename RangeT, typename FinderT>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME range_iterator<RangeT>::type>
|
||||
find(
|
||||
RangeT& Input,
|
||||
const FinderT& Finder)
|
||||
{
|
||||
iterator_range<BOOST_STRING_TYPENAME range_iterator<RangeT>::type> lit_input(as_literal(Input));
|
||||
|
||||
return Finder(begin(lit_input),end(lit_input));
|
||||
}
|
||||
|
||||
// find_first -----------------------------------------------//
|
||||
|
||||
//! Find first algorithm
|
||||
/*!
|
||||
Search for the first occurrence of the substring in the input.
|
||||
|
||||
\param Input A string which will be searched.
|
||||
\param Search A substring to be searched for.
|
||||
\return
|
||||
An \c iterator_range delimiting the match.
|
||||
Returned iterator is either \c RangeT::iterator or
|
||||
\c RangeT::const_iterator, depending on the constness of
|
||||
the input parameter.
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME range_iterator<Range1T>::type>
|
||||
find_first(
|
||||
Range1T& Input,
|
||||
const Range2T& Search)
|
||||
{
|
||||
return find(Input, first_finder(Search));
|
||||
}
|
||||
|
||||
//! Find first algorithm ( case insensitive )
|
||||
/*!
|
||||
Search for the first occurence of the substring in the input.
|
||||
Searching is case insensitive.
|
||||
|
||||
\param Input A string which will be searched.
|
||||
\param Search A substring to be searched for.
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return
|
||||
An \c iterator_range delimiting the match.
|
||||
Returned iterator is either \c Range1T::iterator or
|
||||
\c Range1T::const_iterator, depending on the constness of
|
||||
the input parameter.
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME range_iterator<Range1T>::type>
|
||||
ifind_first(
|
||||
Range1T& Input,
|
||||
const Range2T& Search,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return find(Input, first_finder(Search,is_iequal(Loc)));
|
||||
}
|
||||
|
||||
// find_last -----------------------------------------------//
|
||||
|
||||
//! Find last algorithm
|
||||
/*!
|
||||
Search for the last occurrence of the substring in the input.
|
||||
|
||||
\param Input A string which will be searched.
|
||||
\param Search A substring to be searched for.
|
||||
\return
|
||||
An \c iterator_range delimiting the match.
|
||||
Returned iterator is either \c Range1T::iterator or
|
||||
\c Range1T::const_iterator, depending on the constness of
|
||||
the input parameter.
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME range_iterator<Range1T>::type>
|
||||
find_last(
|
||||
Range1T& Input,
|
||||
const Range2T& Search)
|
||||
{
|
||||
return find(Input, last_finder(Search));
|
||||
}
|
||||
|
||||
//! Find last algorithm ( case insensitive )
|
||||
/*!
|
||||
Search for the last match a string in the input.
|
||||
Searching is case insensitive.
|
||||
|
||||
\param Input A string which will be searched.
|
||||
\param Search A substring to be searched for.
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return
|
||||
An \c iterator_range delimiting the match.
|
||||
Returned iterator is either \c Range1T::iterator or
|
||||
\c Range1T::const_iterator, depending on the constness of
|
||||
the input parameter.
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME range_iterator<Range1T>::type>
|
||||
ifind_last(
|
||||
Range1T& Input,
|
||||
const Range2T& Search,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return find(Input, last_finder(Search, is_iequal(Loc)));
|
||||
}
|
||||
|
||||
// find_nth ----------------------------------------------------------------------//
|
||||
|
||||
//! Find n-th algorithm
|
||||
/*!
|
||||
Search for the n-th (zero-indexed) occurrence of the substring in the
|
||||
input.
|
||||
|
||||
\param Input A string which will be searched.
|
||||
\param Search A substring to be searched for.
|
||||
\param Nth An index (zero-indexed) of the match to be found.
|
||||
For negative N, the matches are counted from the end of string.
|
||||
\return
|
||||
An \c iterator_range delimiting the match.
|
||||
Returned iterator is either \c Range1T::iterator or
|
||||
\c Range1T::const_iterator, depending on the constness of
|
||||
the input parameter.
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME range_iterator<Range1T>::type>
|
||||
find_nth(
|
||||
Range1T& Input,
|
||||
const Range2T& Search,
|
||||
int Nth)
|
||||
{
|
||||
return find(Input, nth_finder(Search,Nth));
|
||||
}
|
||||
|
||||
//! Find n-th algorithm ( case insensitive ).
|
||||
/*!
|
||||
Search for the n-th (zero-indexed) occurrence of the substring in the
|
||||
input. Searching is case insensitive.
|
||||
|
||||
\param Input A string which will be searched.
|
||||
\param Search A substring to be searched for.
|
||||
\param Nth An index (zero-indexed) of the match to be found.
|
||||
For negative N, the matches are counted from the end of string.
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return
|
||||
An \c iterator_range delimiting the match.
|
||||
Returned iterator is either \c Range1T::iterator or
|
||||
\c Range1T::const_iterator, depending on the constness of
|
||||
the input parameter.
|
||||
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME range_iterator<Range1T>::type>
|
||||
ifind_nth(
|
||||
Range1T& Input,
|
||||
const Range2T& Search,
|
||||
int Nth,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return find(Input, nth_finder(Search,Nth,is_iequal(Loc)));
|
||||
}
|
||||
|
||||
// find_head ----------------------------------------------------------------------//
|
||||
|
||||
//! Find head algorithm
|
||||
/*!
|
||||
Get the head of the input. Head is a prefix of the string of the
|
||||
given size. If the input is shorter then required, whole input if considered
|
||||
to be the head.
|
||||
|
||||
\param Input An input string
|
||||
\param N Length of the head
|
||||
For N>=0, at most N characters are extracted.
|
||||
For N<0, size(Input)-|N| characters are extracted.
|
||||
\return
|
||||
An \c iterator_range delimiting the match.
|
||||
Returned iterator is either \c Range1T::iterator or
|
||||
\c Range1T::const_iterator, depending on the constness of
|
||||
the input parameter.
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename RangeT>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME range_iterator<RangeT>::type>
|
||||
find_head(
|
||||
RangeT& Input,
|
||||
int N)
|
||||
{
|
||||
return find(Input, head_finder(N));
|
||||
}
|
||||
|
||||
// find_tail ----------------------------------------------------------------------//
|
||||
|
||||
//! Find tail algorithm
|
||||
/*!
|
||||
Get the head of the input. Head is a suffix of the string of the
|
||||
given size. If the input is shorter then required, whole input if considered
|
||||
to be the tail.
|
||||
|
||||
\param Input An input string
|
||||
\param N Length of the tail.
|
||||
For N>=0, at most N characters are extracted.
|
||||
For N<0, size(Input)-|N| characters are extracted.
|
||||
\return
|
||||
An \c iterator_range delimiting the match.
|
||||
Returned iterator is either \c RangeT::iterator or
|
||||
\c RangeT::const_iterator, depending on the constness of
|
||||
the input parameter.
|
||||
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename RangeT>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME range_iterator<RangeT>::type>
|
||||
find_tail(
|
||||
RangeT& Input,
|
||||
int N)
|
||||
{
|
||||
return find(Input, tail_finder(N));
|
||||
}
|
||||
|
||||
// find_token --------------------------------------------------------------------//
|
||||
|
||||
//! Find token algorithm
|
||||
/*!
|
||||
Look for a given token in the string. Token is a character that matches the
|
||||
given predicate.
|
||||
If the "token compress mode" is enabled, adjacent tokens are considered to be one match.
|
||||
|
||||
\param Input A input string.
|
||||
\param Pred An unary predicate to identify a token
|
||||
\param eCompress Enable/Disable compressing of adjacent tokens
|
||||
\return
|
||||
An \c iterator_range delimiting the match.
|
||||
Returned iterator is either \c RangeT::iterator or
|
||||
\c RangeT::const_iterator, depending on the constness of
|
||||
the input parameter.
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename RangeT, typename PredicateT>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME range_iterator<RangeT>::type>
|
||||
find_token(
|
||||
RangeT& Input,
|
||||
PredicateT Pred,
|
||||
token_compress_mode_type eCompress=token_compress_off)
|
||||
{
|
||||
return find(Input, token_finder(Pred, eCompress));
|
||||
}
|
||||
|
||||
} // namespace algorithm
|
||||
|
||||
// pull names to the boost namespace
|
||||
using algorithm::find;
|
||||
using algorithm::find_first;
|
||||
using algorithm::ifind_first;
|
||||
using algorithm::find_last;
|
||||
using algorithm::ifind_last;
|
||||
using algorithm::find_nth;
|
||||
using algorithm::ifind_nth;
|
||||
using algorithm::find_head;
|
||||
using algorithm::find_tail;
|
||||
using algorithm::find_token;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_FIND_HPP
|
@ -0,0 +1,269 @@
|
||||
// Boost string_algo library find_format.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_FIND_FORMAT_HPP
|
||||
#define BOOST_STRING_FIND_FORMAT_HPP
|
||||
|
||||
#include <deque>
|
||||
#include <boost/detail/iterator.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
#include <boost/range/as_literal.hpp>
|
||||
|
||||
#include <boost/algorithm/string/concept.hpp>
|
||||
#include <boost/algorithm/string/detail/find_format.hpp>
|
||||
#include <boost/algorithm/string/detail/find_format_all.hpp>
|
||||
|
||||
/*! \file
|
||||
Defines generic replace algorithms. Each algorithm replaces
|
||||
part(s) of the input. The part to be replaced is looked up using a Finder object.
|
||||
Result of finding is then used by a Formatter object to generate the replacement.
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// generic replace -----------------------------------------------------------------//
|
||||
|
||||
//! Generic replace algorithm
|
||||
/*!
|
||||
Use the Finder to search for a substring. Use the Formatter to format
|
||||
this substring and replace it in the input.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input sequence
|
||||
\param Finder A Finder object used to search for a match to be replaced
|
||||
\param Formatter A Formatter object used to format a match
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename RangeT,
|
||||
typename FinderT,
|
||||
typename FormatterT>
|
||||
inline OutputIteratorT find_format_copy(
|
||||
OutputIteratorT Output,
|
||||
const RangeT& Input,
|
||||
FinderT Finder,
|
||||
FormatterT Formatter )
|
||||
{
|
||||
// Concept check
|
||||
function_requires<
|
||||
FinderConcept<FinderT,
|
||||
BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> >();
|
||||
function_requires<
|
||||
FormatterConcept<
|
||||
FormatterT,
|
||||
FinderT,BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> >();
|
||||
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> lit_input(as_literal(Input));
|
||||
|
||||
return detail::find_format_copy_impl(
|
||||
Output,
|
||||
lit_input,
|
||||
Formatter,
|
||||
Finder( begin(lit_input), end(lit_input) ) );
|
||||
}
|
||||
|
||||
//! Generic replace algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<
|
||||
typename SequenceT,
|
||||
typename FinderT,
|
||||
typename FormatterT>
|
||||
inline SequenceT find_format_copy(
|
||||
const SequenceT& Input,
|
||||
FinderT Finder,
|
||||
FormatterT Formatter )
|
||||
{
|
||||
// Concept check
|
||||
function_requires<
|
||||
FinderConcept<FinderT,
|
||||
BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type> >();
|
||||
function_requires<
|
||||
FormatterConcept<
|
||||
FormatterT,
|
||||
FinderT,BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type> >();
|
||||
|
||||
return detail::find_format_copy_impl(
|
||||
Input,
|
||||
Formatter,
|
||||
Finder(begin(Input), end(Input)));
|
||||
}
|
||||
|
||||
//! Generic replace algorithm
|
||||
/*!
|
||||
Use the Finder to search for a substring. Use the Formatter to format
|
||||
this substring and replace it in the input. The input is modified in-place.
|
||||
|
||||
\param Input An input sequence
|
||||
\param Finder A Finder object used to search for a match to be replaced
|
||||
\param Formatter A Formatter object used to format a match
|
||||
*/
|
||||
template<
|
||||
typename SequenceT,
|
||||
typename FinderT,
|
||||
typename FormatterT>
|
||||
inline void find_format(
|
||||
SequenceT& Input,
|
||||
FinderT Finder,
|
||||
FormatterT Formatter)
|
||||
{
|
||||
// Concept check
|
||||
function_requires<
|
||||
FinderConcept<FinderT,
|
||||
BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type> >();
|
||||
function_requires<
|
||||
FormatterConcept<
|
||||
FormatterT,
|
||||
FinderT,BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type> >();
|
||||
|
||||
detail::find_format_impl(
|
||||
Input,
|
||||
Formatter,
|
||||
Finder(begin(Input), end(Input)));
|
||||
}
|
||||
|
||||
|
||||
// find_format_all generic ----------------------------------------------------------------//
|
||||
|
||||
//! Generic replace all algorithm
|
||||
/*!
|
||||
Use the Finder to search for a substring. Use the Formatter to format
|
||||
this substring and replace it in the input. Repeat this for all matching
|
||||
substrings.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input sequence
|
||||
\param Finder A Finder object used to search for a match to be replaced
|
||||
\param Formatter A Formatter object used to format a match
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename RangeT,
|
||||
typename FinderT,
|
||||
typename FormatterT>
|
||||
inline OutputIteratorT find_format_all_copy(
|
||||
OutputIteratorT Output,
|
||||
const RangeT& Input,
|
||||
FinderT Finder,
|
||||
FormatterT Formatter)
|
||||
{
|
||||
// Concept check
|
||||
function_requires<
|
||||
FinderConcept<FinderT,
|
||||
BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> >();
|
||||
function_requires<
|
||||
FormatterConcept<
|
||||
FormatterT,
|
||||
FinderT,BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> >();
|
||||
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> lit_input(as_literal(Input));
|
||||
|
||||
return detail::find_format_all_copy_impl(
|
||||
Output,
|
||||
lit_input,
|
||||
Finder,
|
||||
Formatter,
|
||||
Finder(begin(lit_input), end(lit_input)));
|
||||
}
|
||||
|
||||
//! Generic replace all algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<
|
||||
typename SequenceT,
|
||||
typename FinderT,
|
||||
typename FormatterT >
|
||||
inline SequenceT find_format_all_copy(
|
||||
const SequenceT& Input,
|
||||
FinderT Finder,
|
||||
FormatterT Formatter )
|
||||
{
|
||||
// Concept check
|
||||
function_requires<
|
||||
FinderConcept<FinderT,
|
||||
BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type> >();
|
||||
function_requires<
|
||||
FormatterConcept<
|
||||
FormatterT,
|
||||
FinderT,BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type> >();
|
||||
|
||||
return detail::find_format_all_copy_impl(
|
||||
Input,
|
||||
Finder,
|
||||
Formatter,
|
||||
Finder( begin(Input), end(Input) ) );
|
||||
}
|
||||
|
||||
//! Generic replace all algorithm
|
||||
/*!
|
||||
Use the Finder to search for a substring. Use the Formatter to format
|
||||
this substring and replace it in the input. Repeat this for all matching
|
||||
substrings.The input is modified in-place.
|
||||
|
||||
\param Input An input sequence
|
||||
\param Finder A Finder object used to search for a match to be replaced
|
||||
\param Formatter A Formatter object used to format a match
|
||||
*/
|
||||
template<
|
||||
typename SequenceT,
|
||||
typename FinderT,
|
||||
typename FormatterT >
|
||||
inline void find_format_all(
|
||||
SequenceT& Input,
|
||||
FinderT Finder,
|
||||
FormatterT Formatter )
|
||||
{
|
||||
// Concept check
|
||||
function_requires<
|
||||
FinderConcept<FinderT,
|
||||
BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type> >();
|
||||
function_requires<
|
||||
FormatterConcept<
|
||||
FormatterT,
|
||||
FinderT,BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type> >();
|
||||
|
||||
detail::find_format_all_impl(
|
||||
Input,
|
||||
Finder,
|
||||
Formatter,
|
||||
Finder(begin(Input), end(Input)));
|
||||
|
||||
}
|
||||
|
||||
} // namespace algorithm
|
||||
|
||||
// pull the names to the boost namespace
|
||||
using algorithm::find_format_copy;
|
||||
using algorithm::find_format;
|
||||
using algorithm::find_format_all_copy;
|
||||
using algorithm::find_format_all;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_FIND_FORMAT_HPP
|
@ -0,0 +1,387 @@
|
||||
// Boost string_algo library find_iterator.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2004.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_FIND_ITERATOR_HPP
|
||||
#define BOOST_STRING_FIND_ITERATOR_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/iterator/iterator_facade.hpp>
|
||||
#include <boost/iterator/iterator_categories.hpp>
|
||||
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/range/as_literal.hpp>
|
||||
|
||||
#include <boost/algorithm/string/detail/find_iterator.hpp>
|
||||
|
||||
/*! \file
|
||||
Defines find iterator classes. Find iterator repeatly applies a Finder
|
||||
to the specified input string to search for matches. Dereferencing
|
||||
the iterator yields the current match or a range between the last and the current
|
||||
match depending on the iterator used.
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// find_iterator -----------------------------------------------//
|
||||
|
||||
//! find_iterator
|
||||
/*!
|
||||
Find iterator encapsulates a Finder and allows
|
||||
for incremental searching in a string.
|
||||
Each increment moves the iterator to the next match.
|
||||
|
||||
Find iterator is a readable forward traversal iterator.
|
||||
|
||||
Dereferencing the iterator yields an iterator_range delimiting
|
||||
the current match.
|
||||
*/
|
||||
template<typename IteratorT>
|
||||
class find_iterator :
|
||||
public iterator_facade<
|
||||
find_iterator<IteratorT>,
|
||||
const iterator_range<IteratorT>,
|
||||
forward_traversal_tag >,
|
||||
private detail::find_iterator_base<IteratorT>
|
||||
{
|
||||
private:
|
||||
// facade support
|
||||
friend class ::boost::iterator_core_access;
|
||||
|
||||
// base type
|
||||
typedef iterator_facade<
|
||||
find_iterator<IteratorT>,
|
||||
const iterator_range<IteratorT>,
|
||||
forward_traversal_tag> facade_type;
|
||||
|
||||
private:
|
||||
// typedefs
|
||||
|
||||
typedef detail::find_iterator_base<IteratorT> base_type;
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
base_type::input_iterator_type input_iterator_type;
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
base_type::match_type match_type;
|
||||
|
||||
public:
|
||||
//! Default constructor
|
||||
/*!
|
||||
Construct null iterator. All null iterators are equal.
|
||||
|
||||
\post eof()==true
|
||||
*/
|
||||
find_iterator() {}
|
||||
|
||||
//! Copy constructor
|
||||
/*!
|
||||
Construct a copy of the find_iterator
|
||||
*/
|
||||
find_iterator( const find_iterator& Other ) :
|
||||
base_type(Other),
|
||||
m_Match(Other.m_Match),
|
||||
m_End(Other.m_End) {}
|
||||
|
||||
//! Constructor
|
||||
/*!
|
||||
Construct new find_iterator for a given finder
|
||||
and a range.
|
||||
*/
|
||||
template<typename FinderT>
|
||||
find_iterator(
|
||||
IteratorT Begin,
|
||||
IteratorT End,
|
||||
FinderT Finder ) :
|
||||
detail::find_iterator_base<IteratorT>(Finder,0),
|
||||
m_Match(Begin,Begin),
|
||||
m_End(End)
|
||||
{
|
||||
increment();
|
||||
}
|
||||
|
||||
//! Constructor
|
||||
/*!
|
||||
Construct new find_iterator for a given finder
|
||||
and a range.
|
||||
*/
|
||||
template<typename FinderT, typename RangeT>
|
||||
find_iterator(
|
||||
RangeT& Col,
|
||||
FinderT Finder ) :
|
||||
detail::find_iterator_base<IteratorT>(Finder,0)
|
||||
{
|
||||
iterator_range<BOOST_STRING_TYPENAME range_iterator<RangeT>::type> lit_col(as_literal(Col));
|
||||
m_Match=make_iterator_range(begin(lit_col), begin(lit_col));
|
||||
m_End=end(lit_col);
|
||||
|
||||
increment();
|
||||
}
|
||||
|
||||
private:
|
||||
// iterator operations
|
||||
|
||||
// dereference
|
||||
const match_type& dereference() const
|
||||
{
|
||||
return m_Match;
|
||||
}
|
||||
|
||||
// increment
|
||||
void increment()
|
||||
{
|
||||
m_Match=this->do_find(m_Match.end(),m_End);
|
||||
}
|
||||
|
||||
// comparison
|
||||
bool equal( const find_iterator& Other ) const
|
||||
{
|
||||
bool bEof=eof();
|
||||
bool bOtherEof=Other.eof();
|
||||
|
||||
return bEof || bOtherEof ? bEof==bOtherEof :
|
||||
(
|
||||
m_Match==Other.m_Match &&
|
||||
m_End==Other.m_End
|
||||
);
|
||||
}
|
||||
|
||||
public:
|
||||
// operations
|
||||
|
||||
//! Eof check
|
||||
/*!
|
||||
Check the eof condition. Eof condition means that
|
||||
there is nothing more to be searched i.e. find_iterator
|
||||
is after the last match.
|
||||
*/
|
||||
bool eof() const
|
||||
{
|
||||
return
|
||||
this->is_null() ||
|
||||
(
|
||||
m_Match.begin() == m_End &&
|
||||
m_Match.end() == m_End
|
||||
);
|
||||
}
|
||||
|
||||
private:
|
||||
// Attributes
|
||||
match_type m_Match;
|
||||
input_iterator_type m_End;
|
||||
};
|
||||
|
||||
//! find iterator construction helper
|
||||
/*!
|
||||
* Construct a find iterator to iterate through the specified string
|
||||
*/
|
||||
template<typename RangeT, typename FinderT>
|
||||
inline find_iterator<
|
||||
BOOST_STRING_TYPENAME range_iterator<RangeT>::type>
|
||||
make_find_iterator(
|
||||
RangeT& Collection,
|
||||
FinderT Finder)
|
||||
{
|
||||
return find_iterator<BOOST_STRING_TYPENAME range_iterator<RangeT>::type>(
|
||||
Collection, Finder);
|
||||
}
|
||||
|
||||
// split iterator -----------------------------------------------//
|
||||
|
||||
//! split_iterator
|
||||
/*!
|
||||
Split iterator encapsulates a Finder and allows
|
||||
for incremental searching in a string.
|
||||
Unlike the find iterator, split iterator iterates
|
||||
through gaps between matches.
|
||||
|
||||
Find iterator is a readable forward traversal iterator.
|
||||
|
||||
Dereferencing the iterator yields an iterator_range delimiting
|
||||
the current match.
|
||||
*/
|
||||
template<typename IteratorT>
|
||||
class split_iterator :
|
||||
public iterator_facade<
|
||||
split_iterator<IteratorT>,
|
||||
const iterator_range<IteratorT>,
|
||||
forward_traversal_tag >,
|
||||
private detail::find_iterator_base<IteratorT>
|
||||
{
|
||||
private:
|
||||
// facade support
|
||||
friend class ::boost::iterator_core_access;
|
||||
|
||||
// base type
|
||||
typedef iterator_facade<
|
||||
find_iterator<IteratorT>,
|
||||
iterator_range<IteratorT>,
|
||||
forward_traversal_tag> facade_type;
|
||||
|
||||
private:
|
||||
// typedefs
|
||||
|
||||
typedef detail::find_iterator_base<IteratorT> base_type;
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
base_type::input_iterator_type input_iterator_type;
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
base_type::match_type match_type;
|
||||
|
||||
public:
|
||||
//! Default constructor
|
||||
/*!
|
||||
Construct null iterator. All null iterators are equal.
|
||||
|
||||
\post eof()==true
|
||||
*/
|
||||
split_iterator() {}
|
||||
//! Copy constructor
|
||||
/*!
|
||||
Construct a copy of the split_iterator
|
||||
*/
|
||||
split_iterator( const split_iterator& Other ) :
|
||||
base_type(Other),
|
||||
m_Match(Other.m_Match),
|
||||
m_Next(Other.m_Next),
|
||||
m_End(Other.m_End),
|
||||
m_bEof(false)
|
||||
{}
|
||||
|
||||
//! Constructor
|
||||
/*!
|
||||
Construct new split_iterator for a given finder
|
||||
and a range.
|
||||
*/
|
||||
template<typename FinderT>
|
||||
split_iterator(
|
||||
IteratorT Begin,
|
||||
IteratorT End,
|
||||
FinderT Finder ) :
|
||||
detail::find_iterator_base<IteratorT>(Finder,0),
|
||||
m_Match(Begin,Begin),
|
||||
m_Next(Begin),
|
||||
m_End(End),
|
||||
m_bEof(false)
|
||||
{
|
||||
increment();
|
||||
}
|
||||
//! Constructor
|
||||
/*!
|
||||
Construct new split_iterator for a given finder
|
||||
and a collection.
|
||||
*/
|
||||
template<typename FinderT, typename RangeT>
|
||||
split_iterator(
|
||||
RangeT& Col,
|
||||
FinderT Finder ) :
|
||||
detail::find_iterator_base<IteratorT>(Finder,0),
|
||||
m_bEof(false)
|
||||
{
|
||||
iterator_range<BOOST_STRING_TYPENAME range_iterator<RangeT>::type> lit_col(as_literal(Col));
|
||||
m_Match=make_iterator_range(begin(lit_col), begin(lit_col));
|
||||
m_Next=begin(lit_col);
|
||||
m_End=end(lit_col);
|
||||
|
||||
increment();
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
// iterator operations
|
||||
|
||||
// dereference
|
||||
const match_type& dereference() const
|
||||
{
|
||||
return m_Match;
|
||||
}
|
||||
|
||||
// increment
|
||||
void increment()
|
||||
{
|
||||
match_type FindMatch=this->do_find( m_Next, m_End );
|
||||
|
||||
if(FindMatch.begin()==m_End && FindMatch.end()==m_End)
|
||||
{
|
||||
if(m_Match.end()==m_End)
|
||||
{
|
||||
// Mark iterator as eof
|
||||
m_bEof=true;
|
||||
}
|
||||
}
|
||||
|
||||
m_Match=match_type( m_Next, FindMatch.begin() );
|
||||
m_Next=FindMatch.end();
|
||||
}
|
||||
|
||||
// comparison
|
||||
bool equal( const split_iterator& Other ) const
|
||||
{
|
||||
bool bEof=eof();
|
||||
bool bOtherEof=Other.eof();
|
||||
|
||||
return bEof || bOtherEof ? bEof==bOtherEof :
|
||||
(
|
||||
m_Match==Other.m_Match &&
|
||||
m_Next==Other.m_Next &&
|
||||
m_End==Other.m_End
|
||||
);
|
||||
}
|
||||
|
||||
public:
|
||||
// operations
|
||||
|
||||
//! Eof check
|
||||
/*!
|
||||
Check the eof condition. Eof condition means that
|
||||
there is nothing more to be searched i.e. find_iterator
|
||||
is after the last match.
|
||||
*/
|
||||
bool eof() const
|
||||
{
|
||||
return this->is_null() || m_bEof;
|
||||
}
|
||||
|
||||
private:
|
||||
// Attributes
|
||||
match_type m_Match;
|
||||
input_iterator_type m_Next;
|
||||
input_iterator_type m_End;
|
||||
bool m_bEof;
|
||||
};
|
||||
|
||||
//! split iterator construction helper
|
||||
/*!
|
||||
* Construct a split iterator to iterate through the specified collection
|
||||
*/
|
||||
template<typename RangeT, typename FinderT>
|
||||
inline split_iterator<
|
||||
BOOST_STRING_TYPENAME range_iterator<RangeT>::type>
|
||||
make_split_iterator(
|
||||
RangeT& Collection,
|
||||
FinderT Finder)
|
||||
{
|
||||
return split_iterator<BOOST_STRING_TYPENAME range_iterator<RangeT>::type>(
|
||||
Collection, Finder);
|
||||
}
|
||||
|
||||
|
||||
} // namespace algorithm
|
||||
|
||||
// pull names to the boost namespace
|
||||
using algorithm::find_iterator;
|
||||
using algorithm::make_find_iterator;
|
||||
using algorithm::split_iterator;
|
||||
using algorithm::make_split_iterator;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_FIND_ITERATOR_HPP
|
@ -0,0 +1,270 @@
|
||||
// Boost string_algo library finder.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2006.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_FINDER_HPP
|
||||
#define BOOST_STRING_FINDER_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
|
||||
#include <boost/algorithm/string/constants.hpp>
|
||||
#include <boost/algorithm/string/detail/finder.hpp>
|
||||
#include <boost/algorithm/string/compare.hpp>
|
||||
|
||||
/*! \file
|
||||
Defines Finder generators. Finder object is a functor which is able to
|
||||
find a substring matching a specific criteria in the input.
|
||||
Finders are used as a pluggable components for replace, find
|
||||
and split facilities. This header contains generator functions
|
||||
for finders provided in this library.
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// Finder generators ------------------------------------------//
|
||||
|
||||
//! "First" finder
|
||||
/*!
|
||||
Construct the \c first_finder. The finder searches for the first
|
||||
occurrence of the string in a given input.
|
||||
The result is given as an \c iterator_range delimiting the match.
|
||||
|
||||
\param Search A substring to be searched for.
|
||||
\param Comp An element comparison predicate
|
||||
\return An instance of the \c first_finder object
|
||||
*/
|
||||
template<typename RangeT>
|
||||
inline detail::first_finderF<
|
||||
BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type,
|
||||
is_equal>
|
||||
first_finder( const RangeT& Search )
|
||||
{
|
||||
return
|
||||
detail::first_finderF<
|
||||
BOOST_STRING_TYPENAME
|
||||
range_const_iterator<RangeT>::type,
|
||||
is_equal>( as_literal(Search), is_equal() ) ;
|
||||
}
|
||||
|
||||
//! "First" finder
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename RangeT,typename PredicateT>
|
||||
inline detail::first_finderF<
|
||||
BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type,
|
||||
PredicateT>
|
||||
first_finder(
|
||||
const RangeT& Search, PredicateT Comp )
|
||||
{
|
||||
return
|
||||
detail::first_finderF<
|
||||
BOOST_STRING_TYPENAME
|
||||
range_const_iterator<RangeT>::type,
|
||||
PredicateT>( as_literal(Search), Comp );
|
||||
}
|
||||
|
||||
//! "Last" finder
|
||||
/*!
|
||||
Construct the \c last_finder. The finder searches for the last
|
||||
occurrence of the string in a given input.
|
||||
The result is given as an \c iterator_range delimiting the match.
|
||||
|
||||
\param Search A substring to be searched for.
|
||||
\param Comp An element comparison predicate
|
||||
\return An instance of the \c last_finder object
|
||||
*/
|
||||
template<typename RangeT>
|
||||
inline detail::last_finderF<
|
||||
BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type,
|
||||
is_equal>
|
||||
last_finder( const RangeT& Search )
|
||||
{
|
||||
return
|
||||
detail::last_finderF<
|
||||
BOOST_STRING_TYPENAME
|
||||
range_const_iterator<RangeT>::type,
|
||||
is_equal>( as_literal(Search), is_equal() );
|
||||
}
|
||||
//! "Last" finder
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename RangeT, typename PredicateT>
|
||||
inline detail::last_finderF<
|
||||
BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type,
|
||||
PredicateT>
|
||||
last_finder( const RangeT& Search, PredicateT Comp )
|
||||
{
|
||||
return
|
||||
detail::last_finderF<
|
||||
BOOST_STRING_TYPENAME
|
||||
range_const_iterator<RangeT>::type,
|
||||
PredicateT>( as_literal(Search), Comp ) ;
|
||||
}
|
||||
|
||||
//! "Nth" finder
|
||||
/*!
|
||||
Construct the \c nth_finder. The finder searches for the n-th (zero-indexed)
|
||||
occurrence of the string in a given input.
|
||||
The result is given as an \c iterator_range delimiting the match.
|
||||
|
||||
\param Search A substring to be searched for.
|
||||
\param Nth An index of the match to be find
|
||||
\param Comp An element comparison predicate
|
||||
\return An instance of the \c nth_finder object
|
||||
*/
|
||||
template<typename RangeT>
|
||||
inline detail::nth_finderF<
|
||||
BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type,
|
||||
is_equal>
|
||||
nth_finder(
|
||||
const RangeT& Search,
|
||||
int Nth)
|
||||
{
|
||||
return
|
||||
detail::nth_finderF<
|
||||
BOOST_STRING_TYPENAME
|
||||
range_const_iterator<RangeT>::type,
|
||||
is_equal>( as_literal(Search), Nth, is_equal() ) ;
|
||||
}
|
||||
//! "Nth" finder
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename RangeT, typename PredicateT>
|
||||
inline detail::nth_finderF<
|
||||
BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type,
|
||||
PredicateT>
|
||||
nth_finder(
|
||||
const RangeT& Search,
|
||||
int Nth,
|
||||
PredicateT Comp )
|
||||
{
|
||||
return
|
||||
detail::nth_finderF<
|
||||
BOOST_STRING_TYPENAME
|
||||
range_const_iterator<RangeT>::type,
|
||||
PredicateT>( as_literal(Search), Nth, Comp );
|
||||
}
|
||||
|
||||
//! "Head" finder
|
||||
/*!
|
||||
Construct the \c head_finder. The finder returns a head of a given
|
||||
input. The head is a prefix of a string up to n elements in
|
||||
size. If an input has less then n elements, whole input is
|
||||
considered a head.
|
||||
The result is given as an \c iterator_range delimiting the match.
|
||||
|
||||
\param N The size of the head
|
||||
\return An instance of the \c head_finder object
|
||||
*/
|
||||
inline detail::head_finderF
|
||||
head_finder( int N )
|
||||
{
|
||||
return detail::head_finderF(N);
|
||||
}
|
||||
|
||||
//! "Tail" finder
|
||||
/*!
|
||||
Construct the \c tail_finder. The finder returns a tail of a given
|
||||
input. The tail is a suffix of a string up to n elements in
|
||||
size. If an input has less then n elements, whole input is
|
||||
considered a head.
|
||||
The result is given as an \c iterator_range delimiting the match.
|
||||
|
||||
\param N The size of the head
|
||||
\return An instance of the \c tail_finder object
|
||||
*/
|
||||
inline detail::tail_finderF
|
||||
tail_finder( int N )
|
||||
{
|
||||
return detail::tail_finderF(N);
|
||||
}
|
||||
|
||||
//! "Token" finder
|
||||
/*!
|
||||
Construct the \c token_finder. The finder searches for a token
|
||||
specified by a predicate. It is similar to std::find_if
|
||||
algorithm, with an exception that it return a range of
|
||||
instead of a single iterator.
|
||||
|
||||
If "compress token mode" is enabled, adjacent matching tokens are
|
||||
concatenated into one match. Thus the finder can be used to
|
||||
search for continuous segments of characters satisfying the
|
||||
given predicate.
|
||||
|
||||
The result is given as an \c iterator_range delimiting the match.
|
||||
|
||||
\param Pred An element selection predicate
|
||||
\param eCompress Compress flag
|
||||
\return An instance of the \c token_finder object
|
||||
*/
|
||||
template< typename PredicateT >
|
||||
inline detail::token_finderF<PredicateT>
|
||||
token_finder(
|
||||
PredicateT Pred,
|
||||
token_compress_mode_type eCompress=token_compress_off )
|
||||
{
|
||||
return detail::token_finderF<PredicateT>( Pred, eCompress );
|
||||
}
|
||||
|
||||
//! "Range" finder
|
||||
/*!
|
||||
Construct the \c range_finder. The finder does not perform
|
||||
any operation. It simply returns the given range for
|
||||
any input.
|
||||
|
||||
\param Begin Beginning of the range
|
||||
\param End End of the range
|
||||
\param Range The range.
|
||||
\return An instance of the \c range_finger object
|
||||
*/
|
||||
template< typename ForwardIteratorT >
|
||||
inline detail::range_finderF<ForwardIteratorT>
|
||||
range_finder(
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End )
|
||||
{
|
||||
return detail::range_finderF<ForwardIteratorT>( Begin, End );
|
||||
}
|
||||
|
||||
//! "Range" finder
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template< typename ForwardIteratorT >
|
||||
inline detail::range_finderF<ForwardIteratorT>
|
||||
range_finder( iterator_range<ForwardIteratorT> Range )
|
||||
{
|
||||
return detail::range_finderF<ForwardIteratorT>( Range );
|
||||
}
|
||||
|
||||
} // namespace algorithm
|
||||
|
||||
// pull the names to the boost namespace
|
||||
using algorithm::first_finder;
|
||||
using algorithm::last_finder;
|
||||
using algorithm::nth_finder;
|
||||
using algorithm::head_finder;
|
||||
using algorithm::tail_finder;
|
||||
using algorithm::token_finder;
|
||||
using algorithm::range_finder;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_FINDER_HPP
|
@ -0,0 +1,103 @@
|
||||
// Boost string_algo library formatter.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_FORMATTER_HPP
|
||||
#define BOOST_STRING_FORMATTER_HPP
|
||||
|
||||
#include <boost/detail/iterator.hpp>
|
||||
#include <boost/range/value_type.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/as_literal.hpp>
|
||||
|
||||
#include <boost/algorithm/string/detail/formatter.hpp>
|
||||
|
||||
/*! \file
|
||||
Defines Formatter generators. Formatter is a functor which formats
|
||||
a string according to given parameters. A Formatter works
|
||||
in conjunction with a Finder. A Finder can provide additional information
|
||||
for a specific Formatter. An example of such a cooperation is regex_finder
|
||||
and regex_formatter.
|
||||
|
||||
Formatters are used as pluggable components for replace facilities.
|
||||
This header contains generator functions for the Formatters provided in this library.
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// generic formatters ---------------------------------------------------------------//
|
||||
|
||||
//! Constant formatter
|
||||
/*!
|
||||
Construct the \c const_formatter. Const formatter always returns
|
||||
the same value, regardless of the parameter.
|
||||
|
||||
\param Format A predefined value used as a result for formating
|
||||
\return An instance of the \c const_formatter object.
|
||||
*/
|
||||
template<typename RangeT>
|
||||
inline detail::const_formatF<
|
||||
iterator_range<
|
||||
BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> >
|
||||
const_formatter(const RangeT& Format)
|
||||
{
|
||||
return detail::const_formatF<
|
||||
iterator_range<
|
||||
BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> >(as_literal(Format));
|
||||
}
|
||||
|
||||
//! Identity formatter
|
||||
/*!
|
||||
Construct the \c identity_formatter. Identity formatter always returns
|
||||
the parameter.
|
||||
|
||||
\return An instance of the \c identity_formatter object.
|
||||
*/
|
||||
template<typename RangeT>
|
||||
inline detail::identity_formatF<
|
||||
iterator_range<
|
||||
BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> >
|
||||
identity_formatter()
|
||||
{
|
||||
return detail::identity_formatF<
|
||||
iterator_range<
|
||||
BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> >();
|
||||
}
|
||||
|
||||
//! Empty formatter
|
||||
/*!
|
||||
Construct the \c empty_formatter. Empty formatter always returns an empty
|
||||
sequence.
|
||||
|
||||
\param Input container used to select a correct value_type for the
|
||||
resulting empty_container<>.
|
||||
\return An instance of the \c empty_formatter object.
|
||||
*/
|
||||
template<typename RangeT>
|
||||
inline detail::empty_formatF<
|
||||
BOOST_STRING_TYPENAME range_value<RangeT>::type>
|
||||
empty_formatter(const RangeT&)
|
||||
{
|
||||
return detail::empty_formatF<
|
||||
BOOST_STRING_TYPENAME range_value<RangeT>::type>();
|
||||
}
|
||||
|
||||
|
||||
} // namespace algorithm
|
||||
|
||||
// pull the names to the boost namespace
|
||||
using algorithm::const_formatter;
|
||||
using algorithm::identity_formatter;
|
||||
using algorithm::empty_formatter;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_FORMATTER_HPP
|
@ -0,0 +1,190 @@
|
||||
// Boost string_algo library iter_find.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_ITER_FIND_HPP
|
||||
#define BOOST_STRING_ITER_FIND_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <boost/iterator/transform_iterator.hpp>
|
||||
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/range/value_type.hpp>
|
||||
#include <boost/range/as_literal.hpp>
|
||||
|
||||
#include <boost/algorithm/string/concept.hpp>
|
||||
#include <boost/algorithm/string/find_iterator.hpp>
|
||||
#include <boost/algorithm/string/detail/util.hpp>
|
||||
|
||||
/*! \file
|
||||
Defines generic split algorithms. Split algorithms can be
|
||||
used to divide a sequence into several part according
|
||||
to a given criteria. Result is given as a 'container
|
||||
of containers' where elements are copies or references
|
||||
to extracted parts.
|
||||
|
||||
There are two algorithms provided. One iterates over matching
|
||||
substrings, the other one over the gaps between these matches.
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// iterate find ---------------------------------------------------//
|
||||
|
||||
//! Iter find algorithm
|
||||
/*!
|
||||
This algorithm executes a given finder in iteration on the input,
|
||||
until the end of input is reached, or no match is found.
|
||||
Iteration is done using built-in find_iterator, so the real
|
||||
searching is performed only when needed.
|
||||
In each iteration new match is found and added to the result.
|
||||
|
||||
\param Result A 'container container' to contain the result of search.
|
||||
Both outer and inner container must have constructor taking a pair
|
||||
of iterators as an argument.
|
||||
Typical type of the result is
|
||||
\c std::vector<boost::iterator_range<iterator>>
|
||||
(each element of such a vector will container a range delimiting
|
||||
a match).
|
||||
\param Input A container which will be searched.
|
||||
\param Finder A Finder object used for searching
|
||||
\return A reference the result
|
||||
|
||||
\note Prior content of the result will be overwritten.
|
||||
*/
|
||||
template<
|
||||
typename SequenceSequenceT,
|
||||
typename RangeT,
|
||||
typename FinderT >
|
||||
inline SequenceSequenceT&
|
||||
iter_find(
|
||||
SequenceSequenceT& Result,
|
||||
RangeT& Input,
|
||||
FinderT Finder )
|
||||
{
|
||||
function_requires<
|
||||
FinderConcept<FinderT,
|
||||
BOOST_STRING_TYPENAME range_iterator<RangeT>::type> >();
|
||||
|
||||
iterator_range<BOOST_STRING_TYPENAME range_iterator<RangeT>::type> lit_input(as_literal(Input));
|
||||
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
range_iterator<RangeT>::type input_iterator_type;
|
||||
typedef find_iterator<input_iterator_type> find_iterator_type;
|
||||
typedef detail::copy_iterator_rangeF<
|
||||
BOOST_STRING_TYPENAME
|
||||
range_value<SequenceSequenceT>::type,
|
||||
input_iterator_type> copy_range_type;
|
||||
|
||||
input_iterator_type InputEnd=end(lit_input);
|
||||
|
||||
typedef transform_iterator<copy_range_type, find_iterator_type>
|
||||
transform_iter_type;
|
||||
|
||||
transform_iter_type itBegin=
|
||||
make_transform_iterator(
|
||||
find_iterator_type( begin(lit_input), InputEnd, Finder ),
|
||||
copy_range_type());
|
||||
|
||||
transform_iter_type itEnd=
|
||||
make_transform_iterator(
|
||||
find_iterator_type(),
|
||||
copy_range_type());
|
||||
|
||||
SequenceSequenceT Tmp(itBegin, itEnd);
|
||||
|
||||
Result.swap(Tmp);
|
||||
return Result;
|
||||
}
|
||||
|
||||
// iterate split ---------------------------------------------------//
|
||||
|
||||
//! Split find algorithm
|
||||
/*!
|
||||
This algorithm executes a given finder in iteration on the input,
|
||||
until the end of input is reached, or no match is found.
|
||||
Iteration is done using built-in find_iterator, so the real
|
||||
searching is performed only when needed.
|
||||
Each match is used as a separator of segments. These segments are then
|
||||
returned in the result.
|
||||
|
||||
\param Result A 'container container' to container the result of search.
|
||||
Both outer and inner container must have constructor taking a pair
|
||||
of iterators as an argument.
|
||||
Typical type of the result is
|
||||
\c std::vector<boost::iterator_range<iterator>>
|
||||
(each element of such a vector will container a range delimiting
|
||||
a match).
|
||||
\param Input A container which will be searched.
|
||||
\param Finder A finder object used for searching
|
||||
\return A reference the result
|
||||
|
||||
\note Prior content of the result will be overwritten.
|
||||
*/
|
||||
template<
|
||||
typename SequenceSequenceT,
|
||||
typename RangeT,
|
||||
typename FinderT >
|
||||
inline SequenceSequenceT&
|
||||
iter_split(
|
||||
SequenceSequenceT& Result,
|
||||
RangeT& Input,
|
||||
FinderT Finder )
|
||||
{
|
||||
function_requires<
|
||||
FinderConcept<FinderT,
|
||||
BOOST_STRING_TYPENAME range_iterator<RangeT>::type> >();
|
||||
|
||||
iterator_range<BOOST_STRING_TYPENAME range_iterator<RangeT>::type> lit_input(as_literal(Input));
|
||||
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
range_iterator<RangeT>::type input_iterator_type;
|
||||
typedef split_iterator<input_iterator_type> find_iterator_type;
|
||||
typedef detail::copy_iterator_rangeF<
|
||||
BOOST_STRING_TYPENAME
|
||||
range_value<SequenceSequenceT>::type,
|
||||
input_iterator_type> copy_range_type;
|
||||
|
||||
input_iterator_type InputEnd=end(lit_input);
|
||||
|
||||
typedef transform_iterator<copy_range_type, find_iterator_type>
|
||||
transform_iter_type;
|
||||
|
||||
transform_iter_type itBegin=
|
||||
make_transform_iterator(
|
||||
find_iterator_type( begin(lit_input), InputEnd, Finder ),
|
||||
copy_range_type() );
|
||||
|
||||
transform_iter_type itEnd=
|
||||
make_transform_iterator(
|
||||
find_iterator_type(),
|
||||
copy_range_type() );
|
||||
|
||||
SequenceSequenceT Tmp(itBegin, itEnd);
|
||||
|
||||
Result.swap(Tmp);
|
||||
return Result;
|
||||
}
|
||||
|
||||
} // namespace algorithm
|
||||
|
||||
// pull names to the boost namespace
|
||||
using algorithm::iter_find;
|
||||
using algorithm::iter_split;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_ITER_FIND_HPP
|
@ -0,0 +1,145 @@
|
||||
// Boost string_algo library join.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2006.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_JOIN_HPP
|
||||
#define BOOST_STRING_JOIN_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/algorithm/string/detail/sequence.hpp>
|
||||
#include <boost/range/value_type.hpp>
|
||||
#include <boost/range/as_literal.hpp>
|
||||
|
||||
/*! \file
|
||||
Defines join algorithm.
|
||||
|
||||
Join algorithm is a counterpart to split algorithms.
|
||||
It joins strings from a 'list' by adding user defined separator.
|
||||
Additionally there is a version that allows simple filtering
|
||||
by providing a predicate.
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// join --------------------------------------------------------------//
|
||||
|
||||
//! Join algorithm
|
||||
/*!
|
||||
This algorithm joins all strings in a 'list' into one long string.
|
||||
Segments are concatenated by given separator.
|
||||
|
||||
\param Input A container that holds the input strings. It must be a container-of-containers.
|
||||
\param Separator A string that will separate the joined segments.
|
||||
\return Concatenated string.
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template< typename SequenceSequenceT, typename Range1T>
|
||||
inline typename range_value<SequenceSequenceT>::type
|
||||
join(
|
||||
const SequenceSequenceT& Input,
|
||||
const Range1T& Separator)
|
||||
{
|
||||
// Define working types
|
||||
typedef typename range_value<SequenceSequenceT>::type ResultT;
|
||||
typedef typename range_const_iterator<SequenceSequenceT>::type InputIteratorT;
|
||||
|
||||
// Parse input
|
||||
InputIteratorT itBegin=begin(Input);
|
||||
InputIteratorT itEnd=end(Input);
|
||||
|
||||
// Construct container to hold the result
|
||||
ResultT Result;
|
||||
|
||||
// Append first element
|
||||
if(itBegin!=itEnd)
|
||||
{
|
||||
detail::insert(Result, end(Result), *itBegin);
|
||||
++itBegin;
|
||||
}
|
||||
|
||||
for(;itBegin!=itEnd; ++itBegin)
|
||||
{
|
||||
// Add separator
|
||||
detail::insert(Result, end(Result), as_literal(Separator));
|
||||
// Add element
|
||||
detail::insert(Result, end(Result), *itBegin);
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
// join_if ----------------------------------------------------------//
|
||||
|
||||
//! Conditional join algorithm
|
||||
/*!
|
||||
This algorithm joins all strings in a 'list' into one long string.
|
||||
Segments are concatenated by given separator. Only segments that
|
||||
satisfy the predicate will be added to the result.
|
||||
|
||||
\param Input A container that holds the input strings. It must be a container-of-containers.
|
||||
\param Separator A string that will separate the joined segments.
|
||||
\param Pred A segment selection predicate
|
||||
\return Concatenated string.
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template< typename SequenceSequenceT, typename Range1T, typename PredicateT>
|
||||
inline typename range_value<SequenceSequenceT>::type
|
||||
join_if(
|
||||
const SequenceSequenceT& Input,
|
||||
const Range1T& Separator,
|
||||
PredicateT Pred)
|
||||
{
|
||||
// Define working types
|
||||
typedef typename range_value<SequenceSequenceT>::type ResultT;
|
||||
typedef typename range_const_iterator<SequenceSequenceT>::type InputIteratorT;
|
||||
|
||||
// Parse input
|
||||
InputIteratorT itBegin=begin(Input);
|
||||
InputIteratorT itEnd=end(Input);
|
||||
|
||||
// Construct container to hold the result
|
||||
ResultT Result;
|
||||
|
||||
// Roll to the first element that will be added
|
||||
while(itBegin!=itEnd && !Pred(*itBegin)) ++itBegin;
|
||||
// Add this element
|
||||
if(itBegin!=itEnd)
|
||||
{
|
||||
detail::insert(Result, end(Result), *itBegin);
|
||||
++itBegin;
|
||||
}
|
||||
|
||||
for(;itBegin!=itEnd; ++itBegin)
|
||||
{
|
||||
if(Pred(*itBegin))
|
||||
{
|
||||
// Add separator
|
||||
detail::insert(Result, end(Result), as_literal(Separator));
|
||||
// Add element
|
||||
detail::insert(Result, end(Result), *itBegin);
|
||||
}
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
} // namespace algorithm
|
||||
|
||||
// pull names to the boost namespace
|
||||
using algorithm::join;
|
||||
using algorithm::join_if;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_JOIN_HPP
|
||||
|
@ -0,0 +1,475 @@
|
||||
// Boost string_algo library predicate.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_PREDICATE_HPP
|
||||
#define BOOST_STRING_PREDICATE_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
#include <boost/range/as_literal.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
|
||||
#include <boost/algorithm/string/compare.hpp>
|
||||
#include <boost/algorithm/string/find.hpp>
|
||||
#include <boost/algorithm/string/detail/predicate.hpp>
|
||||
|
||||
/*! \file boost/algorithm/string/predicate.hpp
|
||||
Defines string-related predicates.
|
||||
The predicates determine whether a substring is contained in the input string
|
||||
under various conditions: a string starts with the substring, ends with the
|
||||
substring, simply contains the substring or if both strings are equal.
|
||||
Additionaly the algorithm \c all() checks all elements of a container to satisfy a
|
||||
condition.
|
||||
|
||||
All predicates provide the strong exception guarantee.
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// starts_with predicate -----------------------------------------------//
|
||||
|
||||
//! 'Starts with' predicate
|
||||
/*!
|
||||
This predicate holds when the test string is a prefix of the Input.
|
||||
In other words, if the input starts with the test.
|
||||
When the optional predicate is specified, it is used for character-wise
|
||||
comparison.
|
||||
|
||||
\param Input An input sequence
|
||||
\param Test A test sequence
|
||||
\param Comp An element comparison predicate
|
||||
\return The result of the test
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Range1T, typename Range2T, typename PredicateT>
|
||||
inline bool starts_with(
|
||||
const Range1T& Input,
|
||||
const Range2T& Test,
|
||||
PredicateT Comp)
|
||||
{
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range1T>::type> lit_input(as_literal(Input));
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range2T>::type> lit_test(as_literal(Test));
|
||||
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
range_const_iterator<Range1T>::type Iterator1T;
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
range_const_iterator<Range2T>::type Iterator2T;
|
||||
|
||||
Iterator1T InputEnd=end(lit_input);
|
||||
Iterator2T TestEnd=end(lit_test);
|
||||
|
||||
Iterator1T it=begin(lit_input);
|
||||
Iterator2T pit=begin(lit_test);
|
||||
for(;
|
||||
it!=InputEnd && pit!=TestEnd;
|
||||
++it,++pit)
|
||||
{
|
||||
if( !(Comp(*it,*pit)) )
|
||||
return false;
|
||||
}
|
||||
|
||||
return pit==TestEnd;
|
||||
}
|
||||
|
||||
//! 'Starts with' predicate
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline bool starts_with(
|
||||
const Range1T& Input,
|
||||
const Range2T& Test)
|
||||
{
|
||||
return starts_with(Input, Test, is_equal());
|
||||
}
|
||||
|
||||
//! 'Starts with' predicate ( case insensitive )
|
||||
/*!
|
||||
This predicate holds when the test string is a prefix of the Input.
|
||||
In other words, if the input starts with the test.
|
||||
Elements are compared case insensitively.
|
||||
|
||||
\param Input An input sequence
|
||||
\param Test A test sequence
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return The result of the test
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline bool istarts_with(
|
||||
const Range1T& Input,
|
||||
const Range2T& Test,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return starts_with(Input, Test, is_iequal(Loc));
|
||||
}
|
||||
|
||||
|
||||
// ends_with predicate -----------------------------------------------//
|
||||
|
||||
//! 'Ends with' predicate
|
||||
/*!
|
||||
This predicate holds when the test string is a suffix of the Input.
|
||||
In other words, if the input ends with the test.
|
||||
When the optional predicate is specified, it is used for character-wise
|
||||
comparison.
|
||||
|
||||
|
||||
\param Input An input sequence
|
||||
\param Test A test sequence
|
||||
\param Comp An element comparison predicate
|
||||
\return The result of the test
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Range1T, typename Range2T, typename PredicateT>
|
||||
inline bool ends_with(
|
||||
const Range1T& Input,
|
||||
const Range2T& Test,
|
||||
PredicateT Comp)
|
||||
{
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range1T>::type> lit_input(as_literal(Input));
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range2T>::type> lit_test(as_literal(Test));
|
||||
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
range_const_iterator<Range1T>::type Iterator1T;
|
||||
typedef BOOST_STRING_TYPENAME boost::detail::
|
||||
iterator_traits<Iterator1T>::iterator_category category;
|
||||
|
||||
return detail::
|
||||
ends_with_iter_select(
|
||||
begin(lit_input),
|
||||
end(lit_input),
|
||||
begin(lit_test),
|
||||
end(lit_test),
|
||||
Comp,
|
||||
category());
|
||||
}
|
||||
|
||||
|
||||
//! 'Ends with' predicate
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline bool ends_with(
|
||||
const Range1T& Input,
|
||||
const Range2T& Test)
|
||||
{
|
||||
return ends_with(Input, Test, is_equal());
|
||||
}
|
||||
|
||||
//! 'Ends with' predicate ( case insensitive )
|
||||
/*!
|
||||
This predicate holds when the test container is a suffix of the Input.
|
||||
In other words, if the input ends with the test.
|
||||
Elements are compared case insensitively.
|
||||
|
||||
\param Input An input sequence
|
||||
\param Test A test sequence
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return The result of the test
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline bool iends_with(
|
||||
const Range1T& Input,
|
||||
const Range2T& Test,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return ends_with(Input, Test, is_iequal(Loc));
|
||||
}
|
||||
|
||||
// contains predicate -----------------------------------------------//
|
||||
|
||||
//! 'Contains' predicate
|
||||
/*!
|
||||
This predicate holds when the test container is contained in the Input.
|
||||
When the optional predicate is specified, it is used for character-wise
|
||||
comparison.
|
||||
|
||||
\param Input An input sequence
|
||||
\param Test A test sequence
|
||||
\param Comp An element comparison predicate
|
||||
\return The result of the test
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Range1T, typename Range2T, typename PredicateT>
|
||||
inline bool contains(
|
||||
const Range1T& Input,
|
||||
const Range2T& Test,
|
||||
PredicateT Comp)
|
||||
{
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range1T>::type> lit_input(as_literal(Input));
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range2T>::type> lit_test(as_literal(Test));
|
||||
|
||||
if (empty(lit_test))
|
||||
{
|
||||
// Empty range is contained always
|
||||
return true;
|
||||
}
|
||||
|
||||
// Use the temporary variable to make VACPP happy
|
||||
bool bResult=(first_finder(lit_test,Comp)(begin(lit_input), end(lit_input)));
|
||||
return bResult;
|
||||
}
|
||||
|
||||
//! 'Contains' predicate
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline bool contains(
|
||||
const Range1T& Input,
|
||||
const Range2T& Test)
|
||||
{
|
||||
return contains(Input, Test, is_equal());
|
||||
}
|
||||
|
||||
//! 'Contains' predicate ( case insensitive )
|
||||
/*!
|
||||
This predicate holds when the test container is contained in the Input.
|
||||
Elements are compared case insensitively.
|
||||
|
||||
\param Input An input sequence
|
||||
\param Test A test sequence
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return The result of the test
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline bool icontains(
|
||||
const Range1T& Input,
|
||||
const Range2T& Test,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return contains(Input, Test, is_iequal(Loc));
|
||||
}
|
||||
|
||||
// equals predicate -----------------------------------------------//
|
||||
|
||||
//! 'Equals' predicate
|
||||
/*!
|
||||
This predicate holds when the test container is equal to the
|
||||
input container i.e. all elements in both containers are same.
|
||||
When the optional predicate is specified, it is used for character-wise
|
||||
comparison.
|
||||
|
||||
\param Input An input sequence
|
||||
\param Test A test sequence
|
||||
\param Comp An element comparison predicate
|
||||
\return The result of the test
|
||||
|
||||
\note This is a two-way version of \c std::equal algorithm
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Range1T, typename Range2T, typename PredicateT>
|
||||
inline bool equals(
|
||||
const Range1T& Input,
|
||||
const Range2T& Test,
|
||||
PredicateT Comp)
|
||||
{
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range1T>::type> lit_input(as_literal(Input));
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range2T>::type> lit_test(as_literal(Test));
|
||||
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
range_const_iterator<Range1T>::type Iterator1T;
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
range_const_iterator<Range2T>::type Iterator2T;
|
||||
|
||||
Iterator1T InputEnd=end(lit_input);
|
||||
Iterator2T TestEnd=end(lit_test);
|
||||
|
||||
Iterator1T it=begin(lit_input);
|
||||
Iterator2T pit=begin(lit_test);
|
||||
for(;
|
||||
it!=InputEnd && pit!=TestEnd;
|
||||
++it,++pit)
|
||||
{
|
||||
if( !(Comp(*it,*pit)) )
|
||||
return false;
|
||||
}
|
||||
|
||||
return (pit==TestEnd) && (it==InputEnd);
|
||||
}
|
||||
|
||||
//! 'Equals' predicate
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline bool equals(
|
||||
const Range1T& Input,
|
||||
const Range2T& Test)
|
||||
{
|
||||
return equals(Input, Test, is_equal());
|
||||
}
|
||||
|
||||
//! 'Equals' predicate ( case insensitive )
|
||||
/*!
|
||||
This predicate holds when the test container is equal to the
|
||||
input container i.e. all elements in both containers are same.
|
||||
Elements are compared case insensitively.
|
||||
|
||||
\param Input An input sequence
|
||||
\param Test A test sequence
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return The result of the test
|
||||
|
||||
\note This is a two-way version of \c std::equal algorithm
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline bool iequals(
|
||||
const Range1T& Input,
|
||||
const Range2T& Test,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return equals(Input, Test, is_iequal(Loc));
|
||||
}
|
||||
|
||||
// lexicographical_compare predicate -----------------------------//
|
||||
|
||||
//! Lexicographical compare predicate
|
||||
/*!
|
||||
This predicate is an overload of std::lexicographical_compare
|
||||
for range arguments
|
||||
|
||||
It check whether the first argument is lexicographically less
|
||||
then the second one.
|
||||
|
||||
If the optional predicate is specified, it is used for character-wise
|
||||
comparison
|
||||
|
||||
\param Arg1 First argument
|
||||
\param Arg2 Second argument
|
||||
\param Pred Comparison predicate
|
||||
\return The result of the test
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Range1T, typename Range2T, typename PredicateT>
|
||||
inline bool lexicographical_compare(
|
||||
const Range1T& Arg1,
|
||||
const Range2T& Arg2,
|
||||
PredicateT Pred)
|
||||
{
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range1T>::type> lit_arg1(as_literal(Arg1));
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range2T>::type> lit_arg2(as_literal(Arg2));
|
||||
|
||||
return std::lexicographical_compare(
|
||||
begin(lit_arg1),
|
||||
end(lit_arg1),
|
||||
begin(lit_arg2),
|
||||
end(lit_arg2),
|
||||
Pred);
|
||||
}
|
||||
|
||||
//! Lexicographical compare predicate
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline bool lexicographical_compare(
|
||||
const Range1T& Arg1,
|
||||
const Range2T& Arg2)
|
||||
{
|
||||
return lexicographical_compare(Arg1, Arg2, is_less());
|
||||
}
|
||||
|
||||
//! Lexicographical compare predicate (case-insensitive)
|
||||
/*!
|
||||
This predicate is an overload of std::lexicographical_compare
|
||||
for range arguments.
|
||||
It check whether the first argument is lexicographically less
|
||||
then the second one.
|
||||
Elements are compared case insensitively
|
||||
|
||||
|
||||
\param Arg1 First argument
|
||||
\param Arg2 Second argument
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return The result of the test
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline bool ilexicographical_compare(
|
||||
const Range1T& Arg1,
|
||||
const Range2T& Arg2,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return lexicographical_compare(Arg1, Arg2, is_iless(Loc));
|
||||
}
|
||||
|
||||
|
||||
// all predicate -----------------------------------------------//
|
||||
|
||||
//! 'All' predicate
|
||||
/*!
|
||||
This predicate holds it all its elements satisfy a given
|
||||
condition, represented by the predicate.
|
||||
|
||||
\param Input An input sequence
|
||||
\param Pred A predicate
|
||||
\return The result of the test
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename RangeT, typename PredicateT>
|
||||
inline bool all(
|
||||
const RangeT& Input,
|
||||
PredicateT Pred)
|
||||
{
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> lit_input(as_literal(Input));
|
||||
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
range_const_iterator<RangeT>::type Iterator1T;
|
||||
|
||||
Iterator1T InputEnd=end(lit_input);
|
||||
for( Iterator1T It=begin(lit_input); It!=InputEnd; ++It)
|
||||
{
|
||||
if (!Pred(*It))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace algorithm
|
||||
|
||||
// pull names to the boost namespace
|
||||
using algorithm::starts_with;
|
||||
using algorithm::istarts_with;
|
||||
using algorithm::ends_with;
|
||||
using algorithm::iends_with;
|
||||
using algorithm::contains;
|
||||
using algorithm::icontains;
|
||||
using algorithm::equals;
|
||||
using algorithm::iequals;
|
||||
using algorithm::all;
|
||||
using algorithm::lexicographical_compare;
|
||||
using algorithm::ilexicographical_compare;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_PREDICATE_HPP
|
@ -0,0 +1,42 @@
|
||||
// Boost string_algo library predicate_facade.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_PREDICATE_FACADE_HPP
|
||||
#define BOOST_STRING_PREDICATE_FACADE_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
|
||||
/*
|
||||
\file boost/algorith/string/predicate_facade.hpp
|
||||
This file containes predicate_facade definition. This template class is used
|
||||
to identify classification predicates, so they can be combined using
|
||||
composition operators.
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// predicate facade ------------------------------------------------------//
|
||||
|
||||
//! Predicate facade
|
||||
/*!
|
||||
This class allows to recognize classification
|
||||
predicates, so that they can be combined using
|
||||
composition operators.
|
||||
Every classification predicate must be derived from this class.
|
||||
*/
|
||||
template<typename Derived>
|
||||
struct predicate_facade {};
|
||||
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_CLASSIFICATION_DETAIL_HPP
|
@ -0,0 +1,646 @@
|
||||
// Boost string_algo library regex.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_REGEX_HPP
|
||||
#define BOOST_STRING_REGEX_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/range/as_literal.hpp>
|
||||
|
||||
#include <boost/algorithm/string/find_format.hpp>
|
||||
#include <boost/algorithm/string/regex_find_format.hpp>
|
||||
#include <boost/algorithm/string/formatter.hpp>
|
||||
#include <boost/algorithm/string/iter_find.hpp>
|
||||
|
||||
/*! \file
|
||||
Defines regex variants of the algorithms.
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// find_regex -----------------------------------------------//
|
||||
|
||||
//! Find regex algorithm
|
||||
/*!
|
||||
Search for a substring matching the given regex in the input.
|
||||
|
||||
\param Input A container which will be searched.
|
||||
\param Rx A regular expression
|
||||
\param Flags Regex options
|
||||
\return
|
||||
An \c iterator_range delimiting the match.
|
||||
Returned iterator is either \c RangeT::iterator or
|
||||
\c RangeT::const_iterator, depending on the constness of
|
||||
the input parameter.
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename RangeT,
|
||||
typename CharT,
|
||||
typename RegexTraitsT>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME range_iterator<RangeT>::type >
|
||||
find_regex(
|
||||
RangeT& Input,
|
||||
const basic_regex<CharT, RegexTraitsT>& Rx,
|
||||
match_flag_type Flags=match_default )
|
||||
{
|
||||
iterator_range<BOOST_STRING_TYPENAME range_iterator<RangeT>::type> lit_input(as_literal(Input));
|
||||
|
||||
return regex_finder(Rx,Flags)(
|
||||
begin(lit_input), end(lit_input) );
|
||||
}
|
||||
|
||||
// replace_regex --------------------------------------------------------------------//
|
||||
|
||||
//! Replace regex algorithm
|
||||
/*!
|
||||
Search for a substring matching given regex and format it with
|
||||
the specified format.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param Rx A regular expression
|
||||
\param Format Regex format definition
|
||||
\param Flags Regex options
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename RangeT,
|
||||
typename CharT,
|
||||
typename RegexTraitsT,
|
||||
typename FormatStringTraitsT, typename FormatStringAllocatorT >
|
||||
inline OutputIteratorT replace_regex_copy(
|
||||
OutputIteratorT Output,
|
||||
const RangeT& Input,
|
||||
const basic_regex<CharT, RegexTraitsT>& Rx,
|
||||
const std::basic_string<CharT, FormatStringTraitsT, FormatStringAllocatorT>& Format,
|
||||
match_flag_type Flags=match_default | format_default )
|
||||
{
|
||||
return find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
regex_finder( Rx, Flags ),
|
||||
regex_formatter( Format, Flags ) );
|
||||
}
|
||||
|
||||
//! Replace regex algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<
|
||||
typename SequenceT,
|
||||
typename CharT,
|
||||
typename RegexTraitsT,
|
||||
typename FormatStringTraitsT, typename FormatStringAllocatorT >
|
||||
inline SequenceT replace_regex_copy(
|
||||
const SequenceT& Input,
|
||||
const basic_regex<CharT, RegexTraitsT>& Rx,
|
||||
const std::basic_string<CharT, FormatStringTraitsT, FormatStringAllocatorT>& Format,
|
||||
match_flag_type Flags=match_default | format_default )
|
||||
{
|
||||
return find_format_copy(
|
||||
Input,
|
||||
regex_finder( Rx, Flags ),
|
||||
regex_formatter( Format, Flags ) );
|
||||
}
|
||||
|
||||
//! Replace regex algorithm
|
||||
/*!
|
||||
Search for a substring matching given regex and format it with
|
||||
the specified format. The input string is modified in-place.
|
||||
|
||||
\param Input An input string
|
||||
\param Rx A regular expression
|
||||
\param Format Regex format definition
|
||||
\param Flags Regex options
|
||||
*/
|
||||
template<
|
||||
typename SequenceT,
|
||||
typename CharT,
|
||||
typename RegexTraitsT,
|
||||
typename FormatStringTraitsT, typename FormatStringAllocatorT >
|
||||
inline void replace_regex(
|
||||
SequenceT& Input,
|
||||
const basic_regex<CharT, RegexTraitsT>& Rx,
|
||||
const std::basic_string<CharT, FormatStringTraitsT, FormatStringAllocatorT>& Format,
|
||||
match_flag_type Flags=match_default | format_default )
|
||||
{
|
||||
find_format(
|
||||
Input,
|
||||
regex_finder( Rx, Flags ),
|
||||
regex_formatter( Format, Flags ) );
|
||||
}
|
||||
|
||||
// replace_all_regex --------------------------------------------------------------------//
|
||||
|
||||
//! Replace all regex algorithm
|
||||
/*!
|
||||
Format all substrings, matching given regex, with the specified format.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param Rx A regular expression
|
||||
\param Format Regex format definition
|
||||
\param Flags Regex options
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename RangeT,
|
||||
typename CharT,
|
||||
typename RegexTraitsT,
|
||||
typename FormatStringTraitsT, typename FormatStringAllocatorT >
|
||||
inline OutputIteratorT replace_all_regex_copy(
|
||||
OutputIteratorT Output,
|
||||
const RangeT& Input,
|
||||
const basic_regex<CharT, RegexTraitsT>& Rx,
|
||||
const std::basic_string<CharT, FormatStringTraitsT, FormatStringAllocatorT>& Format,
|
||||
match_flag_type Flags=match_default | format_default )
|
||||
{
|
||||
return find_format_all_copy(
|
||||
Output,
|
||||
Input,
|
||||
regex_finder( Rx, Flags ),
|
||||
regex_formatter( Format, Flags ) );
|
||||
}
|
||||
|
||||
//! Replace all regex algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<
|
||||
typename SequenceT,
|
||||
typename CharT,
|
||||
typename RegexTraitsT,
|
||||
typename FormatStringTraitsT, typename FormatStringAllocatorT >
|
||||
inline SequenceT replace_all_regex_copy(
|
||||
const SequenceT& Input,
|
||||
const basic_regex<CharT, RegexTraitsT>& Rx,
|
||||
const std::basic_string<CharT, FormatStringTraitsT, FormatStringAllocatorT>& Format,
|
||||
match_flag_type Flags=match_default | format_default )
|
||||
{
|
||||
return find_format_all_copy(
|
||||
Input,
|
||||
regex_finder( Rx, Flags ),
|
||||
regex_formatter( Format, Flags ) );
|
||||
}
|
||||
|
||||
//! Replace all regex algorithm
|
||||
/*!
|
||||
Format all substrings, matching given regex, with the specified format.
|
||||
The input string is modified in-place.
|
||||
|
||||
\param Input An input string
|
||||
\param Rx A regular expression
|
||||
\param Format Regex format definition
|
||||
\param Flags Regex options
|
||||
*/
|
||||
template<
|
||||
typename SequenceT,
|
||||
typename CharT,
|
||||
typename RegexTraitsT,
|
||||
typename FormatStringTraitsT, typename FormatStringAllocatorT >
|
||||
inline void replace_all_regex(
|
||||
SequenceT& Input,
|
||||
const basic_regex<CharT, RegexTraitsT>& Rx,
|
||||
const std::basic_string<CharT, FormatStringTraitsT, FormatStringAllocatorT>& Format,
|
||||
match_flag_type Flags=match_default | format_default )
|
||||
{
|
||||
find_format_all(
|
||||
Input,
|
||||
regex_finder( Rx, Flags ),
|
||||
regex_formatter( Format, Flags ) );
|
||||
}
|
||||
|
||||
// erase_regex --------------------------------------------------------------------//
|
||||
|
||||
//! Erase regex algorithm
|
||||
/*!
|
||||
Remove a substring matching given regex from the input.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param Rx A regular expression
|
||||
\param Flags Regex options
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename RangeT,
|
||||
typename CharT,
|
||||
typename RegexTraitsT >
|
||||
inline OutputIteratorT erase_regex_copy(
|
||||
OutputIteratorT Output,
|
||||
const RangeT& Input,
|
||||
const basic_regex<CharT, RegexTraitsT>& Rx,
|
||||
match_flag_type Flags=match_default )
|
||||
{
|
||||
return find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
regex_finder( Rx, Flags ),
|
||||
empty_formatter( Input ) );
|
||||
}
|
||||
|
||||
//! Erase regex algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<
|
||||
typename SequenceT,
|
||||
typename CharT,
|
||||
typename RegexTraitsT >
|
||||
inline SequenceT erase_regex_copy(
|
||||
const SequenceT& Input,
|
||||
const basic_regex<CharT, RegexTraitsT>& Rx,
|
||||
match_flag_type Flags=match_default )
|
||||
{
|
||||
return find_format_copy(
|
||||
Input,
|
||||
regex_finder( Rx, Flags ),
|
||||
empty_formatter( Input ) );
|
||||
}
|
||||
|
||||
//! Erase regex algorithm
|
||||
/*!
|
||||
Remove a substring matching given regex from the input.
|
||||
The input string is modified in-place.
|
||||
|
||||
\param Input An input string
|
||||
\param Rx A regular expression
|
||||
\param Flags Regex options
|
||||
*/
|
||||
template<
|
||||
typename SequenceT,
|
||||
typename CharT,
|
||||
typename RegexTraitsT >
|
||||
inline void erase_regex(
|
||||
SequenceT& Input,
|
||||
const basic_regex<CharT, RegexTraitsT>& Rx,
|
||||
match_flag_type Flags=match_default )
|
||||
{
|
||||
find_format(
|
||||
Input,
|
||||
regex_finder( Rx, Flags ),
|
||||
empty_formatter( Input ) );
|
||||
}
|
||||
|
||||
// erase_all_regex --------------------------------------------------------------------//
|
||||
|
||||
//! Erase all regex algorithm
|
||||
/*!
|
||||
Erase all substrings, matching given regex, from the input.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param Rx A regular expression
|
||||
\param Flags Regex options
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename RangeT,
|
||||
typename CharT,
|
||||
typename RegexTraitsT >
|
||||
inline OutputIteratorT erase_all_regex_copy(
|
||||
OutputIteratorT Output,
|
||||
const RangeT& Input,
|
||||
const basic_regex<CharT, RegexTraitsT>& Rx,
|
||||
match_flag_type Flags=match_default )
|
||||
{
|
||||
return find_format_all_copy(
|
||||
Output,
|
||||
Input,
|
||||
regex_finder( Rx, Flags ),
|
||||
empty_formatter( Input ) );
|
||||
}
|
||||
|
||||
//! Erase all regex algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<
|
||||
typename SequenceT,
|
||||
typename CharT,
|
||||
typename RegexTraitsT >
|
||||
inline SequenceT erase_all_regex_copy(
|
||||
const SequenceT& Input,
|
||||
const basic_regex<CharT, RegexTraitsT>& Rx,
|
||||
match_flag_type Flags=match_default )
|
||||
{
|
||||
return find_format_all_copy(
|
||||
Input,
|
||||
regex_finder( Rx, Flags ),
|
||||
empty_formatter( Input ) );
|
||||
}
|
||||
|
||||
//! Erase all regex algorithm
|
||||
/*!
|
||||
Erase all substrings, matching given regex, from the input.
|
||||
The input string is modified in-place.
|
||||
|
||||
\param Input An input string
|
||||
\param Rx A regular expression
|
||||
\param Flags Regex options
|
||||
*/
|
||||
template<
|
||||
typename SequenceT,
|
||||
typename CharT,
|
||||
typename RegexTraitsT>
|
||||
inline void erase_all_regex(
|
||||
SequenceT& Input,
|
||||
const basic_regex<CharT, RegexTraitsT>& Rx,
|
||||
match_flag_type Flags=match_default )
|
||||
{
|
||||
find_format_all(
|
||||
Input,
|
||||
regex_finder( Rx, Flags ),
|
||||
empty_formatter( Input ) );
|
||||
}
|
||||
|
||||
// find_all_regex ------------------------------------------------------------------//
|
||||
|
||||
//! Find all regex algorithm
|
||||
/*!
|
||||
This algorithm finds all substrings matching the give regex
|
||||
in the input.
|
||||
|
||||
Each part is copied and added as a new element to the output container.
|
||||
Thus the result container must be able to hold copies
|
||||
of the matches (in a compatible structure like std::string) or
|
||||
a reference to it (e.g. using the iterator range class).
|
||||
Examples of such a container are \c std::vector<std::string>
|
||||
or \c std::list<boost::iterator_range<std::string::iterator>>
|
||||
|
||||
\param Result A container that can hold copies of references to the substrings.
|
||||
\param Input A container which will be searched.
|
||||
\param Rx A regular expression
|
||||
\param Flags Regex options
|
||||
\return A reference to the result
|
||||
|
||||
\note Prior content of the result will be overwritten.
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename SequenceSequenceT,
|
||||
typename RangeT,
|
||||
typename CharT,
|
||||
typename RegexTraitsT >
|
||||
inline SequenceSequenceT& find_all_regex(
|
||||
SequenceSequenceT& Result,
|
||||
const RangeT& Input,
|
||||
const basic_regex<CharT, RegexTraitsT>& Rx,
|
||||
match_flag_type Flags=match_default )
|
||||
{
|
||||
return iter_find(
|
||||
Result,
|
||||
Input,
|
||||
regex_finder(Rx,Flags) );
|
||||
}
|
||||
|
||||
// split_regex ------------------------------------------------------------------//
|
||||
|
||||
//! Split regex algorithm
|
||||
/*!
|
||||
Tokenize expression. This function is equivalent to C strtok. Input
|
||||
sequence is split into tokens, separated by separators. Separator
|
||||
is an every match of the given regex.
|
||||
Each part is copied and added as a new element to the output container.
|
||||
Thus the result container must be able to hold copies
|
||||
of the matches (in a compatible structure like std::string) or
|
||||
a reference to it (e.g. using the iterator range class).
|
||||
Examples of such a container are \c std::vector<std::string>
|
||||
or \c std::list<boost::iterator_range<std::string::iterator>>
|
||||
|
||||
\param Result A container that can hold copies of references to the substrings.
|
||||
\param Input A container which will be searched.
|
||||
\param Rx A regular expression
|
||||
\param Flags Regex options
|
||||
\return A reference to the result
|
||||
|
||||
\note Prior content of the result will be overwritten.
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename SequenceSequenceT,
|
||||
typename RangeT,
|
||||
typename CharT,
|
||||
typename RegexTraitsT >
|
||||
inline SequenceSequenceT& split_regex(
|
||||
SequenceSequenceT& Result,
|
||||
const RangeT& Input,
|
||||
const basic_regex<CharT, RegexTraitsT>& Rx,
|
||||
match_flag_type Flags=match_default )
|
||||
{
|
||||
return iter_split(
|
||||
Result,
|
||||
Input,
|
||||
regex_finder(Rx,Flags) );
|
||||
}
|
||||
|
||||
// join_if ------------------------------------------------------------------//
|
||||
|
||||
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
//! Conditional join algorithm
|
||||
/*!
|
||||
This algorithm joins all strings in a 'list' into one long string.
|
||||
Segments are concatenated by given separator. Only segments that
|
||||
match the given regular expression will be added to the result
|
||||
|
||||
This is a specialization of join_if algorithm.
|
||||
|
||||
\param Input A container that holds the input strings. It must be a container-of-containers.
|
||||
\param Separator A string that will separate the joined segments.
|
||||
\param Rx A regular expression
|
||||
\param Flags Regex options
|
||||
\return Concatenated string.
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename SequenceSequenceT,
|
||||
typename Range1T,
|
||||
typename CharT,
|
||||
typename RegexTraitsT >
|
||||
inline typename range_value<SequenceSequenceT>::type
|
||||
join_if(
|
||||
const SequenceSequenceT& Input,
|
||||
const Range1T& Separator,
|
||||
const basic_regex<CharT, RegexTraitsT>& Rx,
|
||||
match_flag_type Flags=match_default )
|
||||
{
|
||||
// Define working types
|
||||
typedef typename range_value<SequenceSequenceT>::type ResultT;
|
||||
typedef typename range_const_iterator<SequenceSequenceT>::type InputIteratorT;
|
||||
|
||||
// Parse input
|
||||
InputIteratorT itBegin=begin(Input);
|
||||
InputIteratorT itEnd=end(Input);
|
||||
|
||||
// Construct container to hold the result
|
||||
ResultT Result;
|
||||
|
||||
|
||||
// Roll to the first element that will be added
|
||||
while(
|
||||
itBegin!=itEnd &&
|
||||
!regex_match(begin(*itBegin), end(*itBegin), Rx, Flags)) ++itBegin;
|
||||
|
||||
// Add this element
|
||||
if(itBegin!=itEnd)
|
||||
{
|
||||
detail::insert(Result, end(Result), *itBegin);
|
||||
++itBegin;
|
||||
}
|
||||
|
||||
for(;itBegin!=itEnd; ++itBegin)
|
||||
{
|
||||
if(regex_match(begin(*itBegin), end(*itBegin), Rx, Flags))
|
||||
{
|
||||
// Add separator
|
||||
detail::insert(Result, end(Result), as_literal(Separator));
|
||||
// Add element
|
||||
detail::insert(Result, end(Result), *itBegin);
|
||||
}
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
#else // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
//! Conditional join algorithm
|
||||
/*!
|
||||
This algorithm joins all strings in a 'list' into one long string.
|
||||
Segments are concatenated by given separator. Only segments that
|
||||
match the given regular expression will be added to the result
|
||||
|
||||
This is a specialization of join_if algorithm.
|
||||
|
||||
\param Input A container that holds the input strings. It must be a container-of-containers.
|
||||
\param Separator A string that will separate the joined segments.
|
||||
\param Rx A regular expression
|
||||
\param Flags Regex options
|
||||
\return Concatenated string.
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename SequenceSequenceT,
|
||||
typename Range1T,
|
||||
typename CharT,
|
||||
typename RegexTraitsT >
|
||||
inline typename range_value<SequenceSequenceT>::type
|
||||
join_if_regex(
|
||||
const SequenceSequenceT& Input,
|
||||
const Range1T& Separator,
|
||||
const basic_regex<CharT, RegexTraitsT>& Rx,
|
||||
match_flag_type Flags=match_default )
|
||||
{
|
||||
// Define working types
|
||||
typedef typename range_value<SequenceSequenceT>::type ResultT;
|
||||
typedef typename range_const_iterator<SequenceSequenceT>::type InputIteratorT;
|
||||
|
||||
// Parse input
|
||||
InputIteratorT itBegin=begin(Input);
|
||||
InputIteratorT itEnd=end(Input);
|
||||
|
||||
// Construct container to hold the result
|
||||
ResultT Result;
|
||||
|
||||
|
||||
// Roll to the first element that will be added
|
||||
while(
|
||||
itBegin!=itEnd &&
|
||||
!regex_match(begin(*itBegin), end(*itBegin), Rx, Flags)) ++itBegin;
|
||||
|
||||
// Add this element
|
||||
if(itBegin!=itEnd)
|
||||
{
|
||||
detail::insert(Result, end(Result), *itBegin);
|
||||
++itBegin;
|
||||
}
|
||||
|
||||
for(;itBegin!=itEnd; ++itBegin)
|
||||
{
|
||||
if(regex_match(begin(*itBegin), end(*itBegin), Rx, Flags))
|
||||
{
|
||||
// Add separator
|
||||
detail::insert(Result, end(Result), as_literal(Separator));
|
||||
// Add element
|
||||
detail::insert(Result, end(Result), *itBegin);
|
||||
}
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
|
||||
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
} // namespace algorithm
|
||||
|
||||
// pull names into the boost namespace
|
||||
using algorithm::find_regex;
|
||||
using algorithm::replace_regex;
|
||||
using algorithm::replace_regex_copy;
|
||||
using algorithm::replace_all_regex;
|
||||
using algorithm::replace_all_regex_copy;
|
||||
using algorithm::erase_regex;
|
||||
using algorithm::erase_regex_copy;
|
||||
using algorithm::erase_all_regex;
|
||||
using algorithm::erase_all_regex_copy;
|
||||
using algorithm::find_all_regex;
|
||||
using algorithm::split_regex;
|
||||
|
||||
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
using algorithm::join_if;
|
||||
#else // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
using algorithm::join_if_regex;
|
||||
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_REGEX_HPP
|
@ -0,0 +1,90 @@
|
||||
// Boost string_algo library regex_find_format.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_REGEX_FIND_FORMAT_HPP
|
||||
#define BOOST_STRING_REGEX_FIND_FORMAT_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
#include <boost/algorithm/string/detail/finder_regex.hpp>
|
||||
#include <boost/algorithm/string/detail/formatter_regex.hpp>
|
||||
|
||||
/*! \file
|
||||
Defines the \c regex_finder and \c regex_formatter generators. These two functors
|
||||
are designed to work together. \c regex_formatter uses additional information
|
||||
about a match contained in the regex_finder search result.
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// regex_finder -----------------------------------------------//
|
||||
|
||||
//! "Regex" finder
|
||||
/*!
|
||||
Construct the \c regex_finder. Finder uses the regex engine to search
|
||||
for a match.
|
||||
Result is given in \c regex_search_result. This is an extension
|
||||
of the iterator_range. In addition it containes match results
|
||||
from the \c regex_search algorithm.
|
||||
|
||||
\param Rx A regular expression
|
||||
\param MatchFlags Regex search options
|
||||
\return An instance of the \c regex_finder object
|
||||
*/
|
||||
template<
|
||||
typename CharT,
|
||||
typename RegexTraitsT>
|
||||
inline detail::find_regexF< basic_regex<CharT, RegexTraitsT> >
|
||||
regex_finder(
|
||||
const basic_regex<CharT, RegexTraitsT>& Rx,
|
||||
match_flag_type MatchFlags=match_default )
|
||||
{
|
||||
return detail::
|
||||
find_regexF<
|
||||
basic_regex<CharT, RegexTraitsT> >( Rx, MatchFlags );
|
||||
}
|
||||
|
||||
// regex_formater ---------------------------------------------//
|
||||
|
||||
//! Regex formatter
|
||||
/*!
|
||||
Construct the \c regex_formatter. Regex formatter uses the regex engine to
|
||||
format a match found by the \c regex_finder.
|
||||
This formatted it designed to closely cooperate with \c regex_finder.
|
||||
|
||||
\param Format Regex format definition
|
||||
\param Flags Format flags
|
||||
\return An instance of the \c regex_formatter functor
|
||||
*/
|
||||
template<
|
||||
typename CharT,
|
||||
typename TraitsT, typename AllocT >
|
||||
inline detail::regex_formatF< std::basic_string< CharT, TraitsT, AllocT > >
|
||||
regex_formatter(
|
||||
const std::basic_string<CharT, TraitsT, AllocT>& Format,
|
||||
match_flag_type Flags=format_default )
|
||||
{
|
||||
return
|
||||
detail::regex_formatF< std::basic_string<CharT, TraitsT, AllocT> >(
|
||||
Format,
|
||||
Flags );
|
||||
}
|
||||
|
||||
} // namespace algorithm
|
||||
|
||||
// pull the names to the boost namespace
|
||||
using algorithm::regex_finder;
|
||||
using algorithm::regex_formatter;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_REGEX_FIND_FORMAT_HPP
|
@ -0,0 +1,928 @@
|
||||
// Boost string_algo library replace.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2006.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_REPLACE_HPP
|
||||
#define BOOST_STRING_REPLACE_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
|
||||
#include <boost/algorithm/string/find_format.hpp>
|
||||
#include <boost/algorithm/string/finder.hpp>
|
||||
#include <boost/algorithm/string/formatter.hpp>
|
||||
#include <boost/algorithm/string/compare.hpp>
|
||||
|
||||
/*! \file
|
||||
Defines various replace algorithms. Each algorithm replaces
|
||||
part(s) of the input according to set of searching and replace criteria.
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// replace_range --------------------------------------------------------------------//
|
||||
|
||||
//! Replace range algorithm
|
||||
/*!
|
||||
Replace the given range in the input string.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param SearchRange A range in the input to be substituted
|
||||
\param Format A substitute string
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T>
|
||||
inline OutputIteratorT replace_range_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
const iterator_range<
|
||||
BOOST_STRING_TYPENAME
|
||||
range_const_iterator<Range1T>::type>& SearchRange,
|
||||
const Range2T& Format)
|
||||
{
|
||||
return find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
range_finder(SearchRange),
|
||||
const_formatter(Format));
|
||||
}
|
||||
|
||||
//! Replace range algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline SequenceT replace_range_copy(
|
||||
const SequenceT& Input,
|
||||
const iterator_range<
|
||||
BOOST_STRING_TYPENAME
|
||||
range_const_iterator<SequenceT>::type>& SearchRange,
|
||||
const RangeT& Format)
|
||||
{
|
||||
return find_format_copy(
|
||||
Input,
|
||||
range_finder(SearchRange),
|
||||
const_formatter(Format));
|
||||
}
|
||||
|
||||
//! Replace range algorithm
|
||||
/*!
|
||||
Replace the given range in the input string.
|
||||
The input sequence is modified in-place.
|
||||
|
||||
\param Input An input string
|
||||
\param SearchRange A range in the input to be substituted
|
||||
\param Format A substitute string
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline void replace_range(
|
||||
SequenceT& Input,
|
||||
const iterator_range<
|
||||
BOOST_STRING_TYPENAME
|
||||
range_iterator<SequenceT>::type>& SearchRange,
|
||||
const RangeT& Format)
|
||||
{
|
||||
find_format(
|
||||
Input,
|
||||
range_finder(SearchRange),
|
||||
const_formatter(Format));
|
||||
}
|
||||
|
||||
// replace_first --------------------------------------------------------------------//
|
||||
|
||||
//! Replace first algorithm
|
||||
/*!
|
||||
Replace the first match of the search substring in the input
|
||||
with the format string.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Format A substitute string
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T,
|
||||
typename Range3T>
|
||||
inline OutputIteratorT replace_first_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
const Range3T& Format)
|
||||
{
|
||||
return find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
first_finder(Search),
|
||||
const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace first algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline SequenceT replace_first_copy(
|
||||
const SequenceT& Input,
|
||||
const Range1T& Search,
|
||||
const Range2T& Format )
|
||||
{
|
||||
return find_format_copy(
|
||||
Input,
|
||||
first_finder(Search),
|
||||
const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace first algorithm
|
||||
/*!
|
||||
replace the first match of the search substring in the input
|
||||
with the format string. The input sequence is modified in-place.
|
||||
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Format A substitute string
|
||||
*/
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline void replace_first(
|
||||
SequenceT& Input,
|
||||
const Range1T& Search,
|
||||
const Range2T& Format )
|
||||
{
|
||||
find_format(
|
||||
Input,
|
||||
first_finder(Search),
|
||||
const_formatter(Format) );
|
||||
}
|
||||
|
||||
// replace_first ( case insensitive ) ---------------------------------------------//
|
||||
|
||||
//! Replace first algorithm ( case insensitive )
|
||||
/*!
|
||||
Replace the first match of the search substring in the input
|
||||
with the format string.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
Searching is case insensitive.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Format A substitute string
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T,
|
||||
typename Range3T>
|
||||
inline OutputIteratorT ireplace_first_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
const Range3T& Format,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
first_finder(Search, is_iequal(Loc)),
|
||||
const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace first algorithm ( case insensitive )
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename Range2T, typename Range1T>
|
||||
inline SequenceT ireplace_first_copy(
|
||||
const SequenceT& Input,
|
||||
const Range2T& Search,
|
||||
const Range1T& Format,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return find_format_copy(
|
||||
Input,
|
||||
first_finder(Search, is_iequal(Loc)),
|
||||
const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace first algorithm ( case insensitive )
|
||||
/*!
|
||||
Replace the first match of the search substring in the input
|
||||
with the format string. Input sequence is modified in-place.
|
||||
Searching is case insensitive.
|
||||
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Format A substitute string
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
*/
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline void ireplace_first(
|
||||
SequenceT& Input,
|
||||
const Range1T& Search,
|
||||
const Range2T& Format,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
find_format(
|
||||
Input,
|
||||
first_finder(Search, is_iequal(Loc)),
|
||||
const_formatter(Format) );
|
||||
}
|
||||
|
||||
// replace_last --------------------------------------------------------------------//
|
||||
|
||||
//! Replace last algorithm
|
||||
/*!
|
||||
Replace the last match of the search string in the input
|
||||
with the format string.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Format A substitute string
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T,
|
||||
typename Range3T>
|
||||
inline OutputIteratorT replace_last_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
const Range3T& Format )
|
||||
{
|
||||
return find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
last_finder(Search),
|
||||
const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace last algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline SequenceT replace_last_copy(
|
||||
const SequenceT& Input,
|
||||
const Range1T& Search,
|
||||
const Range2T& Format )
|
||||
{
|
||||
return find_format_copy(
|
||||
Input,
|
||||
last_finder(Search),
|
||||
const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace last algorithm
|
||||
/*!
|
||||
Replace the last match of the search string in the input
|
||||
with the format string. Input sequence is modified in-place.
|
||||
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Format A substitute string
|
||||
*/
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline void replace_last(
|
||||
SequenceT& Input,
|
||||
const Range1T& Search,
|
||||
const Range2T& Format )
|
||||
{
|
||||
find_format(
|
||||
Input,
|
||||
last_finder(Search),
|
||||
const_formatter(Format) );
|
||||
}
|
||||
|
||||
// replace_last ( case insensitive ) -----------------------------------------------//
|
||||
|
||||
//! Replace last algorithm ( case insensitive )
|
||||
/*!
|
||||
Replace the last match of the search string in the input
|
||||
with the format string.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
Searching is case insensitive.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Format A substitute string
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T,
|
||||
typename Range3T>
|
||||
inline OutputIteratorT ireplace_last_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
const Range3T& Format,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
last_finder(Search, is_iequal(Loc)),
|
||||
const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace last algorithm ( case insensitive )
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline SequenceT ireplace_last_copy(
|
||||
const SequenceT& Input,
|
||||
const Range1T& Search,
|
||||
const Range2T& Format,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return find_format_copy(
|
||||
Input,
|
||||
last_finder(Search, is_iequal(Loc)),
|
||||
const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace last algorithm ( case insensitive )
|
||||
/*!
|
||||
Replace the last match of the search string in the input
|
||||
with the format string.The input sequence is modified in-place.
|
||||
Searching is case insensitive.
|
||||
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Format A substitute string
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return A reference to the modified input
|
||||
*/
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline void ireplace_last(
|
||||
SequenceT& Input,
|
||||
const Range1T& Search,
|
||||
const Range2T& Format,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
find_format(
|
||||
Input,
|
||||
last_finder(Search, is_iequal(Loc)),
|
||||
const_formatter(Format) );
|
||||
}
|
||||
|
||||
// replace_nth --------------------------------------------------------------------//
|
||||
|
||||
//! Replace nth algorithm
|
||||
/*!
|
||||
Replace an Nth (zero-indexed) match of the search string in the input
|
||||
with the format string.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Nth An index of the match to be replaced. The index is 0-based.
|
||||
For negative N, matches are counted from the end of string.
|
||||
\param Format A substitute string
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T,
|
||||
typename Range3T>
|
||||
inline OutputIteratorT replace_nth_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
int Nth,
|
||||
const Range3T& Format )
|
||||
{
|
||||
return find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
nth_finder(Search, Nth),
|
||||
const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace nth algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline SequenceT replace_nth_copy(
|
||||
const SequenceT& Input,
|
||||
const Range1T& Search,
|
||||
int Nth,
|
||||
const Range2T& Format )
|
||||
{
|
||||
return find_format_copy(
|
||||
Input,
|
||||
nth_finder(Search, Nth),
|
||||
const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace nth algorithm
|
||||
/*!
|
||||
Replace an Nth (zero-indexed) match of the search string in the input
|
||||
with the format string. Input sequence is modified in-place.
|
||||
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Nth An index of the match to be replaced. The index is 0-based.
|
||||
For negative N, matches are counted from the end of string.
|
||||
\param Format A substitute string
|
||||
*/
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline void replace_nth(
|
||||
SequenceT& Input,
|
||||
const Range1T& Search,
|
||||
int Nth,
|
||||
const Range2T& Format )
|
||||
{
|
||||
find_format(
|
||||
Input,
|
||||
nth_finder(Search, Nth),
|
||||
const_formatter(Format) );
|
||||
}
|
||||
|
||||
// replace_nth ( case insensitive ) -----------------------------------------------//
|
||||
|
||||
//! Replace nth algorithm ( case insensitive )
|
||||
/*!
|
||||
Replace an Nth (zero-indexed) match of the search string in the input
|
||||
with the format string.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
Searching is case insensitive.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Nth An index of the match to be replaced. The index is 0-based.
|
||||
For negative N, matches are counted from the end of string.
|
||||
\param Format A substitute string
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T,
|
||||
typename Range3T>
|
||||
inline OutputIteratorT ireplace_nth_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
int Nth,
|
||||
const Range3T& Format,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
nth_finder(Search, Nth, is_iequal(Loc) ),
|
||||
const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace nth algorithm ( case insensitive )
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline SequenceT ireplace_nth_copy(
|
||||
const SequenceT& Input,
|
||||
const Range1T& Search,
|
||||
int Nth,
|
||||
const Range2T& Format,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return find_format_copy(
|
||||
Input,
|
||||
nth_finder(Search, Nth, is_iequal(Loc)),
|
||||
const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace nth algorithm ( case insensitive )
|
||||
/*!
|
||||
Replace an Nth (zero-indexed) match of the search string in the input
|
||||
with the format string. Input sequence is modified in-place.
|
||||
Searching is case insensitive.
|
||||
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Nth An index of the match to be replaced. The index is 0-based.
|
||||
For negative N, matches are counted from the end of string.
|
||||
\param Format A substitute string
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
*/
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline void ireplace_nth(
|
||||
SequenceT& Input,
|
||||
const Range1T& Search,
|
||||
int Nth,
|
||||
const Range2T& Format,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
find_format(
|
||||
Input,
|
||||
nth_finder(Search, Nth, is_iequal(Loc)),
|
||||
const_formatter(Format) );
|
||||
}
|
||||
|
||||
// replace_all --------------------------------------------------------------------//
|
||||
|
||||
//! Replace all algorithm
|
||||
/*!
|
||||
Replace all occurrences of the search string in the input
|
||||
with the format string.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Format A substitute string
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T,
|
||||
typename Range3T>
|
||||
inline OutputIteratorT replace_all_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
const Range3T& Format )
|
||||
{
|
||||
return find_format_all_copy(
|
||||
Output,
|
||||
Input,
|
||||
first_finder(Search),
|
||||
const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace all algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline SequenceT replace_all_copy(
|
||||
const SequenceT& Input,
|
||||
const Range1T& Search,
|
||||
const Range2T& Format )
|
||||
{
|
||||
return find_format_all_copy(
|
||||
Input,
|
||||
first_finder(Search),
|
||||
const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace all algorithm
|
||||
/*!
|
||||
Replace all occurrences of the search string in the input
|
||||
with the format string. The input sequence is modified in-place.
|
||||
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Format A substitute string
|
||||
\return A reference to the modified input
|
||||
*/
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline void replace_all(
|
||||
SequenceT& Input,
|
||||
const Range1T& Search,
|
||||
const Range2T& Format )
|
||||
{
|
||||
find_format_all(
|
||||
Input,
|
||||
first_finder(Search),
|
||||
const_formatter(Format) );
|
||||
}
|
||||
|
||||
// replace_all ( case insensitive ) -----------------------------------------------//
|
||||
|
||||
//! Replace all algorithm ( case insensitive )
|
||||
/*!
|
||||
Replace all occurrences of the search string in the input
|
||||
with the format string.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
Searching is case insensitive.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Format A substitute string
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T,
|
||||
typename Range3T>
|
||||
inline OutputIteratorT ireplace_all_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
const Range3T& Format,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return find_format_all_copy(
|
||||
Output,
|
||||
Input,
|
||||
first_finder(Search, is_iequal(Loc)),
|
||||
const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace all algorithm ( case insensitive )
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline SequenceT ireplace_all_copy(
|
||||
const SequenceT& Input,
|
||||
const Range1T& Search,
|
||||
const Range2T& Format,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return find_format_all_copy(
|
||||
Input,
|
||||
first_finder(Search, is_iequal(Loc)),
|
||||
const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace all algorithm ( case insensitive )
|
||||
/*!
|
||||
Replace all occurrences of the search string in the input
|
||||
with the format string.The input sequence is modified in-place.
|
||||
Searching is case insensitive.
|
||||
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Format A substitute string
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
*/
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline void ireplace_all(
|
||||
SequenceT& Input,
|
||||
const Range1T& Search,
|
||||
const Range2T& Format,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
find_format_all(
|
||||
Input,
|
||||
first_finder(Search, is_iequal(Loc)),
|
||||
const_formatter(Format) );
|
||||
}
|
||||
|
||||
// replace_head --------------------------------------------------------------------//
|
||||
|
||||
//! Replace head algorithm
|
||||
/*!
|
||||
Replace the head of the input with the given format string.
|
||||
The head is a prefix of a string of given size.
|
||||
If the sequence is shorter then required, whole string if
|
||||
considered to be the head.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param N Length of the head.
|
||||
For N>=0, at most N characters are extracted.
|
||||
For N<0, size(Input)-|N| characters are extracted.
|
||||
\param Format A substitute string
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T>
|
||||
inline OutputIteratorT replace_head_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
int N,
|
||||
const Range2T& Format )
|
||||
{
|
||||
return find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
head_finder(N),
|
||||
const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace head algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline SequenceT replace_head_copy(
|
||||
const SequenceT& Input,
|
||||
int N,
|
||||
const RangeT& Format )
|
||||
{
|
||||
return find_format_copy(
|
||||
Input,
|
||||
head_finder(N),
|
||||
const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace head algorithm
|
||||
/*!
|
||||
Replace the head of the input with the given format string.
|
||||
The head is a prefix of a string of given size.
|
||||
If the sequence is shorter then required, the whole string is
|
||||
considered to be the head. The input sequence is modified in-place.
|
||||
|
||||
\param Input An input string
|
||||
\param N Length of the head.
|
||||
For N>=0, at most N characters are extracted.
|
||||
For N<0, size(Input)-|N| characters are extracted.
|
||||
\param Format A substitute string
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline void replace_head(
|
||||
SequenceT& Input,
|
||||
int N,
|
||||
const RangeT& Format )
|
||||
{
|
||||
find_format(
|
||||
Input,
|
||||
head_finder(N),
|
||||
const_formatter(Format) );
|
||||
}
|
||||
|
||||
// replace_tail --------------------------------------------------------------------//
|
||||
|
||||
//! Replace tail algorithm
|
||||
/*!
|
||||
Replace the tail of the input with the given format string.
|
||||
The tail is a suffix of a string of given size.
|
||||
If the sequence is shorter then required, whole string is
|
||||
considered to be the tail.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param N Length of the tail.
|
||||
For N>=0, at most N characters are extracted.
|
||||
For N<0, size(Input)-|N| characters are extracted.
|
||||
\param Format A substitute string
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T>
|
||||
inline OutputIteratorT replace_tail_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
int N,
|
||||
const Range2T& Format )
|
||||
{
|
||||
return find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
tail_finder(N),
|
||||
const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace tail algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline SequenceT replace_tail_copy(
|
||||
const SequenceT& Input,
|
||||
int N,
|
||||
const RangeT& Format )
|
||||
{
|
||||
return find_format_copy(
|
||||
Input,
|
||||
tail_finder(N),
|
||||
const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace tail algorithm
|
||||
/*!
|
||||
Replace the tail of the input with the given format sequence.
|
||||
The tail is a suffix of a string of given size.
|
||||
If the sequence is shorter then required, the whole string is
|
||||
considered to be the tail. The input sequence is modified in-place.
|
||||
|
||||
\param Input An input string
|
||||
\param N Length of the tail.
|
||||
For N>=0, at most N characters are extracted.
|
||||
For N<0, size(Input)-|N| characters are extracted.
|
||||
\param Format A substitute string
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline void replace_tail(
|
||||
SequenceT& Input,
|
||||
int N,
|
||||
const RangeT& Format )
|
||||
{
|
||||
find_format(
|
||||
Input,
|
||||
tail_finder(N),
|
||||
const_formatter(Format) );
|
||||
}
|
||||
|
||||
} // namespace algorithm
|
||||
|
||||
// pull names to the boost namespace
|
||||
using algorithm::replace_range_copy;
|
||||
using algorithm::replace_range;
|
||||
using algorithm::replace_first_copy;
|
||||
using algorithm::replace_first;
|
||||
using algorithm::ireplace_first_copy;
|
||||
using algorithm::ireplace_first;
|
||||
using algorithm::replace_last_copy;
|
||||
using algorithm::replace_last;
|
||||
using algorithm::ireplace_last_copy;
|
||||
using algorithm::ireplace_last;
|
||||
using algorithm::replace_nth_copy;
|
||||
using algorithm::replace_nth;
|
||||
using algorithm::ireplace_nth_copy;
|
||||
using algorithm::ireplace_nth;
|
||||
using algorithm::replace_all_copy;
|
||||
using algorithm::replace_all;
|
||||
using algorithm::ireplace_all_copy;
|
||||
using algorithm::ireplace_all;
|
||||
using algorithm::replace_head_copy;
|
||||
using algorithm::replace_head;
|
||||
using algorithm::replace_tail_copy;
|
||||
using algorithm::replace_tail;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_REPLACE_HPP
|
@ -0,0 +1,193 @@
|
||||
// Boost string_algo library sequence_traits.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_SEQUENCE_TRAITS_HPP
|
||||
#define BOOST_STRING_SEQUENCE_TRAITS_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/algorithm/string/yes_no_type.hpp>
|
||||
|
||||
/*! \file
|
||||
Traits defined in this header are used by various algorithms to achieve
|
||||
better performance for specific containers.
|
||||
Traits provide fail-safe defaults. If a container supports some of these
|
||||
features, it is possible to specialize the specific trait for this container.
|
||||
For lacking compilers, it is possible of define an override for a specific tester
|
||||
function.
|
||||
|
||||
Due to a language restriction, it is not currently possible to define specializations for
|
||||
stl containers without including the corresponding header. To decrease the overhead
|
||||
needed by this inclusion, user can selectively include a specialization
|
||||
header for a specific container. They are located in boost/algorithm/string/stl
|
||||
directory. Alternatively she can include boost/algorithm/string/std_collection_traits.hpp
|
||||
header which contains specializations for all stl containers.
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// sequence traits -----------------------------------------------//
|
||||
|
||||
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
//! Native replace tester
|
||||
/*!
|
||||
Declare an override of this tester function with return
|
||||
type boost::string_algo::yes_type for a sequence with this property.
|
||||
|
||||
\return yes_type if the container has basic_string like native replace
|
||||
method.
|
||||
*/
|
||||
no_type has_native_replace_tester(...);
|
||||
|
||||
//! Stable iterators tester
|
||||
/*!
|
||||
Declare an override of this tester function with return
|
||||
type boost::string_algo::yes_type for a sequence with this property.
|
||||
|
||||
\return yes_type if the sequence's insert/replace/erase methods do not invalidate
|
||||
existing iterators.
|
||||
*/
|
||||
no_type has_stable_iterators_tester(...);
|
||||
|
||||
//! const time insert tester
|
||||
/*!
|
||||
Declare an override of this tester function with return
|
||||
type boost::string_algo::yes_type for a sequence with this property.
|
||||
|
||||
\return yes_type if the sequence's insert method is working in constant time
|
||||
*/
|
||||
no_type has_const_time_insert_tester(...);
|
||||
|
||||
//! const time erase tester
|
||||
/*!
|
||||
Declare an override of this tester function with return
|
||||
type boost::string_algo::yes_type for a sequence with this property.
|
||||
|
||||
\return yes_type if the sequence's erase method is working in constant time
|
||||
*/
|
||||
no_type has_const_time_erase_tester(...);
|
||||
|
||||
#endif //BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
//! Native replace trait
|
||||
/*!
|
||||
This trait specifies that the sequence has \c std::string like replace method
|
||||
*/
|
||||
template< typename T >
|
||||
class has_native_replace
|
||||
{
|
||||
|
||||
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
private:
|
||||
static T* t;
|
||||
public:
|
||||
BOOST_STATIC_CONSTANT(bool, value=(
|
||||
sizeof(has_native_replace_tester(t))==sizeof(yes_type) ) );
|
||||
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
public:
|
||||
# if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
enum { value = false };
|
||||
# else
|
||||
BOOST_STATIC_CONSTANT(bool, value=false);
|
||||
# endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
|
||||
typedef mpl::bool_<has_native_replace<T>::value> type;
|
||||
};
|
||||
|
||||
|
||||
//! Stable iterators trait
|
||||
/*!
|
||||
This trait specifies that the sequence has stable iterators. It means
|
||||
that operations like insert/erase/replace do not invalidate iterators.
|
||||
*/
|
||||
template< typename T >
|
||||
class has_stable_iterators
|
||||
{
|
||||
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
private:
|
||||
static T* t;
|
||||
public:
|
||||
BOOST_STATIC_CONSTANT(bool, value=(
|
||||
sizeof(has_stable_iterators_tester(t))==sizeof(yes_type) ) );
|
||||
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
public:
|
||||
# if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
enum { value = false };
|
||||
# else
|
||||
BOOST_STATIC_CONSTANT(bool, value=false);
|
||||
# endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
typedef mpl::bool_<has_stable_iterators<T>::value> type;
|
||||
};
|
||||
|
||||
|
||||
//! Const time insert trait
|
||||
/*!
|
||||
This trait specifies that the sequence's insert method has
|
||||
constant time complexity.
|
||||
*/
|
||||
template< typename T >
|
||||
class has_const_time_insert
|
||||
{
|
||||
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
private:
|
||||
static T* t;
|
||||
public:
|
||||
BOOST_STATIC_CONSTANT(bool, value=(
|
||||
sizeof(has_const_time_insert_tester(t))==sizeof(yes_type) ) );
|
||||
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
public:
|
||||
# if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
enum { value = false };
|
||||
# else
|
||||
BOOST_STATIC_CONSTANT(bool, value=false);
|
||||
# endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
typedef mpl::bool_<has_const_time_insert<T>::value> type;
|
||||
};
|
||||
|
||||
|
||||
//! Const time erase trait
|
||||
/*!
|
||||
This trait specifies that the sequence's erase method has
|
||||
constant time complexity.
|
||||
*/
|
||||
template< typename T >
|
||||
class has_const_time_erase
|
||||
{
|
||||
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
private:
|
||||
static T* t;
|
||||
public:
|
||||
BOOST_STATIC_CONSTANT(bool, value=(
|
||||
sizeof(has_const_time_erase_tester(t))==sizeof(yes_type) ) );
|
||||
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
public:
|
||||
# if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
enum { value = false };
|
||||
# else
|
||||
BOOST_STATIC_CONSTANT(bool, value=false);
|
||||
# endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
typedef mpl::bool_<has_const_time_erase<T>::value> type;
|
||||
};
|
||||
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_SEQUENCE_TRAITS_HPP
|
@ -0,0 +1,163 @@
|
||||
// Boost string_algo library split.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2006.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_SPLIT_HPP
|
||||
#define BOOST_STRING_SPLIT_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
|
||||
#include <boost/algorithm/string/iter_find.hpp>
|
||||
#include <boost/algorithm/string/finder.hpp>
|
||||
#include <boost/algorithm/string/compare.hpp>
|
||||
|
||||
/*! \file
|
||||
Defines basic split algorithms.
|
||||
Split algorithms can be used to divide a string
|
||||
into several parts according to given criteria.
|
||||
|
||||
Each part is copied and added as a new element to the
|
||||
output container.
|
||||
Thus the result container must be able to hold copies
|
||||
of the matches (in a compatible structure like std::string) or
|
||||
a reference to it (e.g. using the iterator range class).
|
||||
Examples of such a container are \c std::vector<std::string>
|
||||
or \c std::list<boost::iterator_range<std::string::iterator>>
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// find_all ------------------------------------------------------------//
|
||||
|
||||
//! Find all algorithm
|
||||
/*!
|
||||
This algorithm finds all occurrences of the search string
|
||||
in the input.
|
||||
|
||||
Each part is copied and added as a new element to the
|
||||
output container.
|
||||
Thus the result container must be able to hold copies
|
||||
of the matches (in a compatible structure like std::string) or
|
||||
a reference to it (e.g. using the iterator range class).
|
||||
Examples of such a container are \c std::vector<std::string>
|
||||
or \c std::list<boost::iterator_range<std::string::iterator>>
|
||||
|
||||
\param Result A container that can hold copies of references to the substrings
|
||||
\param Input A container which will be searched.
|
||||
\param Search A substring to be searched for.
|
||||
\return A reference the result
|
||||
|
||||
\note Prior content of the result will be overwritten.
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template< typename SequenceSequenceT, typename Range1T, typename Range2T >
|
||||
inline SequenceSequenceT& find_all(
|
||||
SequenceSequenceT& Result,
|
||||
Range1T& Input,
|
||||
const Range2T& Search)
|
||||
{
|
||||
return iter_find(
|
||||
Result,
|
||||
Input,
|
||||
first_finder(Search) );
|
||||
}
|
||||
|
||||
//! Find all algorithm ( case insensitive )
|
||||
/*!
|
||||
This algorithm finds all occurrences of the search string
|
||||
in the input.
|
||||
Each part is copied and added as a new element to the
|
||||
output container. Thus the result container must be able to hold copies
|
||||
of the matches (in a compatible structure like std::string) or
|
||||
a reference to it (e.g. using the iterator range class).
|
||||
Examples of such a container are \c std::vector<std::string>
|
||||
or \c std::list<boost::iterator_range<std::string::iterator>>
|
||||
|
||||
Searching is case insensitive.
|
||||
|
||||
\param Result A container that can hold copies of references to the substrings
|
||||
\param Input A container which will be searched.
|
||||
\param Search A substring to be searched for.
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return A reference the result
|
||||
|
||||
\note Prior content of the result will be overwritten.
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template< typename SequenceSequenceT, typename Range1T, typename Range2T >
|
||||
inline SequenceSequenceT& ifind_all(
|
||||
SequenceSequenceT& Result,
|
||||
Range1T& Input,
|
||||
const Range2T& Search,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return iter_find(
|
||||
Result,
|
||||
Input,
|
||||
first_finder(Search, is_iequal(Loc) ) );
|
||||
}
|
||||
|
||||
|
||||
// tokenize -------------------------------------------------------------//
|
||||
|
||||
//! Split algorithm
|
||||
/*!
|
||||
Tokenize expression. This function is equivalent to C strtok. Input
|
||||
sequence is split into tokens, separated by separators. Separators
|
||||
are given by means of the predicate.
|
||||
|
||||
Each part is copied and added as a new element to the
|
||||
output container.
|
||||
Thus the result container must be able to hold copies
|
||||
of the matches (in a compatible structure like std::string) or
|
||||
a reference to it (e.g. using the iterator range class).
|
||||
Examples of such a container are \c std::vector<std::string>
|
||||
or \c std::list<boost::iterator_range<std::string::iterator>>
|
||||
|
||||
\param Result A container that can hold copies of references to the substrings
|
||||
\param Input A container which will be searched.
|
||||
\param Pred A predicate to identify separators. This predicate is
|
||||
supposed to return true if a given element is a separator.
|
||||
\param eCompress If eCompress argument is set to token_compress_on, adjacent
|
||||
separators are merged together. Otherwise, every two separators
|
||||
delimit a token.
|
||||
\return A reference the result
|
||||
|
||||
\note Prior content of the result will be overwritten.
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template< typename SequenceSequenceT, typename RangeT, typename PredicateT >
|
||||
inline SequenceSequenceT& split(
|
||||
SequenceSequenceT& Result,
|
||||
RangeT& Input,
|
||||
PredicateT Pred,
|
||||
token_compress_mode_type eCompress=token_compress_off )
|
||||
{
|
||||
return iter_split(
|
||||
Result,
|
||||
Input,
|
||||
token_finder( Pred, eCompress ) );
|
||||
}
|
||||
|
||||
} // namespace algorithm
|
||||
|
||||
// pull names to the boost namespace
|
||||
using algorithm::find_all;
|
||||
using algorithm::ifind_all;
|
||||
using algorithm::split;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_SPLIT_HPP
|
||||
|
@ -0,0 +1,85 @@
|
||||
// Boost string_algo library list_traits.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_STD_LIST_TRAITS_HPP
|
||||
#define BOOST_STRING_STD_LIST_TRAITS_HPP
|
||||
|
||||
#include <boost/algorithm/string/yes_no_type.hpp>
|
||||
#include <list>
|
||||
#include <boost/algorithm/string/sequence_traits.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// std::list<> traits -----------------------------------------------//
|
||||
|
||||
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
// stable iterators tester
|
||||
template<typename T, typename AllocT>
|
||||
yes_type has_stable_iterators_tester( const ::std::list<T,AllocT>* );
|
||||
|
||||
// const time insert tester
|
||||
template<typename T, typename AllocT>
|
||||
yes_type has_const_time_insert_tester( const ::std::list<T,AllocT>* );
|
||||
|
||||
// const time erase tester
|
||||
template<typename T, typename AllocT>
|
||||
yes_type has_const_time_erase_tester( const ::std::list<T,AllocT>* );
|
||||
|
||||
|
||||
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
// stable iterators trait
|
||||
template<typename T, typename AllocT>
|
||||
class has_stable_iterators< ::std::list<T,AllocT> >
|
||||
{
|
||||
public:
|
||||
#if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
enum { value = true };
|
||||
#else
|
||||
BOOST_STATIC_CONSTANT(bool, value=true);
|
||||
#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
typedef mpl::bool_<has_stable_iterators<T>::value> type;
|
||||
};
|
||||
|
||||
// const time insert trait
|
||||
template<typename T, typename AllocT>
|
||||
class has_const_time_insert< ::std::list<T,AllocT> >
|
||||
{
|
||||
public:
|
||||
#if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
enum { value = true };
|
||||
#else
|
||||
BOOST_STATIC_CONSTANT(bool, value=true);
|
||||
#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
typedef mpl::bool_<has_const_time_insert<T>::value> type;
|
||||
};
|
||||
|
||||
// const time erase trait
|
||||
template<typename T, typename AllocT>
|
||||
class has_const_time_erase< ::std::list<T,AllocT> >
|
||||
{
|
||||
public:
|
||||
#if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
enum { value = true };
|
||||
#else
|
||||
BOOST_STATIC_CONSTANT(bool, value=true);
|
||||
#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
typedef mpl::bool_<has_const_time_erase<T>::value> type;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_STD_LIST_TRAITS_HPP
|
@ -0,0 +1,101 @@
|
||||
// Boost string_algo library string_traits.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_STD_ROPE_TRAITS_HPP
|
||||
#define BOOST_STRING_STD_ROPE_TRAITS_HPP
|
||||
|
||||
#include <boost/algorithm/string/yes_no_type.hpp>
|
||||
#include <rope>
|
||||
#include <boost/algorithm/string/sequence_traits.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// SGI's std::rope<> traits -----------------------------------------------//
|
||||
|
||||
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
// native replace tester
|
||||
template<typename T, typename TraitsT, typename AllocT>
|
||||
yes_type has_native_replace_tester( const std::rope<T, TraitsT, AllocT>* );
|
||||
|
||||
// stable iterators tester
|
||||
template<typename T, typename TraitsT, typename AllocT>
|
||||
yes_type has_stable_iterators_tester( const std::rope<T, TraitsT, AllocT>* );
|
||||
|
||||
// const time insert tester
|
||||
template<typename T, typename TraitsT, typename AllocT>
|
||||
yes_type has_const_time_insert_tester( const std::rope<T, TraitsT, AllocT>* );
|
||||
|
||||
// const time erase tester
|
||||
template<typename T, typename TraitsT, typename AllocT>
|
||||
yes_type has_const_time_erase_tester( const std::rope<T, TraitsT, AllocT>* );
|
||||
|
||||
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
// native replace trait
|
||||
template<typename T, typename TraitsT, typename AllocT>
|
||||
class has_native_replace< std::rope<T,TraitsT,AllocT> >
|
||||
{
|
||||
public:
|
||||
#if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
enum { value = true };
|
||||
#else
|
||||
BOOST_STATIC_CONSTANT(bool, value=true);
|
||||
#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
typedef mpl::bool_<value> type;
|
||||
};
|
||||
|
||||
// stable iterators trait
|
||||
template<typename T, typename TraitsT, typename AllocT>
|
||||
class has_stable_iterators< std::rope<T,TraitsT,AllocT> >
|
||||
{
|
||||
public:
|
||||
#if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
enum { value = true };
|
||||
#else
|
||||
BOOST_STATIC_CONSTANT(bool, value=true);
|
||||
#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
typedef mpl::bool_<value> type;
|
||||
};
|
||||
|
||||
// const time insert trait
|
||||
template<typename T, typename TraitsT, typename AllocT>
|
||||
class has_const_time_insert< std::rope<T,TraitsT,AllocT> >
|
||||
{
|
||||
public:
|
||||
#if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
enum { value = true };
|
||||
#else
|
||||
BOOST_STATIC_CONSTANT(bool, value=true);
|
||||
#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
typedef mpl::bool_<value> type;
|
||||
};
|
||||
|
||||
// const time erase trait
|
||||
template<typename T, typename TraitsT, typename AllocT>
|
||||
class has_const_time_erase< std::rope<T,TraitsT,AllocT> >
|
||||
{
|
||||
public:
|
||||
#if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
enum { value = true };
|
||||
#else
|
||||
BOOST_STATIC_CONSTANT(bool, value=true);
|
||||
#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
typedef mpl::bool_<value> type;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_ROPE_TRAITS_HPP
|
@ -0,0 +1,85 @@
|
||||
// Boost string_algo library slist_traits.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_STD_SLIST_TRAITS_HPP
|
||||
#define BOOST_STRING_STD_SLIST_TRAITS_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/algorithm/string/yes_no_type.hpp>
|
||||
#include BOOST_SLIST_HEADER
|
||||
#include <boost/algorithm/string/sequence_traits.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// SGI's std::slist<> traits -----------------------------------------------//
|
||||
|
||||
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
// stable iterators tester
|
||||
template<typename T, typename AllocT>
|
||||
yes_type has_stable_iterators_tester( const BOOST_STD_EXTENSION_NAMESPACE::slist<T,AllocT>* );
|
||||
|
||||
// const time insert tester
|
||||
template<typename T, typename AllocT>
|
||||
yes_type has_const_time_insert_tester( const BOOST_STD_EXTENSION_NAMESPACE::slist<T,AllocT>* );
|
||||
|
||||
// const time erase tester
|
||||
template<typename T, typename AllocT>
|
||||
yes_type has_const_time_erase_tester( const BOOST_STD_EXTENSION_NAMESPACE::slist<T,AllocT>* );
|
||||
|
||||
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
// stable iterators trait
|
||||
template<typename T, typename AllocT>
|
||||
class has_stable_iterators< BOOST_STD_EXTENSION_NAMESPACE::slist<T,AllocT> >
|
||||
{
|
||||
public:
|
||||
#if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
enum { value = true };
|
||||
#else
|
||||
BOOST_STATIC_CONSTANT(bool, value=true);
|
||||
#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
typedef mpl::bool_<has_stable_iterators<T>::value> type;
|
||||
};
|
||||
|
||||
// const time insert trait
|
||||
template<typename T, typename AllocT>
|
||||
class has_const_time_insert< BOOST_STD_EXTENSION_NAMESPACE::slist<T,AllocT> >
|
||||
{
|
||||
public:
|
||||
#if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
enum { value = true };
|
||||
#else
|
||||
BOOST_STATIC_CONSTANT(bool, value=true);
|
||||
#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
typedef mpl::bool_<has_const_time_insert<T>::value> type;
|
||||
};
|
||||
|
||||
// const time erase trait
|
||||
template<typename T, typename AllocT>
|
||||
class has_const_time_erase< BOOST_STD_EXTENSION_NAMESPACE::slist<T,AllocT> >
|
||||
{
|
||||
public:
|
||||
#if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
enum { value = true };
|
||||
#else
|
||||
BOOST_STATIC_CONSTANT(bool, value=true);
|
||||
#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
typedef mpl::bool_<has_const_time_erase<T>::value> type;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_STD_LIST_TRAITS_HPP
|
@ -0,0 +1,52 @@
|
||||
// Boost string_algo library string_traits.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_STD_STRING_TRAITS_HPP
|
||||
#define BOOST_STRING_STD_STRING_TRAITS_HPP
|
||||
|
||||
#include <boost/algorithm/string/yes_no_type.hpp>
|
||||
#include <string>
|
||||
#include <boost/algorithm/string/sequence_traits.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// std::basic_string<> traits -----------------------------------------------//
|
||||
|
||||
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
// native replace tester
|
||||
template<typename T, typename TraitsT, typename AllocT>
|
||||
yes_type has_native_replace_tester( const std::basic_string<T, TraitsT, AllocT>* );
|
||||
|
||||
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
// native replace trait
|
||||
template<typename T, typename TraitsT, typename AllocT>
|
||||
class has_native_replace< std::basic_string<T, TraitsT, AllocT> >
|
||||
{
|
||||
public:
|
||||
#if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
enum { value = true } ;
|
||||
#else
|
||||
BOOST_STATIC_CONSTANT(bool, value=true);
|
||||
#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
|
||||
typedef mpl::bool_<has_native_replace<T>::value> type;
|
||||
};
|
||||
|
||||
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_LIST_TRAITS_HPP
|
@ -0,0 +1,26 @@
|
||||
// Boost string_algo library std_containers_traits.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_STD_CONTAINERS_TRAITS_HPP
|
||||
#define BOOST_STRING_STD_CONTAINERS_TRAITS_HPP
|
||||
|
||||
/*!\file
|
||||
This file includes sequence traits for stl containers.
|
||||
*/
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/algorithm/string/std/string_traits.hpp>
|
||||
#include <boost/algorithm/string/std/list_traits.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_SLIST
|
||||
# include <boost/algorithm/string/std/slist_traits.hpp>
|
||||
#endif
|
||||
|
||||
#endif // BOOST_STRING_STD_CONTAINERS_TRAITS_HPP
|
@ -0,0 +1,398 @@
|
||||
// Boost string_algo library trim.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_TRIM_HPP
|
||||
#define BOOST_STRING_TRIM_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
#include <boost/range/as_literal.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
|
||||
#include <boost/algorithm/string/detail/trim.hpp>
|
||||
#include <boost/algorithm/string/classification.hpp>
|
||||
#include <locale>
|
||||
|
||||
/*! \file
|
||||
Defines trim algorithms.
|
||||
Trim algorithms are used to remove trailing and leading spaces from a
|
||||
sequence (string). Space is recognized using given locales.
|
||||
|
||||
Parametric (\c _if) variants use a predicate (functor) to select which characters
|
||||
are to be trimmed..
|
||||
Functions take a selection predicate as a parameter, which is used to determine
|
||||
whether a character is a space. Common predicates are provided in classification.hpp header.
|
||||
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// left trim -----------------------------------------------//
|
||||
|
||||
|
||||
//! Left trim - parametric
|
||||
/*!
|
||||
Remove all leading spaces from the input.
|
||||
The supplied predicate is used to determine which characters are considered spaces.
|
||||
The result is a trimmed copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input range
|
||||
\param IsSpace An unary predicate identifying spaces
|
||||
\return
|
||||
An output iterator pointing just after the last inserted character or
|
||||
a copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename OutputIteratorT, typename RangeT, typename PredicateT>
|
||||
inline OutputIteratorT trim_left_copy_if(
|
||||
OutputIteratorT Output,
|
||||
const RangeT& Input,
|
||||
PredicateT IsSpace)
|
||||
{
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> lit_range(as_literal(Input));
|
||||
|
||||
std::copy(
|
||||
::boost::algorithm::detail::trim_begin(
|
||||
begin(lit_range),
|
||||
end(lit_range),
|
||||
IsSpace ),
|
||||
end(lit_range),
|
||||
Output);
|
||||
|
||||
return Output;
|
||||
}
|
||||
|
||||
//! Left trim - parametric
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename PredicateT>
|
||||
inline SequenceT trim_left_copy_if(const SequenceT& Input, PredicateT IsSpace)
|
||||
{
|
||||
return SequenceT(
|
||||
::boost::algorithm::detail::trim_begin(
|
||||
begin(Input),
|
||||
end(Input),
|
||||
IsSpace ),
|
||||
end(Input));
|
||||
}
|
||||
|
||||
//! Left trim - parametric
|
||||
/*!
|
||||
Remove all leading spaces from the input.
|
||||
The result is a trimmed copy of the input.
|
||||
|
||||
\param Input An input sequence
|
||||
\param Loc a locale used for 'space' classification
|
||||
\return A trimmed copy of the input
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename SequenceT>
|
||||
inline SequenceT trim_left_copy(const SequenceT& Input, const std::locale& Loc=std::locale())
|
||||
{
|
||||
return
|
||||
trim_left_copy_if(
|
||||
Input,
|
||||
is_space(Loc));
|
||||
}
|
||||
|
||||
//! Left trim
|
||||
/*!
|
||||
Remove all leading spaces from the input. The supplied predicate is
|
||||
used to determine which characters are considered spaces.
|
||||
The input sequence is modified in-place.
|
||||
|
||||
\param Input An input sequence
|
||||
\param IsSpace An unary predicate identifying spaces
|
||||
*/
|
||||
template<typename SequenceT, typename PredicateT>
|
||||
inline void trim_left_if(SequenceT& Input, PredicateT IsSpace)
|
||||
{
|
||||
Input.erase(
|
||||
begin(Input),
|
||||
::boost::algorithm::detail::trim_begin(
|
||||
begin(Input),
|
||||
end(Input),
|
||||
IsSpace));
|
||||
}
|
||||
|
||||
//! Left trim
|
||||
/*!
|
||||
Remove all leading spaces from the input.
|
||||
The Input sequence is modified in-place.
|
||||
|
||||
\param Input An input sequence
|
||||
\param Loc A locale used for 'space' classification
|
||||
*/
|
||||
template<typename SequenceT>
|
||||
inline void trim_left(SequenceT& Input, const std::locale& Loc=std::locale())
|
||||
{
|
||||
trim_left_if(
|
||||
Input,
|
||||
is_space(Loc));
|
||||
}
|
||||
|
||||
// right trim -----------------------------------------------//
|
||||
|
||||
//! Right trim - parametric
|
||||
/*!
|
||||
Remove all trailing spaces from the input.
|
||||
The supplied predicate is used to determine which characters are considered spaces.
|
||||
The result is a trimmed copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input range
|
||||
\param IsSpace An unary predicate identifying spaces
|
||||
\return
|
||||
An output iterator pointing just after the last inserted character or
|
||||
a copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename OutputIteratorT, typename RangeT, typename PredicateT>
|
||||
inline OutputIteratorT trim_right_copy_if(
|
||||
OutputIteratorT Output,
|
||||
const RangeT& Input,
|
||||
PredicateT IsSpace )
|
||||
{
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> lit_range(as_literal(Input));
|
||||
|
||||
std::copy(
|
||||
begin(lit_range),
|
||||
::boost::algorithm::detail::trim_end(
|
||||
begin(lit_range),
|
||||
end(lit_range),
|
||||
IsSpace ),
|
||||
Output );
|
||||
|
||||
return Output;
|
||||
}
|
||||
|
||||
//! Right trim - parametric
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename PredicateT>
|
||||
inline SequenceT trim_right_copy_if(const SequenceT& Input, PredicateT IsSpace)
|
||||
{
|
||||
return SequenceT(
|
||||
begin(Input),
|
||||
::boost::algorithm::detail::trim_end(
|
||||
begin(Input),
|
||||
end(Input),
|
||||
IsSpace)
|
||||
);
|
||||
}
|
||||
|
||||
//! Right trim
|
||||
/*!
|
||||
Remove all trailing spaces from the input.
|
||||
The result is a trimmed copy of the input
|
||||
|
||||
\param Input An input sequence
|
||||
\param Loc A locale used for 'space' classification
|
||||
\return A trimmed copy of the input
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename SequenceT>
|
||||
inline SequenceT trim_right_copy(const SequenceT& Input, const std::locale& Loc=std::locale())
|
||||
{
|
||||
return
|
||||
trim_right_copy_if(
|
||||
Input,
|
||||
is_space(Loc));
|
||||
}
|
||||
|
||||
|
||||
//! Right trim - parametric
|
||||
/*!
|
||||
Remove all trailing spaces from the input.
|
||||
The supplied predicate is used to determine which characters are considered spaces.
|
||||
The input sequence is modified in-place.
|
||||
|
||||
\param Input An input sequence
|
||||
\param IsSpace An unary predicate identifying spaces
|
||||
*/
|
||||
template<typename SequenceT, typename PredicateT>
|
||||
inline void trim_right_if(SequenceT& Input, PredicateT IsSpace)
|
||||
{
|
||||
Input.erase(
|
||||
::boost::algorithm::detail::trim_end(
|
||||
begin(Input),
|
||||
end(Input),
|
||||
IsSpace ),
|
||||
end(Input)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//! Right trim
|
||||
/*!
|
||||
Remove all trailing spaces from the input.
|
||||
The input sequence is modified in-place.
|
||||
|
||||
\param Input An input sequence
|
||||
\param Loc A locale used for 'space' classification
|
||||
*/
|
||||
template<typename SequenceT>
|
||||
inline void trim_right(SequenceT& Input, const std::locale& Loc=std::locale())
|
||||
{
|
||||
trim_right_if(
|
||||
Input,
|
||||
is_space(Loc) );
|
||||
}
|
||||
|
||||
// both side trim -----------------------------------------------//
|
||||
|
||||
//! Trim - parametric
|
||||
/*!
|
||||
Remove all trailing and leading spaces from the input.
|
||||
The supplied predicate is used to determine which characters are considered spaces.
|
||||
The result is a trimmed copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input range
|
||||
\param IsSpace An unary predicate identifying spaces
|
||||
\return
|
||||
An output iterator pointing just after the last inserted character or
|
||||
a copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename OutputIteratorT, typename RangeT, typename PredicateT>
|
||||
inline OutputIteratorT trim_copy_if(
|
||||
OutputIteratorT Output,
|
||||
const RangeT& Input,
|
||||
PredicateT IsSpace)
|
||||
{
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> lit_range(as_literal(Input));
|
||||
|
||||
BOOST_STRING_TYPENAME
|
||||
range_const_iterator<RangeT>::type TrimEnd=
|
||||
::boost::algorithm::detail::trim_end(
|
||||
begin(lit_range),
|
||||
end(lit_range),
|
||||
IsSpace);
|
||||
|
||||
std::copy(
|
||||
detail::trim_begin(
|
||||
begin(lit_range), TrimEnd, IsSpace),
|
||||
TrimEnd,
|
||||
Output
|
||||
);
|
||||
|
||||
return Output;
|
||||
}
|
||||
|
||||
//! Trim - parametric
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename PredicateT>
|
||||
inline SequenceT trim_copy_if(const SequenceT& Input, PredicateT IsSpace)
|
||||
{
|
||||
BOOST_STRING_TYPENAME
|
||||
range_const_iterator<SequenceT>::type TrimEnd=
|
||||
::boost::algorithm::detail::trim_end(
|
||||
begin(Input),
|
||||
end(Input),
|
||||
IsSpace);
|
||||
|
||||
return SequenceT(
|
||||
detail::trim_begin(
|
||||
begin(Input),
|
||||
TrimEnd,
|
||||
IsSpace),
|
||||
TrimEnd
|
||||
);
|
||||
}
|
||||
|
||||
//! Trim
|
||||
/*!
|
||||
Remove all leading and trailing spaces from the input.
|
||||
The result is a trimmed copy of the input
|
||||
|
||||
\param Input An input sequence
|
||||
\param Loc A locale used for 'space' classification
|
||||
\return A trimmed copy of the input
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename SequenceT>
|
||||
inline SequenceT trim_copy( const SequenceT& Input, const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return
|
||||
trim_copy_if(
|
||||
Input,
|
||||
is_space(Loc) );
|
||||
}
|
||||
|
||||
//! Trim
|
||||
/*!
|
||||
Remove all leading and trailing spaces from the input.
|
||||
The supplied predicate is used to determine which characters are considered spaces.
|
||||
The input sequence is modified in-place.
|
||||
|
||||
\param Input An input sequence
|
||||
\param IsSpace An unary predicate identifying spaces
|
||||
*/
|
||||
template<typename SequenceT, typename PredicateT>
|
||||
inline void trim_if(SequenceT& Input, PredicateT IsSpace)
|
||||
{
|
||||
trim_right_if( Input, IsSpace );
|
||||
trim_left_if( Input, IsSpace );
|
||||
}
|
||||
|
||||
//! Trim
|
||||
/*!
|
||||
Remove all leading and trailing spaces from the input.
|
||||
The input sequence is modified in-place.
|
||||
|
||||
\param Input An input sequence
|
||||
\param Loc A locale used for 'space' classification
|
||||
*/
|
||||
template<typename SequenceT>
|
||||
inline void trim(SequenceT& Input, const std::locale& Loc=std::locale())
|
||||
{
|
||||
trim_if(
|
||||
Input,
|
||||
is_space( Loc ) );
|
||||
}
|
||||
|
||||
} // namespace algorithm
|
||||
|
||||
// pull names to the boost namespace
|
||||
using algorithm::trim_left;
|
||||
using algorithm::trim_left_if;
|
||||
using algorithm::trim_left_copy;
|
||||
using algorithm::trim_left_copy_if;
|
||||
using algorithm::trim_right;
|
||||
using algorithm::trim_right_if;
|
||||
using algorithm::trim_right_copy;
|
||||
using algorithm::trim_right_copy_if;
|
||||
using algorithm::trim;
|
||||
using algorithm::trim_if;
|
||||
using algorithm::trim_copy;
|
||||
using algorithm::trim_copy_if;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_STRING_TRIM_HPP
|
@ -0,0 +1,33 @@
|
||||
// Boost string_algo library yes_no_type.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_YES_NO_TYPE_DETAIL_HPP
|
||||
#define BOOST_STRING_YES_NO_TYPE_DETAIL_HPP
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// taken from boost mailing-list
|
||||
// when yes_no_type will become officially
|
||||
// a part of boost distribution, this header
|
||||
// will be deprecated
|
||||
template<int I> struct size_descriptor
|
||||
{
|
||||
typedef char (& type)[I];
|
||||
};
|
||||
|
||||
typedef size_descriptor<1>::type yes_type;
|
||||
typedef size_descriptor<2>::type no_type;
|
||||
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_YES_NO_TYPE_DETAIL_HPP
|
@ -0,0 +1,23 @@
|
||||
// Boost string_algo library string_regex.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2004.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_ALGO_REGEX_HPP
|
||||
#define BOOST_STRING_ALGO_REGEX_HPP
|
||||
|
||||
/*! \file
|
||||
Cumulative include for string_algo library.
|
||||
In addtion to string.hpp contains also regex-related stuff.
|
||||
*/
|
||||
|
||||
#include <boost/regex.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/algorithm/string/regex.hpp>
|
||||
|
||||
#endif // BOOST_STRING_ALGO_REGEX_HPP
|
@ -0,0 +1,170 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost aligned_storage.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2002-2003
|
||||
// Eric Friedman, Itay Maman
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_ALIGNED_STORAGE_HPP
|
||||
#define BOOST_ALIGNED_STORAGE_HPP
|
||||
|
||||
#include <cstddef> // for std::size_t
|
||||
|
||||
#include "boost/config.hpp"
|
||||
#include "boost/detail/workaround.hpp"
|
||||
#include "boost/type_traits/alignment_of.hpp"
|
||||
#include "boost/type_traits/type_with_alignment.hpp"
|
||||
#include "boost/type_traits/is_pod.hpp"
|
||||
|
||||
#include "boost/mpl/eval_if.hpp"
|
||||
#include "boost/mpl/identity.hpp"
|
||||
|
||||
#include "boost/type_traits/detail/bool_trait_def.hpp"
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace detail { namespace aligned_storage {
|
||||
|
||||
BOOST_STATIC_CONSTANT(
|
||||
std::size_t
|
||||
, alignment_of_max_align = ::boost::alignment_of<max_align>::value
|
||||
);
|
||||
|
||||
//
|
||||
// To be TR1 conforming this must be a POD type:
|
||||
//
|
||||
template <
|
||||
std::size_t size_
|
||||
, std::size_t alignment_
|
||||
>
|
||||
struct aligned_storage_imp
|
||||
{
|
||||
union data_t
|
||||
{
|
||||
char buf[size_];
|
||||
|
||||
typename mpl::eval_if_c<
|
||||
alignment_ == std::size_t(-1)
|
||||
, mpl::identity<detail::max_align>
|
||||
, type_with_alignment<alignment_>
|
||||
>::type align_;
|
||||
} data_;
|
||||
};
|
||||
|
||||
}} // namespace detail::aligned_storage
|
||||
|
||||
template <
|
||||
std::size_t size_
|
||||
, std::size_t alignment_ = std::size_t(-1)
|
||||
>
|
||||
class aligned_storage
|
||||
{
|
||||
private: // representation
|
||||
|
||||
detail::aligned_storage::aligned_storage_imp<size_, alignment_> data_;
|
||||
|
||||
public: // constants
|
||||
|
||||
typedef detail::aligned_storage::aligned_storage_imp<size_, alignment_> type;
|
||||
|
||||
BOOST_STATIC_CONSTANT(
|
||||
std::size_t
|
||||
, size = size_
|
||||
);
|
||||
BOOST_STATIC_CONSTANT(
|
||||
std::size_t
|
||||
, alignment = (
|
||||
alignment_ == std::size_t(-1)
|
||||
? ::boost::detail::aligned_storage::alignment_of_max_align
|
||||
: alignment_
|
||||
)
|
||||
);
|
||||
|
||||
#if defined(__GNUC__) &&\
|
||||
(__GNUC__ > 3) ||\
|
||||
(__GNUC__ == 3 && (__GNUC_MINOR__ > 2 ||\
|
||||
(__GNUC_MINOR__ == 2 && __GNUC_PATCHLEVEL__ >=3)))
|
||||
|
||||
private: // noncopyable
|
||||
|
||||
aligned_storage(const aligned_storage&);
|
||||
aligned_storage& operator=(const aligned_storage&);
|
||||
|
||||
#else // gcc less than 3.2.3
|
||||
|
||||
public: // _should_ be noncopyable, but GCC compiler emits error
|
||||
|
||||
aligned_storage(const aligned_storage&);
|
||||
aligned_storage& operator=(const aligned_storage&);
|
||||
|
||||
#endif // gcc < 3.2.3 workaround
|
||||
|
||||
public: // structors
|
||||
|
||||
aligned_storage()
|
||||
{
|
||||
}
|
||||
|
||||
~aligned_storage()
|
||||
{
|
||||
}
|
||||
|
||||
public: // accessors
|
||||
|
||||
void* address()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
|
||||
const void* address() const
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
#else // MSVC6
|
||||
|
||||
const void* address() const;
|
||||
|
||||
#endif // MSVC6 workaround
|
||||
|
||||
};
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
|
||||
// MSVC6 seems not to like inline functions with const void* returns, so we
|
||||
// declare the following here:
|
||||
|
||||
template <std::size_t S, std::size_t A>
|
||||
const void* aligned_storage<S,A>::address() const
|
||||
{
|
||||
return const_cast< aligned_storage<S,A>* >(this)->address();
|
||||
}
|
||||
|
||||
#endif // MSVC6 workaround
|
||||
|
||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
//
|
||||
// Make sure that is_pod recognises aligned_storage<>::type
|
||||
// as a POD (Note that aligned_storage<> itself is not a POD):
|
||||
//
|
||||
template <std::size_t size_, std::size_t alignment_>
|
||||
struct is_pod<boost::detail::aligned_storage::aligned_storage_imp<size_,alignment_> >
|
||||
BOOST_TT_AUX_BOOL_C_BASE(true)
|
||||
{
|
||||
BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(true)
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#include "boost/type_traits/detail/bool_trait_undef.hpp"
|
||||
|
||||
#endif // BOOST_ALIGNED_STORAGE_HPP
|
@ -0,0 +1,235 @@
|
||||
// See http://www.boost.org/libs/any for Documentation.
|
||||
|
||||
#ifndef BOOST_ANY_INCLUDED
|
||||
#define BOOST_ANY_INCLUDED
|
||||
|
||||
// what: variant type boost::any
|
||||
// who: contributed by Kevlin Henney,
|
||||
// with features contributed and bugs found by
|
||||
// Ed Brey, Mark Rodgers, Peter Dimov, and James Curran
|
||||
// when: July 2001
|
||||
// where: tested with BCC 5.5, MSVC 6.0, and g++ 2.95
|
||||
|
||||
#include <algorithm>
|
||||
#include <typeinfo>
|
||||
|
||||
#include "boost/config.hpp"
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <boost/type_traits/is_reference.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
class any
|
||||
{
|
||||
public: // structors
|
||||
|
||||
any()
|
||||
: content(0)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename ValueType>
|
||||
any(const ValueType & value)
|
||||
: content(new holder<ValueType>(value))
|
||||
{
|
||||
}
|
||||
|
||||
any(const any & other)
|
||||
: content(other.content ? other.content->clone() : 0)
|
||||
{
|
||||
}
|
||||
|
||||
~any()
|
||||
{
|
||||
delete content;
|
||||
}
|
||||
|
||||
public: // modifiers
|
||||
|
||||
any & swap(any & rhs)
|
||||
{
|
||||
std::swap(content, rhs.content);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename ValueType>
|
||||
any & operator=(const ValueType & rhs)
|
||||
{
|
||||
any(rhs).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
any & operator=(const any & rhs)
|
||||
{
|
||||
any(rhs).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
public: // queries
|
||||
|
||||
bool empty() const
|
||||
{
|
||||
return !content;
|
||||
}
|
||||
|
||||
const std::type_info & type() const
|
||||
{
|
||||
return content ? content->type() : typeid(void);
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
private: // types
|
||||
#else
|
||||
public: // types (public so any_cast can be non-friend)
|
||||
#endif
|
||||
|
||||
class placeholder
|
||||
{
|
||||
public: // structors
|
||||
|
||||
virtual ~placeholder()
|
||||
{
|
||||
}
|
||||
|
||||
public: // queries
|
||||
|
||||
virtual const std::type_info & type() const = 0;
|
||||
|
||||
virtual placeholder * clone() const = 0;
|
||||
|
||||
};
|
||||
|
||||
template<typename ValueType>
|
||||
class holder : public placeholder
|
||||
{
|
||||
public: // structors
|
||||
|
||||
holder(const ValueType & value)
|
||||
: held(value)
|
||||
{
|
||||
}
|
||||
|
||||
public: // queries
|
||||
|
||||
virtual const std::type_info & type() const
|
||||
{
|
||||
return typeid(ValueType);
|
||||
}
|
||||
|
||||
virtual placeholder * clone() const
|
||||
{
|
||||
return new holder(held);
|
||||
}
|
||||
|
||||
public: // representation
|
||||
|
||||
ValueType held;
|
||||
|
||||
};
|
||||
|
||||
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
|
||||
private: // representation
|
||||
|
||||
template<typename ValueType>
|
||||
friend ValueType * any_cast(any *);
|
||||
|
||||
template<typename ValueType>
|
||||
friend ValueType * unsafe_any_cast(any *);
|
||||
|
||||
#else
|
||||
|
||||
public: // representation (public so any_cast can be non-friend)
|
||||
|
||||
#endif
|
||||
|
||||
placeholder * content;
|
||||
|
||||
};
|
||||
|
||||
class bad_any_cast : public std::bad_cast
|
||||
{
|
||||
public:
|
||||
virtual const char * what() const throw()
|
||||
{
|
||||
return "boost::bad_any_cast: "
|
||||
"failed conversion using boost::any_cast";
|
||||
}
|
||||
};
|
||||
|
||||
template<typename ValueType>
|
||||
ValueType * any_cast(any * operand)
|
||||
{
|
||||
return operand && operand->type() == typeid(ValueType)
|
||||
? &static_cast<any::holder<ValueType> *>(operand->content)->held
|
||||
: 0;
|
||||
}
|
||||
|
||||
template<typename ValueType>
|
||||
inline const ValueType * any_cast(const any * operand)
|
||||
{
|
||||
return any_cast<ValueType>(const_cast<any *>(operand));
|
||||
}
|
||||
|
||||
template<typename ValueType>
|
||||
ValueType any_cast(any & operand)
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME remove_reference<ValueType>::type nonref;
|
||||
|
||||
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
// If 'nonref' is still reference type, it means the user has not
|
||||
// specialized 'remove_reference'.
|
||||
|
||||
// Please use BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION macro
|
||||
// to generate specialization of remove_reference for your class
|
||||
// See type traits library documentation for details
|
||||
BOOST_STATIC_ASSERT(!is_reference<nonref>::value);
|
||||
#endif
|
||||
|
||||
nonref * result = any_cast<nonref>(&operand);
|
||||
if(!result)
|
||||
boost::throw_exception(bad_any_cast());
|
||||
return *result;
|
||||
}
|
||||
|
||||
template<typename ValueType>
|
||||
inline ValueType any_cast(const any & operand)
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME remove_reference<ValueType>::type nonref;
|
||||
|
||||
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
// The comment in the above version of 'any_cast' explains when this
|
||||
// assert is fired and what to do.
|
||||
BOOST_STATIC_ASSERT(!is_reference<nonref>::value);
|
||||
#endif
|
||||
|
||||
return any_cast<const nonref &>(const_cast<any &>(operand));
|
||||
}
|
||||
|
||||
// Note: The "unsafe" versions of any_cast are not part of the
|
||||
// public interface and may be removed at any time. They are
|
||||
// required where we know what type is stored in the any and can't
|
||||
// use typeid() comparison, e.g., when our types may travel across
|
||||
// different shared libraries.
|
||||
template<typename ValueType>
|
||||
inline ValueType * unsafe_any_cast(any * operand)
|
||||
{
|
||||
return &static_cast<any::holder<ValueType> *>(operand->content)->held;
|
||||
}
|
||||
|
||||
template<typename ValueType>
|
||||
inline const ValueType * unsafe_any_cast(const any * operand)
|
||||
{
|
||||
return unsafe_any_cast<ValueType>(const_cast<any *>(operand));
|
||||
}
|
||||
}
|
||||
|
||||
// Copyright Kevlin Henney, 2000, 2001, 2002. All rights reserved.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#endif
|
@ -0,0 +1,55 @@
|
||||
#ifndef BOOST_ARCHIVE_ADD_FACET_HPP
|
||||
#define BOOST_ARCHIVE_ADD_FACET_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// add_facet.hpp
|
||||
|
||||
// (C) Copyright 2003 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <locale>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
// does STLport uses native STL for locales?
|
||||
#if (defined(__SGI_STL_PORT)&& defined(_STLP_NO_OWN_IOSTREAMS))
|
||||
// and this native STL lib is old Dinkumware (has not defined _CPPLIB_VER)
|
||||
# if (defined(_YVALS) && !defined(__IBMCPP__)) || !defined(_CPPLIB_VER)
|
||||
# define BOOST_ARCHIVE_OLD_DINKUMWARE_BENEATH_STLPORT
|
||||
# endif
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
template<class Facet>
|
||||
inline std::locale *
|
||||
add_facet(const std::locale &l, Facet * f){
|
||||
return
|
||||
#if defined BOOST_ARCHIVE_OLD_DINKUMWARE_BENEATH_STLPORT
|
||||
// std namespace used for native locale
|
||||
new std::locale(std::_Addfac(l, f));
|
||||
#elif BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1) // old Dinkumwar
|
||||
// std namespace used for native locale
|
||||
new std::locale(std::_Addfac(l, f));
|
||||
#else
|
||||
// standard compatible
|
||||
new std::locale(l, f);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
#undef BOOST_ARCHIVE_OLD_DINKUMWARE_BENEATH_STLPORT
|
||||
|
||||
#endif // BOOST_ARCHIVE_ADD_FACET_HPP
|
@ -0,0 +1,115 @@
|
||||
#ifndef BOOST_ARCHIVE_ARCHIVE_EXCEPTION_HPP
|
||||
#define BOOST_ARCHIVE_ARCHIVE_EXCEPTION_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// archive/archive_exception.hpp:
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <exception>
|
||||
#include <cassert>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// exceptions thrown by archives
|
||||
//
|
||||
class archive_exception :
|
||||
public virtual std::exception
|
||||
{
|
||||
public:
|
||||
typedef enum {
|
||||
no_exception, // initialized without code
|
||||
other_exception, // any excepton not listed below
|
||||
unregistered_class, // attempt to serialize a pointer of an
|
||||
// an unregistered class
|
||||
invalid_signature, // first line of archive does not contain
|
||||
// expected string
|
||||
unsupported_version,// archive created with library version
|
||||
// subsequent to this one
|
||||
pointer_conflict, // an attempt has been made to directly
|
||||
// serialization::detail an object
|
||||
// after having already serialzed the same
|
||||
// object through a pointer. Were this permited,
|
||||
// it the archive load would result in the
|
||||
// creation of an extra copy of the obect.
|
||||
incompatible_native_format, // attempt to read native binary format
|
||||
// on incompatible platform
|
||||
array_size_too_short,// array being loaded doesn't fit in array allocated
|
||||
stream_error, // i/o error on stream
|
||||
invalid_class_name, // class name greater than the maximum permitted.
|
||||
// most likely a corrupted archive or an attempt
|
||||
// to insert virus via buffer overrun method.
|
||||
unregistered_cast // base - derived relationship not registered with
|
||||
// void_cast_register
|
||||
} exception_code;
|
||||
exception_code code;
|
||||
archive_exception(exception_code c) :
|
||||
code(c)
|
||||
{}
|
||||
virtual const char *what( ) const throw( )
|
||||
{
|
||||
const char *msg = "programming error";
|
||||
switch(code){
|
||||
case no_exception:
|
||||
msg = "uninitialized exception";
|
||||
break;
|
||||
case unregistered_class:
|
||||
msg = "unregistered class";
|
||||
break;
|
||||
case invalid_signature:
|
||||
msg = "invalid signature";
|
||||
break;
|
||||
case unsupported_version:
|
||||
msg = "unsupported version";
|
||||
break;
|
||||
case pointer_conflict:
|
||||
msg = "pointer conflict";
|
||||
break;
|
||||
case incompatible_native_format:
|
||||
msg = "incompatible native format";
|
||||
break;
|
||||
case array_size_too_short:
|
||||
msg = "array size too short";
|
||||
break;
|
||||
case stream_error:
|
||||
msg = "stream error";
|
||||
break;
|
||||
case invalid_class_name:
|
||||
msg = "class name too long";
|
||||
break;
|
||||
case unregistered_cast:
|
||||
msg = "unregistered void cast";
|
||||
break;
|
||||
case other_exception:
|
||||
// if get here - it indicates a derived exception
|
||||
// was sliced by passing by value in catch
|
||||
msg = "unknown derived exception";
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
break;
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
protected:
|
||||
archive_exception() :
|
||||
code(no_exception)
|
||||
{}
|
||||
};
|
||||
|
||||
}// namespace archive
|
||||
}// namespace boost
|
||||
|
||||
#endif //BOOST_ARCHIVE_ARCHIVE_EXCEPTION_HPP
|
@ -0,0 +1,132 @@
|
||||
#ifndef BOOST_ARCHIVE_ARRAY_IARCHIVE_HPP
|
||||
#define BOOST_ARCHIVE_ARRAY_IARCHIVE_HPP
|
||||
|
||||
// (C) Copyright 2005 Matthias Troyer and Dave Abrahams
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
|
||||
#include <boost/archive/basic_archive.hpp>
|
||||
#include <boost/archive/archive_exception.hpp>
|
||||
#include <boost/archive/detail/common_iarchive.hpp>
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
#include <boost/serialization/array.hpp>
|
||||
#include <boost/serialization/collection_size_type.hpp>
|
||||
#include <boost/serialization/detail/get_data.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/mpl/apply.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/pfto.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace archive { namespace array {
|
||||
|
||||
// To conveniently array-optimize an input archive X:
|
||||
//
|
||||
// * Derive it from iarchive<X, Impl>, where Impl is an
|
||||
// archive implementation base class from
|
||||
// Boost.Serialization
|
||||
//
|
||||
// * add a member function template that implements the
|
||||
// procedure for serializing arrays of T (for appropriate T)
|
||||
//
|
||||
// template <class T>
|
||||
// load_array(serialization::array<T> &, unsigned int)
|
||||
//
|
||||
// * add a unary MPL lambda expression member called
|
||||
// use_array_optimization whose result is convertible to
|
||||
// mpl::true_ iff array elements of type T can be serialized
|
||||
// with the load_array member function, and to mpl::false_ if
|
||||
// the unoptimized procedure must be used.
|
||||
|
||||
template <class Archive>
|
||||
class iarchive
|
||||
: public archive::detail::common_iarchive<Archive>
|
||||
{
|
||||
typedef archive::detail::common_iarchive<Archive> Base;
|
||||
public:
|
||||
iarchive(unsigned int flags)
|
||||
: archive::detail::common_iarchive<Archive>(flags)
|
||||
{}
|
||||
|
||||
|
||||
// save_override for std::vector and serialization::array dispatches to
|
||||
// save_optimized with an additional argument.
|
||||
//
|
||||
// If that argument is of type mpl::true_, an optimized serialization is provided
|
||||
// If it is false, we just forward to the default serialization in the base class
|
||||
|
||||
//the default version dispatches to the base class
|
||||
template<class T>
|
||||
void load_optimized(T &t, unsigned int version, mpl::false_)
|
||||
{
|
||||
Base::load_override(t, version);
|
||||
}
|
||||
|
||||
// the optimized implementation for vector uses serialization::array
|
||||
// template<class U, class Allocator>
|
||||
// void load_optimized(
|
||||
// std::vector<U, Allocator> &t, unsigned int version, mpl::true_)
|
||||
// {
|
||||
// t.clear();
|
||||
// // retrieve number of elements
|
||||
// serialization::collection_size_type count;
|
||||
// *this->This() >> BOOST_SERIALIZATION_NVP(count);
|
||||
// t.resize(count);
|
||||
// if (!t.empty())
|
||||
// * this->This() >> serialization::make_array(serialization::detail::get_data(t),t.size());
|
||||
// }
|
||||
|
||||
// the optimized implementation for serialization::array uses save_array
|
||||
template<class ValueType>
|
||||
void load_optimized(
|
||||
serialization::array<ValueType> &t, unsigned int version, mpl::true_)
|
||||
{
|
||||
this->This()->load_array(t,version);
|
||||
}
|
||||
|
||||
|
||||
// to load a vector:
|
||||
// if the value type is trivially constructable or an optimized array save exists,
|
||||
// then we can use the optimized version
|
||||
|
||||
// template<class ValueType, class Allocator>
|
||||
// void load_override(std::vector<ValueType,Allocator> &x, unsigned int version)
|
||||
// {
|
||||
// typedef typename mpl::and_<
|
||||
// mpl::not_<is_same<ValueType,bool> >,
|
||||
// mpl::apply1<
|
||||
// BOOST_DEDUCED_TYPENAME Archive::use_array_optimization
|
||||
// , ValueType>
|
||||
// >::type use_optimized;
|
||||
// load_optimized(x,version, use_optimized() );
|
||||
// }
|
||||
|
||||
|
||||
// dispatch loading of arrays to the optimized version where supported
|
||||
template<class ValueType>
|
||||
void load_override(serialization::array<ValueType> const& x, unsigned int version)
|
||||
{
|
||||
typedef typename mpl::apply1<
|
||||
BOOST_DEDUCED_TYPENAME Archive::use_array_optimization
|
||||
, ValueType
|
||||
>::type use_optimized;
|
||||
load_optimized(const_cast<serialization::array<ValueType>&>(x),version,use_optimized());
|
||||
}
|
||||
|
||||
// Load everything else in the usual way, forwarding on to the base class
|
||||
template<class T>
|
||||
void load_override(T & x, unsigned BOOST_PFTO int version)
|
||||
{
|
||||
Base::load_override(x, static_cast<unsigned int>(version));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} } } // end namespace boost::archive::array
|
||||
|
||||
|
||||
|
||||
#endif // BOOST_ARCHIVE_ARRAY_OARCHIVE_HPP
|
||||
|
@ -0,0 +1,130 @@
|
||||
#ifndef BOOST_ARCHIVE_ARRAY_OARCHIVE_HPP
|
||||
#define BOOST_ARCHIVE_ARRAY_OARCHIVE_HPP
|
||||
|
||||
// (C) Copyright 2005 Matthias Troyer and Dave Abrahams
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
|
||||
#include <boost/archive/basic_archive.hpp>
|
||||
#include <boost/archive/detail/common_oarchive.hpp>
|
||||
#include <boost/serialization/array.hpp>
|
||||
#include <boost/serialization/collection_size_type.hpp>
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
#include <boost/serialization/detail/get_data.hpp>
|
||||
#include <boost/type_traits/remove_const.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/mpl/apply.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/pfto.hpp>
|
||||
|
||||
namespace boost { namespace archive { namespace array {
|
||||
|
||||
// To conveniently array-optimize an output archive X:
|
||||
//
|
||||
// * Derive it from oarchive<X, Impl>, where Impl is an
|
||||
// archive implementation base class from
|
||||
// Boost.Serialization
|
||||
//
|
||||
// * add a member function template that implements the
|
||||
// procedure for serializing arrays of T (for appropriate T)
|
||||
//
|
||||
// template <class T>
|
||||
// save_array(serialization::array<T> const &, unsigned int)
|
||||
//
|
||||
// * add a unary MPL lambda expression member called
|
||||
// use_array_optimization whose result is convertible to
|
||||
// mpl::true_ iff array elements of type T can be serialized
|
||||
// with the load_array member function, and to mpl::false_ if
|
||||
// the unoptimized procedure must be used.
|
||||
|
||||
template <class Archive>
|
||||
class oarchive
|
||||
: public archive::detail::common_oarchive<Archive>
|
||||
{
|
||||
typedef archive::detail::common_oarchive<Archive> Base;
|
||||
public:
|
||||
|
||||
oarchive(unsigned int flags)
|
||||
: archive::detail::common_oarchive<Archive>(flags)
|
||||
{}
|
||||
|
||||
// save_override for std::vector and serialization::array dispatches to
|
||||
// save_optimized with an additional argument.
|
||||
//
|
||||
// If that argument is of type mpl::true_, an optimized serialization is provided
|
||||
// If it is false, we just forward to the default serialization in the base class
|
||||
|
||||
//the default version dispatches to the base class
|
||||
template<class T>
|
||||
void save_optimized(T const &t, unsigned int version, mpl::false_)
|
||||
{
|
||||
Base::save_override(t, version);
|
||||
}
|
||||
|
||||
|
||||
// the optimized implementation for vector uses serialization::array
|
||||
// template<class ValueType, class Allocator>
|
||||
// void save_optimized(
|
||||
// const std::vector<ValueType, Allocator> &t, unsigned int, mpl::true_)
|
||||
// {
|
||||
// const serialization::collection_size_type count(t.size());
|
||||
// * this->This() << BOOST_SERIALIZATION_NVP(count);
|
||||
// if (!t.empty())
|
||||
// * this->This() << serialization::make_array(serialization::detail::get_data(t),t.size());
|
||||
// }
|
||||
|
||||
// the optimized implementation for serialization::array uses save_array
|
||||
template<class ValueType>
|
||||
void save_optimized(
|
||||
const serialization::array<ValueType> &t, unsigned int version, mpl::true_)
|
||||
{
|
||||
this->This()->save_array(t,version);
|
||||
}
|
||||
|
||||
|
||||
// to save a vector:
|
||||
// if the value type is trivially constructable or an optimized array save exists,
|
||||
// then we can use the optimized version
|
||||
|
||||
// template<class ValueType, class Allocator>
|
||||
// void save_override(std::vector<ValueType,Allocator> const &x, unsigned int version)
|
||||
// {
|
||||
// typedef BOOST_DEDUCED_TYPENAME remove_const<ValueType>::type value_type;
|
||||
// typedef typename mpl::and_<
|
||||
// mpl::not_<is_same<value_type,bool> >,
|
||||
// mpl::apply1<
|
||||
// BOOST_DEDUCED_TYPENAME Archive::use_array_optimization
|
||||
// , value_type>
|
||||
// >::type use_optimized;
|
||||
// save_optimized(x,version,use_optimized() );
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// dispatch saving of arrays to the optimized version where supported
|
||||
template<class ValueType>
|
||||
void save_override(serialization::array<ValueType> const& x, unsigned int version)
|
||||
{
|
||||
typedef typename mpl::apply1<
|
||||
BOOST_DEDUCED_TYPENAME Archive::use_array_optimization
|
||||
, BOOST_DEDUCED_TYPENAME remove_const<ValueType>::type
|
||||
>::type use_optimized;
|
||||
save_optimized(x,version,use_optimized());
|
||||
}
|
||||
|
||||
// Load everything else in the usual way, forwarding on to the
|
||||
// Base class
|
||||
template<class T>
|
||||
void save_override(T const& x, unsigned BOOST_PFTO int version)
|
||||
{
|
||||
Base::save_override(x, static_cast<unsigned int>(version));
|
||||
}
|
||||
};
|
||||
|
||||
} } } // end namespace boost::archive::array
|
||||
|
||||
|
||||
#endif // BOOST_ARCHIVE_ARRAY_OARCHIVE_HPP
|
||||
|
@ -0,0 +1,120 @@
|
||||
#ifndef BOOST_ARCHIVE_BASIC_ARCHIVE_HPP
|
||||
#define BOOST_ARCHIVE_BASIC_ARCHIVE_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// basic_archive.hpp:
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/strong_typedef.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
|
||||
#include <boost/archive/detail/auto_link_archive.hpp>
|
||||
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
BOOST_STRONG_TYPEDEF(unsigned int, version_type)
|
||||
BOOST_STRONG_TYPEDEF(int, class_id_type)
|
||||
BOOST_STRONG_TYPEDEF(int, class_id_optional_type)
|
||||
BOOST_STRONG_TYPEDEF(int, class_id_reference_type)
|
||||
BOOST_STRONG_TYPEDEF(unsigned int, object_id_type)
|
||||
BOOST_STRONG_TYPEDEF(unsigned int, object_reference_type)
|
||||
|
||||
struct tracking_type {
|
||||
typedef bool value_type;
|
||||
bool t;
|
||||
explicit tracking_type(const bool t_ = false)
|
||||
: t(t_)
|
||||
{};
|
||||
tracking_type(const tracking_type & t_)
|
||||
: t(t_.t)
|
||||
{}
|
||||
operator bool () const {
|
||||
return t;
|
||||
};
|
||||
operator bool & () {
|
||||
return t;
|
||||
};
|
||||
tracking_type & operator=(const bool t_){
|
||||
t = t_;
|
||||
return *this;
|
||||
}
|
||||
bool operator==(const tracking_type & rhs) const {
|
||||
return t == rhs.t;
|
||||
}
|
||||
bool operator==(const bool & rhs) const {
|
||||
return t == rhs;
|
||||
}
|
||||
tracking_type & operator=(const tracking_type & rhs){
|
||||
t = rhs.t;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
struct class_name_type : private boost::noncopyable {
|
||||
char *t;
|
||||
operator const char * & () const {
|
||||
return const_cast<const char * &>(t);
|
||||
}
|
||||
operator char * () {
|
||||
return t;
|
||||
}
|
||||
explicit class_name_type(const char *key_)
|
||||
: t(const_cast<char *>(key_)){}
|
||||
explicit class_name_type(char *key_)
|
||||
: t(key_){}
|
||||
class_name_type & operator=(const class_name_type & rhs){
|
||||
t = rhs.t;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
enum archive_flags {
|
||||
no_header = 1, // suppress archive header info
|
||||
no_codecvt = 2, // suppress alteration of codecvt facet
|
||||
no_xml_tag_checking = 4, // suppress checking of xml tags
|
||||
no_tracking = 8 // suppress ALL tracking
|
||||
// no_object_creation = 16 // don't create any new objects
|
||||
};
|
||||
|
||||
#define NULL_POINTER_TAG class_id_type(-1)
|
||||
|
||||
BOOST_ARCHIVE_DECL(const char *)
|
||||
ARCHIVE_SIGNATURE();
|
||||
|
||||
BOOST_ARCHIVE_DECL(unsigned char)
|
||||
ARCHIVE_VERSION();
|
||||
|
||||
}// namespace archive
|
||||
}// namespace boost
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
#include <boost/serialization/level.hpp>
|
||||
|
||||
// set implementation level to primitive for all types
|
||||
// used internally by the serialization library
|
||||
|
||||
BOOST_CLASS_IMPLEMENTATION(boost::archive::version_type, primitive_type)
|
||||
BOOST_CLASS_IMPLEMENTATION(boost::archive::class_id_type, primitive_type)
|
||||
BOOST_CLASS_IMPLEMENTATION(boost::archive::class_id_reference_type, primitive_type)
|
||||
BOOST_CLASS_IMPLEMENTATION(boost::archive::class_id_optional_type, primitive_type)
|
||||
BOOST_CLASS_IMPLEMENTATION(boost::archive::class_name_type, primitive_type)
|
||||
BOOST_CLASS_IMPLEMENTATION(boost::archive::object_id_type, primitive_type)
|
||||
BOOST_CLASS_IMPLEMENTATION(boost::archive::object_reference_type, primitive_type)
|
||||
BOOST_CLASS_IMPLEMENTATION(boost::archive::tracking_type, primitive_type)
|
||||
|
||||
#endif //BOOST_ARCHIVE_BASIC_ARCHIVE_HPP
|
@ -0,0 +1,125 @@
|
||||
#ifndef BOOST_ARCHIVE_BASIC_BINARY_IARCHIVE_HPP
|
||||
#define BOOST_ARCHIVE_BASIC_BINARY_IARCHIVE_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// basic_binary_iarchive.hpp
|
||||
//
|
||||
// archives stored as native binary - this should be the fastest way
|
||||
// to archive the state of a group of obects. It makes no attempt to
|
||||
// convert to any canonical form.
|
||||
|
||||
// IN GENERAL, ARCHIVES CREATED WITH THIS CLASS WILL NOT BE READABLE
|
||||
// ON PLATFORM APART FROM THE ONE THEY ARE CREATED ON
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//#include <cstring>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/pfto.hpp>
|
||||
|
||||
#include <boost/serialization/string.hpp>
|
||||
#include <boost/serialization/collection_size_type.hpp>
|
||||
#include <boost/archive/array/iarchive.hpp>
|
||||
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// class basic_binary_iarchive - read serialized objects from a input binary stream
|
||||
template<class Archive>
|
||||
class basic_binary_iarchive :
|
||||
public array::iarchive<Archive>
|
||||
{
|
||||
protected:
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
public:
|
||||
#elif defined(BOOST_MSVC)
|
||||
// for some inexplicable reason insertion of "class" generates compile erro
|
||||
// on msvc 7.1
|
||||
friend detail::interface_iarchive<Archive>;
|
||||
#else
|
||||
friend class detail::interface_iarchive<Archive>;
|
||||
#endif
|
||||
// intermediate level to support override of operators
|
||||
// fot templates in the absence of partial function
|
||||
// template ordering. If we get here pass to base class
|
||||
// note extra nonsense to sneak it pass the borland compiers
|
||||
typedef array::iarchive<Archive> array_iarchive;
|
||||
template<class T>
|
||||
void load_override(T & t, BOOST_PFTO int){
|
||||
this->array_iarchive::load_override(t, 0);
|
||||
}
|
||||
// binary files don't include the optional information
|
||||
void load_override(class_id_optional_type & /* t */, int){}
|
||||
|
||||
// the following have been overridden to provide specific sizes
|
||||
// for these pseudo prmitive types.
|
||||
void load_override(version_type & t, int){
|
||||
// upto 255 versions
|
||||
unsigned char x=0;
|
||||
* this->This() >> x;
|
||||
t = version_type(x);
|
||||
}
|
||||
void load_override(class_id_type & t, int){
|
||||
// upto 32K classes
|
||||
int_least16_t x=0;
|
||||
* this->This() >> x;
|
||||
t = class_id_type(x);
|
||||
}
|
||||
void load_override(class_id_reference_type & t, int){
|
||||
// upto 32K classes
|
||||
int_least16_t x=0;
|
||||
* this->This() >> x;
|
||||
t = class_id_reference_type(x);
|
||||
}
|
||||
void load_override(object_id_type & t, int){
|
||||
// upto 2G objects
|
||||
uint_least32_t x=0;
|
||||
* this->This() >> x;
|
||||
t = object_id_type(x);
|
||||
}
|
||||
void load_override(object_reference_type & t, int){
|
||||
// upto 2G objects
|
||||
uint_least32_t x=0;
|
||||
* this->This() >> x;
|
||||
t = object_reference_type(x);
|
||||
}
|
||||
void load_override(tracking_type & t, int){
|
||||
char x=0;
|
||||
* this->This() >> x;
|
||||
t = (0 != x);
|
||||
}
|
||||
void load_override(serialization::collection_size_type & t, int){
|
||||
unsigned int x=0;
|
||||
* this->This() >> x;
|
||||
t = serialization::collection_size_type(x);
|
||||
}
|
||||
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
load_override(class_name_type & t, int);
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
init();
|
||||
|
||||
basic_binary_iarchive(unsigned int flags) :
|
||||
array_iarchive(flags)
|
||||
{}
|
||||
};
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
#endif // BOOST_ARCHIVE_BASIC_BINARY_IARCHIVE_HPP
|
@ -0,0 +1,192 @@
|
||||
#ifndef BOOST_ARCHIVE_BINARY_IPRIMITIVE_HPP
|
||||
#define BOOST_ARCHIVE_BINARY_IPRIMITIVE_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// basic_binary_iprimitive.hpp
|
||||
//
|
||||
// archives stored as native binary - this should be the fastest way
|
||||
// to archive the state of a group of obects. It makes no attempt to
|
||||
// convert to any canonical form.
|
||||
|
||||
// IN GENERAL, ARCHIVES CREATED WITH THIS CLASS WILL NOT BE READABLE
|
||||
// ON PLATFORM APART FROM THE ONE THEY ARE CREATED ON
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <iosfwd>
|
||||
#include <cassert>
|
||||
#include <locale>
|
||||
#include <cstring> // std::memcpy
|
||||
#include <cstddef> // std::size_t
|
||||
#include <streambuf> // basic_streambuf
|
||||
#include <string>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std{
|
||||
using ::memcpy;
|
||||
using ::size_t;
|
||||
} // namespace std
|
||||
#endif
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
//#include <boost/limits.hpp>
|
||||
//#include <boost/io/ios_state.hpp>
|
||||
|
||||
#include <boost/archive/basic_streambuf_locale_saver.hpp>
|
||||
#include <boost/archive/archive_exception.hpp>
|
||||
#include <boost/archive/detail/auto_link_archive.hpp>
|
||||
#include <boost/mpl/placeholders.hpp>
|
||||
#include <boost/serialization/is_bitwise_serializable.hpp>
|
||||
#include <boost/serialization/array.hpp>
|
||||
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// class binary_iarchive - read serialized objects from a input binary stream
|
||||
template<class Archive, class Elem, class Tr>
|
||||
class basic_binary_iprimitive
|
||||
{
|
||||
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
friend class load_access;
|
||||
protected:
|
||||
#else
|
||||
public:
|
||||
#endif
|
||||
std::basic_streambuf<Elem, Tr> & m_sb;
|
||||
// return a pointer to the most derived class
|
||||
Archive * This(){
|
||||
return static_cast<Archive *>(this);
|
||||
}
|
||||
boost::scoped_ptr<std::locale> archive_locale;
|
||||
basic_streambuf_locale_saver<Elem, Tr> locale_saver;
|
||||
|
||||
// main template for serilization of primitive types
|
||||
template<class T>
|
||||
void load(T & t){
|
||||
load_binary(& t, sizeof(T));
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
// fundamental types that need special treatment
|
||||
|
||||
// trap usage of invalid uninitialized boolean
|
||||
void load(bool & t){
|
||||
load_binary(& t, sizeof(t));
|
||||
int i = t;
|
||||
assert(0 == i || 1 == i);
|
||||
(void)i; // warning suppression for release builds.
|
||||
}
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
load(std::string &s);
|
||||
#ifndef BOOST_NO_STD_WSTRING
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
load(std::wstring &ws);
|
||||
#endif
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
load(char * t);
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
load(wchar_t * t);
|
||||
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
init();
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
|
||||
basic_binary_iprimitive(
|
||||
std::basic_streambuf<Elem, Tr> & sb,
|
||||
bool no_codecvt
|
||||
);
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
|
||||
~basic_binary_iprimitive();
|
||||
public:
|
||||
// we provide an optimized load for all fundamental types
|
||||
//typedef serialization::is_bitwise_serializable<mpl::_1>
|
||||
// use_array_optimization;
|
||||
struct use_array_optimization {
|
||||
template <class T>
|
||||
struct apply : public serialization::is_bitwise_serializable<T> {};
|
||||
};
|
||||
|
||||
// the optimized load_array dispatches to load_binary
|
||||
template <class ValueType>
|
||||
void load_array(serialization::array<ValueType>& a, unsigned int)
|
||||
{
|
||||
load_binary(a.address(),a.count()*sizeof(ValueType));
|
||||
}
|
||||
|
||||
void
|
||||
load_binary(void *address, std::size_t count);
|
||||
};
|
||||
|
||||
template<class Archive, class Elem, class Tr>
|
||||
inline void
|
||||
basic_binary_iprimitive<Archive, Elem, Tr>::load_binary(
|
||||
void *address,
|
||||
std::size_t count
|
||||
){
|
||||
#if 0
|
||||
assert(
|
||||
static_cast<std::size_t>((std::numeric_limits<std::streamsize>::max)()) >= count
|
||||
);
|
||||
//if(is.fail())
|
||||
// boost::throw_exception(archive_exception(archive_exception::stream_error));
|
||||
// note: an optimizer should eliminate the following for char files
|
||||
std::size_t s = count / sizeof(BOOST_DEDUCED_TYPENAME IStream::char_type);
|
||||
is.read(
|
||||
static_cast<BOOST_DEDUCED_TYPENAME IStream::char_type *>(address),
|
||||
s
|
||||
);
|
||||
// note: an optimizer should eliminate the following for char files
|
||||
s = count % sizeof(BOOST_DEDUCED_TYPENAME IStream::char_type);
|
||||
if(0 < s){
|
||||
if(is.fail())
|
||||
boost::throw_exception(archive_exception(archive_exception::stream_error));
|
||||
BOOST_DEDUCED_TYPENAME IStream::char_type t;
|
||||
is.read(& t, 1);
|
||||
std::memcpy(address, &t, s);
|
||||
}
|
||||
#endif
|
||||
// note: an optimizer should eliminate the following for char files
|
||||
std::streamsize s = count / sizeof(Elem);
|
||||
std::streamsize scount = m_sb.sgetn(
|
||||
static_cast<Elem *>(address),
|
||||
s
|
||||
);
|
||||
if(scount != static_cast<std::streamsize>(s))
|
||||
boost::throw_exception(
|
||||
archive_exception(archive_exception::stream_error)
|
||||
);
|
||||
// note: an optimizer should eliminate the following for char files
|
||||
s = count % sizeof(Elem);
|
||||
if(0 < s){
|
||||
// if(is.fail())
|
||||
// boost::throw_exception(archive_exception(archive_exception::stream_error));
|
||||
Elem t;
|
||||
scount = m_sb.sgetn(& t, 1);
|
||||
if(scount != 1)
|
||||
boost::throw_exception(
|
||||
archive_exception(archive_exception::stream_error)
|
||||
);
|
||||
std::memcpy(address, &t, s);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pop pragams
|
||||
|
||||
#endif // BOOST_ARCHIVE_BINARY_IPRIMITIVE_HPP
|
@ -0,0 +1,127 @@
|
||||
#ifndef BOOST_ARCHIVE_BASIC_BINARY_OARCHIVE_HPP
|
||||
#define BOOST_ARCHIVE_BASIC_BINARY_OARCHIVE_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// basic_binary_oarchive.hpp
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
// archives stored as native binary - this should be the fastest way
|
||||
// to archive the state of a group of obects. It makes no attempt to
|
||||
// convert to any canonical form.
|
||||
|
||||
// IN GENERAL, ARCHIVES CREATED WITH THIS CLASS WILL NOT BE READABLE
|
||||
// ON PLATFORM APART FROM THE ONE THEY ARE CREATE ON
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/pfto.hpp>
|
||||
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/archive/array/oarchive.hpp>
|
||||
#include <boost/serialization/string.hpp>
|
||||
#include <boost/serialization/collection_size_type.hpp>
|
||||
#include <boost/archive/array/oarchive.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// class basic_binary_oarchive - write serialized objects to a binary output stream
|
||||
// note: this archive has no pretensions to portability. Archive format
|
||||
// may vary across machine architectures and compilers. About the only
|
||||
// guarentee is that an archive created with this code will be readable
|
||||
// by a program built with the same tools for the same machne. This class
|
||||
// does have the virtue of buiding the smalles archive in the minimum amount
|
||||
// of time. So under some circumstances it may be he right choice.
|
||||
template<class Archive>
|
||||
class basic_binary_oarchive :
|
||||
public array::oarchive<Archive>
|
||||
{
|
||||
protected:
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
public:
|
||||
#elif defined(BOOST_MSVC)
|
||||
// for some inexplicable reason insertion of "class" generates compile erro
|
||||
// on msvc 7.1
|
||||
friend detail::interface_oarchive<Archive>;
|
||||
#else
|
||||
friend class detail::interface_oarchive<Archive>;
|
||||
#endif
|
||||
// any datatype not specifed below will be handled by base class
|
||||
typedef array::oarchive<Archive> array_oarchive;
|
||||
template<class T>
|
||||
void save_override(const T & t, BOOST_PFTO int){
|
||||
this->array_oarchive::save_override(t, 0);
|
||||
}
|
||||
template<class T>
|
||||
void save_override(T & t, BOOST_PFTO int){
|
||||
this->save_override(const_cast<const T &>(t), 0);
|
||||
}
|
||||
// binary files don't include the optional information
|
||||
void save_override(const class_id_optional_type & /* t */, int){}
|
||||
|
||||
void save_override(const version_type & t, int){
|
||||
// upto 255 versions
|
||||
// note:t.t resolves borland ambguity
|
||||
const unsigned char x = t.t;
|
||||
* this->This() << x;
|
||||
}
|
||||
void save_override(const class_id_type & t, int){
|
||||
// upto 32K classes
|
||||
const int_least16_t x = t.t;
|
||||
* this->This() << x;
|
||||
}
|
||||
void save_override(const class_id_reference_type & t, int){
|
||||
// upto 32K classes
|
||||
const int_least16_t x = t.t;
|
||||
* this->This() << x;
|
||||
}
|
||||
void save_override(const object_id_type & t, int){
|
||||
// upto 2G objects
|
||||
const uint_least32_t x = t.t;
|
||||
* this->This() << x;
|
||||
}
|
||||
void save_override(const object_reference_type & t, int){
|
||||
// upto 2G objects
|
||||
uint_least32_t x = t.t;
|
||||
* this->This() << x;
|
||||
}
|
||||
void save_override(const tracking_type & t, int){
|
||||
const char x = t.t;
|
||||
* this->This() << x;
|
||||
}
|
||||
|
||||
// explicitly convert to char * to avoid compile ambiguities
|
||||
void save_override(const class_name_type & t, int){
|
||||
const std::string s(t);
|
||||
* this->This() << s;
|
||||
}
|
||||
|
||||
void save_override(const serialization::collection_size_type & t, int){
|
||||
// for backward compatibility, 64 bit integer or variable length integer would be preferred
|
||||
unsigned int x = t.t;
|
||||
* this->This() << x;
|
||||
}
|
||||
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
init();
|
||||
|
||||
basic_binary_oarchive(unsigned int flags) :
|
||||
array_oarchive(flags)
|
||||
{}
|
||||
};
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_ARCHIVE_BASIC_BINARY_OARCHIVE_HPP
|
@ -0,0 +1,173 @@
|
||||
#ifndef BOOST_ARCHIVE_BASIC_BINARY_OPRIMITIVE_HPP
|
||||
#define BOOST_ARCHIVE_BASIC_BINARY_OPRIMITIVE_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// basic_binary_oprimitive.hpp
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
// archives stored as native binary - this should be the fastest way
|
||||
// to archive the state of a group of obects. It makes no attempt to
|
||||
// convert to any canonical form.
|
||||
|
||||
// IN GENERAL, ARCHIVES CREATED WITH THIS CLASS WILL NOT BE READABLE
|
||||
// ON PLATFORM APART FROM THE ONE THEY ARE CREATE ON
|
||||
|
||||
#include <iosfwd>
|
||||
#include <cassert>
|
||||
#include <locale>
|
||||
#include <cstddef> // size_t
|
||||
#include <streambuf> // basic_streambuf
|
||||
#include <string>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std{
|
||||
using ::size_t;
|
||||
} // namespace std
|
||||
#endif
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
//#include <boost/limits.hpp>
|
||||
//#include <boost/io/ios_state.hpp>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
#include <boost/archive/basic_streambuf_locale_saver.hpp>
|
||||
#include <boost/archive/archive_exception.hpp>
|
||||
#include <boost/archive/detail/auto_link_archive.hpp>
|
||||
#include <boost/serialization/is_bitwise_serializable.hpp>
|
||||
#include <boost/mpl/placeholders.hpp>
|
||||
#include <boost/serialization/array.hpp>
|
||||
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// class basic_binary_oprimitive - binary output of prmitives
|
||||
|
||||
template<class Archive, class Elem, class Tr>
|
||||
class basic_binary_oprimitive
|
||||
{
|
||||
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
friend class save_access;
|
||||
protected:
|
||||
#else
|
||||
public:
|
||||
#endif
|
||||
std::basic_streambuf<Elem, Tr> & m_sb;
|
||||
// return a pointer to the most derived class
|
||||
Archive * This(){
|
||||
return static_cast<Archive *>(this);
|
||||
}
|
||||
boost::scoped_ptr<std::locale> archive_locale;
|
||||
basic_streambuf_locale_saver<Elem, Tr> locale_saver;
|
||||
|
||||
// default saving of primitives.
|
||||
template<class T>
|
||||
void save(const T & t)
|
||||
{
|
||||
save_binary(& t, sizeof(T));
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
// fundamental types that need special treatment
|
||||
|
||||
// trap usage of invalid uninitialized boolean which would
|
||||
// otherwise crash on load.
|
||||
void save(const bool t){
|
||||
int i = t;
|
||||
assert(0 == i || 1 == i);
|
||||
save_binary(& t, sizeof(t));
|
||||
}
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
save(const std::string &s);
|
||||
#ifndef BOOST_NO_STD_WSTRING
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
save(const std::wstring &ws);
|
||||
#endif
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
save(const char * t);
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
save(const wchar_t * t);
|
||||
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
init();
|
||||
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
|
||||
basic_binary_oprimitive(
|
||||
std::basic_streambuf<Elem, Tr> & sb,
|
||||
bool no_codecvt
|
||||
);
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
|
||||
~basic_binary_oprimitive();
|
||||
public:
|
||||
|
||||
// we provide an optimized save for all fundamental types
|
||||
// typedef serialization::is_bitwise_serializable<mpl::_1>
|
||||
// use_array_optimization;
|
||||
// workaround without using mpl lambdas
|
||||
struct use_array_optimization {
|
||||
template <class T>
|
||||
struct apply : public serialization::is_bitwise_serializable<T> {};
|
||||
};
|
||||
|
||||
|
||||
// the optimized save_array dispatches to save_binary
|
||||
template <class ValueType>
|
||||
void save_array(serialization::array<ValueType> const& a, unsigned int)
|
||||
{
|
||||
save_binary(a.address(),a.count()*sizeof(ValueType));
|
||||
}
|
||||
|
||||
void save_binary(const void *address, std::size_t count);
|
||||
};
|
||||
|
||||
template<class Archive, class Elem, class Tr>
|
||||
inline void
|
||||
basic_binary_oprimitive<Archive, Elem, Tr>::save_binary(
|
||||
const void *address,
|
||||
std::size_t count
|
||||
){
|
||||
//assert(
|
||||
// static_cast<std::size_t>((std::numeric_limits<std::streamsize>::max)()) >= count
|
||||
//);
|
||||
// note: if the following assertions fail
|
||||
// a likely cause is that the output stream is set to "text"
|
||||
// mode where by cr characters recieve special treatment.
|
||||
// be sure that the output stream is opened with ios::binary
|
||||
//if(os.fail())
|
||||
// boost::throw_exception(archive_exception(archive_exception::stream_error));
|
||||
// figure number of elements to output - round up
|
||||
count = ( count + sizeof(Elem) - 1)
|
||||
/ sizeof(Elem);
|
||||
std::streamsize scount = m_sb.sputn(
|
||||
static_cast<const Elem *>(address),
|
||||
count
|
||||
);
|
||||
if(count != static_cast<std::size_t>(scount))
|
||||
boost::throw_exception(archive_exception(archive_exception::stream_error));
|
||||
//os.write(
|
||||
// static_cast<const BOOST_DEDUCED_TYPENAME OStream::char_type *>(address),
|
||||
// count
|
||||
//);
|
||||
//assert(os.good());
|
||||
}
|
||||
|
||||
} //namespace boost
|
||||
} //namespace archive
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pop pragams
|
||||
|
||||
#endif // BOOST_ARCHIVE_BASIC_BINARY_OPRIMITIVE_HPP
|
@ -0,0 +1,61 @@
|
||||
#ifndef BOOST_ARCHIVE_BASIC_STREAMBUF_LOCALE_SAVER_HPP
|
||||
#define BOOST_ARCHIVE_BASIC_STREAMBUF_LOCALE_SAVER_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// basic_streambuf_local_saver.hpp
|
||||
|
||||
// (C) Copyright 2005 Robert Ramey - http://www.rrsd.com
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
// note derived from boost/io/ios_state.hpp
|
||||
// Copyright 2002, 2005 Daryle Walker. Use, modification, and distribution
|
||||
// are subject to the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or a copy at <http://www.boost.org/LICENSE_1_0.txt>.)
|
||||
|
||||
// See <http://www.boost.org/libs/io/> for the library's home page.
|
||||
|
||||
#ifndef BOOST_NO_STD_LOCALE
|
||||
#include <locale> // for std::locale
|
||||
#endif
|
||||
#include <streambuf> // for std::basic_streambuf
|
||||
|
||||
namespace boost{
|
||||
namespace archive{
|
||||
|
||||
#ifndef BOOST_NO_STD_LOCALE
|
||||
template < typename Ch, class Tr >
|
||||
class basic_streambuf_locale_saver
|
||||
{
|
||||
public:
|
||||
typedef ::std::basic_streambuf<Ch, Tr> state_type;
|
||||
typedef ::std::locale aspect_type;
|
||||
explicit basic_streambuf_locale_saver( state_type &s )
|
||||
: s_save_( s ), a_save_( s.getloc() )
|
||||
{}
|
||||
basic_streambuf_locale_saver( state_type &s, aspect_type const &a )
|
||||
: s_save_( s ), a_save_( s.pubimbue(a) )
|
||||
{}
|
||||
~basic_streambuf_locale_saver()
|
||||
{ this->restore(); }
|
||||
void restore()
|
||||
{ s_save_.pubimbue( a_save_ ); }
|
||||
private:
|
||||
state_type & s_save_;
|
||||
aspect_type const a_save_;
|
||||
};
|
||||
|
||||
} // archive
|
||||
} // boost
|
||||
|
||||
#endif // BOOST_NO_STD_LOCALE
|
||||
#endif // BOOST_ARCHIVE_BASIC_STREAMBUF_LOCALE_SAVER_HPP
|
@ -0,0 +1,94 @@
|
||||
#ifndef BOOST_ARCHIVE_BASIC_TEXT_IARCHIVE_HPP
|
||||
#define BOOST_ARCHIVE_BASIC_TEXT_IARCHIVE_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// basic_text_iarchive.hpp
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
// archives stored as text - note these ar templated on the basic
|
||||
// stream templates to accommodate wide (and other?) kind of characters
|
||||
//
|
||||
// note the fact that on libraries without wide characters, ostream is
|
||||
// is not a specialization of basic_ostream which in fact is not defined
|
||||
// in such cases. So we can't use basic_ostream<IStream::char_type> but rather
|
||||
// use two template parameters
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/pfto.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#include <boost/archive/detail/common_iarchive.hpp>
|
||||
#include <boost/serialization/string.hpp>
|
||||
|
||||
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// class basic_text_iarchive - read serialized objects from a input text stream
|
||||
template<class Archive>
|
||||
class basic_text_iarchive :
|
||||
public detail::common_iarchive<Archive>
|
||||
{
|
||||
protected:
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
public:
|
||||
#elif defined(BOOST_MSVC)
|
||||
// for some inexplicable reason insertion of "class" generates compile erro
|
||||
// on msvc 7.1
|
||||
friend detail::interface_iarchive<Archive>;
|
||||
#else
|
||||
friend class detail::interface_iarchive<Archive>;
|
||||
#endif
|
||||
// intermediate level to support override of operators
|
||||
// fot templates in the absence of partial function
|
||||
// template ordering
|
||||
typedef detail::common_iarchive<Archive> detail_common_iarchive;
|
||||
template<class T>
|
||||
void load_override(T & t, BOOST_PFTO int)
|
||||
{
|
||||
this->detail_common_iarchive::load_override(t, 0);
|
||||
}
|
||||
#if 0
|
||||
// Borland compilers has a problem with strong type. Try to fix this here
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
|
||||
void load_override(version_type & t, int){
|
||||
unsigned int x;
|
||||
* this->This() >> x;
|
||||
t.t = version_type(x);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
// text file don't include the optional information
|
||||
void load_override(class_id_optional_type & /*t*/, int){}
|
||||
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
load_override(class_name_type & t, int);
|
||||
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
init(void);
|
||||
|
||||
basic_text_iarchive(unsigned int flags) :
|
||||
detail::common_iarchive<Archive>(flags)
|
||||
{}
|
||||
~basic_text_iarchive(){}
|
||||
};
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
#endif // BOOST_ARCHIVE_BASIC_TEXT_IARCHIVE_HPP
|
@ -0,0 +1,130 @@
|
||||
#ifndef BOOST_ARCHIVE_BASIC_TEXT_IPRIMITIVE_HPP
|
||||
#define BOOST_ARCHIVE_BASIC_TEXT_IPRIMITIVE_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// basic_text_iprimitive.hpp
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
// archives stored as text - note these ar templated on the basic
|
||||
// stream templates to accommodate wide (and other?) kind of characters
|
||||
//
|
||||
// note the fact that on libraries without wide characters, ostream is
|
||||
// is not a specialization of basic_ostream which in fact is not defined
|
||||
// in such cases. So we can't use basic_ostream<IStream::char_type> but rather
|
||||
// use two template parameters
|
||||
|
||||
#include <cassert>
|
||||
#include <locale>
|
||||
#include <cstddef> // size_t
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std{
|
||||
using ::size_t;
|
||||
#if ! defined(BOOST_DINKUMWARE_STDLIB) && ! defined(__SGI_STL_PORT)
|
||||
using ::locale;
|
||||
#endif
|
||||
} // namespace std
|
||||
#endif
|
||||
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1)
|
||||
#include <boost/archive/dinkumware.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/io/ios_state.hpp>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
#include <boost/archive/archive_exception.hpp>
|
||||
|
||||
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// class basic_text_iarchive - load serialized objects from a input text stream
|
||||
template<class IStream>
|
||||
class basic_text_iprimitive
|
||||
{
|
||||
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
protected:
|
||||
#else
|
||||
public:
|
||||
#endif
|
||||
IStream &is;
|
||||
io::ios_flags_saver flags_saver;
|
||||
io::ios_precision_saver precision_saver;
|
||||
boost::scoped_ptr<std::locale> archive_locale;
|
||||
io::basic_ios_locale_saver<
|
||||
BOOST_DEDUCED_TYPENAME IStream::char_type, BOOST_DEDUCED_TYPENAME IStream::traits_type
|
||||
> locale_saver;
|
||||
template<class T>
|
||||
void load(T & t)
|
||||
{
|
||||
if(is.fail())
|
||||
boost::throw_exception(archive_exception(archive_exception::stream_error));
|
||||
is >> t;
|
||||
}
|
||||
void load(unsigned char & t)
|
||||
{
|
||||
if(is.fail())
|
||||
boost::throw_exception(archive_exception(archive_exception::stream_error));
|
||||
unsigned short int i;
|
||||
is >> i;
|
||||
t = static_cast<unsigned char>(i);
|
||||
}
|
||||
void load(signed char & t)
|
||||
{
|
||||
if(is.fail())
|
||||
boost::throw_exception(archive_exception(archive_exception::stream_error));
|
||||
signed short int i;
|
||||
is >> i;
|
||||
t = static_cast<signed char>(i);
|
||||
}
|
||||
void load(char & t)
|
||||
{
|
||||
if(is.fail())
|
||||
boost::throw_exception(archive_exception(archive_exception::stream_error));
|
||||
short int i;
|
||||
is >> i;
|
||||
t = static_cast<char>(i);
|
||||
}
|
||||
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
|
||||
void load(wchar_t & t)
|
||||
{
|
||||
if(is.fail())
|
||||
boost::throw_exception(archive_exception(archive_exception::stream_error));
|
||||
unsigned i;
|
||||
is >> i;
|
||||
t = static_cast<wchar_t>(i);
|
||||
}
|
||||
#endif
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
|
||||
basic_text_iprimitive(IStream &is, bool no_codecvt);
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
|
||||
~basic_text_iprimitive();
|
||||
public:
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
load_binary(void *address, std::size_t count);
|
||||
};
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pop pragams
|
||||
|
||||
#endif // BOOST_ARCHIVE_BASIC_TEXT_IPRIMITIVE_HPP
|
@ -0,0 +1,134 @@
|
||||
#ifndef BOOST_ARCHIVE_BASIC_TEXT_OARCHIVE_HPP
|
||||
#define BOOST_ARCHIVE_BASIC_TEXT_OARCHIVE_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// basic_text_oarchive.hpp
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
// archives stored as text - note these ar templated on the basic
|
||||
// stream templates to accommodate wide (and other?) kind of characters
|
||||
//
|
||||
// note the fact that on libraries without wide characters, ostream is
|
||||
// is not a specialization of basic_ostream which in fact is not defined
|
||||
// in such cases. So we can't use basic_ostream<OStream::char_type> but rather
|
||||
// use two template parameters
|
||||
|
||||
#include <cassert>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/pfto.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#include <boost/archive/detail/common_oarchive.hpp>
|
||||
#include <boost/serialization/string.hpp>
|
||||
|
||||
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// class basic_text_iarchive - read serialized objects from a input text stream
|
||||
template<class Archive>
|
||||
class basic_text_oarchive :
|
||||
public detail::common_oarchive<Archive>
|
||||
{
|
||||
protected:
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) \
|
||||
|| BOOST_WORKAROUND(__BORLANDC__,BOOST_TESTED_AT(0x560))
|
||||
public:
|
||||
#elif defined(BOOST_MSVC)
|
||||
// for some inexplicable reason insertion of "class" generates compile erro
|
||||
// on msvc 7.1
|
||||
friend detail::interface_oarchive<Archive>;
|
||||
#else
|
||||
friend class detail::interface_oarchive<Archive>;
|
||||
#endif
|
||||
enum {
|
||||
none,
|
||||
eol,
|
||||
space
|
||||
} delimiter;
|
||||
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
newtoken();
|
||||
|
||||
void newline(){
|
||||
delimiter = eol;
|
||||
}
|
||||
|
||||
// default processing - kick back to base class. Note the
|
||||
// extra stuff to get it passed borland compilers
|
||||
typedef detail::common_oarchive<Archive> detail_common_oarchive;
|
||||
template<class T>
|
||||
void save_override(T & t, BOOST_PFTO int){
|
||||
this->detail_common_oarchive::save_override(t, 0);
|
||||
}
|
||||
|
||||
// start new objects on a new line
|
||||
void save_override(const object_id_type & t, int){
|
||||
this->This()->newline();
|
||||
// note extra .t to funciton with Borland 5.51 compiler
|
||||
// and invoke prmitive to underlying value
|
||||
this->This()->save(t.t);
|
||||
}
|
||||
|
||||
void save_override(const object_reference_type & t, int){
|
||||
this->This()->newline();
|
||||
// note extra .t to funciton with Borland 5.51 compiler
|
||||
// and invoke prmitive to underlying value
|
||||
this->This()->save(t.t);
|
||||
}
|
||||
|
||||
// note the following four overrides are necessary for some borland
|
||||
// compilers(5.51) which don't handle BOOST_STRONG_TYPE properly.
|
||||
void save_override(const version_type & t, int){
|
||||
// note:t.t resolves borland ambguity
|
||||
const unsigned int x = t.t;
|
||||
* this->This() << x;
|
||||
}
|
||||
void save_override(const class_id_type & t, int){
|
||||
// note:t.t resolves borland ambguity
|
||||
const int x = t.t;
|
||||
* this->This() << x;
|
||||
}
|
||||
void save_override(const class_id_reference_type & t, int){
|
||||
// note:t.t resolves borland ambguity
|
||||
const int x = t.t;
|
||||
* this->This() << x;
|
||||
}
|
||||
|
||||
// text file don't include the optional information
|
||||
void save_override(const class_id_optional_type & /* t */, int){}
|
||||
|
||||
void save_override(const class_name_type & t, int){
|
||||
const std::string s(t);
|
||||
* this->This() << s;
|
||||
}
|
||||
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
init();
|
||||
|
||||
basic_text_oarchive(unsigned int flags) :
|
||||
detail::common_oarchive<Archive>(flags),
|
||||
delimiter(none)
|
||||
{}
|
||||
~basic_text_oarchive(){}
|
||||
};
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
#endif // BOOST_ARCHIVE_BASIC_TEXT_OARCHIVE_HPP
|
@ -0,0 +1,167 @@
|
||||
#ifndef BOOST_ARCHIVE_BASIC_TEXT_OPRIMITIVE_HPP
|
||||
#define BOOST_ARCHIVE_BASIC_TEXT_OPRIMITIVE_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// basic_text_oprimitive.hpp
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
// archives stored as text - note these ar templated on the basic
|
||||
// stream templates to accommodate wide (and other?) kind of characters
|
||||
//
|
||||
// note the fact that on libraries without wide characters, ostream is
|
||||
// is not a specialization of basic_ostream which in fact is not defined
|
||||
// in such cases. So we can't use basic_ostream<OStream::char_type> but rather
|
||||
// use two template parameters
|
||||
|
||||
#include <iomanip>
|
||||
#include <locale>
|
||||
#include <cstddef> // size_t
|
||||
#include <cmath> // isnan
|
||||
#include <cassert>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1)
|
||||
#include <boost/archive/dinkumware.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std{
|
||||
using ::size_t;
|
||||
#if ! defined(BOOST_DINKUMWARE_STDLIB) && ! defined(__SGI_STL_PORT)
|
||||
using ::locale;
|
||||
#endif
|
||||
} // namespace std
|
||||
#endif
|
||||
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/io/ios_state.hpp>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/archive/archive_exception.hpp>
|
||||
|
||||
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
class save_access;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// class basic_text_oprimitive - output of prmitives to stream
|
||||
template<class OStream>
|
||||
class basic_text_oprimitive
|
||||
{
|
||||
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
protected:
|
||||
#else
|
||||
public:
|
||||
#endif
|
||||
OStream &os;
|
||||
io::ios_flags_saver flags_saver;
|
||||
io::ios_precision_saver precision_saver;
|
||||
boost::scoped_ptr<std::locale> archive_locale;
|
||||
io::basic_ios_locale_saver<
|
||||
BOOST_DEDUCED_TYPENAME OStream::char_type, BOOST_DEDUCED_TYPENAME OStream::traits_type
|
||||
> locale_saver;
|
||||
|
||||
// default saving of primitives.
|
||||
template<class T>
|
||||
void save(const T &t){
|
||||
if(os.fail())
|
||||
boost::throw_exception(archive_exception(archive_exception::stream_error));
|
||||
os << t;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
// fundamental types that need special treatment
|
||||
void save(const bool t){
|
||||
// trap usage of invalid uninitialized boolean which would
|
||||
// otherwise crash on load.
|
||||
int i = t;
|
||||
assert(0 == i || 1 == i);
|
||||
if(os.fail())
|
||||
boost::throw_exception(archive_exception(archive_exception::stream_error));
|
||||
os << t;
|
||||
}
|
||||
void save(const signed char t)
|
||||
{
|
||||
if(os.fail())
|
||||
boost::throw_exception(archive_exception(archive_exception::stream_error));
|
||||
os << static_cast<short int>(t);
|
||||
}
|
||||
void save(const unsigned char t)
|
||||
{
|
||||
if(os.fail())
|
||||
boost::throw_exception(archive_exception(archive_exception::stream_error));
|
||||
os << static_cast<short unsigned int>(t);
|
||||
}
|
||||
void save(const char t)
|
||||
{
|
||||
if(os.fail())
|
||||
boost::throw_exception(archive_exception(archive_exception::stream_error));
|
||||
os << static_cast<short int>(t);
|
||||
}
|
||||
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
|
||||
void save(const wchar_t t)
|
||||
{
|
||||
if(os.fail())
|
||||
boost::throw_exception(archive_exception(archive_exception::stream_error));
|
||||
os << static_cast<int>(t);
|
||||
}
|
||||
#endif
|
||||
void save(const float t)
|
||||
{
|
||||
// must be a user mistake - can't serialize un-initialized data
|
||||
if(os.fail())
|
||||
boost::throw_exception(archive_exception(archive_exception::stream_error));
|
||||
os << std::setprecision(std::numeric_limits<float>::digits10 + 2);
|
||||
os << t;
|
||||
}
|
||||
void save(const double t)
|
||||
{
|
||||
// must be a user mistake - can't serialize un-initialized data
|
||||
if(os.fail())
|
||||
boost::throw_exception(archive_exception(archive_exception::stream_error));
|
||||
os << std::setprecision(std::numeric_limits<double>::digits10 + 2);
|
||||
os << t;
|
||||
}
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
|
||||
basic_text_oprimitive(OStream & os, bool no_codecvt);
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
|
||||
~basic_text_oprimitive();
|
||||
public:
|
||||
// unformatted append of one character
|
||||
void put(int c){
|
||||
if(os.fail())
|
||||
boost::throw_exception(archive_exception(archive_exception::stream_error));
|
||||
os.put(c);
|
||||
}
|
||||
// unformatted append of null terminated string
|
||||
void put(const char * s){
|
||||
if(os.fail())
|
||||
boost::throw_exception(archive_exception(archive_exception::stream_error));
|
||||
while('\0' != *s)
|
||||
os.put(*s++);
|
||||
}
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
save_binary(const void *address, std::size_t count);
|
||||
};
|
||||
|
||||
} //namespace boost
|
||||
} //namespace archive
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
#endif // BOOST_ARCHIVE_BASIC_TEXT_OPRIMITIVE_HPP
|
@ -0,0 +1,102 @@
|
||||
#ifndef BOOST_ARCHIVE_BASIC_XML_TEXT_ARCHIVE_HPP
|
||||
#define BOOST_ARCHIVE_BASIC_XML_TEXT_ARCHIVE_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// basic_xml_archive.hpp:
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <boost/archive/detail/auto_link_archive.hpp>
|
||||
#include <boost/archive/archive_exception.hpp>
|
||||
|
||||
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// exceptions thrown by xml archives
|
||||
//
|
||||
class xml_archive_exception :
|
||||
public virtual archive_exception
|
||||
{
|
||||
public:
|
||||
typedef enum {
|
||||
xml_archive_parsing_error, // see save_register
|
||||
xml_archive_tag_mismatch,
|
||||
xml_archive_tag_name_error
|
||||
} exception_code;
|
||||
xml_archive_exception(exception_code c)
|
||||
{}
|
||||
virtual const char *what( ) const throw( )
|
||||
{
|
||||
const char *msg;
|
||||
switch(code){
|
||||
case xml_archive_parsing_error:
|
||||
msg = "unrecognized XML syntax";
|
||||
break;
|
||||
case xml_archive_tag_mismatch:
|
||||
msg = "XML start/end tag mismatch";
|
||||
break;
|
||||
case xml_archive_tag_name_error:
|
||||
msg = "Invalid XML tag name";
|
||||
break;
|
||||
default:
|
||||
msg = archive_exception::what();
|
||||
break;
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
};
|
||||
|
||||
// constant strings used in xml i/o
|
||||
|
||||
extern
|
||||
BOOST_ARCHIVE_DECL(const char *)
|
||||
OBJECT_ID();
|
||||
|
||||
extern
|
||||
BOOST_ARCHIVE_DECL(const char *)
|
||||
OBJECT_REFERENCE();
|
||||
|
||||
extern
|
||||
BOOST_ARCHIVE_DECL(const char *)
|
||||
CLASS_ID();
|
||||
|
||||
extern
|
||||
BOOST_ARCHIVE_DECL(const char *)
|
||||
CLASS_ID_REFERENCE();
|
||||
|
||||
extern
|
||||
BOOST_ARCHIVE_DECL(const char *)
|
||||
CLASS_NAME();
|
||||
|
||||
extern
|
||||
BOOST_ARCHIVE_DECL(const char *)
|
||||
TRACKING();
|
||||
|
||||
extern
|
||||
BOOST_ARCHIVE_DECL(const char *)
|
||||
VERSION();
|
||||
|
||||
extern
|
||||
BOOST_ARCHIVE_DECL(const char *)
|
||||
SIGNATURE();
|
||||
|
||||
}// namespace archive
|
||||
}// namespace boost
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
#endif // BOOST_ARCHIVE_BASIC_XML_TEXT_ARCHIVE_HPP
|
||||
|
@ -0,0 +1,118 @@
|
||||
#ifndef BOOST_ARCHIVE_BASIC_XML_IARCHIVE_HPP
|
||||
#define BOOST_ARCHIVE_BASIC_XML_IARCHIVE_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// basic_xml_iarchive.hpp
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/pfto.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#include <boost/archive/detail/common_iarchive.hpp>
|
||||
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
#include <boost/serialization/string.hpp>
|
||||
|
||||
#include <boost/mpl/assert.hpp>
|
||||
|
||||
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// class xml_iarchive - read serialized objects from a input text stream
|
||||
template<class Archive>
|
||||
class basic_xml_iarchive :
|
||||
public detail::common_iarchive<Archive>
|
||||
{
|
||||
protected:
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
public:
|
||||
#elif defined(BOOST_MSVC)
|
||||
// for some inexplicable reason insertion of "class" generates compile erro
|
||||
// on msvc 7.1
|
||||
friend detail::interface_oarchive<Archive>;
|
||||
#else
|
||||
friend class detail::interface_oarchive<Archive>;
|
||||
#endif
|
||||
unsigned int depth;
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
load_start(const char *name);
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
load_end(const char *name);
|
||||
|
||||
// Anything not an attribute and not a name-value pair is an
|
||||
// should be trapped here.
|
||||
template<class T>
|
||||
void load_override(T & t, BOOST_PFTO int)
|
||||
{
|
||||
// If your program fails to compile here, its most likely due to
|
||||
// not specifying an nvp wrapper around the variable to
|
||||
// be serialized.
|
||||
BOOST_MPL_ASSERT((serialization::is_wrapper<T>));
|
||||
this->detail_common_iarchive::load_override(t, 0);
|
||||
}
|
||||
|
||||
// Anything not an attribute - see below - should be a name value
|
||||
// pair and be processed here
|
||||
typedef detail::common_iarchive<Archive> detail_common_iarchive;
|
||||
template<class T>
|
||||
void load_override(
|
||||
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
const
|
||||
#endif
|
||||
boost::serialization::nvp<T> & t,
|
||||
int
|
||||
){
|
||||
load_start(t.name());
|
||||
this->detail_common_iarchive::load_override(t.value(), 0);
|
||||
load_end(t.name());
|
||||
}
|
||||
|
||||
// specific overrides for attributes - handle as
|
||||
// primitives. These are not name-value pairs
|
||||
// so they have to be intercepted here and passed on to load.
|
||||
// although the class_id is included in the xml text file in order
|
||||
// to make the file self describing, it isn't used when loading
|
||||
// an xml archive. So we can skip it here. Note: we MUST override
|
||||
// it otherwise it will be loaded as a normal primitive w/o tag and
|
||||
// leaving the archive in an undetermined state
|
||||
void load_override(class_id_optional_type & /* t */, int){}
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
load_override(object_id_type & t, int);
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
load_override(version_type & t, int);
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
load_override(class_id_type & t, int);
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
load_override(tracking_type & t, int);
|
||||
// class_name_type can't be handled here as it depends upon the
|
||||
// char type used by the stream. So require the derived implementation
|
||||
// handle this.
|
||||
// void load_override(class_name_type & t, int);
|
||||
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
|
||||
basic_xml_iarchive(unsigned int flags);
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
|
||||
~basic_xml_iarchive();
|
||||
};
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
#endif // BOOST_ARCHIVE_BASIC_XML_IARCHIVE_HPP
|
@ -0,0 +1,137 @@
|
||||
#ifndef BOOST_ARCHIVE_BASIC_XML_OARCHIVE_HPP
|
||||
#define BOOST_ARCHIVE_BASIC_XML_OARCHIVE_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// basic_xml_oarchive.hpp
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#include <boost/archive/detail/common_oarchive.hpp>
|
||||
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
#include <boost/serialization/tracking.hpp>
|
||||
#include <boost/serialization/string.hpp>
|
||||
|
||||
#include <boost/mpl/assert.hpp>
|
||||
|
||||
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
|
||||
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// class basic_xml_oarchive - write serialized objects to a xml output stream
|
||||
template<class Archive>
|
||||
class basic_xml_oarchive :
|
||||
public detail::common_oarchive<Archive>
|
||||
{
|
||||
protected:
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
public:
|
||||
#elif defined(BOOST_MSVC)
|
||||
// for some inexplicable reason insertion of "class" generates compile erro
|
||||
// on msvc 7.1
|
||||
friend detail::interface_oarchive<Archive>;
|
||||
friend class save_access;
|
||||
#else
|
||||
friend class detail::interface_oarchive<Archive>;
|
||||
friend class save_access;
|
||||
#endif
|
||||
// special stuff for xml output
|
||||
unsigned int depth;
|
||||
bool indent_next;
|
||||
bool pending_preamble;
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
indent();
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
init();
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
write_attribute(
|
||||
const char *attribute_name,
|
||||
int t,
|
||||
const char *conjunction = "=\""
|
||||
);
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
write_attribute(
|
||||
const char *attribute_name,
|
||||
const char *key
|
||||
);
|
||||
// helpers used below
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
save_start(const char *name);
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
save_end(const char *name);
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
end_preamble();
|
||||
|
||||
// Anything not an attribute and not a name-value pair is an
|
||||
// error and should be trapped here.
|
||||
template<class T>
|
||||
void save_override(T & t, BOOST_PFTO int)
|
||||
{
|
||||
// If your program fails to compile here, its most likely due to
|
||||
// not specifying an nvp wrapper around the variable to
|
||||
// be serialized.
|
||||
BOOST_MPL_ASSERT((serialization::is_wrapper<T>));
|
||||
this->detail_common_oarchive::save_override(t, 0);
|
||||
}
|
||||
|
||||
// special treatment for name-value pairs.
|
||||
typedef detail::common_oarchive<Archive> detail_common_oarchive;
|
||||
template<class T>
|
||||
void save_override(
|
||||
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
const
|
||||
#endif
|
||||
::boost::serialization::nvp<T> & t,
|
||||
int
|
||||
){
|
||||
save_start(t.name());
|
||||
this->detail_common_oarchive::save_override(t.const_value(), 0);
|
||||
save_end(t.name());
|
||||
}
|
||||
|
||||
// specific overrides for attributes - not name value pairs so we
|
||||
// want to trap them before the above "fall through"
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
save_override(const object_id_type & t, int);
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
save_override(const object_reference_type & t, int);
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
save_override(const version_type & t, int);
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
save_override(const class_id_type & t, int);
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
save_override(const class_id_optional_type & t, int);
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
save_override(const class_id_reference_type & t, int);
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
save_override(const class_name_type & t, int);
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
save_override(const tracking_type & t, int);
|
||||
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
|
||||
basic_xml_oarchive(unsigned int flags);
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
|
||||
~basic_xml_oarchive();
|
||||
};
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
#endif // BOOST_ARCHIVE_BASIC_XML_OARCHIVE_HPP
|
@ -0,0 +1,92 @@
|
||||
#ifndef BOOST_ARCHIVE_BINARY_IARCHIVE_HPP
|
||||
#define BOOST_ARCHIVE_BINARY_IARCHIVE_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// binary_iarchive.hpp
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <istream>
|
||||
#include <boost/archive/binary_iarchive_impl.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
// do not derive from the classes below. If you want to extend this functionality
|
||||
// via inhertance, derived from text_iarchive_impl instead. This will
|
||||
// preserve correct static polymorphism.
|
||||
|
||||
// same as binary_iarchive below - without the shared_ptr_helper
|
||||
class naked_binary_iarchive :
|
||||
public binary_iarchive_impl<
|
||||
boost::archive::naked_binary_iarchive,
|
||||
std::istream::char_type,
|
||||
std::istream::traits_type
|
||||
>
|
||||
{
|
||||
public:
|
||||
naked_binary_iarchive(std::istream & is, unsigned int flags = 0) :
|
||||
binary_iarchive_impl<
|
||||
naked_binary_iarchive, std::istream::char_type, std::istream::traits_type
|
||||
>(is, flags)
|
||||
{}
|
||||
naked_binary_iarchive(std::streambuf & bsb, unsigned int flags = 0) :
|
||||
binary_iarchive_impl<
|
||||
naked_binary_iarchive, std::istream::char_type, std::istream::traits_type
|
||||
>(bsb, flags)
|
||||
{}
|
||||
};
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// note special treatment of shared_ptr. This type needs a special
|
||||
// structure associated with every archive. We created a "mix-in"
|
||||
// class to provide this functionality. Since shared_ptr holds a
|
||||
// special esteem in the boost library - we included it here by default.
|
||||
#include <boost/archive/shared_ptr_helper.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
// do not derive from this class. If you want to extend this functionality
|
||||
// via inhertance, derived from binary_iarchive_impl instead. This will
|
||||
// preserve correct static polymorphism.
|
||||
class binary_iarchive :
|
||||
public binary_iarchive_impl<
|
||||
boost::archive::binary_iarchive,
|
||||
std::istream::char_type,
|
||||
std::istream::traits_type
|
||||
>,
|
||||
public detail::shared_ptr_helper
|
||||
{
|
||||
public:
|
||||
binary_iarchive(std::istream & is, unsigned int flags = 0) :
|
||||
binary_iarchive_impl<
|
||||
binary_iarchive, std::istream::char_type, std::istream::traits_type
|
||||
>(is, flags)
|
||||
{}
|
||||
binary_iarchive(std::streambuf & bsb, unsigned int flags = 0) :
|
||||
binary_iarchive_impl<
|
||||
binary_iarchive, std::istream::char_type, std::istream::traits_type
|
||||
>(bsb, flags)
|
||||
{}
|
||||
};
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::binary_iarchive)
|
||||
|
||||
#endif // BOOST_ARCHIVE_BINARY_IARCHIVE_HPP
|
@ -0,0 +1,87 @@
|
||||
#ifndef BOOST_ARCHIVE_BINARY_IARCHIVE_IMPL_HPP
|
||||
#define BOOST_ARCHIVE_BINARY_IARCHIVE_IMPL_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// binary_iarchive_impl.hpp
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <istream>
|
||||
#include <boost/pfto.hpp>
|
||||
#include <boost/archive/basic_binary_iprimitive.hpp>
|
||||
#include <boost/archive/basic_binary_iarchive.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
template<class Archive, class Elem, class Tr>
|
||||
class binary_iarchive_impl :
|
||||
public basic_binary_iprimitive<Archive, Elem, Tr>,
|
||||
public basic_binary_iarchive<Archive>
|
||||
{
|
||||
#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
public:
|
||||
#else
|
||||
friend class detail::interface_iarchive<Archive>;
|
||||
friend class basic_binary_iarchive<Archive>;
|
||||
friend class load_access;
|
||||
protected:
|
||||
#endif
|
||||
// note: the following should not needed - but one compiler (vc 7.1)
|
||||
// fails to compile one test (test_shared_ptr) without it !!!
|
||||
// make this protected so it can be called from a derived archive
|
||||
template<class T>
|
||||
void load_override(T & t, BOOST_PFTO int){
|
||||
basic_binary_iarchive<Archive>::load_override(t, 0);
|
||||
}
|
||||
void init(unsigned int flags){
|
||||
if(0 != (flags & no_header))
|
||||
return;
|
||||
#if ! defined(__MWERKS__)
|
||||
this->basic_binary_iarchive<Archive>::init();
|
||||
this->basic_binary_iprimitive<Archive, Elem, Tr>::init();
|
||||
#else
|
||||
basic_binary_iarchive<Archive>::init();
|
||||
basic_binary_iprimitive<Archive, Elem, Tr>::init();
|
||||
#endif
|
||||
}
|
||||
binary_iarchive_impl(
|
||||
std::basic_streambuf<Elem, Tr> & bsb,
|
||||
unsigned int flags
|
||||
) :
|
||||
basic_binary_iprimitive<Archive, Elem, Tr>(
|
||||
bsb,
|
||||
0 != (flags & no_codecvt)
|
||||
),
|
||||
basic_binary_iarchive<Archive>(flags)
|
||||
{
|
||||
init(flags);
|
||||
}
|
||||
binary_iarchive_impl(
|
||||
std::basic_istream<Elem, Tr> & is,
|
||||
unsigned int flags
|
||||
) :
|
||||
basic_binary_iprimitive<Archive, Elem, Tr>(
|
||||
* is.rdbuf(),
|
||||
0 != (flags & no_codecvt)
|
||||
),
|
||||
basic_binary_iarchive<Archive>(flags)
|
||||
{
|
||||
init(flags);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_ARCHIVE_BINARY_IARCHIVE_IMPL_HPP
|
@ -0,0 +1,54 @@
|
||||
#ifndef BOOST_ARCHIVE_BINARY_OARCHIVE_HPP
|
||||
#define BOOST_ARCHIVE_BINARY_OARCHIVE_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// binary_oarchive.hpp
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <ostream>
|
||||
#include <boost/archive/binary_oarchive_impl.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
// do not derive from this class. If you want to extend this functionality
|
||||
// via inhertance, derived from binary_oarchive_impl instead. This will
|
||||
// preserve correct static polymorphism.
|
||||
class binary_oarchive :
|
||||
public binary_oarchive_impl<
|
||||
binary_oarchive, std::ostream::char_type, std::ostream::traits_type
|
||||
>
|
||||
{
|
||||
public:
|
||||
binary_oarchive(std::ostream & os, unsigned int flags = 0) :
|
||||
binary_oarchive_impl<
|
||||
binary_oarchive, std::ostream::char_type, std::ostream::traits_type
|
||||
>(os, flags)
|
||||
{}
|
||||
binary_oarchive(std::streambuf & bsb, unsigned int flags = 0) :
|
||||
binary_oarchive_impl<
|
||||
binary_oarchive, std::ostream::char_type, std::ostream::traits_type
|
||||
>(bsb, flags)
|
||||
{}
|
||||
};
|
||||
|
||||
typedef binary_oarchive naked_binary_oarchive;
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::binary_oarchive)
|
||||
|
||||
#endif // BOOST_ARCHIVE_BINARY_OARCHIVE_HPP
|
@ -0,0 +1,87 @@
|
||||
#ifndef BOOST_ARCHIVE_BINARY_OARCHIVE_IMPL_HPP
|
||||
#define BOOST_ARCHIVE_BINARY_OARCHIVE_IMPL_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// binary_oarchive_impl.hpp
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <ostream>
|
||||
#include <boost/pfto.hpp>
|
||||
#include <boost/archive/basic_binary_oprimitive.hpp>
|
||||
#include <boost/archive/basic_binary_oarchive.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
template<class Archive, class Elem, class Tr>
|
||||
class binary_oarchive_impl :
|
||||
public basic_binary_oprimitive<Archive, Elem, Tr>,
|
||||
public basic_binary_oarchive<Archive>
|
||||
{
|
||||
#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
public:
|
||||
#else
|
||||
friend class detail::interface_oarchive<Archive>;
|
||||
friend class basic_binary_oarchive<Archive>;
|
||||
friend class save_access;
|
||||
protected:
|
||||
#endif
|
||||
// note: the following should not needed - but one compiler (vc 7.1)
|
||||
// fails to compile one test (test_shared_ptr) without it !!!
|
||||
// make this protected so it can be called from a derived archive
|
||||
template<class T>
|
||||
void save_override(T & t, BOOST_PFTO int){
|
||||
basic_binary_oarchive<Archive>::save_override(t, 0);
|
||||
}
|
||||
void init(unsigned int flags) {
|
||||
if(0 != (flags & no_header))
|
||||
return;
|
||||
#if ! defined(__MWERKS__)
|
||||
this->basic_binary_oarchive<Archive>::init();
|
||||
this->basic_binary_oprimitive<Archive, Elem, Tr>::init();
|
||||
#else
|
||||
basic_binary_oarchive<Archive>::init();
|
||||
basic_binary_oprimitive<Archive, Elem, Tr>::init();
|
||||
#endif
|
||||
}
|
||||
binary_oarchive_impl(
|
||||
std::basic_streambuf<Elem, Tr> & bsb,
|
||||
unsigned int flags
|
||||
) :
|
||||
basic_binary_oprimitive<Archive, Elem, Tr>(
|
||||
bsb,
|
||||
0 != (flags & no_codecvt)
|
||||
),
|
||||
basic_binary_oarchive<Archive>(flags)
|
||||
{
|
||||
init(flags);
|
||||
}
|
||||
binary_oarchive_impl(
|
||||
std::basic_ostream<Elem, Tr> & os,
|
||||
unsigned int flags
|
||||
) :
|
||||
basic_binary_oprimitive<Archive, Elem, Tr>(
|
||||
* os.rdbuf(),
|
||||
0 != (flags & no_codecvt)
|
||||
),
|
||||
basic_binary_oarchive<Archive>(flags)
|
||||
{
|
||||
init(flags);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_ARCHIVE_BINARY_OARCHIVE_IMPL_HPP
|
@ -0,0 +1,92 @@
|
||||
#ifndef BOOST_ARCHIVE_BINARY_WIARCHIVE_HPP
|
||||
#define BOOST_ARCHIVE_BINARY_WIARCHIVE_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// binary_wiarchive.hpp
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#ifdef BOOST_NO_STD_WSTREAMBUF
|
||||
#error "wide char i/o not supported on this platform"
|
||||
#else
|
||||
|
||||
#include <istream> // wistream
|
||||
#include <boost/archive/binary_iarchive_impl.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
// same as binary_wiarchive below - without the shared_ptr_helper
|
||||
class naked_binary_wiarchive :
|
||||
public binary_iarchive_impl<
|
||||
boost::archive::naked_binary_wiarchive,
|
||||
std::wistream::char_type,
|
||||
std::wistream::traits_type
|
||||
>
|
||||
{
|
||||
public:
|
||||
naked_binary_wiarchive(std::wistream & is, unsigned int flags = 0) :
|
||||
binary_iarchive_impl<
|
||||
naked_binary_wiarchive,
|
||||
std::wistream::char_type,
|
||||
std::wistream::traits_type
|
||||
>(is, flags)
|
||||
{}
|
||||
naked_binary_wiarchive(std::wstreambuf & bsb, unsigned int flags = 0) :
|
||||
binary_iarchive_impl<
|
||||
naked_binary_wiarchive,
|
||||
std::wistream::char_type,
|
||||
std::wistream::traits_type
|
||||
>(bsb, flags)
|
||||
{}
|
||||
};
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// note special treatment of shared_ptr. This type needs a special
|
||||
// structure associated with every archive. We created a "mix-in"
|
||||
// class to provide this functionality. Since shared_ptr holds a
|
||||
// special esteem in the boost library - we included it here by default.
|
||||
#include <boost/archive/shared_ptr_helper.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
class binary_wiarchive :
|
||||
public binary_iarchive_impl<
|
||||
binary_wiarchive, std::wistream::char_type, std::wistream::traits_type
|
||||
>
|
||||
{
|
||||
public:
|
||||
binary_wiarchive(std::wistream & is, unsigned int flags = 0) :
|
||||
binary_iarchive_impl<
|
||||
binary_wiarchive, std::wistream::char_type, std::wistream::traits_type
|
||||
>(is, flags)
|
||||
{}
|
||||
binary_wiarchive(std::wstreambuf & bsb, unsigned int flags = 0) :
|
||||
binary_iarchive_impl<
|
||||
binary_wiarchive, std::wistream::char_type, std::wistream::traits_type
|
||||
>(bsb, flags)
|
||||
{}
|
||||
};
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::binary_wiarchive)
|
||||
|
||||
#endif // BOOST_NO_STD_WSTREAMBUF
|
||||
#endif // BOOST_ARCHIVE_BINARY_WIARCHIVE_HPP
|
@ -0,0 +1,60 @@
|
||||
#ifndef BOOST_ARCHIVE_BINARY_WOARCHIVE_HPP
|
||||
#define BOOST_ARCHIVE_BINARY_WOARCHIVE_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// binary_woarchive.hpp
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#ifdef BOOST_NO_STD_WSTREAMBUF
|
||||
#error "wide char i/o not supported on this platform"
|
||||
#else
|
||||
|
||||
#include <ostream>
|
||||
#include <boost/archive/binary_oarchive_impl.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
// do not derive from this class. If you want to extend this functionality
|
||||
// via inhertance, derived from binary_oarchive_impl instead. This will
|
||||
// preserve correct static polymorphism.
|
||||
class binary_woarchive :
|
||||
public binary_oarchive_impl<
|
||||
binary_woarchive, std::wostream::char_type, std::wostream::traits_type
|
||||
>
|
||||
{
|
||||
public:
|
||||
binary_woarchive(std::wostream & os, unsigned int flags = 0) :
|
||||
binary_oarchive_impl<
|
||||
binary_woarchive, std::wostream::char_type, std::wostream::traits_type
|
||||
>(os, flags)
|
||||
{}
|
||||
binary_woarchive(std::wstreambuf & bsb, unsigned int flags = 0) :
|
||||
binary_oarchive_impl<
|
||||
binary_woarchive, std::wostream::char_type, std::wostream::traits_type
|
||||
>(bsb, flags)
|
||||
{}
|
||||
};
|
||||
|
||||
typedef binary_woarchive naked_binary_woarchive;
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::binary_woarchive)
|
||||
|
||||
#endif // BOOST_NO_STD_WSTREAMBUF
|
||||
#endif // BOOST_ARCHIVE_BINARY_WOARCHIVE_HPP
|
@ -0,0 +1,93 @@
|
||||
#ifndef BOOST_ARCHIVE_CODECVT_NULL_HPP
|
||||
#define BOOST_ARCHIVE_CODECVT_NULL_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// codecvt_null.hpp:
|
||||
|
||||
// (C) Copyright 2004 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <locale>
|
||||
#include <cstddef>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/archive/detail/auto_link_archive.hpp>
|
||||
|
||||
namespace std{
|
||||
#if defined(__LIBCOMO__)
|
||||
using ::mbstate_t;
|
||||
#elif defined(__QNXNTO__)
|
||||
//using std::mbstate_t;
|
||||
#elif defined(BOOST_DINKUMWARE_STDLIB) && BOOST_DINKUMWARE_STDLIB == 1
|
||||
using ::mbstate_t;
|
||||
#elif defined(__SGI_STL_PORT)
|
||||
#elif defined(BOOST_NO_STDC_NAMESPACE)
|
||||
using ::codecvt;
|
||||
using ::mbstate_t;
|
||||
#elif defined(BOOST_RWSTD_VER)
|
||||
using ::mbstate_t;
|
||||
#endif
|
||||
} // namespace std
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
template<class Ch>
|
||||
class codecvt_null;
|
||||
|
||||
template<>
|
||||
class codecvt_null<char> : public std::codecvt<char, char, std::mbstate_t>
|
||||
{
|
||||
virtual bool do_always_noconv() const throw() {
|
||||
return true;
|
||||
}
|
||||
public:
|
||||
explicit codecvt_null(std::size_t no_locale_manage = 0) :
|
||||
std::codecvt<char, char, std::mbstate_t>(no_locale_manage)
|
||||
{}
|
||||
};
|
||||
|
||||
template<>
|
||||
class codecvt_null<wchar_t> : public std::codecvt<wchar_t, char, std::mbstate_t>
|
||||
{
|
||||
virtual BOOST_ARCHIVE_DECL(std::codecvt_base::result)
|
||||
do_out(
|
||||
std::mbstate_t & state,
|
||||
const wchar_t * first1,
|
||||
const wchar_t * last1,
|
||||
const wchar_t * & next1,
|
||||
char * first2,
|
||||
char * last2,
|
||||
char * & next2
|
||||
) const;
|
||||
virtual BOOST_ARCHIVE_DECL(std::codecvt_base::result)
|
||||
do_in(
|
||||
std::mbstate_t & state,
|
||||
const char * first1,
|
||||
const char * last1,
|
||||
const char * & next1,
|
||||
wchar_t * first2,
|
||||
wchar_t * last2,
|
||||
wchar_t * & next2
|
||||
) const;
|
||||
virtual int do_encoding( ) const throw( ){
|
||||
return sizeof(wchar_t) / sizeof(char);
|
||||
}
|
||||
virtual int do_max_length( ) const throw( ){
|
||||
return do_encoding();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
#endif //BOOST_ARCHIVE_CODECVT_NULL_HPP
|
@ -0,0 +1,20 @@
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// abi_prefix.hpp
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <boost/config/abi_prefix.hpp> // must be the last header
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable : 4251 4231 4660 4275)
|
||||
#endif
|
||||
|
||||
#if defined( __BORLANDC__ )
|
||||
#pragma nopushoptwarn
|
||||
#endif
|
||||
|
@ -0,0 +1,19 @@
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// abi_suffix.hpp
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
#include <boost/config/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
#if defined( __BORLANDC__ )
|
||||
#pragma nopushoptwarn
|
||||
#endif
|
||||
|
@ -0,0 +1,92 @@
|
||||
#ifndef BOOST_ARCHIVE_ARCHIVE_POINTER_ISERIALIZER_POINTER_HPP
|
||||
#define BOOST_ARCHIVE_ARCHIVE_POINTER_ISERIALIZER_POINTER_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// archive_pointer_iserializer.hpp
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <cassert>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#include <boost/archive/detail/basic_serializer.hpp>
|
||||
#include <boost/archive/detail/basic_pointer_iserializer.hpp>
|
||||
|
||||
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace serialization {
|
||||
class extended_type_info;
|
||||
} // namespace serialization
|
||||
|
||||
namespace archive {
|
||||
namespace detail {
|
||||
|
||||
template<class Archive>
|
||||
class archive_pointer_iserializer :
|
||||
public basic_pointer_iserializer {
|
||||
protected:
|
||||
explicit BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
|
||||
archive_pointer_iserializer(
|
||||
const boost::serialization::extended_type_info & eti
|
||||
);
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
|
||||
// account for bogus gcc warning
|
||||
#if defined(__GNUC__)
|
||||
virtual
|
||||
#endif
|
||||
~archive_pointer_iserializer();
|
||||
public:
|
||||
virtual const basic_iserializer & get_basic_serializer() const
|
||||
// mscvc 6.0 requires template functions to be implemented. For this
|
||||
// reason we can't make abstract.
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) || defined(__MWERKS__)
|
||||
{
|
||||
assert(false);
|
||||
return *static_cast<const basic_iserializer *>(NULL);
|
||||
}
|
||||
#else
|
||||
= 0;
|
||||
#endif
|
||||
virtual void load_object_ptr(
|
||||
basic_iarchive & ar,
|
||||
void * & x,
|
||||
const unsigned int file_version
|
||||
) const
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) || defined(__MWERKS__)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
#else
|
||||
= 0;
|
||||
#endif
|
||||
// return the type_extended load pointer corresponding to a given
|
||||
// type_info. returns NULL if there is no such instance. This
|
||||
// would indicate that the no object of the specified type was loaded
|
||||
// any where in the code.
|
||||
static
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(const basic_pointer_iserializer *)
|
||||
find(
|
||||
const boost::serialization::extended_type_info & eti
|
||||
);
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
#endif // BOOST_ARCHIVE_ARCHIVE_POINTER_ISERIALIZER_POINTER_HPP
|
@ -0,0 +1,67 @@
|
||||
#ifndef BOOST_ARCHIVE_ARCHIVE_POINTER_OSERIALIZER_POINTER_HPP
|
||||
#define BOOST_ARCHIVE_ARCHIVE_POINTER_OSERIALIZER_POINTER_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// archive_pointer_oserializer.hpp: extenstion of type_info required for
|
||||
// serialization.
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/archive/detail/basic_serializer.hpp>
|
||||
#include <boost/archive/detail/basic_pointer_oserializer.hpp>
|
||||
|
||||
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace serialization {
|
||||
class extended_type_info;
|
||||
} // namespace serialization
|
||||
|
||||
namespace archive {
|
||||
namespace detail {
|
||||
|
||||
template<class Archive>
|
||||
class archive_pointer_oserializer :
|
||||
public basic_pointer_oserializer {
|
||||
protected:
|
||||
explicit BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
|
||||
archive_pointer_oserializer(
|
||||
const boost::serialization::extended_type_info & eti
|
||||
);
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
|
||||
// account for bogus gcc warning
|
||||
#if defined(__GNUC__)
|
||||
virtual
|
||||
#endif
|
||||
~archive_pointer_oserializer();
|
||||
public:
|
||||
// return the type_extended save pointer corresponding to a give
|
||||
// type_info. returns NULL, if there is no such instance. This
|
||||
// would indicate that the no object of the specified type was saved
|
||||
// any where in the code.
|
||||
static
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(const basic_pointer_oserializer *)
|
||||
find(
|
||||
const boost::serialization::extended_type_info & eti
|
||||
);
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
#endif // BOOST_ARCHIVE_ARCHIVE_POINTER_OSERIALIZER_POINTER_HPP
|
@ -0,0 +1,47 @@
|
||||
#ifndef BOOST_ARCHIVE_DETAIL_AUTO_LINK_ARCHIVE_HPP
|
||||
#define BOOST_ARCHIVE_DETAIL_AUTO_LINK_ARCHIVE_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// auto_link_archive.hpp
|
||||
//
|
||||
// © Copyright Robert Ramey 2004
|
||||
// Use, modification, and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See library home page at http://www.boost.org/libs/serialization
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
// This header implements separate compilation features as described in
|
||||
// http://www.boost.org/more/separate_compilation.html
|
||||
|
||||
// enable automatic library variant selection ------------------------------//
|
||||
|
||||
#include <boost/archive/detail/decl.hpp>
|
||||
|
||||
#if !defined(BOOST_ARCHIVE_SOURCE) \
|
||||
&& !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_SERIALIZATION_NO_LIB)
|
||||
|
||||
// Set the name of our library, this will get undef'ed by auto_link.hpp
|
||||
// once it's done with it:
|
||||
//
|
||||
#define BOOST_LIB_NAME boost_serialization
|
||||
//
|
||||
// If we're importing code from a dll, then tell auto_link.hpp about it:
|
||||
//
|
||||
#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_SERIALIZATION_DYN_LINK)
|
||||
# define BOOST_DYN_LINK
|
||||
#endif
|
||||
//
|
||||
// And include the header that does the work:
|
||||
//
|
||||
#include <boost/config/auto_link.hpp>
|
||||
#endif // auto-linking disabled
|
||||
|
||||
#endif // ARCHIVE_DETAIL_AUTO_LINK_ARCHIVE_HPP
|
@ -0,0 +1,47 @@
|
||||
#ifndef BOOST_ARCHIVE_DETAIL_AUTO_LINK_WARCHIVE_HPP
|
||||
#define BOOST_ARCHIVE_DETAIL_AUTO_LINK_WARCHIVE_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// auto_link_warchive.hpp
|
||||
//
|
||||
// © Copyright Robert Ramey 2004
|
||||
// Use, modification, and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See library home page at http://www.boost.org/libs/serialization
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
// This header implements separate compilation features as described in
|
||||
// http://www.boost.org/more/separate_compilation.html
|
||||
|
||||
// enable automatic library variant selection ------------------------------//
|
||||
|
||||
#include <boost/archive/detail/decl.hpp>
|
||||
|
||||
#if !defined(BOOST_WARCHIVE_SOURCE) \
|
||||
&& !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_SERIALIZATION_NO_LIB)
|
||||
|
||||
// Set the name of our library, this will get undef'ed by auto_link.hpp
|
||||
// once it's done with it:
|
||||
//
|
||||
#define BOOST_LIB_NAME boost_wserialization
|
||||
//
|
||||
// If we're importing code from a dll, then tell auto_link.hpp about it:
|
||||
//
|
||||
#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_SERIALIZATION_DYN_LINK)
|
||||
# define BOOST_DYN_LINK
|
||||
#endif
|
||||
//
|
||||
// And include the header that does the work:
|
||||
//
|
||||
#include <boost/config/auto_link.hpp>
|
||||
#endif // auto-linking disabled
|
||||
|
||||
#endif // ARCHIVE_DETAIL_AUTO_LINK_ARCHIVE_HPP
|
@ -0,0 +1,48 @@
|
||||
#ifndef BOOST_ARCHIVE_DETAIL_BASIC_ARCHIVE_IMPL_HPP
|
||||
#define BOOST_ARCHIVE_DETAIL_BASIC_ARCHIVE_IMPL_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// basic_archive_impl.hpp:
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
// can't use this - much as I'd like to as borland doesn't support it
|
||||
// #include <boost/scoped_ptr.hpp>
|
||||
|
||||
#include <set>
|
||||
|
||||
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
|
||||
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
class extended_type_info;
|
||||
} // namespace serialization
|
||||
|
||||
namespace archive {
|
||||
namespace detail {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_archive_impl
|
||||
{
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace serialization
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
#endif //BOOST_ARCHIVE_DETAIL_BASIC_ARCHIVE_IMPL_HPP
|
||||
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue