first commit
This commit is contained in:
674
libraries/ArduinoSTL/LICENSE
Normal file
674
libraries/ArduinoSTL/LICENSE
Normal file
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. 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
|
||||
them 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 prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. 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.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey 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;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If 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 convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU 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 that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
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.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
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.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
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
|
||||
state 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 3 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, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program 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, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU 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. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
98
libraries/ArduinoSTL/README.md
Normal file
98
libraries/ArduinoSTL/README.md
Normal file
@@ -0,0 +1,98 @@
|
||||
# ArduinoSTL
|
||||
|
||||
This is an implementation of a C++ standard library packaged as an Arduino library. The library supports teaching my CS-11M class by adding key C++ features into the Arduino environment.
|
||||
|
||||
The library is ported from uClibc++:
|
||||
|
||||
http://git.uclibc.org/uClibc++
|
||||
|
||||
With a streams implementation from Andy Brown's Arduino Library:
|
||||
|
||||
http://andybrown.me.uk/2011/01/15/the-standard-template-library-stl-for-avr-with-c-streams/
|
||||
|
||||
|
||||
## Using printf() and scanf()
|
||||
The ArduinoSTL header file contains code to bind a serial port of your choice to
|
||||
the stdio primitives. This happens automatically but the user must still call
|
||||
Serial.begin()
|
||||
|
||||
```c++
|
||||
#include <ArduinoSTL.h>
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
printf("Hello World\n");
|
||||
}
|
||||
```
|
||||
|
||||
## Using ```cin``` an ```cout```
|
||||
When you include this header file you automatically get cin and cout based on ```Serial```. See below for how to specify your own device. Here's an example sketch using ```cin``` and ```cout``` .
|
||||
|
||||
```c++
|
||||
#include <ArduinoSTL.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
cout << "Feed me an integers." << endl;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
int foo;
|
||||
if (cin >> foo) {
|
||||
cout << "You fed me " << foo << endl;
|
||||
}else{
|
||||
cin.clear();
|
||||
cin.ignore();
|
||||
}
|
||||
}
|
||||
```
|
||||
## Changing the Serial Port
|
||||
You can change what serial port that ```cin```, ```cout``` and ```printf()``` use. You can use built-in serial ports (e.g. ```Serial1``` on Leonardo) or you can use software serial ports that implement ```Stream```.
|
||||
|
||||
### Using a Built-in Port
|
||||
In ```src/ArduinoSTL.cpp``` change the value of ```ARDUINOSTL_DEFAULT_SERIAL```. Leave the other defaults uncommented.
|
||||
|
||||
### Using a SoftwareSerial port.
|
||||
Set ```ARDUINO_DEFAULT_SERAL``` to ```NULL```. Comment out the other defaults.
|
||||
|
||||
Here's an example sketch that uses SofwareSerial:
|
||||
|
||||
```c++
|
||||
#include <ArduinoSTL.h>
|
||||
#include <SoftwareSerial.h>
|
||||
|
||||
SoftwareSerial mySerial(0, 1);
|
||||
|
||||
namespace std {
|
||||
ohserialstream cout(mySerial);
|
||||
ihserialstream cin(mySerial);
|
||||
}
|
||||
|
||||
void setup() {
|
||||
mySerial.begin(9600);
|
||||
ArduinoSTL_Serial.connect(mySerial);
|
||||
}
|
||||
```
|
||||
|
||||
## Avoiding Instantiation of ```cin``` and ```cout```
|
||||
Comment out ```ARDUINOSTL_DEFAULT_CIN_COUT``` and nothing will be instantiated. You must comment out this flag if you intend to select a non-default serial port. There's no appreciable overhead for using ```printf()``` so you cannot currently avoid initializaing it.
|
||||
|
||||
## Known Issues
|
||||
|
||||
Printing of floats and doubles using ```cout``` ignores format specifiers.
|
||||
|
||||
uClibc seems to be fairly complete. Strings and vectors both work, even with the limited amount of heap available to Arduino. The uClibc++ status page can be found here:
|
||||
|
||||
https://cxx.uclibc.org/status.html
|
||||
|
||||
Always use the latest Arduino IDE. This library uses the Arduino IDE Library Specification rev.2.1 with features only available on Arduino 1.6.10 and higher. The specification can be found here:
|
||||
|
||||
https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification
|
||||
|
||||
## License
|
||||
|
||||
The uClibc++ library is licensed under the LGPL. This project adopts the LGPL to be compatible with the bulk of the code that it uses. Unless otherwise noted all code is licensed under the LGPL. There's one exception:
|
||||
|
||||
- src/serstream is licensed under the BSD license according to Andy Brown's wishes here: http://andybrown.me.uk/terms-and-conditions/
|
||||
4
libraries/ArduinoSTL/keywords.txt
Normal file
4
libraries/ArduinoSTL/keywords.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
cin KEYWORD1
|
||||
cout KEYWORD1
|
||||
printf KEYWORD1
|
||||
scanf KEYWORD1
|
||||
10
libraries/ArduinoSTL/library.properties
Normal file
10
libraries/ArduinoSTL/library.properties
Normal file
@@ -0,0 +1,10 @@
|
||||
name=ArduinoSTL
|
||||
version=1.3.3
|
||||
author=Mike Matera <matera@lifealgorithmic.com>, Chris Johnson <chrisjohnsonmail@gmail.com>, Arduino
|
||||
maintainer=Mike Matera <matera@lifealgorithmic.com>
|
||||
sentence=A port of uClibc++ Arduino library.
|
||||
paragraph=This library includes important C++ functions, including cout and cin, printf and scanf. It also includes STL containers like vector and algorithm.
|
||||
category=Other
|
||||
url=https://github.com/mike-matera/ArduinoSTL
|
||||
architectures=avr,megaavr
|
||||
includes=ArduinoSTL.h
|
||||
80
libraries/ArduinoSTL/src/ArduinoSTL.cpp
Normal file
80
libraries/ArduinoSTL/src/ArduinoSTL.cpp
Normal file
@@ -0,0 +1,80 @@
|
||||
#include "ArduinoSTL.h"
|
||||
#include <Arduino.h>
|
||||
|
||||
//
|
||||
// Configuration Help
|
||||
//
|
||||
// If you're using a serial port that's statically declared somewhere in
|
||||
// Arduino (e.g. Serial1 on Leonardo)
|
||||
// 1. Set ARDUINOSTL_SERIAL_DEVICE to your device
|
||||
// 2. Uncomment the ARDUINOSTL_DEFAULT_CIN_COUT flag.
|
||||
//
|
||||
// If you're using a sofware serial port:
|
||||
// 1. Set ARDUINOSTL_DEFAULT_SERIAL to NULL
|
||||
// 2. Comment out ARDUINOSTL_DEFAULT_CIN_COUT
|
||||
// Your sketch must contain delarations of cin and cout, and a call to
|
||||
// ArduinoSTL_serial.connect().
|
||||
//
|
||||
|
||||
#define ARDUINOSTL_DEFAULT_SERIAL Serial
|
||||
#define ARDUINOSTL_DEFAULT_CIN_COUT
|
||||
|
||||
using namespace std;
|
||||
|
||||
#ifdef ARDUINOSTL_DEFAULT_CIN_COUT
|
||||
// Create cout and cin.. there doesn't seem to be a way
|
||||
// to control what serial device at runtime. Grr.
|
||||
namespace std
|
||||
{
|
||||
ohserialstream cout(ARDUINOSTL_DEFAULT_SERIAL);
|
||||
ihserialstream cin(ARDUINOSTL_DEFAULT_SERIAL);
|
||||
}
|
||||
#endif // ARDUINOSTL_DEFAULT_CIN_COUT
|
||||
|
||||
/*
|
||||
* Implementation of printf() is highly libc dependent.
|
||||
*
|
||||
* This implementation is tested on:
|
||||
*
|
||||
* ARDUINO_ARCH_AVR (Classic Arduinos) - Working
|
||||
* TEENSYDUINO (ARM-based Teensy) - cin/cout work, printf doesn't
|
||||
* ARDUINO_ARCH_* - ARMs are probably the same as above.
|
||||
*/
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
|
||||
ArduinoSTL_STDIO ArduinoSTL_Serial(ARDUINOSTL_DEFAULT_SERIAL);
|
||||
|
||||
// arduino_putchar(char, FILE*)
|
||||
// Output a single character to the serial port.
|
||||
// returns: 0 on success, 1 on error
|
||||
// note:
|
||||
// To maintain serial port compatibility this function
|
||||
// automatically addes a \r when it sees a \n
|
||||
//
|
||||
static int arduino_putchar(char c, FILE* f) {
|
||||
Stream *uart = ArduinoSTL_Serial.getUart();
|
||||
if (c == '\n') uart->write('\r');
|
||||
return uart->write(c) == 1? 0 : 1;
|
||||
}
|
||||
|
||||
// arduino_getchar(FILE*)
|
||||
// Take a character from the serial port. This function
|
||||
// must block until a character is ready.
|
||||
// returns: The character or -1 on a read error
|
||||
//
|
||||
static int arduino_getchar(FILE *f) {
|
||||
Stream *uart = ArduinoSTL_Serial.getUart();
|
||||
while (! uart->available()) { /* wait */ }
|
||||
return uart->read();
|
||||
}
|
||||
|
||||
void ArduinoSTL_STDIO::connect(Stream *u) {
|
||||
if (file != NULL)
|
||||
free (file);
|
||||
uart = u;
|
||||
file = fdevopen(arduino_putchar, arduino_getchar);
|
||||
}
|
||||
|
||||
#else
|
||||
#warning "printf() will not be functional on this platform."
|
||||
#endif
|
||||
56
libraries/ArduinoSTL/src/ArduinoSTL.h
Normal file
56
libraries/ArduinoSTL/src/ArduinoSTL.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/*---------------------
|
||||
*
|
||||
* ArduinoSTL Core Library
|
||||
*
|
||||
* This header has some glue to make STL and Streams work from a sketch.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ARDUINOSTL_M_H
|
||||
#define ARDUINOSTL_M_H
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "serstream"
|
||||
|
||||
// Create cout and cin.. there doesn't seem to be a way
|
||||
// to control what serial device at runtime. Grr.
|
||||
namespace std
|
||||
{
|
||||
extern ohserialstream cout;
|
||||
extern ihserialstream cin;
|
||||
}
|
||||
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
|
||||
class ArduinoSTL_STDIO {
|
||||
public:
|
||||
// Initialize STDIO using a pointer to whatever Serial is.
|
||||
// Serial.begin() must be called at some point.
|
||||
ArduinoSTL_STDIO(Stream *u) : file(NULL) {
|
||||
connect(u);
|
||||
}
|
||||
|
||||
ArduinoSTL_STDIO(Stream &u) : file(NULL) {
|
||||
connect(u);
|
||||
}
|
||||
|
||||
Stream *getUart() {
|
||||
return uart;
|
||||
}
|
||||
|
||||
void connect(Stream *u);
|
||||
|
||||
inline void connect(Stream &u) {
|
||||
connect(static_cast<Stream*>(&u));
|
||||
}
|
||||
|
||||
private:
|
||||
Stream *uart;
|
||||
FILE *file;
|
||||
};
|
||||
|
||||
extern ArduinoSTL_STDIO ArduinoSTL_Serial;
|
||||
|
||||
#endif // ARDUINO_ARCH_AVR
|
||||
|
||||
#endif // ARDUINOSTL_M_H
|
||||
45
libraries/ArduinoSTL/src/abi/abi.cpp
Normal file
45
libraries/ArduinoSTL/src/abi/abi.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc C++ Library. This library 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, or (at your option)
|
||||
any later version.
|
||||
|
||||
This library 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 library; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
USA.
|
||||
*/
|
||||
|
||||
#include "cstdlib"
|
||||
#include "typeinfo"
|
||||
#include "basic_definitions"
|
||||
|
||||
/* This file implements a number of the language support features
|
||||
* needed to deal with the C++ abi, as originally documented in the
|
||||
* Itanium C++ ABI, though now industry standard
|
||||
*/
|
||||
|
||||
extern "C" {
|
||||
|
||||
#if defined(ARDUINO)
|
||||
/* Arduino defines some of these.
|
||||
* There can be link issues if they're redefined
|
||||
*/
|
||||
#else
|
||||
/* This function is called in the event that a non-overidden
|
||||
* pure virtual function is called. The compiler should never
|
||||
* let that happen. We get to choose what to do - we will abort
|
||||
*/
|
||||
void __cxa_pure_virtual (){
|
||||
abort();
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
4
libraries/ArduinoSTL/src/abi/libgcc_eh/Makefile
Normal file
4
libraries/ArduinoSTL/src/abi/libgcc_eh/Makefile
Normal file
@@ -0,0 +1,4 @@
|
||||
top_srcdir=../../../
|
||||
top_builddir=../../../
|
||||
include $(top_srcdir)Rules.mak
|
||||
include Makefile.in
|
||||
24
libraries/ArduinoSTL/src/abi/libgcc_eh/Makefile.in
Normal file
24
libraries/ArduinoSTL/src/abi/libgcc_eh/Makefile.in
Normal file
@@ -0,0 +1,24 @@
|
||||
LIBGCC_EH_OUT := $(top_builddir)src/abi/libgcc_eh/
|
||||
|
||||
OBJS = $(call list-archive-members,$(LIBGCC_EH))
|
||||
libgcc_eh-$(IMPORT_LIBGCC_EH) := $(OBJS)
|
||||
|
||||
LIBGCC_EH_VAR := $(call variablify,$(LIBGCC_EH))
|
||||
LIBGCC_EH_DEP := $(LIBGCC_EH_OUT).$(call print-hash,$(LIBGCC_EH_VAR)).dep
|
||||
|
||||
ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
|
||||
-include $(LIBGCC_EH_DEP)
|
||||
endif
|
||||
|
||||
|
||||
ifneq ($(libgcc_eh-y),)
|
||||
$(libgcc_eh-y): $(LIBGCC_EH)
|
||||
endif
|
||||
$(LIBGCC_EH_DEP): $(LIBGCC_EH)
|
||||
$(Q)$(RM) $(LIBGCC_EH_OUT).*dep $(LIBGCC_EH_OUT)*.o
|
||||
$(Q)$(if $(LIBGCC_EH),(cd $(LIBGCC_EH_OUT) && $(AR) x $(LIBGCC_EH)))
|
||||
$(Q)printf "# %s\n\n%s\n" "$(LIBGCC_EH)" "libgcc_eh-y := \$$(addprefix \$$(LIBGCC_EH_OUT),$(libgcc_eh-y))" > $@
|
||||
|
||||
CLEAN_src/abi/libgcc_eh: ;
|
||||
DISTCLEAN_src/abi/libgcc_eh:
|
||||
$(do_rm) $(addprefix $(LIBGCC_EH_OUT),.*dep *.o)
|
||||
4
libraries/ArduinoSTL/src/abi/libsupc/Makefile
Normal file
4
libraries/ArduinoSTL/src/abi/libsupc/Makefile
Normal file
@@ -0,0 +1,4 @@
|
||||
top_srcdir=../../../
|
||||
top_builddir=../../../
|
||||
include $(top_srcdir)Rules.mak
|
||||
include Makefile.in
|
||||
24
libraries/ArduinoSTL/src/abi/libsupc/Makefile.in
Normal file
24
libraries/ArduinoSTL/src/abi/libsupc/Makefile.in
Normal file
@@ -0,0 +1,24 @@
|
||||
LIBSUPC_OUT := $(top_builddir)src/abi/libsupc/
|
||||
|
||||
OBJS = $(call list-archive-members,$(LIBSUP))
|
||||
OBJS-OMIT = $(filter new_op%.o del_op%.o pure.o new_handler.o eh_alloc.o eh_globals.o,$(OBJS))
|
||||
libsupc-$(IMPORT_LIBSUP) := $(filter-out $(OBJS-OMIT),$(OBJS))
|
||||
|
||||
LIBSUP_VAR := $(call variablify,$(LIBSUP))
|
||||
LIBSUP_DEP := $(LIBSUPC_OUT).$(call print-hash,$(LIBSUP_VAR)).dep
|
||||
|
||||
ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
|
||||
-include $(LIBSUP_DEP)
|
||||
endif
|
||||
|
||||
ifneq ($(libsupc-y),)
|
||||
$(libsupc-y): $(LIBSUP)
|
||||
endif
|
||||
$(LIBSUP_DEP): $(LIBSUP) $(LIBSUPC_OUT)Makefile.in
|
||||
$(Q)$(RM) $(LIBSUPC_OUT).*dep $(LIBSUPC_OUT)*.o
|
||||
$(Q)$(if $(LIBSUP),(cd $(LIBSUPC_OUT) && $(AR) x $(LIBSUP) && $(RM) $(OBJS-OMIT)))
|
||||
$(Q)printf "# %s\n\n%s\n" "$(LIBSUP)" "libsupc-y := \$$(addprefix \$$(LIBSUPC_OUT),$(libsupc-y))" > $@
|
||||
|
||||
CLEAN_src/abi/libsupc: ;
|
||||
DISTCLEAN_src/abi/libsupc:
|
||||
$(do_rm) $(addprefix $(LIBSUPC_OUT), .*dep *.o)
|
||||
1706
libraries/ArduinoSTL/src/algorithm
Normal file
1706
libraries/ArduinoSTL/src/algorithm
Normal file
File diff suppressed because it is too large
Load Diff
30
libraries/ArduinoSTL/src/algorithm.cpp
Normal file
30
libraries/ArduinoSTL/src/algorithm.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "algorithm"
|
||||
|
||||
|
||||
namespace std{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
68
libraries/ArduinoSTL/src/array
Normal file
68
libraries/ArduinoSTL/src/array
Normal file
@@ -0,0 +1,68 @@
|
||||
#ifndef __ARRAY__
|
||||
#define __ARRAY__
|
||||
|
||||
#include "cstddef"
|
||||
#include "initializer_list"
|
||||
|
||||
namespace std {
|
||||
|
||||
template <typename T, size_t N>
|
||||
class array {
|
||||
public:
|
||||
typedef T value_type;
|
||||
typedef T* pointer;
|
||||
typedef const T* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef pointer iterator;
|
||||
typedef const_pointer const_iterator;
|
||||
typedef size_t size_type;
|
||||
|
||||
private:
|
||||
value_type _data[N ? N : 1];
|
||||
|
||||
public:
|
||||
array() = default;
|
||||
array(std::initializer_list<T> init) {
|
||||
if (init.size() != N) {
|
||||
// error
|
||||
}
|
||||
size_t i = 0;
|
||||
for(const auto& item : init) {
|
||||
_data[i++] = item;
|
||||
}
|
||||
}
|
||||
array& operator=(const array& other) = default;
|
||||
|
||||
reference operator[](size_type i) { return _data[i]; }
|
||||
const_reference operator[](size_type i) const { return _data[i]; }
|
||||
reference front() { return _data[0]; }
|
||||
const_reference front() const { return _data[0]; }
|
||||
reference back() { return _data[N - 1]; }
|
||||
const_reference back() const { return _data[N - 1]; }
|
||||
pointer data() noexcept { return _data; }
|
||||
const_pointer data() const noexcept { return _data; }
|
||||
reference at(size_type pos) { return _data[pos]; }
|
||||
const_reference at(size_type pos) const { return _data[pos]; }
|
||||
|
||||
iterator begin() noexcept { return _data; }
|
||||
const_iterator begin() const noexcept { return _data; }
|
||||
const_iterator cbegin() const noexcept { return _data; }
|
||||
iterator end() noexcept { return _data + N; }
|
||||
const_iterator end() const noexcept { return _data + N; }
|
||||
const_iterator cend() const noexcept { return _data + N; }
|
||||
|
||||
bool empty() const noexcept { return begin() == end(); }
|
||||
size_type size() const noexcept { return N; }
|
||||
size_type max_size() const noexcept { return N; }
|
||||
|
||||
void fill(const_reference value) {
|
||||
for (auto i = 0u; i < N; ++i) {
|
||||
_data[i] = value;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
639
libraries/ArduinoSTL/src/associative_base
Normal file
639
libraries/ArduinoSTL/src/associative_base
Normal file
@@ -0,0 +1,639 @@
|
||||
/* Copyright (C) 2007 Garrett A. Kajmowicz
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "memory"
|
||||
#include "utility"
|
||||
#include "iterator"
|
||||
#include "functional"
|
||||
#include "list"
|
||||
|
||||
|
||||
#ifndef __STD_HEADER_ASSOCIATIVE_BASE
|
||||
#define __STD_HEADER_ASSOCIATIVE_BASE
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
|
||||
namespace std{
|
||||
|
||||
|
||||
/*
|
||||
* The basic premise here is that most of the code used by map, multimap, set and
|
||||
* multiset is really common. There are a number of interface additions, and
|
||||
* considerations about how to address multiple entries with the same key.
|
||||
* The goal is that the tree/storage code should be here, and managing
|
||||
* single or multiple counts will be left to subclasses.
|
||||
* Yes, inheritence for the purpose of code sharing is usually a bad idea.
|
||||
* However, since our goal is to reduce the total amount of code written
|
||||
* and the overall binary size, this seems to be the best approach possible.
|
||||
*/
|
||||
|
||||
template<class Key, class ValueType, class Compare = less<Key>, class Allocator = allocator<ValueType> > class __base_associative;
|
||||
template<class ValueType, class Compare, class Allocator> class _associative_iter;
|
||||
template<class ValueType, class Compare, class Allocator> class _associative_citer;
|
||||
|
||||
template<class Key, class ValueType, class Compare = less<Key>, class Allocator = allocator<ValueType> > class __single_associative;
|
||||
template<class Key, class ValueType, class Compare = less<Key>, class Allocator = allocator<ValueType> > class __multi_associative;
|
||||
|
||||
template<class Key, class ValueType, class Compare, class Allocator> class _UCXXEXPORT __base_associative{
|
||||
|
||||
protected:
|
||||
|
||||
public:
|
||||
typedef Key key_type;
|
||||
typedef ValueType value_type;
|
||||
typedef Compare key_compare;
|
||||
typedef Allocator allocator_type;
|
||||
typedef typename Allocator::reference reference;
|
||||
typedef typename Allocator::const_reference const_reference;
|
||||
typedef typename Allocator::size_type size_type;
|
||||
typedef typename Allocator::difference_type difference_type;
|
||||
typedef typename Allocator::pointer pointer;
|
||||
typedef typename Allocator::const_pointer const_pointer;
|
||||
typedef __base_associative<Key, ValueType, Compare, Allocator> associative_type;
|
||||
|
||||
typedef _associative_iter<value_type, Compare, Allocator> iterator;
|
||||
typedef _associative_citer<value_type, Compare, Allocator> const_iterator;
|
||||
typedef typename std::reverse_iterator<iterator> reverse_iterator;
|
||||
typedef typename std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
|
||||
|
||||
explicit __base_associative(const Compare& comp, const Allocator& A, const key_type (*v_to_k)(const value_type))
|
||||
: c(comp), value_to_key(v_to_k) { }
|
||||
protected:
|
||||
__base_associative(const associative_type& x)
|
||||
: c(x.c), backing(x.backing), value_to_key(x.value_to_key) { }
|
||||
|
||||
public:
|
||||
~__base_associative(){
|
||||
}
|
||||
|
||||
bool empty() const{
|
||||
return backing.empty();
|
||||
}
|
||||
size_type size() const{
|
||||
return backing.size();
|
||||
}
|
||||
size_type max_size() const{
|
||||
return backing.max_size();
|
||||
}
|
||||
|
||||
iterator begin(){
|
||||
return iterator(backing.begin());
|
||||
}
|
||||
|
||||
const_iterator begin() const{
|
||||
return const_iterator(backing.begin());
|
||||
}
|
||||
|
||||
iterator end() {
|
||||
return iterator(backing.end());
|
||||
}
|
||||
|
||||
const_iterator end() const{
|
||||
return const_iterator(backing.end());
|
||||
}
|
||||
|
||||
reverse_iterator rbegin(){
|
||||
return reverse_iterator(end());
|
||||
}
|
||||
|
||||
const_reverse_iterator rbegin() const{
|
||||
return const_reverse_iterator(end());
|
||||
}
|
||||
|
||||
reverse_iterator rend(){
|
||||
return reverse_iterator(begin());
|
||||
}
|
||||
|
||||
const_reverse_iterator rend() const{
|
||||
return const_reverse_iterator(begin());
|
||||
}
|
||||
|
||||
|
||||
iterator lower_bound(const key_type &x);
|
||||
const_iterator lower_bound(const key_type &x) const;
|
||||
iterator upper_bound(const key_type &x);
|
||||
const_iterator upper_bound(const key_type &x) const;
|
||||
|
||||
pair<iterator,iterator> equal_range(const key_type& x){
|
||||
pair<iterator, iterator> retval;
|
||||
retval.first = lower_bound(x);
|
||||
retval.second = retval.first;
|
||||
while(retval.second != end() && !c(x, value_to_key(*retval.second))){
|
||||
++retval.second;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
pair<const_iterator,const_iterator> equal_range(const key_type& x) const{
|
||||
pair<const_iterator, const_iterator> retval;
|
||||
retval.first = lower_bound(x);
|
||||
retval.second = retval.first;
|
||||
while(retval.second != end() && !c(x, value_to_key(*retval.second))){
|
||||
++retval.second;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
iterator find(const key_type& x){
|
||||
iterator retval = lower_bound(x);
|
||||
if(retval == end()){
|
||||
return retval;
|
||||
}
|
||||
if(c(x, value_to_key(*retval))){
|
||||
return end();
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
const_iterator find(const key_type& x) const{
|
||||
const_iterator retval = lower_bound(x);
|
||||
if(retval == end()){
|
||||
return retval;
|
||||
}
|
||||
if(c(x, value_to_key(*retval))){
|
||||
return end();
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
size_type count(const key_type& x) const{
|
||||
size_type retval(0);
|
||||
const_iterator first = lower_bound(x);
|
||||
while(first != end() && !c(x, value_to_key(*first))){
|
||||
++retval;
|
||||
++first;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
void clear(){
|
||||
backing.clear();
|
||||
}
|
||||
|
||||
void erase(iterator pos){
|
||||
backing.erase(pos.base_iterator());
|
||||
}
|
||||
size_type erase(const key_type& x){
|
||||
size_type count(0);
|
||||
iterator start = lower_bound(x);
|
||||
iterator end = upper_bound(x);
|
||||
while(start != end){
|
||||
start = backing.erase(start.base_iterator());
|
||||
++count;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
void erase(iterator first, iterator last){
|
||||
while(first != last){
|
||||
first = backing.erase(first.base_iterator());
|
||||
}
|
||||
}
|
||||
|
||||
key_compare key_comp() const{
|
||||
return c;
|
||||
}
|
||||
|
||||
__base_associative &operator=(const __base_associative & x){
|
||||
c = x.c;
|
||||
backing = x.backing;
|
||||
value_to_key = x.value_to_key;
|
||||
return *this;
|
||||
}
|
||||
bool operator==(const __base_associative & x){
|
||||
return x.backing == backing;
|
||||
}
|
||||
bool operator!=(const __base_associative & x){
|
||||
return !(x.backing == backing);
|
||||
}
|
||||
|
||||
protected:
|
||||
void swap(__base_associative & x);
|
||||
|
||||
Compare c;
|
||||
std::list<value_type> backing;
|
||||
|
||||
const key_type (*value_to_key)(const value_type);
|
||||
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Tree iterators for the base associative class
|
||||
*/
|
||||
|
||||
template<class ValueType, class Compare, class Allocator> class _associative_citer
|
||||
: public std::iterator<
|
||||
bidirectional_iterator_tag,
|
||||
ValueType,
|
||||
typename Allocator::difference_type,
|
||||
ValueType*,
|
||||
ValueType&
|
||||
>
|
||||
{
|
||||
protected:
|
||||
typedef std::list<ValueType> listtype;
|
||||
|
||||
typename listtype::const_iterator base_iter;
|
||||
friend class _associative_iter<ValueType, Compare, Allocator>;
|
||||
public:
|
||||
_associative_citer() { }
|
||||
_associative_citer(const _associative_citer & m)
|
||||
: base_iter(m.base_iter) { }
|
||||
_associative_citer(const typename listtype::const_iterator & m)
|
||||
: base_iter(m) { }
|
||||
~_associative_citer() { }
|
||||
ValueType operator*() const{
|
||||
return *base_iter;
|
||||
}
|
||||
const ValueType * operator->() const{
|
||||
return &(*base_iter);
|
||||
}
|
||||
_associative_citer & operator=(const _associative_citer & m){
|
||||
base_iter = m.base_iter;
|
||||
return *this;
|
||||
}
|
||||
bool operator==(const _associative_citer & m) const{
|
||||
return m.base_iter == base_iter;
|
||||
}
|
||||
bool operator!=(const _associative_citer & m) const{
|
||||
return m.base_iter != base_iter;
|
||||
}
|
||||
_associative_citer & operator++(){
|
||||
++base_iter;
|
||||
return *this;
|
||||
}
|
||||
_associative_citer operator++(int){
|
||||
//The following approach ensures that we only need to
|
||||
//provide code for ++ in one place (above)
|
||||
_associative_citer temp(base_iter);
|
||||
++base_iter;
|
||||
return temp;
|
||||
}
|
||||
_associative_citer & operator--(){
|
||||
--base_iter;
|
||||
return *this;
|
||||
}
|
||||
_associative_citer operator--(int){
|
||||
//The following approach ensures that we only need to
|
||||
//provide code for -- in one place (above)
|
||||
_associative_citer temp(base_iter);
|
||||
--base_iter;
|
||||
return temp;
|
||||
}
|
||||
|
||||
//This is an implementation-defined function designed to make internals work correctly
|
||||
typename listtype::const_iterator base_iterator(){
|
||||
return base_iter;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<class ValueType, class Compare, class Allocator> class _associative_iter
|
||||
: public std::iterator<
|
||||
bidirectional_iterator_tag,
|
||||
ValueType,
|
||||
typename Allocator::difference_type,
|
||||
ValueType*,
|
||||
ValueType&
|
||||
>
|
||||
{
|
||||
protected:
|
||||
typedef std::list<ValueType> listtype;
|
||||
|
||||
typename listtype::iterator base_iter;
|
||||
typedef _associative_citer<ValueType, Compare, Allocator> __associative_citer;
|
||||
|
||||
public:
|
||||
_associative_iter() { }
|
||||
_associative_iter(const _associative_iter & m)
|
||||
: base_iter(m.base_iter) { }
|
||||
_associative_iter(const typename listtype::iterator & m)
|
||||
: base_iter(m) { }
|
||||
~_associative_iter() { }
|
||||
const ValueType & operator*() const{
|
||||
return *base_iter;
|
||||
}
|
||||
ValueType & operator*(){
|
||||
return *base_iter;
|
||||
}
|
||||
ValueType * operator->(){
|
||||
return &(*base_iter);
|
||||
}
|
||||
const ValueType * operator->() const{
|
||||
return &(*base_iter);
|
||||
}
|
||||
_associative_iter & operator=(const _associative_iter & m){
|
||||
base_iter = m.base_iter;
|
||||
return *this;
|
||||
}
|
||||
bool operator==(const _associative_iter & m) const{
|
||||
return m.base_iter == base_iter;
|
||||
}
|
||||
bool operator==(const __associative_citer & m) const{
|
||||
return m.base_iter == base_iter;
|
||||
}
|
||||
bool operator!=(const _associative_iter & m) const{
|
||||
return m.base_iter != base_iter;
|
||||
}
|
||||
bool operator!=(const __associative_citer & m) const{
|
||||
return m.base_iter != base_iter;
|
||||
}
|
||||
_associative_iter & operator++(){
|
||||
++base_iter;
|
||||
return *this;
|
||||
}
|
||||
_associative_iter operator++(int){
|
||||
//The following approach ensures that we only need to
|
||||
//provide code for ++ in one place (above)
|
||||
_associative_iter temp(base_iter);
|
||||
++base_iter;
|
||||
return temp;
|
||||
}
|
||||
_associative_iter & operator--(){
|
||||
--base_iter;
|
||||
return *this;
|
||||
}
|
||||
_associative_iter operator--(int){
|
||||
//The following approach ensures that we only need to
|
||||
//provide code for -- in one place (above)
|
||||
_associative_iter temp(base_iter);
|
||||
--base_iter;
|
||||
return temp;
|
||||
}
|
||||
operator __associative_citer() const{
|
||||
return __associative_citer(base_iter);
|
||||
}
|
||||
typename listtype::iterator base_iterator(){
|
||||
return base_iter;
|
||||
}
|
||||
const typename listtype::iterator base_iterator() const{
|
||||
return base_iter;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
// The lower_bound code is really crappy linear search. However, it is a dead
|
||||
// simple implementation (easy to audit). It can also be easily replaced.
|
||||
|
||||
|
||||
template <class Key, class ValueType, class Compare, class Allocator>
|
||||
typename __base_associative<Key, ValueType, Compare, Allocator>::iterator
|
||||
__base_associative<Key, ValueType, Compare, Allocator>::lower_bound(const key_type &x)
|
||||
{
|
||||
iterator retval = begin();
|
||||
while(retval != end() && c(value_to_key(*retval), x)){
|
||||
++retval;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
template <class Key, class ValueType, class Compare, class Allocator>
|
||||
typename __base_associative<Key, ValueType, Compare, Allocator>::const_iterator
|
||||
__base_associative<Key, ValueType, Compare, Allocator>::lower_bound(const key_type &x) const
|
||||
{
|
||||
const_iterator retval = begin();
|
||||
while(retval != end() && c(value_to_key(*retval), x)){
|
||||
++retval;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
// Upper bound search is linear from the point of lower_bound. This is likely the best solution
|
||||
// in all but the most pathological of cases.
|
||||
|
||||
template <class Key, class ValueType, class Compare, class Allocator>
|
||||
typename __base_associative<Key, ValueType, Compare, Allocator>::iterator
|
||||
__base_associative<Key, ValueType, Compare, Allocator>::upper_bound(const key_type &x)
|
||||
{
|
||||
iterator retval = lower_bound(x);
|
||||
while(retval != end() && !c(x, value_to_key(*retval))){
|
||||
++retval;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
template <class Key, class ValueType, class Compare, class Allocator>
|
||||
typename __base_associative<Key, ValueType, Compare, Allocator>::const_iterator
|
||||
__base_associative<Key, ValueType, Compare, Allocator>::upper_bound(const key_type &x) const
|
||||
{
|
||||
const_iterator retval = begin();
|
||||
while(retval != end() && !c(x, value_to_key(*retval))){
|
||||
++retval;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
template <class Key, class ValueType, class Compare, class Allocator>
|
||||
void __base_associative<Key, ValueType, Compare, Allocator>::swap(__base_associative<Key, ValueType, Compare, Allocator>& m)
|
||||
{
|
||||
Compare n = c;
|
||||
c = m.c;
|
||||
m.c = n;
|
||||
|
||||
m.backing.swap(backing);
|
||||
}
|
||||
|
||||
|
||||
template<class Key, class ValueType, class Compare, class Allocator> class _UCXXEXPORT __single_associative :
|
||||
public __base_associative<Key, ValueType, Compare, Allocator>
|
||||
{
|
||||
protected:
|
||||
typedef __base_associative<Key, ValueType, Compare, Allocator> base;
|
||||
using base::backing;
|
||||
|
||||
using base::c;
|
||||
|
||||
public:
|
||||
typedef typename base::key_type key_type;
|
||||
typedef typename base::value_type value_type;
|
||||
typedef typename base::key_compare key_compare;
|
||||
typedef typename base::allocator_type allocator_type;
|
||||
typedef typename base::reference reference;
|
||||
typedef typename base::const_reference const_reference;
|
||||
typedef typename base::iterator iterator;
|
||||
typedef typename base::const_iterator const_iterator;
|
||||
typedef typename base::size_type size_type;
|
||||
typedef typename base::difference_type difference_type;
|
||||
typedef typename base::pointer pointer;
|
||||
typedef typename base::const_pointer const_pointer;
|
||||
typedef typename base::reverse_iterator reverse_iterator;
|
||||
typedef typename base::const_reverse_iterator const_reverse_iterator;
|
||||
|
||||
using base::begin;
|
||||
using base::end;
|
||||
using base::rbegin;
|
||||
using base::rend;
|
||||
|
||||
using base::empty;
|
||||
using base::size;
|
||||
using base::max_size;
|
||||
|
||||
using base::find;
|
||||
using base::count;
|
||||
using base::lower_bound;
|
||||
using base::upper_bound;
|
||||
using base::equal_range;
|
||||
|
||||
using base::operator=;
|
||||
using base::operator==;
|
||||
using base::operator!=;
|
||||
|
||||
explicit __single_associative(const Compare& comp, const Allocator& A, const key_type (*v_to_k)(const value_type))
|
||||
: base(comp, A, v_to_k) { }
|
||||
|
||||
template <class InputIterator> __single_associative(
|
||||
InputIterator first,
|
||||
InputIterator last,
|
||||
const Compare& comp,
|
||||
const Allocator& A,
|
||||
const key_type (*v_to_k)(const value_type)
|
||||
) : base(comp, A, v_to_k) {
|
||||
insert(first, last);
|
||||
}
|
||||
|
||||
pair<iterator, bool> insert(const value_type& x){
|
||||
pair<iterator, bool> retval;
|
||||
iterator location = lower_bound(this->value_to_key(x));
|
||||
retval.second = true;
|
||||
//Empty list or need to insert at end
|
||||
if(end() == location){
|
||||
backing.push_back(x);
|
||||
retval.first = --(end());
|
||||
return retval;
|
||||
}
|
||||
//Something in the list
|
||||
if(c(this->value_to_key(x), this->value_to_key(*location))){
|
||||
location = backing.insert(location.base_iterator(), x);
|
||||
retval.first = location;
|
||||
}else{
|
||||
retval.second = false;
|
||||
retval.first = location;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
iterator insert(iterator position, const value_type& x){
|
||||
// FIXME - this is cheating and probably should be more efficient since we are
|
||||
// now log(n) to find for inserts
|
||||
return insert(x).first;
|
||||
}
|
||||
|
||||
template <class InputIterator> void insert(InputIterator first, InputIterator last){
|
||||
while(first != last){
|
||||
insert(*first);
|
||||
++first;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
template<class Key, class ValueType, class Compare, class Allocator> class _UCXXEXPORT __multi_associative :
|
||||
public __base_associative<Key, ValueType, Compare, Allocator>
|
||||
{
|
||||
protected:
|
||||
typedef __base_associative<Key, ValueType, Compare, Allocator> base;
|
||||
using base::backing;
|
||||
|
||||
using base::c;
|
||||
|
||||
public:
|
||||
typedef typename base::key_type key_type;
|
||||
typedef typename base::value_type value_type;
|
||||
typedef typename base::key_compare key_compare;
|
||||
typedef typename base::allocator_type allocator_type;
|
||||
typedef typename base::reference reference;
|
||||
typedef typename base::const_reference const_reference;
|
||||
typedef typename base::iterator iterator;
|
||||
typedef typename base::const_iterator const_iterator;
|
||||
typedef typename base::size_type size_type;
|
||||
typedef typename base::difference_type difference_type;
|
||||
typedef typename base::pointer pointer;
|
||||
typedef typename base::const_pointer const_pointer;
|
||||
typedef typename base::reverse_iterator reverse_iterator;
|
||||
typedef typename base::const_reverse_iterator const_reverse_iterator;
|
||||
|
||||
using base::begin;
|
||||
using base::end;
|
||||
using base::rbegin;
|
||||
using base::rend;
|
||||
|
||||
using base::empty;
|
||||
using base::size;
|
||||
using base::max_size;
|
||||
|
||||
using base::find;
|
||||
using base::count;
|
||||
using base::lower_bound;
|
||||
using base::upper_bound;
|
||||
using base::equal_range;
|
||||
|
||||
using base::operator=;
|
||||
using base::operator==;
|
||||
|
||||
|
||||
explicit __multi_associative(const Compare& comp, const Allocator& A, const key_type (*v_to_k)(const value_type))
|
||||
: base(comp, A, v_to_k) { }
|
||||
|
||||
template <class InputIterator> __multi_associative(
|
||||
InputIterator first,
|
||||
InputIterator last,
|
||||
const Compare& comp,
|
||||
const Allocator& A,
|
||||
const key_type (*v_to_k)(const value_type)
|
||||
) : base(comp, A, v_to_k) {
|
||||
insert(first, last);
|
||||
}
|
||||
|
||||
iterator insert(const value_type& x){
|
||||
iterator location = lower_bound(this->value_to_key(x));
|
||||
|
||||
if(location == begin()){
|
||||
backing.push_front(x);
|
||||
location = begin();
|
||||
}else{
|
||||
location = backing.insert(location.base_iterator(), x);
|
||||
}
|
||||
return location;
|
||||
}
|
||||
|
||||
iterator insert(iterator position, const value_type& x){
|
||||
// FIXME - this is cheating and probably should be more efficient since we are
|
||||
// now log(n) to find for inserts
|
||||
return insert(x);
|
||||
}
|
||||
|
||||
template <class InputIterator> void insert(InputIterator first, InputIterator last){
|
||||
while(first != last){
|
||||
insert(*first);
|
||||
++first;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#pragma GCC visibility pop
|
||||
|
||||
#endif //__STD_HEADER_ASSOCIATIVE_BASE
|
||||
|
||||
26
libraries/ArduinoSTL/src/associative_base.cpp
Normal file
26
libraries/ArduinoSTL/src/associative_base.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/* Copyright (C) 2007 Garrett A. Kajmowicz
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "associative_base"
|
||||
|
||||
namespace std{
|
||||
|
||||
|
||||
|
||||
}
|
||||
86
libraries/ArduinoSTL/src/basic_definitions
Normal file
86
libraries/ArduinoSTL/src/basic_definitions
Normal file
@@ -0,0 +1,86 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
This file is part of the uClibc++ Library.
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef __BASIC_DEFINITIONS
|
||||
#define __BASIC_DEFINITIONS 1
|
||||
|
||||
#include "system_configuration.h"
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
|
||||
//The following is used to support GCC symbol visibility patch
|
||||
|
||||
#ifdef GCC_HASCLASSVISIBILITY
|
||||
#define _UCXXEXPORT __attribute__ ((visibility("default")))
|
||||
#define _UCXXLOCAL __attribute__ ((visibility("hidden")))
|
||||
#else
|
||||
#define _UCXXEXPORT
|
||||
#define _UCXXLOCAL
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __GCC__
|
||||
#define __UCLIBCXX_NORETURN __attribute__ ((__noreturn__))
|
||||
#else
|
||||
#define __UCLIBCXX_NORETURN
|
||||
#endif
|
||||
|
||||
#ifdef __GCC__
|
||||
# ifndef _UCXX_NOTHROW
|
||||
# ifndef __cplusplus
|
||||
# define _UCXX_NOTHROW __attribute__((__nothrow__))
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
# if __cplusplus >= 201103L
|
||||
# define _UCXX_NOEXCEPT noexcept
|
||||
# define _UCXX_USE_NOEXCEPT noexcept
|
||||
# define _UCXX_THROW(_EXCEPTION)
|
||||
# else
|
||||
# define _UCXX_NOEXCEPT
|
||||
# define _UCXX_USE_NOEXCEPT throw()
|
||||
# define _UCXX_THROW(_EXCEPTION) throw(_EXCEPTION)
|
||||
# endif
|
||||
# ifndef _UCXX_NOTHROW
|
||||
# define _UCXX_NOTHROW _UCXX_USE_NOEXCEPT
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __UCLIBCXX_HAS_TLS__
|
||||
#define __UCLIBCXX_TLS __thread
|
||||
#else
|
||||
#define __UCLIBCXX_TLS
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//Testing purposes
|
||||
#define __STRING_MAX_UNITS 65535
|
||||
|
||||
namespace std{
|
||||
typedef signed long int streamsize;
|
||||
}
|
||||
|
||||
#pragma GCC visibility pop
|
||||
|
||||
# ifdef __DODEBUG__
|
||||
#define UCLIBCXX_DEBUG 1
|
||||
# else
|
||||
#define UCLIBCXX_DEBUG 0
|
||||
# endif
|
||||
#endif
|
||||
423
libraries/ArduinoSTL/src/bitset
Normal file
423
libraries/ArduinoSTL/src/bitset
Normal file
@@ -0,0 +1,423 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "basic_definitions"
|
||||
#include "cstddef"
|
||||
#include "climits"
|
||||
#include "func_exception"
|
||||
#include "string"
|
||||
#include "iosfwd"
|
||||
|
||||
#ifndef __STD_BITSET_HEADER
|
||||
#define __STD_BITSET_HEADER 1
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
|
||||
namespace std{
|
||||
template <size_t N> class bitset;
|
||||
|
||||
|
||||
template <size_t N> bitset<N> operator&(const bitset<N>&, const bitset<N>&);
|
||||
template <size_t N> bitset<N> operator|(const bitset<N>&, const bitset<N>&);
|
||||
template <size_t N> bitset<N> operator^(const bitset<N>&, const bitset<N>&);
|
||||
template <class charT, class traits, size_t N> basic_istream<charT, traits>&
|
||||
operator>>(basic_istream<charT, traits>& is, bitset<N>& x);
|
||||
|
||||
template <class charT, class traits, size_t N> basic_ostream<charT, traits>&
|
||||
operator<<(basic_ostream<charT, traits>& os, const bitset<N>& x);
|
||||
|
||||
//Actual Code
|
||||
|
||||
|
||||
template<size_t N> class _UCXXEXPORT bitset {
|
||||
private:
|
||||
//Number of characters allocated to hold the bits
|
||||
static const size_t WORD_SIZE = CHAR_BIT; //Use int maybe?
|
||||
static const size_t num_bytes = (N + WORD_SIZE - 1) / WORD_SIZE;
|
||||
|
||||
//From the bit number, figure out which byte we are working with
|
||||
size_t byte_num(size_t bit_num) const{
|
||||
if(WORD_SIZE == 8){
|
||||
return (bit_num >> 3);
|
||||
}
|
||||
if(WORD_SIZE == 16){
|
||||
return (bit_num >> 4);
|
||||
}
|
||||
if(WORD_SIZE == 32){
|
||||
return (bit_num >> 5);
|
||||
}
|
||||
if(WORD_SIZE == 64){
|
||||
return (bit_num >> 6);
|
||||
}
|
||||
return bit_num / WORD_SIZE;
|
||||
}
|
||||
//From the bit number, figure out which bit inside the byte we need
|
||||
size_t bit_num(const size_t bit_num) const{
|
||||
return bit_num % WORD_SIZE;
|
||||
}
|
||||
|
||||
|
||||
//Point to the actual data
|
||||
char data[num_bytes];
|
||||
public:
|
||||
|
||||
class _UCXXEXPORT reference {
|
||||
friend class bitset;
|
||||
reference() : bit_num(0), parent(0) { }
|
||||
size_t bit_num;
|
||||
bitset * parent;
|
||||
public:
|
||||
~reference() { }
|
||||
reference& operator=(bool x){ // for b[i] = x;
|
||||
parent->set(bit_num, x);
|
||||
return *this;
|
||||
}
|
||||
reference& operator=(const reference& x){ // for b[i] = b[j];
|
||||
parent->set(bit_num, x);
|
||||
return *this;
|
||||
}
|
||||
bool operator~() const{ // flips the bit
|
||||
return !parent->test(bit_num);
|
||||
}
|
||||
operator bool() const{ // for x = b[i];
|
||||
return parent->test(bit_num);
|
||||
}
|
||||
reference& flip(){ // for b[i].flip();
|
||||
parent->flip(bit_num);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
bitset(){
|
||||
reset();
|
||||
}
|
||||
bitset(unsigned long val){
|
||||
reset();
|
||||
size_t count = sizeof(val) * CHAR_BIT;
|
||||
if(count > N){
|
||||
count = N;
|
||||
}
|
||||
for(size_t i = 0; i < count; ++i){
|
||||
set(i, ((val >> i) & 1));
|
||||
}
|
||||
}
|
||||
|
||||
bitset(const bitset & val){
|
||||
for(size_t i = 0; i < num_bytes; ++i){
|
||||
data[i] = val.data[i];
|
||||
}
|
||||
}
|
||||
|
||||
template<class charT, class traits, class Allocator> _UCXXEXPORT
|
||||
explicit bitset(
|
||||
const basic_string<charT,traits,Allocator>& str,
|
||||
typename basic_string<charT,traits,Allocator>::size_type pos = 0,
|
||||
typename basic_string<charT,traits,Allocator>::size_type n =
|
||||
basic_string<charT>::npos
|
||||
|
||||
){
|
||||
reset();
|
||||
if(n > str.length()){
|
||||
n = str.length();
|
||||
}
|
||||
size_t width = n;
|
||||
if (width + pos > str.length()){
|
||||
width = str.length() - pos;
|
||||
}
|
||||
|
||||
for(size_t i = 0; i < width; ++i){
|
||||
switch(str[pos + width - i - 1]){
|
||||
case '0':
|
||||
break;
|
||||
case '1':
|
||||
set(i);
|
||||
break;
|
||||
default:
|
||||
__throw_invalid_argument();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bitset<N>& operator&=(const bitset<N>& rhs){
|
||||
for(size_t i =0; i < num_bytes; ++i){
|
||||
data[i] &= rhs.data[i];
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
bitset<N>& operator|=(const bitset<N>& rhs){
|
||||
for(size_t i =0; i < num_bytes; ++i){
|
||||
data[i] |= rhs.data[i];
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
bitset<N>& operator^=(const bitset<N>& rhs){
|
||||
for(size_t i=0; i < num_bytes; ++i){
|
||||
data[i] ^= rhs.data[i];
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
bitset<N>& operator<<=(size_t pos){
|
||||
for(size_t i = N-1; i >=pos; --i){
|
||||
set(i, test(i - pos));
|
||||
}
|
||||
for(size_t i = 0; i < pos; ++i){
|
||||
reset(i);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
bitset<N>& operator>>=(size_t pos){
|
||||
for(size_t i = 0; i < (N - pos); ++i){
|
||||
set(i, test(i + pos));
|
||||
}
|
||||
for(size_t i = pos; i > 0; --i){
|
||||
reset(N - i);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
bitset<N>& set(){
|
||||
size_t i;
|
||||
for(i = 0; i < N ; ++i){
|
||||
data[byte_num(i)] |= (1<<bit_num(i));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
bitset<N>& set(size_t pos, int val = true){
|
||||
if(val == true){
|
||||
data[byte_num(pos)] |= (1<<bit_num(pos));
|
||||
}else{
|
||||
data[byte_num(pos)] &= ~(1<<bit_num(pos));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
bitset<N>& reset(){
|
||||
for(size_t i = 0; i < num_bytes; ++i){
|
||||
data[i] = 0;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
bitset<N>& reset(size_t pos){
|
||||
data[byte_num(pos)] &= ~(1<<bit_num(pos));
|
||||
return *this;
|
||||
}
|
||||
bitset<N> operator~() const{
|
||||
bitset<N> retval(*this);
|
||||
retval.flip();
|
||||
return retval;
|
||||
}
|
||||
|
||||
bitset<N>& flip(){
|
||||
for(size_t i = 0; i < num_bytes; ++i){
|
||||
data[i] = ~data[i];
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
bitset<N>& flip(size_t pos){
|
||||
char temp = data[byte_num(pos)] & (1 << bit_num(pos));
|
||||
if(temp == 0){ //Bit was 0
|
||||
data[byte_num(pos)] |= (1 << bit_num(pos));
|
||||
}else{ //Bit was 1
|
||||
data[byte_num(pos)] &= ~(1<<bit_num(pos));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
reference operator[](size_t pos){ // for b[i];
|
||||
reference retval;
|
||||
retval.parent = this;
|
||||
retval.bit_num = pos;
|
||||
return retval;
|
||||
}
|
||||
|
||||
unsigned long to_ulong() const{
|
||||
if(N > sizeof(unsigned long) * CHAR_BIT){
|
||||
__throw_overflow_error();
|
||||
}
|
||||
unsigned long retval = 0;
|
||||
size_t count = N;
|
||||
for(size_t i = count; i > 0; --i){
|
||||
if(test(i)){
|
||||
retval +=1;
|
||||
}
|
||||
retval<<=1;
|
||||
}
|
||||
if(test(0)){
|
||||
retval +=1;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
template <class charT, class traits, class Allocator>
|
||||
basic_string<charT, traits, Allocator> to_string() const
|
||||
{
|
||||
basic_string<charT, traits, Allocator> retval;
|
||||
retval.reserve(N);
|
||||
for(size_t i = N ; i > 0; --i){
|
||||
if(test(i-1) == true){
|
||||
retval.append("1");
|
||||
}else{
|
||||
retval.append("0");
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
size_t count() const{
|
||||
size_t retval = 0;
|
||||
for(size_t i =0; i < N; ++i){
|
||||
if(test(i)){
|
||||
++retval;
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
size_t size() const{
|
||||
return N;
|
||||
}
|
||||
|
||||
bitset<N>& operator=(const bitset<N> & rhs){
|
||||
if(&rhs == this){
|
||||
return *this;
|
||||
}
|
||||
for(size_t i = 0; i < num_bytes; ++i){
|
||||
data[i] = rhs.data[i];
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
bool operator==(const bitset<N>& rhs) const{
|
||||
for(size_t i =0; i< N; ++i){
|
||||
if(test(i) != rhs.test(i)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator!=(const bitset<N>& rhs) const{
|
||||
for(size_t i =0; i< N; ++i){
|
||||
if(test(i) != rhs.test(i)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool test(size_t pos) const{
|
||||
return (data[byte_num(pos)] & (1<<bit_num(pos)) ) != 0;
|
||||
}
|
||||
|
||||
bool any() const{
|
||||
for(size_t i = 0; i< N; ++i){
|
||||
if(test(i)==true){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool none() const{
|
||||
if(any() == true){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bitset<N> operator<<(size_t pos) const{
|
||||
bitset retval(*this);
|
||||
retval<<=pos;
|
||||
return retval;
|
||||
}
|
||||
bitset<N> operator>>(size_t pos) const{
|
||||
bitset retval(*this);
|
||||
retval>>=pos;
|
||||
return retval;
|
||||
}
|
||||
};
|
||||
|
||||
//Non-member functions
|
||||
|
||||
|
||||
template <size_t N> _UCXXEXPORT bitset<N> operator&(const bitset<N>& lhs, const bitset<N>& rhs){
|
||||
bitset<N> retval(lhs);
|
||||
retval &= rhs;
|
||||
return retval;
|
||||
}
|
||||
|
||||
template <size_t N> _UCXXEXPORT bitset<N> operator|(const bitset<N>& lhs, const bitset<N>& rhs){
|
||||
bitset<N> retval(lhs);
|
||||
retval |= rhs;
|
||||
return retval;
|
||||
}
|
||||
|
||||
template <size_t N> _UCXXEXPORT bitset<N> operator^(const bitset<N>& lhs, const bitset<N>& rhs){
|
||||
bitset<N> retval(lhs);
|
||||
retval ^= rhs;
|
||||
return retval;
|
||||
}
|
||||
|
||||
template <class charT, class traits, size_t N> _UCXXEXPORT basic_istream<charT, traits>&
|
||||
operator>>(basic_istream<charT, traits>& is, bitset<N>& x)
|
||||
{
|
||||
string s;
|
||||
charT c;
|
||||
for(size_t i = 0; i < N; ++i){
|
||||
is.get(c);
|
||||
if(!is.good()){
|
||||
break;
|
||||
}
|
||||
if(c != '1' && c !='0'){
|
||||
is.putback(c);
|
||||
break;
|
||||
}
|
||||
s+=c;
|
||||
}
|
||||
bitset<N> temp(s);
|
||||
x = temp;
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
template <class charT, class traits, size_t N> _UCXXEXPORT basic_ostream<charT, traits>&
|
||||
operator<<(basic_ostream<charT, traits>& os, const bitset<N>& x)
|
||||
{
|
||||
for(size_t i = N ; i > 0; --i){
|
||||
if(x.test(i-1) == true){
|
||||
os << "1";
|
||||
}else{
|
||||
os << "0";
|
||||
}
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#pragma GCC visibility pop
|
||||
|
||||
#endif
|
||||
|
||||
26
libraries/ArduinoSTL/src/bitset.cpp
Normal file
26
libraries/ArduinoSTL/src/bitset.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "bitset"
|
||||
|
||||
namespace std{
|
||||
|
||||
|
||||
|
||||
}
|
||||
19
libraries/ArduinoSTL/src/cassert
Normal file
19
libraries/ArduinoSTL/src/cassert
Normal file
@@ -0,0 +1,19 @@
|
||||
/* Copyright (C) 2005 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
37
libraries/ArduinoSTL/src/cctype
Normal file
37
libraries/ArduinoSTL/src/cctype
Normal file
@@ -0,0 +1,37 @@
|
||||
/* Copyright (C) 2006 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
namespace std{
|
||||
|
||||
using ::isalnum;
|
||||
using ::isalpha;
|
||||
using ::iscntrl;
|
||||
using ::isdigit;
|
||||
using ::isgraph;
|
||||
using ::islower;
|
||||
using ::isprint;
|
||||
using ::ispunct;
|
||||
using ::isspace;
|
||||
using ::isupper;
|
||||
using ::isxdigit;
|
||||
using ::tolower;
|
||||
using ::toupper;
|
||||
|
||||
}
|
||||
19
libraries/ArduinoSTL/src/cerrno
Normal file
19
libraries/ArduinoSTL/src/cerrno
Normal file
@@ -0,0 +1,19 @@
|
||||
/* Copyright (C) 2005 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
30
libraries/ArduinoSTL/src/cfloat
Normal file
30
libraries/ArduinoSTL/src/cfloat
Normal file
@@ -0,0 +1,30 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <setjmp.h>
|
||||
|
||||
#ifndef __STD_HEADER_CFLOAT
|
||||
#define __STD_HEADER_CFLOAT 1
|
||||
|
||||
|
||||
#include <float.h>
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
198
libraries/ArduinoSTL/src/char_traits
Normal file
198
libraries/ArduinoSTL/src/char_traits
Normal file
@@ -0,0 +1,198 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "basic_definitions"
|
||||
#include <string.h>
|
||||
#include "exception"
|
||||
#include "memory"
|
||||
|
||||
#ifdef __UCLIBCXX_HAS_WCHAR__
|
||||
#include "cwchar"
|
||||
#include "cwctype"
|
||||
#endif
|
||||
|
||||
#ifndef __HEADER_CHAR_TRAITS
|
||||
#define __HEADER_CHAR_TRAITS 1
|
||||
|
||||
namespace std{
|
||||
/* Inlining all wrapped function calls to shrink the amount of code generated*/
|
||||
//Typedefs to use for stuff
|
||||
typedef signed int char_traits_off_type;
|
||||
|
||||
//Generic char_traits
|
||||
template<class charT> struct _UCXXEXPORT char_traits { };
|
||||
|
||||
//Specialize for char
|
||||
template<> struct _UCXXEXPORT char_traits<char> {
|
||||
typedef char char_type;
|
||||
typedef short int int_type;
|
||||
typedef char_traits_off_type off_type;
|
||||
typedef char_traits_off_type pos_type;
|
||||
typedef char state_type;
|
||||
|
||||
inline static void assign(char_type & c, const char_type & d) { c = d; }
|
||||
|
||||
static bool eq(const char_type& c1, const char_type& c2);
|
||||
|
||||
static char_type to_char_type(const int_type & i);
|
||||
|
||||
inline static int_type to_int_type(const char_type & c){
|
||||
return static_cast<short int>(static_cast<unsigned char>(c));
|
||||
}
|
||||
|
||||
inline static bool eq_int_type(const int_type & a, const int_type & b){
|
||||
if(a==b){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
inline static bool lt(const char_type& c1, const char_type& c2){
|
||||
if(strncmp(&c1, &c2, 1) < 0){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline static char_type* move(char_type* s1, const char_type* s2, size_t n){
|
||||
return static_cast<char*>(memmove(s1, s2, n));
|
||||
}
|
||||
|
||||
inline static char_type* copy(char_type* s1, const char_type* s2, size_t n){
|
||||
for(unsigned long int i=0; i< n; ++i){
|
||||
assign(s1[i], s2[i]);
|
||||
}
|
||||
return s1 + n;
|
||||
}
|
||||
|
||||
inline static char_type* assign(char_type* s, size_t n, char_type a){
|
||||
return static_cast<char *>(memset(s, a, n));
|
||||
}
|
||||
|
||||
inline static int compare(const char_type* s1, const char_type* s2, size_t n){
|
||||
return strncmp(s1, s2, n);
|
||||
}
|
||||
|
||||
inline static size_t length(const char_type* s){
|
||||
return strlen(s);
|
||||
}
|
||||
|
||||
static const char_type* find(const char_type* s, int n, const char_type& a);
|
||||
|
||||
inline static char_type eos() { return 0; }
|
||||
inline static int_type eof() { return -1; }
|
||||
inline static int_type not_eof(const int_type & i) {
|
||||
if(i == -1){
|
||||
return 0;
|
||||
} else {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
static state_type get_state(pos_type p){
|
||||
p = p;
|
||||
state_type a;
|
||||
return a;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#ifdef __UCLIBCXX_HAS_WCHAR__
|
||||
template<> struct _UCXXEXPORT char_traits<wchar_t> {
|
||||
typedef wchar_t char_type;
|
||||
typedef wint_t int_type;
|
||||
typedef char_traits_off_type off_type;
|
||||
typedef char_traits_off_type pos_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
static void assign(char_type & c, const char_type & d){ c=d; }
|
||||
|
||||
static char_type to_char_type(const int_type & i){
|
||||
return i;
|
||||
}
|
||||
|
||||
static int_type to_int_type(const char_type & c){
|
||||
return c;
|
||||
}
|
||||
|
||||
inline static bool eq_int_type(const int_type & a, const int_type & b){
|
||||
if(a==b){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline static bool eq(const char_type& c1, const char_type& c2){
|
||||
if(wcsncmp(&c1, &c2, 1) == 0){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline static bool lt(const char_type& c1, const char_type& c2){
|
||||
if(wcsncmp(&c1, &c2, 1) < 0){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline static char_type* move(char_type* s1, const char_type* s2, size_t n){
|
||||
return (char_type*) memmove(s1, s2, n * sizeof(char_type));
|
||||
}
|
||||
|
||||
inline static char_type* copy(char_type* s1, const char_type* s2, size_t n){
|
||||
for(unsigned long int i=0; i< n; ++i){
|
||||
assign(s1[i], s2[i]);
|
||||
}
|
||||
return s1 + n;
|
||||
}
|
||||
|
||||
inline static char_type* assign(char_type* s, size_t n, char_type a){
|
||||
return (char_type *)memset(s, a, n); /*FIXME*/
|
||||
}
|
||||
|
||||
inline static int compare(const char_type* s1, const char_type* s2, size_t n){
|
||||
return wcsncmp(s1, s2, n);
|
||||
}
|
||||
|
||||
inline static size_t length(const char_type* s){
|
||||
return wcslen(s);
|
||||
}
|
||||
|
||||
static const char_type* find(const char_type* s, int n, const char_type& a);
|
||||
|
||||
inline static char_type eos() { return 0; }
|
||||
inline static int_type eof() { return WEOF; }
|
||||
inline static int_type not_eof(const int_type & i) {
|
||||
if(i == WEOF){
|
||||
return (int_type)0;
|
||||
} else {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
static state_type get_state(pos_type){
|
||||
state_type a;
|
||||
return a;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
69
libraries/ArduinoSTL/src/char_traits.cpp
Normal file
69
libraries/ArduinoSTL/src/char_traits.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#define __UCLIBCXX_COMPILE_CHAR_TRAITS__ 1
|
||||
|
||||
|
||||
#include "basic_definitions"
|
||||
#include "char_traits"
|
||||
|
||||
namespace std{
|
||||
|
||||
_UCXXEXPORT const char_traits<char>::char_type* char_traits<char>::find(const char_type* s, int n, const char_type& a){
|
||||
for(int i=0; i < n; i++){
|
||||
if(eq(s[i], a)){
|
||||
return (s+i);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
_UCXXEXPORT bool char_traits<char>::eq(const char_type& c1, const char_type& c2){
|
||||
if(strncmp(&c1, &c2, 1) == 0){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
_UCXXEXPORT char_traits<char>::char_type char_traits<char>::to_char_type(const int_type & i){
|
||||
if(i > 0 && i <= 255){
|
||||
return (char)(unsigned char)i;
|
||||
}
|
||||
|
||||
//Out of range
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef __UCLIBCXX_HAS_WCHAR__
|
||||
|
||||
_UCXXEXPORT const char_traits<wchar_t>::char_type* char_traits<wchar_t>::find(const char_type* s, int n, const char_type& a){
|
||||
for(int i=0; i < n; i++){
|
||||
if(eq(s[i], a)){
|
||||
return (s+i);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
1
libraries/ArduinoSTL/src/cinttypes
Normal file
1
libraries/ArduinoSTL/src/cinttypes
Normal file
@@ -0,0 +1 @@
|
||||
#include <inttypes.h>
|
||||
28
libraries/ArduinoSTL/src/climits
Normal file
28
libraries/ArduinoSTL/src/climits
Normal file
@@ -0,0 +1,28 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef __STD_HEADER_CLIMITS
|
||||
#define __STD_HEADER_CLIMITS 1
|
||||
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
30
libraries/ArduinoSTL/src/clocale
Normal file
30
libraries/ArduinoSTL/src/clocale
Normal file
@@ -0,0 +1,30 @@
|
||||
/* Copyright (C) 2005 Garrett A. Kajmowicz
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef __STD_HEADER_CLOCALE
|
||||
#define __STD_HEADER_CLOCALE 1
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
namespace std {
|
||||
using ::lconv;
|
||||
using ::setlocale;
|
||||
using ::localeconv;
|
||||
}
|
||||
|
||||
#endif // __STD_HEADER_CLOCALE
|
||||
234
libraries/ArduinoSTL/src/cmath
Normal file
234
libraries/ArduinoSTL/src/cmath
Normal file
@@ -0,0 +1,234 @@
|
||||
/* Copyright (C) 2006 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#ifndef __STD_HEADER_CMATH
|
||||
#define __STD_HEADER_CMATH 1
|
||||
|
||||
#undef abs
|
||||
#undef acos
|
||||
#undef asin
|
||||
#undef atan
|
||||
#undef atan2
|
||||
#undef ceil
|
||||
#undef cos
|
||||
#undef cosh
|
||||
#undef exp
|
||||
#undef fabs
|
||||
#undef floor
|
||||
#undef fmod
|
||||
#undef frexp
|
||||
#undef ldexp
|
||||
#undef log
|
||||
#undef log10
|
||||
#undef modf
|
||||
#undef pow
|
||||
#undef sin
|
||||
#undef sinh
|
||||
#undef sqrt
|
||||
#undef tan
|
||||
#undef tanh
|
||||
|
||||
namespace std {
|
||||
|
||||
using ::acos;
|
||||
using ::asin;
|
||||
using ::atan;
|
||||
using ::atan2;
|
||||
using ::ceil;
|
||||
using ::cos;
|
||||
using ::cosh;
|
||||
using ::exp;
|
||||
using ::fabs;
|
||||
using ::floor;
|
||||
using ::fmod;
|
||||
using ::frexp;
|
||||
using ::ldexp;
|
||||
using ::log;
|
||||
using ::log10;
|
||||
using ::modf;
|
||||
using ::pow;
|
||||
using ::sin;
|
||||
using ::sinh;
|
||||
using ::sqrt;
|
||||
using ::tan;
|
||||
using ::tanh;
|
||||
|
||||
#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
|
||||
inline float abs (float x){
|
||||
return fabsf(x);
|
||||
}
|
||||
inline float acos (float x){
|
||||
return acosf(x);
|
||||
}
|
||||
inline float asin (float x){
|
||||
return asinf(x);
|
||||
}
|
||||
inline float atan (float x){
|
||||
return atanf(x);
|
||||
}
|
||||
inline float atan2(float y, float x){
|
||||
return atan2f(y, x);
|
||||
}
|
||||
inline float ceil (float x){
|
||||
return ceilf(x);
|
||||
}
|
||||
inline float cos (float x){
|
||||
return cosf(x);
|
||||
}
|
||||
inline float cosh (float x){
|
||||
return coshf(x);
|
||||
}
|
||||
inline float exp (float x){
|
||||
return expf(x);
|
||||
}
|
||||
inline float fabs (float x){
|
||||
return fabsf(x);
|
||||
}
|
||||
inline float floor(float x){
|
||||
return floorf(x);
|
||||
}
|
||||
inline float fmod (float x, float y){
|
||||
return fmodf(x, y);
|
||||
}
|
||||
inline float frexp(float x, int* exp){
|
||||
return frexpf(x, exp);
|
||||
}
|
||||
inline float ldexp(float x, int exp){
|
||||
return ldexpf(x, exp);
|
||||
}
|
||||
inline float log (float x){
|
||||
return logf(x);
|
||||
}
|
||||
inline float log10(float x){
|
||||
return log10f(x);
|
||||
}
|
||||
inline float modf (float x, float* inptr){
|
||||
return modff(x, inptr);
|
||||
}
|
||||
inline float pow (float x, float y){
|
||||
return powf(x, y);
|
||||
}
|
||||
#if 1 // DR 550 removed this
|
||||
inline float pow (float x, int y){
|
||||
return pow((double)x, (double)y);
|
||||
}
|
||||
#endif
|
||||
inline float sin (float x){
|
||||
return sinf(x);
|
||||
}
|
||||
inline float sinh (float x){
|
||||
return sinhf(x);
|
||||
}
|
||||
inline float sqrt (float x){
|
||||
return sqrtf(x);
|
||||
}
|
||||
inline float tan (float x){
|
||||
return tanf(x);
|
||||
}
|
||||
inline float tanh (float x){
|
||||
return tanhf(x);
|
||||
}
|
||||
inline double abs(double x){
|
||||
return fabs(x);
|
||||
}
|
||||
inline double pow(double x, int y){
|
||||
return pow((double)x, (double)y);
|
||||
}
|
||||
|
||||
# ifdef __UCLIBCXX_HAS_LONG_DOUBLE__
|
||||
inline long double abs (long double x){
|
||||
return fabsl(x);
|
||||
}
|
||||
inline long double acos (long double x){
|
||||
return acosl(x);
|
||||
}
|
||||
inline long double asin (long double x){
|
||||
return asinl(x);
|
||||
}
|
||||
inline long double atan (long double x){
|
||||
return atanl(x);
|
||||
}
|
||||
inline long double atan2(long double y, long double x){
|
||||
return atan2l(y, x);
|
||||
}
|
||||
inline long double ceil (long double x){
|
||||
return ceill(x);
|
||||
}
|
||||
inline long double cos (long double x){
|
||||
return cosl(x);
|
||||
}
|
||||
inline long double cosh (long double x){
|
||||
return coshl(x);
|
||||
}
|
||||
inline long double exp (long double x){
|
||||
return expl(x);
|
||||
}
|
||||
inline long double fabs (long double x){
|
||||
return fabsl(x);
|
||||
}
|
||||
inline long double floor(long double x){
|
||||
return floorl(x);
|
||||
}
|
||||
inline long double frexp(long double x, int* exp){
|
||||
return frexpl(x, exp);
|
||||
}
|
||||
inline long double fmod (long double x, long double y){
|
||||
return fmodl(x, y);
|
||||
}
|
||||
inline long double ldexp(long double x, int y){
|
||||
return ldexpl(x, y);
|
||||
}
|
||||
inline long double log (long double x){
|
||||
return logl(x);
|
||||
}
|
||||
inline long double log10(long double x){
|
||||
return log10l(x);
|
||||
}
|
||||
inline long double modf (long double x, long double* iptr){
|
||||
return modfl(x, iptr);
|
||||
}
|
||||
inline long double pow (long double x, long double y){
|
||||
return powl(x, y);
|
||||
}
|
||||
inline long double pow (long double x, int y){
|
||||
return powl(x, (long double)y );
|
||||
}
|
||||
inline long double sin (long double x){
|
||||
return sinl(x);
|
||||
}
|
||||
inline long double sinh (long double x){
|
||||
return sinhl(x);
|
||||
}
|
||||
inline long double sqrt (long double x){
|
||||
return sqrtl(x);
|
||||
}
|
||||
inline long double tan (long double x){
|
||||
return tanl(x);
|
||||
}
|
||||
inline long double tanh (long double x){
|
||||
return tanhl(x);
|
||||
}
|
||||
# endif // __UCLIBCXX_HAS_LONG_DOUBLE__
|
||||
#endif // __CORRECT_ISO_CPP_MATH_H_PROTO
|
||||
}
|
||||
|
||||
#endif //__STD_HEADER_CMATH
|
||||
|
||||
327
libraries/ArduinoSTL/src/complex
Normal file
327
libraries/ArduinoSTL/src/complex
Normal file
@@ -0,0 +1,327 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "istream"
|
||||
#include "ostream"
|
||||
|
||||
#ifndef __STD_HEADER_COMPLEX
|
||||
#define __STD_HEADER_COMPLEX 1
|
||||
|
||||
|
||||
namespace std {
|
||||
// class complex<float>;
|
||||
// class complex<double>;
|
||||
// class complex<long double>;
|
||||
|
||||
template<class T> class _UCXXEXPORT complex{
|
||||
public:
|
||||
typedef T value_type;
|
||||
|
||||
complex(const T& re = T(), const T& im = T()) : r(re), i(im) { }
|
||||
complex(const complex& c): r(c.r), i(c.i){ }
|
||||
template<class X> complex(const complex<X>& c): r(c.r), i(c.i){ }
|
||||
|
||||
inline T real() const{
|
||||
return r;
|
||||
}
|
||||
inline T imag() const{
|
||||
return i;
|
||||
}
|
||||
|
||||
complex<T>& operator= (const T& v){
|
||||
r = v;
|
||||
i = 0;
|
||||
return *this;
|
||||
}
|
||||
complex<T>& operator+=(const T& v){
|
||||
r +=v;
|
||||
return *this;
|
||||
}
|
||||
complex<T>& operator-=(const T& v){
|
||||
r -=v;
|
||||
return *this;
|
||||
}
|
||||
complex<T>& operator*=(const T& v){
|
||||
r*=v;
|
||||
i*=v;
|
||||
return *this;
|
||||
}
|
||||
complex<T>& operator/=(const T& v){
|
||||
r/=v;
|
||||
i/=v;
|
||||
return *this;
|
||||
}
|
||||
complex& operator=(const complex& v){
|
||||
if(&v != this){
|
||||
r = v.r;
|
||||
i = v.i;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
template<class X> complex<T>& operator= (const complex<X>& v){
|
||||
r = v.r;
|
||||
i = v.i;
|
||||
return *this;
|
||||
}
|
||||
template<class X> complex<T>& operator+=(const complex<X>& v){
|
||||
r+=v.r;
|
||||
i+=v.i;
|
||||
return *this;
|
||||
}
|
||||
template<class X> complex<T>& operator-=(const complex<X>& v){
|
||||
r-=v.r;
|
||||
i-=v.i;
|
||||
return *this;
|
||||
}
|
||||
template<class X> complex<T>& operator*=(const complex<X>& v){
|
||||
T tempr = r*v.r - i*v.i;
|
||||
T tempi = r*v.i + i*v.r;
|
||||
r = tempr;
|
||||
i = tempi;
|
||||
return *this;
|
||||
}
|
||||
template<class X> complex<T>& operator/=(const complex<X>& v){
|
||||
T tempr = (r*v.r + i*v.i) / (v.r*v.r + v.i*v.i);
|
||||
T tempi = (i*v.r - r*v.i) / (v.r*v.r + v.i*v.i);
|
||||
r = tempr;
|
||||
i = tempi;
|
||||
return *this;
|
||||
}
|
||||
private:
|
||||
T r;
|
||||
T i;
|
||||
};
|
||||
|
||||
template<class T> _UCXXEXPORT complex<T> operator+(const complex<T>& ls, const complex<T>& rs){
|
||||
complex<T> retval(ls);
|
||||
retval += rs;
|
||||
return retval;
|
||||
}
|
||||
template<class T> _UCXXEXPORT complex<T> operator+(const complex<T>& ls, const T& rs){
|
||||
complex<T> retval(ls);
|
||||
ls += rs;
|
||||
return retval;
|
||||
}
|
||||
template<class T> _UCXXEXPORT inline complex<T> operator+(const T& ls, const complex<T>& rs){
|
||||
return rs + ls;
|
||||
}
|
||||
template<class T> _UCXXEXPORT complex<T> operator-(const complex<T>& ls, const complex<T>& rs){
|
||||
complex<T> retval(ls);
|
||||
retval -= rs;
|
||||
return retval;
|
||||
}
|
||||
template<class T> _UCXXEXPORT complex<T> operator-(const complex<T>& ls, const T& rs){
|
||||
complex<T> retval(ls);
|
||||
retval -= rs;
|
||||
return retval;
|
||||
}
|
||||
template<class T> _UCXXEXPORT complex<T> operator-(const T& ls, const complex<T>& rs){
|
||||
complex<T> retval(ls);
|
||||
retval -= rs;
|
||||
return retval;
|
||||
}
|
||||
template<class T> _UCXXEXPORT complex<T> operator*(const complex<T>& ls, const complex<T>& rs){
|
||||
complex<T> retval(ls);
|
||||
retval *= rs;
|
||||
return retval;
|
||||
}
|
||||
template<class T> _UCXXEXPORT complex<T> operator*(const complex<T>& ls, const T& rs){
|
||||
complex<T> retval(ls);
|
||||
retval *= rs;
|
||||
return retval;
|
||||
}
|
||||
template<class T> _UCXXEXPORT complex<T> operator*(const T& ls, const complex<T>& rs){
|
||||
complex<T> retval(ls);
|
||||
retval *=rs;
|
||||
return retval;
|
||||
}
|
||||
template<class T> _UCXXEXPORT complex<T> operator/(const complex<T>& ls, const complex<T>& rs){
|
||||
complex<T> retval(ls);
|
||||
retval/=rs;
|
||||
return retval;
|
||||
}
|
||||
template<class T> _UCXXEXPORT complex<T> operator/(const complex<T>& ls, const T& rs){
|
||||
complex<T> retval(ls);
|
||||
retval/=rs;
|
||||
return retval;
|
||||
}
|
||||
template<class T> _UCXXEXPORT complex<T> operator/(const T& ls, const complex<T>& rs){
|
||||
complex<T> retval(ls);
|
||||
retval/=rs;
|
||||
return retval;
|
||||
}
|
||||
template<class T> _UCXXEXPORT complex<T> operator+(const complex<T>& v){
|
||||
return v;
|
||||
}
|
||||
template<class T> _UCXXEXPORT complex<T> operator-(const complex<T>& v){
|
||||
return complex<T> (-v.real(), -v.imag());
|
||||
}
|
||||
template<class T> _UCXXEXPORT bool operator==(const complex<T>& ls, const complex<T>& rs){
|
||||
if( ls.real() == rs.real() && ls.imag() == rs.image()){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
template<class T> _UCXXEXPORT bool operator==(const complex<T>& ls, const T& rs){
|
||||
if(ls.real() == rs && ls.imag() == T()){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
template<class T> _UCXXEXPORT bool operator==(const T& ls, const complex<T>& rs){
|
||||
if(ls == rs.real() && rs.imag() == T()){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
template<class T> _UCXXEXPORT bool operator!=(const complex<T>& ls, const complex<T>& rs){
|
||||
if(ls == rs){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
template<class T> _UCXXEXPORT bool operator!=(const complex<T>& ls, const T& rs){
|
||||
if(ls == rs){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
template<class T> _UCXXEXPORT bool operator!=(const T& ls, const complex<T>& rs){
|
||||
if(ls == rs){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
template<class T, class charT, class traits> _UCXXEXPORT basic_istream<charT, traits>&
|
||||
operator>>(basic_istream<charT, traits>& is, complex<T>& v)
|
||||
{
|
||||
T tempr;
|
||||
T tempi;
|
||||
is >> tempr;
|
||||
is.get();
|
||||
is >> tempi;
|
||||
v = complex<T>(tempr, tempi);
|
||||
return is;
|
||||
}
|
||||
|
||||
template<class T, class charT, class traits> _UCXXEXPORT basic_ostream<charT, traits>&
|
||||
operator<<(basic_ostream<charT, traits>& os, const complex<T>&v)
|
||||
{
|
||||
os << v.real() << ", " << v.imag();
|
||||
return os;
|
||||
}
|
||||
|
||||
template<class T> _UCXXEXPORT T real(const complex<T>& v){
|
||||
return v.real();
|
||||
}
|
||||
|
||||
template<class T> _UCXXEXPORT T imag(const complex<T>& v){
|
||||
return v.imag();
|
||||
}
|
||||
|
||||
template<class T> _UCXXEXPORT T norm(const complex<T>& v){
|
||||
return (v.real() * v.real() + v.imag() * v.imag());
|
||||
}
|
||||
|
||||
template<class T> _UCXXEXPORT complex<T> conj(const complex<T>& v){
|
||||
return complex<T>(v.real(), -v.imag());
|
||||
}
|
||||
|
||||
#ifdef __UCLIBCXX_SUPPORT_MATH__ //Can we link with libm?
|
||||
|
||||
template<class T> _UCXXEXPORT T abs(const complex<T>& v){
|
||||
return sqrt(v.real() * v.real() + v.imag() * v.imag());
|
||||
}
|
||||
|
||||
template<class T> _UCXXEXPORT T arg(const complex<T>& v){
|
||||
return atan2(v.imag(), v.real());
|
||||
}
|
||||
|
||||
template<class T> _UCXXEXPORT complex<T> polar(const T& rho, const T& theta){
|
||||
return complex<T>(rho * cos(theta), rho * sin(theta));
|
||||
}
|
||||
|
||||
template<class T> _UCXXEXPORT complex<T> cos (const complex<T>& v){
|
||||
return complex<T>(cos(v.real()) * cosh(v.imag()), -sin(v.real()) * sinh(v.imag()));
|
||||
}
|
||||
|
||||
template<class T> _UCXXEXPORT complex<T> cosh (const complex<T>& v){
|
||||
return complex<T>(cosh(v.real()) * cos(v.imag()), sinh(v.real()) * sin(v.imag()));
|
||||
}
|
||||
|
||||
template<class T> _UCXXEXPORT complex<T> exp (const complex<T>& v){
|
||||
return polar(exp(v.real()), v.imag());
|
||||
}
|
||||
|
||||
template<class T> _UCXXEXPORT complex<T> log (const complex<T>& v){
|
||||
return complex<T>(log(abs(v)), arg(v));
|
||||
}
|
||||
|
||||
template<class T> _UCXXEXPORT complex<T> log10(const complex<T>& v){
|
||||
return (log(v) / log(T(10.0)));
|
||||
}
|
||||
|
||||
template<class T> _UCXXEXPORT complex<T> pow(const complex<T>& v, int p){
|
||||
T rho = pow(abs(v), p);
|
||||
T theta = arg(v);
|
||||
return complex<T>(rho * cos(p * theta), rho * sin(p * theta) );
|
||||
}
|
||||
|
||||
template<class T> _UCXXEXPORT complex<T> pow(const complex<T>& v, const T& p){
|
||||
return polar( pow(abs(v),p), arg(v)*p );
|
||||
}
|
||||
|
||||
template<class T> _UCXXEXPORT complex<T> pow(const complex<T>& v, const complex<T>& p){
|
||||
if(v == T()){
|
||||
//We are using "0" as the value
|
||||
return T();
|
||||
}
|
||||
return exp(p * log(v));
|
||||
}
|
||||
|
||||
template<class T> _UCXXEXPORT complex<T> pow(const T& v, const complex<T>& p){
|
||||
if(v == T()){
|
||||
return T();
|
||||
}
|
||||
return polar(pow(v,p.real()), p.imag() * log(x) );
|
||||
}
|
||||
|
||||
template<class T> _UCXXEXPORT complex<T> sin (const complex<T>& v){
|
||||
return complex<T>(sin(v.real()) * cosh(v.imag()), cosh(v.real()) * sin(v.imag()));
|
||||
}
|
||||
|
||||
template<class T> _UCXXEXPORT complex<T> sinh (const complex<T>& v){
|
||||
return complex<T>(sinh(v.real()) * cos(v.imag()), cosh(v.real()) * sin(v.imag()) );
|
||||
}
|
||||
|
||||
template<class T> _UCXXEXPORT complex<T> sqrt (const complex<T>&);
|
||||
template<class T> _UCXXEXPORT complex<T> tan (const complex<T>& v){
|
||||
return sin(v) / cos(v);
|
||||
}
|
||||
|
||||
template<class T> _UCXXEXPORT complex<T> tanh (const complex<T>& v){
|
||||
return sinh(v) / cosh(v);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
28
libraries/ArduinoSTL/src/complex.cpp
Normal file
28
libraries/ArduinoSTL/src/complex.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
/* Copyright (C) 2005 Garrett A. Kajmowicz
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "complex"
|
||||
|
||||
|
||||
namespace std{
|
||||
|
||||
|
||||
template class _UCXXEXPORT complex<float>;
|
||||
|
||||
|
||||
}
|
||||
44
libraries/ArduinoSTL/src/csetjmp
Normal file
44
libraries/ArduinoSTL/src/csetjmp
Normal file
@@ -0,0 +1,44 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <setjmp.h>
|
||||
|
||||
#ifndef __STD_HEADER_CSETJMP
|
||||
#define __STD_HEADER_CSETJMP 1
|
||||
|
||||
|
||||
//From GCC Header files
|
||||
#undef longjmp
|
||||
|
||||
// Adhere to section 17.4.1.2 clause 5 of ISO 14882:1998
|
||||
#ifndef setjmp
|
||||
#define setjmp(env) setjmp (env)
|
||||
#endif
|
||||
|
||||
//Mine again
|
||||
|
||||
|
||||
namespace std{
|
||||
using ::longjmp;
|
||||
using ::jmp_buf;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
61
libraries/ArduinoSTL/src/csignal
Normal file
61
libraries/ArduinoSTL/src/csignal
Normal file
@@ -0,0 +1,61 @@
|
||||
// -*- C++ -*- forwarding header.
|
||||
|
||||
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
|
||||
// Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library 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, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library 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 library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
// USA.
|
||||
|
||||
// As a special exception, you may use this file as part of a free software
|
||||
// library without restriction. Specifically, if other files instantiate
|
||||
// templates or use macros or inline functions from this file, or you compile
|
||||
// this file and link it with other files to produce an executable, this
|
||||
// file does not by itself cause the resulting executable to be covered by
|
||||
// the GNU General Public License. This exception does not however
|
||||
// invalidate any other reasons why the executable file might be covered by
|
||||
// the GNU General Public License.
|
||||
|
||||
//
|
||||
// ISO C++ 14882: 20.4.6 C library
|
||||
//
|
||||
|
||||
/** @file csignal
|
||||
* This is a Standard C++ Library file. You should @c #include this file
|
||||
* in your programs, rather than any of the "*.h" implementation files.
|
||||
*
|
||||
* This is the C++ version of the Standard C Library header @c signal.h,
|
||||
* and its contents are (mostly) the same as that header, but are all
|
||||
* contained in the namespace @c std.
|
||||
*/
|
||||
|
||||
#ifndef _CPP_CSIGNAL
|
||||
#define _CPP_CSIGNAL 1
|
||||
|
||||
#pragma GCC system_header
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
// Get rid of those macros defined in <signal.h> in lieu of real functions.
|
||||
#undef raise
|
||||
|
||||
namespace std
|
||||
{
|
||||
using ::sig_atomic_t;
|
||||
using ::signal;
|
||||
using ::raise;
|
||||
}
|
||||
|
||||
#endif
|
||||
60
libraries/ArduinoSTL/src/cstdarg
Normal file
60
libraries/ArduinoSTL/src/cstdarg
Normal file
@@ -0,0 +1,60 @@
|
||||
// -*- C++ -*- forwarding header.
|
||||
|
||||
// Copyright (C) 1997, 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library 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, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library 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 library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
// USA.
|
||||
|
||||
// As a special exception, you may use this file as part of a free software
|
||||
// library without restriction. Specifically, if other files instantiate
|
||||
// templates or use macros or inline functions from this file, or you compile
|
||||
// this file and link it with other files to produce an executable, this
|
||||
// file does not by itself cause the resulting executable to be covered by
|
||||
// the GNU General Public License. This exception does not however
|
||||
// invalidate any other reasons why the executable file might be covered by
|
||||
// the GNU General Public License.
|
||||
|
||||
//
|
||||
// ISO C++ 14882: 20.4.6 C library
|
||||
//
|
||||
|
||||
/** @file cstdarg
|
||||
* This is a Standard C++ Library file. You should @c #include this file
|
||||
* in your programs, rather than any of the "*.h" implementation files.
|
||||
*
|
||||
* This is the C++ version of the Standard C Library header @c stdarg.h,
|
||||
* and its contents are (mostly) the same as that header, but are all
|
||||
* contained in the namespace @c std.
|
||||
*/
|
||||
|
||||
#ifndef _CPP_CSTDARG
|
||||
#define _CPP_CSTDARG 1
|
||||
|
||||
#pragma GCC system_header
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
// Adhere to section 17.4.1.2 clause 5 of ISO 14882:1998
|
||||
#ifndef va_end
|
||||
#define va_end(ap) va_end (ap)
|
||||
#endif
|
||||
|
||||
namespace std
|
||||
{
|
||||
using ::va_list;
|
||||
}
|
||||
|
||||
#endif
|
||||
58
libraries/ArduinoSTL/src/cstddef
Normal file
58
libraries/ArduinoSTL/src/cstddef
Normal file
@@ -0,0 +1,58 @@
|
||||
// -*- C++ -*- forwarding header.
|
||||
|
||||
// Copyright (C) 1997, 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library 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, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library 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 library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
// USA.
|
||||
|
||||
// As a special exception, you may use this file as part of a free software
|
||||
// library without restriction. Specifically, if other files instantiate
|
||||
// templates or use macros or inline functions from this file, or you compile
|
||||
// this file and link it with other files to produce an executable, this
|
||||
// file does not by itself cause the resulting executable to be covered by
|
||||
// the GNU General Public License. This exception does not however
|
||||
// invalidate any other reasons why the executable file might be covered by
|
||||
// the GNU General Public License.
|
||||
|
||||
//
|
||||
// ISO C++ 14882: 18.1 Types
|
||||
//
|
||||
|
||||
/** @file cstddef
|
||||
* This is a Standard C++ Library file. You should @c #include this file
|
||||
* in your programs, rather than any of the "*.h" implementation files.
|
||||
*
|
||||
* This is the C++ version of the Standard C Library header @c stddef.h,
|
||||
* and its contents are (mostly) the same as that header, but are all
|
||||
* contained in the namespace @c std.
|
||||
*/
|
||||
|
||||
#ifndef _CPP_CSTDDEF
|
||||
#define _CPP_CSTDDEF 1
|
||||
|
||||
#ifdef __GCC__
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
namespace std
|
||||
{
|
||||
using ::ptrdiff_t;
|
||||
using ::size_t;
|
||||
}
|
||||
|
||||
#endif
|
||||
32
libraries/ArduinoSTL/src/cstdint
Normal file
32
libraries/ArduinoSTL/src/cstdint
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef _CPP_CSTDINT
|
||||
#define _CPP_CSTDINT 1
|
||||
|
||||
#ifdef __GCC__
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace std {
|
||||
|
||||
using :: int8_t; using :: int16_t;
|
||||
using :: int32_t; using :: int64_t;
|
||||
using :: uint8_t; using :: uint16_t;
|
||||
using :: uint32_t; using :: uint64_t;
|
||||
|
||||
using :: int_least8_t; using :: int_least16_t;
|
||||
using :: int_least32_t; using :: int_least64_t;
|
||||
using :: uint_least8_t; using :: uint_least16_t;
|
||||
using :: uint_least32_t; using :: uint_least64_t;
|
||||
|
||||
using :: int_fast8_t; using :: int_fast16_t;
|
||||
using :: int_fast32_t; using :: int_fast64_t;
|
||||
using :: uint_fast8_t; using :: uint_fast16_t;
|
||||
using :: uint_fast32_t; using :: uint_fast64_t;
|
||||
|
||||
using :: intmax_t; using :: intptr_t;
|
||||
using :: uintmax_t; using :: uintptr_t;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
89
libraries/ArduinoSTL/src/cstdio
Normal file
89
libraries/ArduinoSTL/src/cstdio
Normal file
@@ -0,0 +1,89 @@
|
||||
/* Copyright (C) 2006 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation version 2.1
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "basic_definitions"
|
||||
|
||||
#ifndef __HEADER_CSTDIO
|
||||
#define __HEADER_CSTDIO 1
|
||||
|
||||
#undef clearerr
|
||||
#undef feof
|
||||
#undef ferror
|
||||
#undef fgetc
|
||||
#undef fputc
|
||||
#undef getc
|
||||
#undef getchar
|
||||
#undef putc
|
||||
#undef putchar
|
||||
|
||||
namespace std{
|
||||
using ::FILE;
|
||||
using ::fpos_t;
|
||||
|
||||
using ::clearerr;
|
||||
using ::fclose;
|
||||
using ::feof;
|
||||
using ::ferror;
|
||||
using ::fflush;
|
||||
using ::fgetc;
|
||||
using ::fgetpos;
|
||||
using ::fgets;
|
||||
using ::fopen;
|
||||
using ::fprintf;
|
||||
using ::fputc;
|
||||
using ::fputs;
|
||||
using ::fread;
|
||||
using ::freopen;
|
||||
using ::fscanf;
|
||||
using ::fseek;
|
||||
using ::fsetpos;
|
||||
using ::ftell;
|
||||
using ::fwrite;
|
||||
using ::getc;
|
||||
using ::getchar;
|
||||
#if __cplusplus <= 201103L
|
||||
// LWG 2249
|
||||
using ::gets;
|
||||
#endif
|
||||
using ::perror;
|
||||
using ::printf;
|
||||
using ::putc;
|
||||
using ::putchar;
|
||||
using ::puts;
|
||||
using ::remove;
|
||||
using ::rename;
|
||||
using ::rewind;
|
||||
using ::scanf;
|
||||
using ::setbuf;
|
||||
using ::setvbuf;
|
||||
using ::sprintf;
|
||||
using ::sscanf;
|
||||
using ::tmpfile;
|
||||
#ifdef _GLIBCXX_USE_TMPNAM
|
||||
using ::tmpnam;
|
||||
#endif
|
||||
using ::ungetc;
|
||||
using ::vfprintf;
|
||||
using ::vprintf;
|
||||
using ::vsprintf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
72
libraries/ArduinoSTL/src/cstdlib
Normal file
72
libraries/ArduinoSTL/src/cstdlib
Normal file
@@ -0,0 +1,72 @@
|
||||
/* Copyright (C) 2005 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "basic_definitions"
|
||||
|
||||
#ifndef __HEADER_CSTDLIB
|
||||
#define __HEADER_CSTDLIB 1
|
||||
|
||||
|
||||
namespace std{
|
||||
using ::abort;
|
||||
using ::abs;
|
||||
using ::atexit;
|
||||
using ::atol;
|
||||
using ::atof;
|
||||
using ::atoi;
|
||||
using ::bsearch;
|
||||
using ::calloc;
|
||||
using ::div;
|
||||
using ::exit;
|
||||
using ::free;
|
||||
using ::getenv;
|
||||
using ::labs;
|
||||
using ::ldiv;
|
||||
using ::malloc;
|
||||
using ::qsort;
|
||||
using ::rand;
|
||||
using ::realloc;
|
||||
using ::srand;
|
||||
using ::strtod;
|
||||
using ::strtol;
|
||||
using ::strtoul;
|
||||
using ::system;
|
||||
#ifdef __UCLIBCXX_HAS_WCHAR__
|
||||
using ::mblen;
|
||||
using ::mbstowcs;
|
||||
using ::mbtowc;
|
||||
using ::wctomb;
|
||||
using ::wcstombs;
|
||||
#endif
|
||||
|
||||
/* Defined in Arduino
|
||||
inline long abs(long i){
|
||||
return labs(i);
|
||||
}
|
||||
*/
|
||||
inline ldiv_t div(long i, long j){
|
||||
return ldiv(i, j);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
77
libraries/ArduinoSTL/src/cstring
Normal file
77
libraries/ArduinoSTL/src/cstring
Normal file
@@ -0,0 +1,77 @@
|
||||
/* Copyright (C) 2005 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "cstddef"
|
||||
#include <string.h>
|
||||
|
||||
#ifndef __HEADER_CSTRING
|
||||
#define __HEADER_CSTRING 1
|
||||
|
||||
|
||||
namespace std{
|
||||
|
||||
using ::memchr;
|
||||
using ::memcmp;
|
||||
using ::memcpy;
|
||||
using ::memmove;
|
||||
using ::memset;
|
||||
using ::strcat;
|
||||
using ::strchr;
|
||||
using ::strcmp;
|
||||
using ::strcoll;
|
||||
using ::strcpy;
|
||||
using ::strcspn;
|
||||
using ::strerror;
|
||||
using ::strlen;
|
||||
using ::strncat;
|
||||
using ::strncmp;
|
||||
using ::strncpy;
|
||||
using ::strpbrk;
|
||||
using ::strrchr;
|
||||
using ::strspn;
|
||||
using ::strstr;
|
||||
using ::strtok;
|
||||
using ::strxfrm;
|
||||
|
||||
#ifndef __CORRECT_ISO_CPP_STRING_H_PROTO
|
||||
//Extra definitions required in c++ spec
|
||||
|
||||
inline void* memchr(void* s, int c, size_t n){
|
||||
return memchr(const_cast<const void *>(s), c, n);
|
||||
}
|
||||
|
||||
inline char* strchr(char* s, int c){
|
||||
return strchr(const_cast<const char *>(s), c);
|
||||
}
|
||||
|
||||
inline char* strpbrk(char* s1, const char* s2){
|
||||
return strpbrk(const_cast<const char *>(s1), s2);
|
||||
}
|
||||
|
||||
inline char* strrchr(char* s, int c){
|
||||
return strrchr(const_cast<const char *>(s), c);
|
||||
}
|
||||
|
||||
inline char* strstr(char* s1, const char* s2){
|
||||
return strstr(const_cast<const char *>(s1), s2);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
81
libraries/ArduinoSTL/src/ctime
Normal file
81
libraries/ArduinoSTL/src/ctime
Normal file
@@ -0,0 +1,81 @@
|
||||
// -*- C++ -*- forwarding header.
|
||||
|
||||
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
|
||||
// Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library 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, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library 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 library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
// USA.
|
||||
|
||||
// As a special exception, you may use this file as part of a free software
|
||||
// library without restriction. Specifically, if other files instantiate
|
||||
// templates or use macros or inline functions from this file, or you compile
|
||||
// this file and link it with other files to produce an executable, this
|
||||
// file does not by itself cause the resulting executable to be covered by
|
||||
// the GNU General Public License. This exception does not however
|
||||
// invalidate any other reasons why the executable file might be covered by
|
||||
// the GNU General Public License.
|
||||
|
||||
//
|
||||
// ISO C++ 14882: 20.5 Date and time
|
||||
//
|
||||
|
||||
/** @file ctime
|
||||
* This is a Standard C++ Library file. You should @c #include this file
|
||||
* in your programs, rather than any of the "*.h" implementation files.
|
||||
*
|
||||
* This is the C++ version of the Standard C Library header @c time.h,
|
||||
* and its contents are (mostly) the same as that header, but are all
|
||||
* contained in the namespace @c std.
|
||||
*/
|
||||
|
||||
#ifndef _CPP_CTIME
|
||||
#define _CPP_CTIME 1
|
||||
|
||||
#pragma GCC system_header
|
||||
|
||||
#include "cstddef"
|
||||
|
||||
#include <time.h>
|
||||
|
||||
// Get rid of those macros defined in <time.h> in lieu of real functions.
|
||||
#undef clock
|
||||
#undef difftime
|
||||
#undef mktime
|
||||
#undef time
|
||||
#undef asctime
|
||||
#undef ctime
|
||||
#undef gmtime
|
||||
#undef localtime
|
||||
#undef strftime
|
||||
|
||||
namespace std
|
||||
{
|
||||
using ::clock_t;
|
||||
using ::time_t;
|
||||
using ::tm;
|
||||
|
||||
using ::clock;
|
||||
using ::difftime;
|
||||
using ::mktime;
|
||||
using ::time;
|
||||
using ::asctime;
|
||||
using ::ctime;
|
||||
using ::gmtime;
|
||||
using ::localtime;
|
||||
using ::strftime;
|
||||
}
|
||||
|
||||
#endif
|
||||
86
libraries/ArduinoSTL/src/cwchar
Normal file
86
libraries/ArduinoSTL/src/cwchar
Normal file
@@ -0,0 +1,86 @@
|
||||
/* Copyright (C) 2006 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation version 2.1
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <wchar.h>
|
||||
#include "basic_definitions"
|
||||
|
||||
#ifndef __HEADER_CWCHAR
|
||||
#define __HEADER_CWCHAR 1
|
||||
|
||||
|
||||
namespace std{
|
||||
using ::mbstate_t;
|
||||
using ::wint_t;
|
||||
|
||||
using ::btowc;
|
||||
using ::fgetwc;
|
||||
using ::fgetws;
|
||||
using ::fputwc;
|
||||
using ::fputws;
|
||||
using ::fwide;
|
||||
using ::fwprintf;
|
||||
using ::fwscanf;
|
||||
using ::getwc;
|
||||
using ::getwchar;
|
||||
using ::mbrlen;
|
||||
using ::mbrtowc;
|
||||
using ::mbsinit;
|
||||
using ::mbsrtowcs;
|
||||
using ::putwc;
|
||||
using ::putwchar;
|
||||
using ::swprintf;
|
||||
using ::swscanf;
|
||||
using ::ungetwc;
|
||||
using ::vfwprintf;
|
||||
using ::vswprintf;
|
||||
using ::vwprintf;
|
||||
using ::wcrtomb;
|
||||
using ::wcscat;
|
||||
using ::wcschr;
|
||||
using ::wcscmp;
|
||||
using ::wcscoll;
|
||||
using ::wcscpy;
|
||||
using ::wcscspn;
|
||||
using ::wcsftime;
|
||||
using ::wcslen;
|
||||
using ::wcsncat;
|
||||
using ::wcsncmp;
|
||||
using ::wcsncpy;
|
||||
using ::wcspbrk;
|
||||
using ::wcsrchr;
|
||||
using ::wcsrtombs;
|
||||
using ::wcsspn;
|
||||
using ::wcsstr;
|
||||
using ::wcstod;
|
||||
using ::wcstok;
|
||||
using ::wcstol;
|
||||
using ::wcstoul;
|
||||
using ::wcsxfrm;
|
||||
using ::wctob;
|
||||
using ::wmemchr;
|
||||
using ::wmemcmp;
|
||||
using ::wmemcpy;
|
||||
using ::wmemmove;
|
||||
using ::wmemset;
|
||||
using ::wprintf;
|
||||
using ::wscanf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
106
libraries/ArduinoSTL/src/cwctype
Normal file
106
libraries/ArduinoSTL/src/cwctype
Normal file
@@ -0,0 +1,106 @@
|
||||
// -*- C++ -*- forwarding header.
|
||||
|
||||
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
|
||||
// Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library 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, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library 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 library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
// USA.
|
||||
|
||||
// As a special exception, you may use this file as part of a free software
|
||||
// library without restriction. Specifically, if other files instantiate
|
||||
// templates or use macros or inline functions from this file, or you compile
|
||||
// this file and link it with other files to produce an executable, this
|
||||
// file does not by itself cause the resulting executable to be covered by
|
||||
// the GNU General Public License. This exception does not however
|
||||
// invalidate any other reasons why the executable file might be covered by
|
||||
// the GNU General Public License.
|
||||
|
||||
//
|
||||
// ISO C++ 14882: <cwctype>
|
||||
//
|
||||
|
||||
/** @file cwctype
|
||||
* This is a Standard C++ Library file. You should @c #include this file
|
||||
* in your programs, rather than any of the "*.h" implementation files.
|
||||
*
|
||||
* This is the C++ version of the Standard C Library header @c wctype.h,
|
||||
* and its contents are (mostly) the same as that header, but are all
|
||||
* contained in the namespace @c std.
|
||||
*/
|
||||
|
||||
#ifndef _CPP_CWCTYPE
|
||||
#define _CPP_CWCTYPE 1
|
||||
|
||||
#pragma GCC system_header
|
||||
|
||||
//#include <bits/c++config.h>
|
||||
|
||||
#ifdef __UCLIBCXX_HAS_WCHAR__
|
||||
#include <wctype.h>
|
||||
#endif
|
||||
|
||||
// Get rid of those macros defined in <wctype.h> in lieu of real functions.
|
||||
#undef iswalnum
|
||||
#undef iswalpha
|
||||
#undef iswblank
|
||||
#undef iswcntrl
|
||||
#undef iswdigit
|
||||
#undef iswgraph
|
||||
#undef iswlower
|
||||
#undef iswprint
|
||||
#undef iswprint
|
||||
#undef iswpunct
|
||||
#undef iswspace
|
||||
#undef iswupper
|
||||
#undef iswxdigit
|
||||
#undef iswctype
|
||||
#undef towlower
|
||||
#undef towupper
|
||||
#undef towctrans
|
||||
#undef wctrans
|
||||
#undef wctype
|
||||
|
||||
#if __UCLIBCXX_HAS_WCHAR__
|
||||
namespace std
|
||||
{
|
||||
using ::wint_t; // cwchar
|
||||
|
||||
using ::wctype_t;
|
||||
using ::wctrans_t;
|
||||
|
||||
using ::iswalnum;
|
||||
using ::iswalpha;
|
||||
using ::iswblank;
|
||||
using ::iswcntrl;
|
||||
using ::iswdigit;
|
||||
using ::iswgraph;
|
||||
using ::iswlower;
|
||||
using ::iswprint;
|
||||
using ::iswprint;
|
||||
using ::iswpunct;
|
||||
using ::iswspace;
|
||||
using ::iswupper;
|
||||
using ::iswxdigit;
|
||||
using ::iswctype;
|
||||
using ::towlower;
|
||||
using ::towupper;
|
||||
using ::towctrans;
|
||||
using ::wctrans;
|
||||
using ::wctype;
|
||||
}
|
||||
#endif //__ULIBCXX_HAS_WCHAR__
|
||||
|
||||
#endif
|
||||
31
libraries/ArduinoSTL/src/del_op.cpp
Normal file
31
libraries/ArduinoSTL/src/del_op.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
// Arduino 1.0 contains an implementation for this.
|
||||
#if ARDUINO < 100
|
||||
|
||||
#include <new>
|
||||
#include <cstdlib>
|
||||
#include <func_exception>
|
||||
|
||||
_UCXXEXPORT void operator delete(void* ptr) _UCXX_USE_NOEXCEPT{
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
#endif
|
||||
28
libraries/ArduinoSTL/src/del_opnt.cpp
Normal file
28
libraries/ArduinoSTL/src/del_opnt.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "new"
|
||||
#include "cstdlib"
|
||||
#include "func_exception"
|
||||
|
||||
#ifndef NO_NOTHROW
|
||||
_UCXXEXPORT void operator delete(void* ptr, const std::nothrow_t& ) _UCXX_USE_NOEXCEPT {
|
||||
free(ptr);
|
||||
}
|
||||
#endif
|
||||
27
libraries/ArduinoSTL/src/del_ops.cpp
Normal file
27
libraries/ArduinoSTL/src/del_ops.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
/* Copyright (C) 2015 Bernhard Reutner-Fischer
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
/* C++14 sized deallocation */
|
||||
|
||||
#include "new"
|
||||
#include "cstdlib"
|
||||
#include "func_exception"
|
||||
|
||||
_UCXXEXPORT void operator delete(void* ptr, std::size_t) _UCXX_USE_NOEXCEPT{
|
||||
::operator delete (ptr);
|
||||
}
|
||||
31
libraries/ArduinoSTL/src/del_opv.cpp
Normal file
31
libraries/ArduinoSTL/src/del_opv.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
// Arduino 1.0 contains an implementation for this.
|
||||
#if ARDUINO < 100
|
||||
|
||||
#include <new>
|
||||
#include <cstdlib>
|
||||
#include <func_exception>
|
||||
|
||||
_UCXXEXPORT void operator delete[](void * ptr) _UCXX_USE_NOEXCEPT{
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
#endif
|
||||
28
libraries/ArduinoSTL/src/del_opvnt.cpp
Normal file
28
libraries/ArduinoSTL/src/del_opvnt.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "new"
|
||||
#include "cstdlib"
|
||||
#include "func_exception"
|
||||
|
||||
#ifndef NO_NOTHROW
|
||||
_UCXXEXPORT void operator delete[](void* ptr, const std::nothrow_t& ) _UCXX_USE_NOEXCEPT{
|
||||
free(ptr);
|
||||
}
|
||||
#endif
|
||||
27
libraries/ArduinoSTL/src/del_opvs.cpp
Normal file
27
libraries/ArduinoSTL/src/del_opvs.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
/* Copyright (C) 2015 Bernhard Reutner-Fischer
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
/* C++14 sized deallocation */
|
||||
|
||||
#include "new"
|
||||
#include "cstdlib"
|
||||
#include "func_exception"
|
||||
|
||||
_UCXXEXPORT void operator delete[](void * ptr, std::size_t) _UCXX_USE_NOEXCEPT{
|
||||
::operator delete[] (ptr);
|
||||
}
|
||||
884
libraries/ArduinoSTL/src/deque
Normal file
884
libraries/ArduinoSTL/src/deque
Normal file
@@ -0,0 +1,884 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
This file is part of the uClibc++ Library.
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "memory"
|
||||
#include "iterator"
|
||||
#include "stdexcept"
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
|
||||
#ifndef __STD_HEADER_DEQUE
|
||||
#define __STD_HEADER_DEQUE
|
||||
|
||||
|
||||
namespace std{
|
||||
template <class T, class Allocator = allocator<T> > class deque;
|
||||
template <class T, class Allocator> bool operator==(const deque<T,Allocator>& x, const deque<T,Allocator>& y);
|
||||
template <class T, class Allocator> bool operator< (const deque<T,Allocator>& x, const deque<T,Allocator>& y);
|
||||
template <class T, class Allocator> bool operator!=(const deque<T,Allocator>& x, const deque<T,Allocator>& y);
|
||||
template <class T, class Allocator> bool operator> (const deque<T,Allocator>& x, const deque<T,Allocator>& y);
|
||||
template <class T, class Allocator> bool operator>=(const deque<T,Allocator>& x, const deque<T,Allocator>& y);
|
||||
template <class T, class Allocator> bool operator<=(const deque<T,Allocator>& x, const deque<T,Allocator>& y);
|
||||
template <class T, class Allocator> void swap(deque<T,Allocator>& x, deque<T,Allocator>& y);
|
||||
|
||||
template <class T, class Allocator> class _UCXXEXPORT deque {
|
||||
public:
|
||||
friend bool operator==<>(const deque<T, Allocator>& x, const deque<T, Allocator>& y);
|
||||
friend class deque_iter;
|
||||
friend class deque_citer;
|
||||
class deque_iter;
|
||||
class deque_citer;
|
||||
|
||||
typedef typename Allocator::reference reference;
|
||||
typedef typename Allocator::const_reference const_reference;
|
||||
typedef deque_iter iterator;
|
||||
typedef deque_citer const_iterator;
|
||||
typedef typename Allocator::size_type size_type;
|
||||
typedef typename Allocator::difference_type difference_type;
|
||||
typedef T value_type;
|
||||
typedef Allocator allocator_type;
|
||||
typedef typename Allocator::pointer pointer;
|
||||
typedef typename Allocator::const_pointer const_pointer;
|
||||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
|
||||
explicit deque(const Allocator& al = Allocator());
|
||||
explicit deque(size_type n, const T& value = T(), const Allocator& al = Allocator());
|
||||
template <class InputIterator> deque(InputIterator first, InputIterator last, const Allocator& = Allocator());
|
||||
deque(const deque<T,Allocator>& x);
|
||||
~deque();
|
||||
|
||||
deque<T,Allocator>& operator=(const deque<T,Allocator>& x);
|
||||
template <class InputIterator> void assign(InputIterator first, InputIterator last);
|
||||
template <class Size, class U> void assign(Size n, const U& u = U());
|
||||
allocator_type get_allocator() const;
|
||||
|
||||
iterator begin();
|
||||
const_iterator begin() const;
|
||||
iterator end();
|
||||
const_iterator end() const;
|
||||
reverse_iterator rbegin();
|
||||
const_reverse_iterator rbegin() const;
|
||||
reverse_iterator rend();
|
||||
const_reverse_iterator rend() const;
|
||||
|
||||
size_type size() const;
|
||||
size_type max_size() const;
|
||||
void resize(size_type sz, T c = T());
|
||||
bool empty() const;
|
||||
|
||||
reference operator[](size_type n);
|
||||
const_reference operator[](size_type n) const;
|
||||
reference at(size_type n);
|
||||
const_reference at(size_type n) const;
|
||||
reference front();
|
||||
const_reference front() const;
|
||||
reference back();
|
||||
const_reference back() const;
|
||||
|
||||
void push_front(const T& x);
|
||||
void push_back(const T& x);
|
||||
iterator insert(iterator position, const T& x = T());
|
||||
void insert(iterator position, size_type n, const T& x);
|
||||
template <class InputIterator> void insert (iterator position, InputIterator first, InputIterator last);
|
||||
void pop_front();
|
||||
void pop_back();
|
||||
|
||||
iterator erase(iterator position);
|
||||
iterator erase(iterator first, iterator last);
|
||||
void swap(deque<T,Allocator>&);
|
||||
void clear();
|
||||
|
||||
protected:
|
||||
void reserve(size_type n);
|
||||
inline size_type array_element(size_type deque_element) const{
|
||||
if(deque_element < (data_size - first_element)){
|
||||
return first_element + deque_element;
|
||||
}
|
||||
return deque_element - (data_size - first_element);
|
||||
}
|
||||
inline size_type first_subtract(size_type sub_size) const{
|
||||
if(sub_size > first_element){
|
||||
return (data_size - first_element) - sub_size;
|
||||
}
|
||||
return first_element - sub_size;
|
||||
}
|
||||
|
||||
T * data;
|
||||
size_type data_size; //Physical size of array
|
||||
size_type elements; //Elements in array
|
||||
size_type first_element; //Element number of array 0..n
|
||||
size_type last_element; //Element number of array 0..n
|
||||
Allocator a;
|
||||
|
||||
};
|
||||
|
||||
|
||||
template<class T, class Allocator> class _UCXXEXPORT deque<T, Allocator>::deque_iter
|
||||
: public std::iterator<
|
||||
random_access_iterator_tag,
|
||||
T,
|
||||
typename Allocator::difference_type,
|
||||
typename Allocator::pointer,
|
||||
typename Allocator::reference
|
||||
>
|
||||
{
|
||||
friend class deque<T, Allocator>;
|
||||
protected:
|
||||
deque<T, Allocator> * container;
|
||||
typename Allocator::size_type element;
|
||||
|
||||
public:
|
||||
deque_iter() : container(0), element(0) { }
|
||||
deque_iter(const deque_iter & d) : container (d.container), element(d.element) { }
|
||||
deque_iter(deque<T, Allocator> * c, typename Allocator::size_type e)
|
||||
: container(c), element(e)
|
||||
{
|
||||
return;
|
||||
}
|
||||
~deque_iter() { }
|
||||
deque_iter & operator=(const deque_iter & d){
|
||||
container = d.container;
|
||||
element = d.element;
|
||||
return *this;
|
||||
}
|
||||
T & operator*(){
|
||||
return container->data[container->array_element(element)];
|
||||
}
|
||||
T * operator->(){
|
||||
return container->data + container->array_element(element);
|
||||
}
|
||||
const T & operator*() const{
|
||||
return container->data[container->array_element(element)];
|
||||
}
|
||||
const T * operator->() const{
|
||||
return container->data + container->array_element(element);
|
||||
}
|
||||
bool operator==(const deque_iter & d) const{
|
||||
if(container == d.container && element == d.element){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool operator==(const deque_citer & d) const{
|
||||
if(container == d.container && element == d.element){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool operator!=(const deque_iter & d) const{
|
||||
if(container != d.container || element != d.element){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool operator!=(const deque_citer & d) const{
|
||||
if(container != d.container || element != d.element){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool operator<(const deque_iter & d) const{
|
||||
if(element < d.element){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool operator<(const deque_citer & d) const{
|
||||
if(element < d.element){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool operator<=(const deque_iter & d) const{
|
||||
if(element <= d.element){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool operator<=(const deque_citer & d) const{
|
||||
if(element <= d.element){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool operator>(const deque_iter & d) const{
|
||||
if(element > d.element){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool operator>(const deque_citer & d) const{
|
||||
if(element > d.element){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool operator>=(const deque_iter & d) const{
|
||||
if(element >= d.element){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool operator>=(const deque_citer & d) const{
|
||||
if(element >= d.element){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
deque_iter & operator++(){
|
||||
++element;
|
||||
return *this;
|
||||
}
|
||||
deque_iter operator++(int){
|
||||
deque_iter temp(container, element);
|
||||
++element;
|
||||
return temp;
|
||||
}
|
||||
deque_iter operator+(typename Allocator::size_type n){
|
||||
deque_iter temp(container, element + n);
|
||||
return temp;
|
||||
}
|
||||
deque_iter & operator+=(typename Allocator::size_type n){
|
||||
element += n;
|
||||
return *this;
|
||||
}
|
||||
deque_iter & operator--(){
|
||||
--element;
|
||||
return *this;
|
||||
}
|
||||
deque_iter operator--(int){
|
||||
deque_iter temp(container, element);
|
||||
--element;
|
||||
return temp;
|
||||
}
|
||||
deque_iter operator-(typename Allocator::size_type n){
|
||||
deque_iter temp(container, element - n);
|
||||
return temp;
|
||||
}
|
||||
deque_iter & operator-=(typename Allocator::size_type n){
|
||||
element -= n;
|
||||
return *this;
|
||||
}
|
||||
typename Allocator::size_type operator-(const deque_iter & d){
|
||||
return element - d.element;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template<class T, class Allocator> class _UCXXEXPORT deque<T, Allocator>::deque_citer
|
||||
: public std::iterator<
|
||||
random_access_iterator_tag,
|
||||
T,
|
||||
typename Allocator::difference_type,
|
||||
typename Allocator::const_pointer,
|
||||
typename Allocator::const_reference
|
||||
>
|
||||
{
|
||||
friend class deque<T, Allocator>;
|
||||
protected:
|
||||
const deque<T, Allocator> * container;
|
||||
typename Allocator::size_type element;
|
||||
|
||||
public:
|
||||
deque_citer() : container(0), element(0) { }
|
||||
deque_citer(const deque_citer & d) : container (d.container), element(d.element) { }
|
||||
deque_citer(const deque_iter & d) : container (d.container), element(d.element) { }
|
||||
deque_citer(const deque<T, Allocator> * c, typename Allocator::size_type e)
|
||||
: container(c), element(e)
|
||||
{
|
||||
return;
|
||||
}
|
||||
~deque_citer() { }
|
||||
deque_citer & operator=(const deque_iter & d){
|
||||
container = d.container;
|
||||
element = d.element;
|
||||
return *this;
|
||||
}
|
||||
const T & operator*() const{
|
||||
return container->data[container->array_element(element)];
|
||||
}
|
||||
const T * operator->() const{
|
||||
return container->data + container->array_element(element);
|
||||
}
|
||||
bool operator==(const deque_citer & d) const{
|
||||
if(container == d.container && element == d.element){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool operator==(const deque_iter & d) const{
|
||||
if(container == d.container && element == d.element){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool operator!=(const deque_citer & d) const{
|
||||
if(container != d.container || element != d.element){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool operator!=(const deque_iter & d) const{
|
||||
if(container != d.container || element != d.element){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool operator<(const deque_citer & d) const{
|
||||
if(element < d.element){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool operator<(const deque_iter & d) const{
|
||||
if(element < d.element){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool operator<=(const deque_citer & d) const{
|
||||
if(element <= d.element){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool operator<=(const deque_iter & d) const{
|
||||
if(element <= d.element){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool operator>(const deque_citer & d) const{
|
||||
if(element > d.element){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool operator>(const deque_iter & d) const{
|
||||
if(element > d.element){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool operator>=(const deque_citer & d){
|
||||
if(element >= d.element){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool operator>=(const deque_iter & d){
|
||||
if(element >= d.element){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
deque_citer & operator++(){
|
||||
++element;
|
||||
return *this;
|
||||
}
|
||||
deque_citer operator++(int){
|
||||
deque_citer temp(container, element);
|
||||
++element;
|
||||
return temp;
|
||||
}
|
||||
deque_citer operator+(typename Allocator::size_type n){
|
||||
deque_citer temp(container, element + n);
|
||||
return temp;
|
||||
}
|
||||
deque_citer & operator+=(typename Allocator::size_type n){
|
||||
element += n;
|
||||
return *this;
|
||||
}
|
||||
deque_citer & operator--(){
|
||||
--element;
|
||||
return *this;
|
||||
}
|
||||
deque_citer operator--(int){
|
||||
deque_citer temp(container, element);
|
||||
--element;
|
||||
return temp;
|
||||
}
|
||||
deque_citer operator-(typename Allocator::size_type n){
|
||||
deque_citer temp(container, element - n);
|
||||
return temp;
|
||||
}
|
||||
deque_citer & operator-=(typename Allocator::size_type n){
|
||||
element -= n;
|
||||
return *this;
|
||||
}
|
||||
typename Allocator::size_type operator-(const deque_citer & d){
|
||||
return element - d.element;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template<class T, class Allocator> deque<T, Allocator>::deque(const Allocator& al)
|
||||
: data(0),
|
||||
data_size(0), elements(0), first_element(0), last_element(0), a(al)
|
||||
{
|
||||
data_size = __UCLIBCXX_STL_BUFFER_SIZE__;
|
||||
data = a.allocate(data_size);
|
||||
first_element = data_size /2;
|
||||
last_element = first_element;
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Allocator> deque<T, Allocator>::deque(
|
||||
size_type n, const T& value, const Allocator& al)
|
||||
: data(0),
|
||||
elements(n), first_element(0), last_element(0), a(al)
|
||||
{
|
||||
data_size = elements + __UCLIBCXX_STL_BUFFER_SIZE__;
|
||||
data = a.allocate(data_size);
|
||||
first_element = (data_size - elements) / 2;
|
||||
last_element = first_element;
|
||||
|
||||
for(n=first_element ; n < last_element; ++n ){
|
||||
a.construct(data+n, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Allocator> template <class InputIterator>
|
||||
deque<T, Allocator>::deque(InputIterator first, InputIterator last, const Allocator& al)
|
||||
: data(0),
|
||||
data_size(0), elements(0), first_element(0), last_element(0), a(al)
|
||||
{
|
||||
data_size = __UCLIBCXX_STL_BUFFER_SIZE__;
|
||||
data = a.allocate(data_size);
|
||||
first_element = data_size / 4; //Note sure how big, but let's add a little space...
|
||||
last_element = first_element;
|
||||
while(first != last){
|
||||
push_back(*first);
|
||||
++first;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Allocator> deque<T, Allocator>::deque(const deque<T,Allocator>& x)
|
||||
: data(0),
|
||||
elements(0), first_element(0), last_element(0), a(x.a)
|
||||
{
|
||||
data_size = x.elements + __UCLIBCXX_STL_BUFFER_SIZE__;
|
||||
data = a.allocate(data_size);
|
||||
first_element = (data_size - x.elements) / 2;
|
||||
last_element = first_element;
|
||||
for(size_type i=0; i < x.elements; ++i){
|
||||
push_back(x[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Allocator> deque<T, Allocator>::~deque(){
|
||||
clear();
|
||||
a.deallocate(data, data_size);
|
||||
}
|
||||
|
||||
template<class T, class Allocator> deque<T,Allocator>& deque<T, Allocator>::
|
||||
operator=(const deque<T,Allocator>& x)
|
||||
{
|
||||
if(&x == this){
|
||||
return *this;
|
||||
}
|
||||
resize(x.elements);
|
||||
for(size_t i = 0; i < elements; ++i){
|
||||
data[array_element(i)] = x[i];
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Allocator> template <class InputIterator> void
|
||||
deque<T, Allocator>::assign(InputIterator first, InputIterator last)
|
||||
{
|
||||
clear();
|
||||
while(first !=last){
|
||||
push_back(*first);
|
||||
++first;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Allocator> template <class Size, class U> void
|
||||
deque<T, Allocator>::assign(Size n, const U& u)
|
||||
{
|
||||
if(&u == this){
|
||||
return;
|
||||
}
|
||||
clear();
|
||||
for(size_type i = 0; i < n; ++i){
|
||||
push_back(u);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Allocator> typename deque<T, Allocator>::allocator_type
|
||||
deque<T, Allocator>::get_allocator() const
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
template<class T, class Allocator> typename
|
||||
deque<T, Allocator>::iterator deque<T, Allocator>::begin()
|
||||
{
|
||||
return deque_iter(this, 0);
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Allocator> typename deque<T, Allocator>::const_iterator
|
||||
deque<T, Allocator>::begin() const
|
||||
{
|
||||
return deque_citer(this, 0);
|
||||
}
|
||||
|
||||
template<class T, class Allocator> typename
|
||||
deque<T, Allocator>::iterator deque<T, Allocator>::end()
|
||||
{
|
||||
return deque_iter(this, elements);
|
||||
}
|
||||
|
||||
template<class T, class Allocator> typename
|
||||
deque<T, Allocator>::const_iterator deque<T, Allocator>::end() const
|
||||
{
|
||||
return deque_citer(this, elements);
|
||||
}
|
||||
|
||||
template<class T, class Allocator> typename
|
||||
deque<T, Allocator>::reverse_iterator deque<T, Allocator>::rbegin()
|
||||
{
|
||||
return reverse_iterator(end());
|
||||
}
|
||||
|
||||
template<class T, class Allocator> typename
|
||||
deque<T, Allocator>::const_reverse_iterator deque<T, Allocator>::rbegin() const
|
||||
{
|
||||
return const_reverse_iterator(end());
|
||||
}
|
||||
|
||||
template<class T, class Allocator> typename
|
||||
deque<T, Allocator>::reverse_iterator deque<T, Allocator>::rend()
|
||||
{
|
||||
return reverse_iterator(begin());
|
||||
}
|
||||
|
||||
template<class T, class Allocator> typename
|
||||
deque<T, Allocator>::const_reverse_iterator deque<T, Allocator>::rend() const
|
||||
{
|
||||
return const_reverse_iterator(begin());
|
||||
}
|
||||
|
||||
template<class T, class Allocator> typename
|
||||
deque<T, Allocator>::size_type deque<T, Allocator>::size() const
|
||||
{
|
||||
return elements;
|
||||
}
|
||||
|
||||
template<class T, class Allocator> typename
|
||||
deque<T, Allocator>::size_type deque<T, Allocator>::max_size() const
|
||||
{
|
||||
return ((size_type)(-1)) / sizeof(T);
|
||||
}
|
||||
|
||||
template<class T, class Allocator> void deque<T, Allocator>::resize(size_type sz, T c){
|
||||
reserve(sz);
|
||||
while(sz > size()){
|
||||
push_back(c);
|
||||
}
|
||||
while(sz < size()){
|
||||
pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, class Allocator> bool deque<T, Allocator>::empty() const{
|
||||
return (elements == 0);
|
||||
}
|
||||
|
||||
template<class T, class Allocator> typename
|
||||
deque<T, Allocator>::reference deque<T, Allocator>::operator[](size_type n)
|
||||
{
|
||||
return data[array_element(n)];
|
||||
}
|
||||
|
||||
template<class T, class Allocator> typename
|
||||
deque<T, Allocator>::const_reference deque<T, Allocator>::operator[](size_type n) const
|
||||
{
|
||||
return data[array_element(n)];
|
||||
}
|
||||
|
||||
template<class T, class Allocator> typename
|
||||
deque<T, Allocator>::reference deque<T, Allocator>::at(size_type n)
|
||||
{
|
||||
if(n > elements){
|
||||
__throw_out_of_range("Out of deque range");
|
||||
}
|
||||
return data[array_element(n)];
|
||||
}
|
||||
|
||||
template<class T, class Allocator> typename
|
||||
deque<T, Allocator>::const_reference deque<T, Allocator>::at(size_type n) const
|
||||
{
|
||||
if(n > elements){
|
||||
__throw_out_of_range("Out of deque range");
|
||||
}
|
||||
return data[array_element(n)];
|
||||
}
|
||||
|
||||
template<class T, class Allocator> typename
|
||||
deque<T, Allocator>::reference deque<T, Allocator>::front()
|
||||
{
|
||||
return data[first_element];
|
||||
}
|
||||
|
||||
template<class T, class Allocator> typename
|
||||
deque<T, Allocator>::const_reference deque<T, Allocator>::front() const
|
||||
{
|
||||
return data[first_element];
|
||||
}
|
||||
|
||||
template<class T, class Allocator> typename
|
||||
deque<T, Allocator>::reference deque<T, Allocator>::back()
|
||||
{
|
||||
return data[array_element(elements-1)];
|
||||
}
|
||||
|
||||
template<class T, class Allocator> typename
|
||||
deque<T, Allocator>::const_reference deque<T, Allocator>::back() const
|
||||
{
|
||||
return data[array_element(elements-1)];
|
||||
}
|
||||
|
||||
template<class T, class Allocator> void deque<T, Allocator>::push_front(const T& x){
|
||||
reserve(elements + 1);
|
||||
first_element = first_subtract(1);
|
||||
a.construct(data + first_element, x);
|
||||
++elements;
|
||||
}
|
||||
|
||||
template<class T, class Allocator> void deque<T, Allocator>::push_back(const T& x){
|
||||
reserve(elements + 1);
|
||||
a.construct(data + last_element, x);
|
||||
++elements;
|
||||
last_element = array_element(elements);
|
||||
}
|
||||
|
||||
template<class T, class Allocator> typename
|
||||
deque<T, Allocator>::iterator deque<T, Allocator>::insert(iterator position, const T& x)
|
||||
{
|
||||
reserve(elements+1);
|
||||
if(position.element > (elements/2)){
|
||||
//Push all elements back 1
|
||||
push_back(x);
|
||||
for(size_type i = elements-1; i > position.element; --i){
|
||||
at(i) = at(i-1);
|
||||
}
|
||||
}else{
|
||||
//Push all elements forward 1
|
||||
push_front(x);
|
||||
for(size_type i = 0; i < position.element; ++i){
|
||||
at(i) = at(i+1);
|
||||
}
|
||||
}
|
||||
at(position.element) = x;
|
||||
return deque_iter(this, position.element);
|
||||
}
|
||||
|
||||
template<class T, class Allocator> void deque<T, Allocator>::
|
||||
insert(typename deque<T, Allocator>::iterator position, size_type n, const T& x)
|
||||
{
|
||||
reserve(elements + n);
|
||||
for(size_t i =0; i < n; ++i){
|
||||
position = insert(position, x);
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, class Allocator> template <class InputIterator>
|
||||
void deque<T, Allocator>::insert (iterator position, InputIterator first, InputIterator last)
|
||||
{
|
||||
while(first != last){
|
||||
position = insert(position, *first);
|
||||
++first;
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, class Allocator> void deque<T, Allocator>::pop_front(){
|
||||
if(elements == 0){
|
||||
__throw_out_of_range("deque pop_front");
|
||||
}
|
||||
a.destroy(data + first_element);
|
||||
first_element = array_element(1);
|
||||
--elements;
|
||||
}
|
||||
|
||||
template<class T, class Allocator> void deque<T, Allocator>::pop_back(){
|
||||
last_element = array_element(elements - 1);
|
||||
a.destroy(data + last_element);
|
||||
--elements;
|
||||
}
|
||||
|
||||
template<class T, class Allocator> typename
|
||||
deque<T, Allocator>::iterator deque<T, Allocator>::erase(typename deque<T, Allocator>::iterator position)
|
||||
{
|
||||
if(position.element > (elements /2)){
|
||||
for(size_type i = position.element; i < elements - 1; ++i){
|
||||
at(i) = at(i+1);
|
||||
}
|
||||
pop_back();
|
||||
}else{
|
||||
for(size_type i = position.element; i > 0; --i){
|
||||
at(i) = at(i-1);
|
||||
}
|
||||
pop_front();
|
||||
}
|
||||
return deque_iter(this, position.element);
|
||||
}
|
||||
|
||||
template<class T, class Allocator> typename deque<T, Allocator>::iterator
|
||||
deque<T, Allocator>::
|
||||
erase(typename deque<T, Allocator>::iterator first, typename deque<T, Allocator>::iterator last)
|
||||
{
|
||||
//Shift backwards
|
||||
size_type num_move = last.element - first.element;
|
||||
if( first.element > (elements - last.element) ){
|
||||
for(size_type i = last.element; i < elements ; ++i){
|
||||
at(i-num_move) = at(i);
|
||||
}
|
||||
for(size_type i = 0; i < num_move ; ++i){
|
||||
pop_back();
|
||||
}
|
||||
}else{
|
||||
for(size_type i = 0; i < first.element ; ++i){
|
||||
at(last.element - i - 1) = at(first.element - i - 1);
|
||||
}
|
||||
for(size_type i = 0; i < num_move ; ++i){
|
||||
pop_front();
|
||||
}
|
||||
}
|
||||
return deque_iter(this, first.element);
|
||||
}
|
||||
|
||||
template<class T, class Allocator> void deque<T, Allocator>::swap(deque<T,Allocator>& x)
|
||||
{
|
||||
T * temp_data;
|
||||
typename deque<T,Allocator>::size_type temp_size;
|
||||
|
||||
//Swap data pointers
|
||||
temp_data = x.data;
|
||||
x.data = data;
|
||||
data = temp_data;
|
||||
|
||||
//Swap array sizes
|
||||
temp_size = x.data_size;
|
||||
x.data_size = data_size;
|
||||
data_size = temp_size;
|
||||
|
||||
//Swap num array elements
|
||||
temp_size = x.elements;
|
||||
x.elements = elements;
|
||||
elements = temp_size;
|
||||
|
||||
//Swap first_pointer
|
||||
temp_size = x.first_element;
|
||||
x.first_element = first_element;
|
||||
first_element = temp_size;
|
||||
|
||||
//Swap last_pointer
|
||||
temp_size = x.last_element;
|
||||
x.last_element = last_element;
|
||||
last_element = temp_size;
|
||||
}
|
||||
|
||||
template<class T, class Allocator> void deque<T, Allocator>::clear()
|
||||
{
|
||||
while(elements > 0 ){
|
||||
pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Allocator> void deque<T, Allocator>::reserve(typename deque<T, Allocator>::size_type n)
|
||||
{
|
||||
if(data_size >= n){
|
||||
return;
|
||||
}
|
||||
|
||||
size_type size_temp;
|
||||
size_type first_temp;
|
||||
T * data_temp;
|
||||
size_temp = n + __UCLIBCXX_STL_BUFFER_SIZE__; //Reserve extra 'cause we can
|
||||
data_temp = a.allocate(size_temp);
|
||||
|
||||
first_temp = (size_temp - elements) / 2;
|
||||
for(size_type i = 0; i < elements; ++i){
|
||||
a.construct(data_temp + first_temp + i, data[array_element(i)]);
|
||||
a.destroy(data + array_element(i));
|
||||
}
|
||||
|
||||
//Now shuffle pointers
|
||||
a.deallocate(data, data_size);
|
||||
data = data_temp;
|
||||
data_size = size_temp;
|
||||
first_element = first_temp;
|
||||
last_element = first_element + elements;
|
||||
}
|
||||
|
||||
|
||||
template <class T, class Allocator> _UCXXEXPORT
|
||||
bool
|
||||
operator==(const deque<T,Allocator>& x, const deque<T,Allocator>& y)
|
||||
{
|
||||
if(x.elements != y.elements){
|
||||
return false;
|
||||
}
|
||||
for(typename deque<T,Allocator>::size_type i = 0; i < x.elements; ++i){
|
||||
if(x[i] < y[i] || y[i] < x[i]){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class T, class Allocator> bool operator< (const deque<T,Allocator>& x, const deque<T,Allocator>& y);
|
||||
template <class T, class Allocator> _UCXXEXPORT
|
||||
bool
|
||||
operator!=(const deque<T,Allocator>& x, const deque<T,Allocator>& y)
|
||||
{
|
||||
if(x == y){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
template <class T, class Allocator> bool operator> (const deque<T,Allocator>& x, const deque<T,Allocator>& y);
|
||||
template <class T, class Allocator> bool operator>=(const deque<T,Allocator>& x, const deque<T,Allocator>& y);
|
||||
template <class T, class Allocator> bool operator<=(const deque<T,Allocator>& x, const deque<T,Allocator>& y);
|
||||
template <class T, class Allocator> _UCXXEXPORT void swap(deque<T,Allocator>& x, deque<T,Allocator>& y){
|
||||
x.swap(y);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#pragma GCC visibility pop
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
42
libraries/ArduinoSTL/src/deque.cpp
Normal file
42
libraries/ArduinoSTL/src/deque.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "deque"
|
||||
|
||||
|
||||
namespace std{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
65
libraries/ArduinoSTL/src/eh_alloc.cpp
Normal file
65
libraries/ArduinoSTL/src/eh_alloc.cpp
Normal file
@@ -0,0 +1,65 @@
|
||||
/* Copyright (C) 2006 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation, version 2.1
|
||||
of the License.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "cstdlib"
|
||||
#include "cstring"
|
||||
#include "func_exception"
|
||||
|
||||
//This is a system-specific header which does all of the error-handling management
|
||||
#include "unwind-cxx.h"
|
||||
|
||||
namespace __cxxabiv1
|
||||
{
|
||||
|
||||
extern "C" void * __cxa_allocate_exception(std::size_t thrown_size) _UCXX_USE_NOEXCEPT{
|
||||
void *e;
|
||||
// The sizeof crap is required by Itanium ABI because we need to
|
||||
// provide space for accounting information which is implementation
|
||||
// (gcc) defined.
|
||||
e = malloc (thrown_size + sizeof(__cxa_refcounted_exception));
|
||||
if (0 == e){
|
||||
std::terminate();
|
||||
}
|
||||
memset (e, 0, sizeof(__cxa_refcounted_exception));
|
||||
return (void *)((unsigned char *)e + sizeof(__cxa_refcounted_exception));
|
||||
}
|
||||
|
||||
extern "C" void __cxa_free_exception(void *vptr) _UCXX_USE_NOEXCEPT{
|
||||
free( (char *)(vptr) - sizeof(__cxa_refcounted_exception) );
|
||||
}
|
||||
|
||||
|
||||
extern "C" __cxa_dependent_exception * __cxa_allocate_dependent_exception() _UCXX_USE_NOEXCEPT{
|
||||
__cxa_dependent_exception *retval;
|
||||
// The sizeof crap is required by Itanium ABI because we need to
|
||||
// provide space for accounting information which is implementation
|
||||
// (gcc) defined.
|
||||
retval = static_cast<__cxa_dependent_exception*>(malloc (sizeof(__cxa_dependent_exception)));
|
||||
if (0 == retval){
|
||||
std::terminate();
|
||||
}
|
||||
memset (retval, 0, sizeof(__cxa_dependent_exception));
|
||||
return retval;
|
||||
}
|
||||
|
||||
extern "C" void __cxa_free_dependent_exception(__cxa_dependent_exception *vptr) _UCXX_USE_NOEXCEPT{
|
||||
free( (char *)(vptr) );
|
||||
}
|
||||
|
||||
} /* namespace __cxxabiv1 */
|
||||
42
libraries/ArduinoSTL/src/eh_globals.cpp
Normal file
42
libraries/ArduinoSTL/src/eh_globals.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
/* Copyright (C) 2006 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation, version 2.1
|
||||
of the License.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "cstdlib"
|
||||
#include "cstring"
|
||||
#include "func_exception"
|
||||
|
||||
//This is a system-specific header which does all of the error-handling management
|
||||
#include "unwind-cxx.h"
|
||||
|
||||
//The following functionality is derived from reading of the GNU libstdc++ code and making it...simple
|
||||
|
||||
|
||||
namespace __cxxabiv1{
|
||||
|
||||
static __UCLIBCXX_TLS __cxa_eh_globals eh_globals;
|
||||
|
||||
extern "C" __cxa_eh_globals* __cxa_get_globals() _UCXX_USE_NOEXCEPT{
|
||||
return &eh_globals;
|
||||
}
|
||||
|
||||
extern "C" __cxa_eh_globals* __cxa_get_globals_fast() _UCXX_USE_NOEXCEPT{
|
||||
return &eh_globals;
|
||||
}
|
||||
|
||||
}
|
||||
120
libraries/ArduinoSTL/src/exception
Normal file
120
libraries/ArduinoSTL/src/exception
Normal file
@@ -0,0 +1,120 @@
|
||||
// Exception Handling support header for -*- C++ -*-
|
||||
|
||||
// Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001, 2002
|
||||
// Free Software Foundation
|
||||
//
|
||||
// This file is part of GNU CC.
|
||||
//
|
||||
// GNU CC 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, or (at your option)
|
||||
// any later version.
|
||||
//
|
||||
// GNU CC 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 GNU CC; see the file COPYING. If not, write to
|
||||
// the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
// Boston, MA 02111-1307, USA.
|
||||
|
||||
// As a special exception, you may use this file as part of a free software
|
||||
// library without restriction. Specifically, if other files instantiate
|
||||
// templates or use macros or inline functions from this file, or you compile
|
||||
// this file and link it with other files to produce an executable, this
|
||||
// file does not by itself cause the resulting executable to be covered by
|
||||
// the GNU General Public License. This exception does not however
|
||||
// invalidate any other reasons why the executable file might be covered by
|
||||
// the GNU General Public License.
|
||||
|
||||
/** @file exception
|
||||
* This header defines several types and functions relating to the
|
||||
* handling of exceptions in a C++ program.
|
||||
*/
|
||||
|
||||
#ifndef __EXCEPTION__
|
||||
#define __EXCEPTION__
|
||||
|
||||
#include "basic_definitions"
|
||||
|
||||
extern "C++" {
|
||||
|
||||
namespace std
|
||||
{
|
||||
/**
|
||||
* @brief Base class for all library exceptions.
|
||||
*
|
||||
* This is the base class for all exceptions thrown by the standard
|
||||
* library, and by certain language expressions. You are free to derive
|
||||
* your own %exception classes, or use a different hierarchy, or to
|
||||
* throw non-class data (e.g., fundamental types).
|
||||
*/
|
||||
class exception
|
||||
{
|
||||
public:
|
||||
exception() _UCXX_NOTHROW { }
|
||||
virtual ~exception() _UCXX_NOTHROW;
|
||||
/** Returns a C-style character string describing the general cause
|
||||
* of the current error. */
|
||||
virtual const char* what() const _UCXX_NOTHROW;
|
||||
};
|
||||
|
||||
/** If an %exception is thrown which is not listed in a function's
|
||||
* %exception specification, one of these may be thrown. */
|
||||
class bad_exception : public exception
|
||||
{
|
||||
public:
|
||||
bad_exception() _UCXX_USE_NOEXCEPT { }
|
||||
// This declaration is not useless:
|
||||
// http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118
|
||||
virtual ~bad_exception() _UCXX_USE_NOEXCEPT;
|
||||
};
|
||||
|
||||
/// If you write a replacement %terminate handler, it must be of this type.
|
||||
typedef void (*terminate_handler) ();
|
||||
/// If you write a replacement %unexpected handler, it must be of this type.
|
||||
typedef void (*unexpected_handler) ();
|
||||
|
||||
/// Takes a new handler function as an argument, returns the old function.
|
||||
terminate_handler set_terminate(terminate_handler) _UCXX_USE_NOEXCEPT;
|
||||
/** The runtime will call this function if %exception handling must be
|
||||
* abandoned for any reason. */
|
||||
void terminate() __UCLIBCXX_NORETURN;
|
||||
|
||||
/// Takes a new handler function as an argument, returns the old function.
|
||||
unexpected_handler set_unexpected(unexpected_handler) _UCXX_USE_NOEXCEPT;
|
||||
/** The runtime will call this function if an %exception is thrown which
|
||||
* violates the function's %exception specification. */
|
||||
void unexpected() __UCLIBCXX_NORETURN;
|
||||
|
||||
/** [18.6.4]/1: "Returns true after completing evaluation of a
|
||||
* throw-expression until either completing initialization of the
|
||||
* exception-declaration in the matching handler or entering @c unexpected()
|
||||
* due to the throw; or after entering @c terminate() for any reason
|
||||
* other than an explicit call to @c terminate(). [Note: This includes
|
||||
* stack unwinding [15.2]. end note]"
|
||||
*
|
||||
* 2: "When @c uncaught_exception() is true, throwing an %exception can
|
||||
* result in a call of @c terminate() (15.5.1)."
|
||||
*/
|
||||
bool uncaught_exception() _UCXX_USE_NOEXCEPT;
|
||||
} // namespace std
|
||||
|
||||
namespace __gnu_cxx
|
||||
{
|
||||
/** A replacement for the standard terminate_handler which prints more
|
||||
information about the terminating exception (if any) on stderr. Call
|
||||
@code
|
||||
std::set_terminate (__gnu_cxx::__verbose_terminate_handler)
|
||||
@endcode
|
||||
to use. For more info, see
|
||||
http://gcc.gnu.org/onlinedocs/libstdc++/19_diagnostics/howto.html#4
|
||||
*/
|
||||
void __verbose_terminate_handler ();
|
||||
} // namespace __gnu_cxx
|
||||
|
||||
} // extern "C++"
|
||||
|
||||
#endif
|
||||
52
libraries/ArduinoSTL/src/exception.cpp
Normal file
52
libraries/ArduinoSTL/src/exception.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "exception"
|
||||
|
||||
//We can't do this yet because gcc is too stupid to be able to handle
|
||||
//different implementations of exception class.
|
||||
|
||||
#undef __UCLIBCXX_EXCEPTION_SUPPORT__
|
||||
|
||||
#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__
|
||||
|
||||
namespace std{
|
||||
_UCXXEXPORT static char * __std_exception_what_value = "exception";
|
||||
|
||||
//We are providing our own versions to be sneaky
|
||||
|
||||
|
||||
_UCXXEXPORT exception::~exception() _UCXX_USE_NOEXCEPT{
|
||||
//Empty function
|
||||
}
|
||||
|
||||
_UCXXEXPORT const char* exception::what() const _UCXX_USE_NOEXCEPT{
|
||||
return __std_exception_what_value;
|
||||
}
|
||||
|
||||
_UCXXEXPORT bad_exception::~bad_exception() _UCXX_USE_NOEXCEPT{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
41
libraries/ArduinoSTL/src/func_exception
Normal file
41
libraries/ArduinoSTL/src/func_exception
Normal file
@@ -0,0 +1,41 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "basic_definitions"
|
||||
#include "exception"
|
||||
|
||||
|
||||
#ifndef HEADER_IMPLEMENTATION_FUNC_EXCEPTION
|
||||
#define HEADER_IMPLEMENTATION_FUNC_EXCEPTION
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
|
||||
namespace std{
|
||||
|
||||
_UCXXEXPORT void __throw_bad_alloc();
|
||||
_UCXXEXPORT void __throw_out_of_range(const char * message = 0);
|
||||
_UCXXEXPORT void __throw_overflow_error(const char * message = 0);
|
||||
_UCXXEXPORT void __throw_length_error(const char * message = 0);
|
||||
_UCXXEXPORT void __throw_invalid_argument(const char * message = 0);
|
||||
}
|
||||
|
||||
#pragma GCC visibility pop
|
||||
|
||||
#endif
|
||||
|
||||
87
libraries/ArduinoSTL/src/func_exception.cpp
Normal file
87
libraries/ArduinoSTL/src/func_exception.cpp
Normal file
@@ -0,0 +1,87 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "exception"
|
||||
#include "func_exception"
|
||||
#include "stdexcept"
|
||||
#include "cstdlib"
|
||||
|
||||
namespace std{
|
||||
|
||||
#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__
|
||||
|
||||
_UCXXEXPORT void __throw_bad_alloc(){
|
||||
throw bad_alloc();
|
||||
}
|
||||
|
||||
_UCXXEXPORT void __throw_out_of_range( const char * message){
|
||||
if(message == 0){
|
||||
throw out_of_range();
|
||||
}
|
||||
throw out_of_range(message);
|
||||
}
|
||||
|
||||
_UCXXEXPORT void __throw_overflow_error( const char * message){
|
||||
if(message == 0){
|
||||
throw overflow_error();
|
||||
}
|
||||
throw overflow_error(message);
|
||||
}
|
||||
|
||||
_UCXXEXPORT void __throw_length_error(const char * message){
|
||||
if(message == 0){
|
||||
throw length_error();
|
||||
}
|
||||
throw length_error(message);
|
||||
}
|
||||
|
||||
_UCXXEXPORT void __throw_invalid_argument(const char * message){
|
||||
if(message == 0){
|
||||
throw invalid_argument();
|
||||
}
|
||||
throw invalid_argument(message);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
_UCXXEXPORT void __throw_bad_alloc(){
|
||||
abort();
|
||||
}
|
||||
|
||||
_UCXXEXPORT void __throw_out_of_range( const char * ){
|
||||
abort();
|
||||
}
|
||||
|
||||
_UCXXEXPORT void __throw_overflow_error( const char * ){
|
||||
abort();
|
||||
}
|
||||
|
||||
_UCXXEXPORT void __throw_length_error(const char * ){
|
||||
abort();
|
||||
}
|
||||
|
||||
_UCXXEXPORT void __throw_invalid_argument(const char *){
|
||||
abort();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
}
|
||||
439
libraries/ArduinoSTL/src/functional
Normal file
439
libraries/ArduinoSTL/src/functional
Normal file
@@ -0,0 +1,439 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
This file is part of the uClibc++ Library.
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __STD_HEADER_FUNCTIONAL
|
||||
#define __STD_HEADER_FUNCTIONAL 1
|
||||
|
||||
#include "basic_definitions"
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
|
||||
namespace std{
|
||||
|
||||
template <class Arg, class Result> struct unary_function;
|
||||
template <class Arg1, class Arg2, class Result> struct binary_function;
|
||||
|
||||
template <class T> struct plus;
|
||||
template <class T> struct minus;
|
||||
template <class T> struct multiplies;
|
||||
template <class T> struct divides;
|
||||
template <class T> struct modulus;
|
||||
template <class T> struct negate;
|
||||
|
||||
template <class T> struct equal_to;
|
||||
template <class T> struct not_equal_to;
|
||||
template <class T> struct greater;
|
||||
template <class T> struct less;
|
||||
template <class T> struct greater_equal;
|
||||
template <class T> struct less_equal;
|
||||
|
||||
template <class T> struct logical_and;
|
||||
template <class T> struct logical_or;
|
||||
template <class T> struct logical_not;
|
||||
|
||||
template <class Predicate> struct unary_negate;
|
||||
template <class Predicate> unary_negate<Predicate> not1(const Predicate&);
|
||||
template <class Predicate> struct binary_negate;
|
||||
template <class Predicate> binary_negate<Predicate> not2(const Predicate&);
|
||||
|
||||
|
||||
template <class Operation> class binder1st;
|
||||
template <class Operation, class T> binder1st<Operation> bind1st(const Operation&, const T&);
|
||||
template <class Operation> class binder2nd;
|
||||
template <class Operation, class T> binder2nd<Operation> bind2nd(const Operation&, const T&);
|
||||
|
||||
template <class Arg, class Result> class pointer_to_unary_function;
|
||||
template <class Arg, class Result> pointer_to_unary_function<Arg,Result> ptr_fun(Result (*)(Arg));
|
||||
template <class Arg1, class Arg2, class Result> class pointer_to_binary_function;
|
||||
template <class Arg1, class Arg2, class Result>
|
||||
pointer_to_binary_function<Arg1,Arg2,Result> ptr_fun(Result (*)(Arg1,Arg2));
|
||||
|
||||
template<class S, class T> class mem_fun_t;
|
||||
template<class S, class T, class A> class mem_fun1_t;
|
||||
template<class S, class T> class const_mem_fun_t;
|
||||
template<class S, class T, class A> class const_mem_fun1_t;
|
||||
template<class S, class T> mem_fun_t<S,T> mem_fun(S (T::*f)());
|
||||
template<class S, class T, class A> mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A));
|
||||
template<class S, class T> class mem_fun_ref_t;
|
||||
template<class S, class T, class A> class mem_fun1_ref_t;
|
||||
template<class S, class T> mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)());
|
||||
template<class S, class T, class A> mem_fun1_ref_t<S,T,A> mem_fun1_ref(S (T::*f)(A));
|
||||
|
||||
//Implementation
|
||||
|
||||
template <class Arg, class Result> struct _UCXXEXPORT unary_function{
|
||||
typedef Arg argument_type;
|
||||
typedef Result result_type;
|
||||
};
|
||||
|
||||
|
||||
template <class Arg1, class Arg2, class Result> struct _UCXXEXPORT binary_function{
|
||||
typedef Arg1 first_argument_type;
|
||||
typedef Arg2 second_argument_type;
|
||||
typedef Result result_type;
|
||||
};
|
||||
|
||||
template <class T> struct _UCXXEXPORT plus : binary_function<T,T,T>{
|
||||
T operator()(const T& x, const T& y) const{
|
||||
return x + y;
|
||||
}
|
||||
};
|
||||
|
||||
template <class T> struct _UCXXEXPORT minus : binary_function<T,T,T>{
|
||||
T operator()(const T& x, const T& y) const{
|
||||
return x - y;
|
||||
}
|
||||
};
|
||||
|
||||
template <class T> struct _UCXXEXPORT multiplies : binary_function<T,T,T>{
|
||||
T operator()(const T& x, const T& y) const{
|
||||
return x * y;
|
||||
}
|
||||
};
|
||||
|
||||
template <class T> struct _UCXXEXPORT divides : binary_function<T,T,T>{
|
||||
T operator()(const T& x, const T& y) const{
|
||||
return x / y;
|
||||
}
|
||||
};
|
||||
|
||||
template <class T> struct _UCXXEXPORT modulus : binary_function<T,T,T>{
|
||||
T operator()(const T& x, const T& y) const{
|
||||
return x % y;
|
||||
}
|
||||
};
|
||||
|
||||
template <class T> struct _UCXXEXPORT negate : unary_function<T,T>{
|
||||
T operator()(const T& x) const{
|
||||
return -x;
|
||||
}
|
||||
};
|
||||
|
||||
template <class T> struct _UCXXEXPORT equal_to : binary_function<T,T,bool>{
|
||||
bool operator()(const T& x, const T& y) const{
|
||||
return (x == y);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T> struct _UCXXEXPORT not_equal_to : binary_function<T,T,bool>{
|
||||
bool operator()(const T& x, const T& y) const{
|
||||
return (x != y);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T> struct _UCXXEXPORT greater : binary_function<T,T,bool>{
|
||||
bool operator()(const T& x, const T& y) const _UCXX_NOTHROW {
|
||||
return (x > y);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T> struct _UCXXEXPORT less : binary_function<T,T,bool>{
|
||||
bool operator()(const T& x, const T& y) const _UCXX_NOTHROW {
|
||||
return (x < y);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T> struct _UCXXEXPORT greater_equal : binary_function<T,T,bool>{
|
||||
bool operator()(const T& x, const T& y) const _UCXX_NOTHROW {
|
||||
return (x >= y);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T> struct _UCXXEXPORT less_equal : binary_function<T,T,bool>{
|
||||
bool operator()(const T& x, const T& y) const _UCXX_NOTHROW {
|
||||
return (x <= y);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T> struct _UCXXEXPORT logical_and : binary_function<T,T,bool> {
|
||||
bool operator()(const T& x, const T& y) const{
|
||||
return (x && y);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T> struct _UCXXEXPORT logical_or : binary_function<T,T,bool> {
|
||||
bool operator()(const T& x, const T& y) const{
|
||||
return (x || y);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T> struct _UCXXEXPORT logical_not : unary_function<T,bool> {
|
||||
bool operator()(const T& x) const{
|
||||
return !x;
|
||||
}
|
||||
};
|
||||
|
||||
template <class Predicate> class _UCXXEXPORT unary_negate
|
||||
: public unary_function<typename Predicate::argument_type,bool>
|
||||
{
|
||||
public:
|
||||
explicit unary_negate(const Predicate& pred) : p(pred) { }
|
||||
bool operator()(const typename Predicate::argument_type& x) const{
|
||||
return !p(x);
|
||||
}
|
||||
private:
|
||||
Predicate p;
|
||||
};
|
||||
|
||||
|
||||
template <class Predicate> _UCXXEXPORT unary_negate<Predicate> not1(const Predicate& pred){
|
||||
return unary_negate<Predicate>(pred);
|
||||
}
|
||||
|
||||
|
||||
template <class Predicate> class _UCXXEXPORT binary_negate : public
|
||||
binary_function<typename Predicate::first_argument_type,
|
||||
typename Predicate::second_argument_type, bool>
|
||||
{
|
||||
public:
|
||||
explicit binary_negate(const Predicate& pred) : p(pred) { }
|
||||
bool operator()(const typename Predicate::first_argument_type& x,
|
||||
const typename Predicate::second_argument_type& y) const
|
||||
{
|
||||
return !p(x, y);
|
||||
}
|
||||
private:
|
||||
Predicate p;
|
||||
};
|
||||
|
||||
|
||||
template <class Predicate> _UCXXEXPORT binary_negate<Predicate> not2(const Predicate& pred){
|
||||
return binary_negate<Predicate>(pred);
|
||||
}
|
||||
|
||||
|
||||
template <class Operation> class _UCXXEXPORT binder1st
|
||||
: public unary_function<typename Operation::second_argument_type,
|
||||
typename Operation::result_type>
|
||||
{
|
||||
protected:
|
||||
Operation op;
|
||||
typename Operation::first_argument_type value;
|
||||
public:
|
||||
binder1st(const Operation& x, const typename Operation::first_argument_type& y) : op(x), value(y){ }
|
||||
typename Operation::result_type operator()(const typename Operation::second_argument_type& x) const{
|
||||
return op(value,x);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <class Operation, class T> _UCXXEXPORT binder1st<Operation> bind1st(const Operation& op, const T& x){
|
||||
return binder1st<Operation>(op, typename Operation::first_argument_type(x));
|
||||
}
|
||||
|
||||
|
||||
template <class Operation> class _UCXXEXPORT binder2nd
|
||||
: public unary_function<typename Operation::first_argument_type,
|
||||
typename Operation::result_type>
|
||||
{
|
||||
protected:
|
||||
Operation op;
|
||||
typename Operation::second_argument_type value;
|
||||
public:
|
||||
binder2nd(const Operation& x, const typename Operation::second_argument_type& y) : op(x), value(y) { }
|
||||
typename Operation::result_type operator()(const typename Operation::first_argument_type& x) const{
|
||||
return op(x,value);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <class Operation, class T> _UCXXEXPORT
|
||||
binder2nd<Operation> bind2nd(const Operation& op, const T& x)
|
||||
{
|
||||
return binder2nd<Operation>(op, typename Operation::second_argument_type(x));
|
||||
}
|
||||
|
||||
|
||||
template <class Arg, class Result> class _UCXXEXPORT
|
||||
pointer_to_unary_function : public unary_function<Arg, Result>
|
||||
{
|
||||
protected:
|
||||
Result (*func)(Arg);
|
||||
public:
|
||||
explicit pointer_to_unary_function(Result (*f)(Arg)) : func(f) { }
|
||||
Result operator()(Arg x) const{
|
||||
return func(x);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <class Arg, class Result> _UCXXEXPORT pointer_to_unary_function<Arg, Result> ptr_fun(Result (*f)(Arg)){
|
||||
return pointer_to_unary_function<Arg, Result>(f);
|
||||
}
|
||||
|
||||
|
||||
template <class Arg1, class Arg2, class Result> class _UCXXEXPORT
|
||||
pointer_to_binary_function : public binary_function<Arg1,Arg2,Result>
|
||||
{
|
||||
protected:
|
||||
Result (*func)(Arg1, Arg2);
|
||||
public:
|
||||
explicit pointer_to_binary_function(Result (*f)(Arg1, Arg2)) : func(f) { }
|
||||
Result operator()(Arg1 x, Arg2 y) const{
|
||||
return func(x, y);
|
||||
}
|
||||
};
|
||||
|
||||
template <class Arg1, class Arg2, class Result> _UCXXEXPORT
|
||||
pointer_to_binary_function<Arg1,Arg2,Result> ptr_fun(Result (*f)(Arg1, Arg2))
|
||||
{
|
||||
return pointer_to_binary_function<Arg1,Arg2,Result>(f);
|
||||
}
|
||||
|
||||
|
||||
template <class S, class T> class _UCXXEXPORT mem_fun_t
|
||||
: public unary_function<T*, S>
|
||||
{
|
||||
public:
|
||||
explicit mem_fun_t(S (T::*p)()) : m(p) { }
|
||||
S operator()(T* p) const { return (p->*m)(); }
|
||||
private:
|
||||
S (T::*m)();
|
||||
};
|
||||
|
||||
|
||||
template <class S, class T, class A> class _UCXXEXPORT mem_fun1_t
|
||||
: public binary_function<T*, A, S>
|
||||
{
|
||||
public:
|
||||
explicit mem_fun1_t(S (T::*p)(A)) : m(p) { }
|
||||
S operator()(T* p, A x) const { return (p->*m)(x); }
|
||||
private:
|
||||
S (T::*m)(A);
|
||||
};
|
||||
|
||||
|
||||
template <class S, class T> class _UCXXEXPORT const_mem_fun_t
|
||||
: public unary_function<const T*, S>
|
||||
{
|
||||
public:
|
||||
explicit const_mem_fun_t(S (T::*p)() const) : m(p) { }
|
||||
S operator()(const T* p) const { return (p->*m)(); }
|
||||
private:
|
||||
S (T::*m)() const;
|
||||
};
|
||||
|
||||
|
||||
template <class S, class T, class A> class _UCXXEXPORT const_mem_fun1_t
|
||||
: public binary_function<T*, A, S>
|
||||
{
|
||||
public:
|
||||
explicit const_mem_fun1_t(S (T::*p)(A) const) : m(p) { }
|
||||
S operator()(const T* p, A x) const { return (p->*m)(x); }
|
||||
private:
|
||||
S (T::*m)(A) const;
|
||||
};
|
||||
|
||||
|
||||
template<class S, class T> _UCXXEXPORT mem_fun_t<S,T> mem_fun(S (T::*f)()){
|
||||
return mem_fun_t<S, T>(f);
|
||||
}
|
||||
|
||||
template<class S, class T> _UCXXEXPORT const_mem_fun_t<S,T> mem_fun(S (T::*f)() const){
|
||||
return const_mem_fun_t<S, T>(f);
|
||||
}
|
||||
|
||||
template<class S, class T, class A> _UCXXEXPORT mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A)){
|
||||
return mem_fun1_t<S, T, A>(f);
|
||||
}
|
||||
|
||||
template<class S, class T, class A> _UCXXEXPORT const_mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A) const){
|
||||
return const_mem_fun1_t<S, T, A>(f);
|
||||
}
|
||||
|
||||
template <class S, class T> class _UCXXEXPORT mem_fun_ref_t
|
||||
: public unary_function<T, S>
|
||||
{
|
||||
public:
|
||||
explicit mem_fun_ref_t(S (T::*p)()) : mf(p) { }
|
||||
S operator()(T& p) { return (p.*mf)(); }
|
||||
private:
|
||||
S (T::*mf)();
|
||||
};
|
||||
|
||||
template <class S, class T, class A> class _UCXXEXPORT mem_fun1_ref_t
|
||||
: public binary_function<T, A, S>
|
||||
{
|
||||
public:
|
||||
explicit mem_fun1_ref_t(S (T::*p)(A)) : mf(p) { }
|
||||
S operator()(T& p, A x) { return (p.*mf)(x); }
|
||||
private:
|
||||
S (T::*mf)(A);
|
||||
};
|
||||
|
||||
template<class S, class T> _UCXXEXPORT mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)()){
|
||||
return mem_fun_ref_t<S,T>(f);
|
||||
}
|
||||
|
||||
template<class S, class T, class A> _UCXXEXPORT mem_fun1_ref_t<S,T,A> mem_fun1_ref(S (T::*f)(A)){
|
||||
return mem_fun1_ref_t<S,T,A>(f);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//These are SGI extensions which are checked for by some conformance checks. They
|
||||
// are *NOT* part of the C++ standard, however
|
||||
|
||||
template <class Op1, class Op2> class _UCXXEXPORT unary_compose :
|
||||
public std::unary_function<typename Op2::argument_type,
|
||||
typename Op1::result_type>
|
||||
{
|
||||
protected:
|
||||
Op1 mf1;
|
||||
Op2 mf2;
|
||||
public:
|
||||
unary_compose(const Op1& x, const Op2& y) : mf1(x), mf2(y) { }
|
||||
typename Op1::result_type operator()(const typename Op2::argument_type& x) const {
|
||||
return mf1(mf2(x));
|
||||
}
|
||||
};
|
||||
|
||||
template <class Op1, class Op2> _UCXXEXPORT
|
||||
inline unary_compose<Op1, Op2>
|
||||
compose1(const Op1& fn1, const Op2& fn2){
|
||||
return unary_compose<Op1, Op2>(fn1, fn2);
|
||||
}
|
||||
|
||||
template <class Op1, class Op2, class Op3> class _UCXXEXPORT binary_compose :
|
||||
public std::unary_function<typename Op2::argument_type, typename Op1::result_type>
|
||||
{
|
||||
protected:
|
||||
Op1 mf1;
|
||||
Op2 mf2;
|
||||
Op3 mf3;
|
||||
public:
|
||||
binary_compose(const Op1 & x, const Op2 & y, const Op3 & z)
|
||||
: mf1(x), mf2(y), mf3(z){ }
|
||||
typename Op1::result_type operator()(const typename Op2::argument_type & x) const {
|
||||
return mf1(mf2(x), mf3(x));
|
||||
}
|
||||
};
|
||||
|
||||
template <class Op1, class Op2, class Op3> inline _UCXXEXPORT binary_compose<Op1, Op2, Op3>
|
||||
compose2(const Op1 & fn1, const Op2 & fn2, const Op3 & fn3){
|
||||
return binary_compose<Op1, Op2, Op3>(fn1, fn2, fn3);
|
||||
}
|
||||
|
||||
#pragma GCC visibility pop
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
60
libraries/ArduinoSTL/src/initializer_list
Normal file
60
libraries/ArduinoSTL/src/initializer_list
Normal file
@@ -0,0 +1,60 @@
|
||||
/* Copyright (C) 2016 Michael Matera
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __STD_HEADER_INITIALIZER_LIST
|
||||
#define __STD_HEADER_INITIALIZER_LIST
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
|
||||
namespace std {
|
||||
|
||||
template<class T>
|
||||
class initializer_list {
|
||||
|
||||
private:
|
||||
const T* array;
|
||||
size_t len;
|
||||
|
||||
// Initialize from a { ... } construct
|
||||
initializer_list(const T *a, size_t l): array(a), len(l) { }
|
||||
|
||||
public:
|
||||
|
||||
// default constructor
|
||||
initializer_list() : array(NULL), len(0) {}
|
||||
|
||||
size_t size() const {
|
||||
return len;
|
||||
}
|
||||
|
||||
const T *begin() {
|
||||
return array;
|
||||
}
|
||||
|
||||
const T *end() {
|
||||
return array + len;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
170
libraries/ArduinoSTL/src/iomanip
Normal file
170
libraries/ArduinoSTL/src/iomanip
Normal file
@@ -0,0 +1,170 @@
|
||||
/* Copyright (C) 2005 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "exception"
|
||||
#include "ios"
|
||||
|
||||
#ifndef __STD_IOMANIP
|
||||
#define __STD_IOMANIP 1
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
|
||||
namespace std{
|
||||
|
||||
// These are the helper classes which we are going to be using to
|
||||
// hold the required data
|
||||
|
||||
class _UCXXEXPORT __resetiosflags{
|
||||
public:
|
||||
ios_base::fmtflags m;
|
||||
_UCXXEXPORT __resetiosflags(ios_base::fmtflags mask) : m(mask){ }
|
||||
};
|
||||
|
||||
class _UCXXEXPORT __setiosflags{
|
||||
public:
|
||||
ios_base::fmtflags m;
|
||||
_UCXXEXPORT __setiosflags(ios_base::fmtflags mask) : m(mask){ }
|
||||
};
|
||||
|
||||
class _UCXXEXPORT __setbase{
|
||||
public:
|
||||
int base;
|
||||
_UCXXEXPORT __setbase(int b) : base(b){ }
|
||||
};
|
||||
|
||||
class _UCXXEXPORT __setfill{
|
||||
public:
|
||||
int character;
|
||||
_UCXXEXPORT __setfill(int c): character(c){ }
|
||||
};
|
||||
|
||||
class _UCXXEXPORT __setprecision{
|
||||
public:
|
||||
int digits;
|
||||
_UCXXEXPORT __setprecision(int n): digits(n) { }
|
||||
};
|
||||
|
||||
class _UCXXEXPORT __setw{
|
||||
public:
|
||||
int width;
|
||||
_UCXXEXPORT __setw(int n): width(n) { }
|
||||
};
|
||||
|
||||
|
||||
//Actual manipulator functions
|
||||
|
||||
inline __resetiosflags resetiosflags(ios_base::fmtflags mask){
|
||||
return __resetiosflags(mask);
|
||||
}
|
||||
|
||||
inline __setiosflags setiosflags(ios_base::fmtflags mask){
|
||||
return __setiosflags(mask);
|
||||
}
|
||||
|
||||
inline __setbase setbase(int b){
|
||||
return __setbase(b);
|
||||
}
|
||||
|
||||
inline __setfill setfill(int c){
|
||||
return __setfill(c);
|
||||
}
|
||||
|
||||
inline __setprecision setprecision(int n){
|
||||
return __setprecision(n);
|
||||
}
|
||||
|
||||
inline __setw setw(int n){
|
||||
return __setw(n);
|
||||
}
|
||||
|
||||
|
||||
//How to handle interaction with [i|o]stream classes
|
||||
|
||||
template<class Ch, class Tr> _UCXXEXPORT basic_ostream<Ch, Tr>&
|
||||
operator<<(basic_ostream<Ch, Tr>& os, const __resetiosflags s)
|
||||
{
|
||||
os.setf(ios_base::fmtflags(0),s.m);
|
||||
return os;
|
||||
}
|
||||
|
||||
template<class Ch, class Tr> _UCXXEXPORT basic_istream<Ch, Tr>&
|
||||
operator>>(basic_istream<Ch, Tr>& is, const __resetiosflags s)
|
||||
{
|
||||
is.setf(ios_base::fmtflags(0),s.m);
|
||||
return is;
|
||||
}
|
||||
|
||||
template<class Ch, class Tr> _UCXXEXPORT basic_ostream<Ch, Tr>&
|
||||
operator<<(basic_ostream<Ch, Tr>& os, const __setiosflags s)
|
||||
{
|
||||
os.setf(s.m);
|
||||
return os;
|
||||
}
|
||||
|
||||
template<class Ch, class Tr> _UCXXEXPORT basic_ostream<Ch, Tr>&
|
||||
operator<<(basic_ostream<Ch, Tr>& os, const __setbase s)
|
||||
{
|
||||
ios_base::fmtflags f(0);
|
||||
switch(s.base){
|
||||
case 8:
|
||||
f = ios_base::oct;
|
||||
break;
|
||||
case 10:
|
||||
f = ios_base::dec;
|
||||
break;
|
||||
case 16:
|
||||
f = ios_base::hex;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
os.setf(f, ios_base::basefield);
|
||||
return os;
|
||||
}
|
||||
|
||||
template<class Ch, class Tr> _UCXXEXPORT basic_ostream<Ch, Tr>&
|
||||
operator<<(basic_ostream<Ch, Tr>& os, const __setfill s)
|
||||
{
|
||||
os.fill(s.character);
|
||||
return os;
|
||||
}
|
||||
|
||||
template<class Ch, class Tr> _UCXXEXPORT basic_ostream<Ch, Tr>&
|
||||
operator<<(basic_ostream<Ch, Tr>& os, const __setprecision s)
|
||||
{
|
||||
os.precision(s.digits);
|
||||
return os;
|
||||
}
|
||||
|
||||
template<class Ch, class Tr> _UCXXEXPORT basic_ostream<Ch, Tr>&
|
||||
operator<<(basic_ostream<Ch, Tr>& os, const __setw s)
|
||||
{
|
||||
os.width(s.width);
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#pragma GCC visibility pop
|
||||
|
||||
#endif
|
||||
|
||||
29
libraries/ArduinoSTL/src/iomanip.cpp
Normal file
29
libraries/ArduinoSTL/src/iomanip.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
/* Copyright (C) 2005 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "iomanip"
|
||||
|
||||
namespace std{
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
503
libraries/ArduinoSTL/src/ios
Normal file
503
libraries/ArduinoSTL/src/ios
Normal file
@@ -0,0 +1,503 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "basic_definitions"
|
||||
#include "cstddef"
|
||||
#include "locale"
|
||||
#include "iosfwd"
|
||||
|
||||
#ifndef __HEADER_STD_IOS
|
||||
#define __HEADER_STD_IOS 1
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
|
||||
namespace std{
|
||||
typedef signed long int streamoff;
|
||||
|
||||
template <class stateT> class fpos;
|
||||
|
||||
class _UCXXEXPORT ios_base {
|
||||
public:
|
||||
class failure;
|
||||
#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__
|
||||
class failure : public exception {
|
||||
public:
|
||||
explicit failure(const std::string&) { }
|
||||
explicit failure() { }
|
||||
virtual const char* what() const _UCXX_USE_NOEXCEPT {
|
||||
return "std::ios_base failure exception";
|
||||
}
|
||||
};
|
||||
#endif
|
||||
#ifdef __UCLIBCXX_SUPPORT_CDIR__
|
||||
class _UCXXLOCAL Init{
|
||||
public:
|
||||
_UCXXEXPORT Init();
|
||||
_UCXXEXPORT ~Init();
|
||||
private:
|
||||
static int init_cnt;
|
||||
};
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
typedef unsigned short int fmtflags;
|
||||
|
||||
static const fmtflags skipws = 0x0001;
|
||||
|
||||
static const fmtflags left = 0x0002;
|
||||
static const fmtflags right = 0x0004;
|
||||
static const fmtflags internal = 0x0008;
|
||||
|
||||
static const fmtflags boolalpha = 0x0010;
|
||||
|
||||
static const fmtflags dec = 0x0020;
|
||||
static const fmtflags oct = 0x0040;
|
||||
static const fmtflags hex = 0x0080;
|
||||
|
||||
static const fmtflags scientific = 0x0100;
|
||||
static const fmtflags fixed = 0x0200;
|
||||
|
||||
static const fmtflags showbase = 0x0400;
|
||||
static const fmtflags showpoint = 0x0800;
|
||||
static const fmtflags showpos = 0x1000;
|
||||
static const fmtflags uppercase = 0x2000;
|
||||
|
||||
static const fmtflags adjustfield = left | right | internal;
|
||||
static const fmtflags basefield = dec | oct | hex;
|
||||
static const fmtflags floatfield = fixed | scientific;
|
||||
|
||||
static const fmtflags unitbuf = 0x4000;
|
||||
|
||||
typedef unsigned char iostate;
|
||||
static const iostate goodbit = 0x00;
|
||||
static const iostate badbit = 0x01;
|
||||
static const iostate eofbit = 0x02;
|
||||
static const iostate failbit = 0x04;
|
||||
|
||||
typedef unsigned char openmode;
|
||||
static const openmode app = 0x01;
|
||||
static const openmode ate = 0x02;
|
||||
static const openmode binary = 0x04;
|
||||
static const openmode in = 0x08;
|
||||
static const openmode out = 0x10;
|
||||
static const openmode trunc = 0x20;
|
||||
|
||||
typedef unsigned char seekdir;
|
||||
static const seekdir beg = 0x01;
|
||||
static const seekdir cur = 0x02;
|
||||
static const seekdir end = 0x04;
|
||||
|
||||
_UCXXEXPORT fmtflags flags() const{
|
||||
return mformat;
|
||||
}
|
||||
_UCXXEXPORT fmtflags flags(fmtflags fmtfl);
|
||||
|
||||
fmtflags setf(fmtflags fmtfl);
|
||||
fmtflags setf(fmtflags fmtfl, fmtflags mask );
|
||||
|
||||
_UCXXEXPORT void unsetf(fmtflags mask){
|
||||
mformat&= ~mask;
|
||||
}
|
||||
|
||||
_UCXXEXPORT streamsize precision() const{
|
||||
return mprecision;
|
||||
}
|
||||
|
||||
_UCXXEXPORT streamsize precision(streamsize prec);
|
||||
|
||||
_UCXXEXPORT streamsize width() const{
|
||||
return mwidth;
|
||||
}
|
||||
|
||||
_UCXXEXPORT streamsize width(streamsize wide);
|
||||
|
||||
_UCXXEXPORT locale imbue(const locale& loc);
|
||||
|
||||
_UCXXEXPORT locale getloc() const{
|
||||
return mLocale;
|
||||
}
|
||||
|
||||
// FIXME - These need to be implemented
|
||||
// static int xalloc();
|
||||
// long& iword(int index);
|
||||
// void*& pword(int index);
|
||||
|
||||
enum event { erase_event, imbue_event, copyfmt_event };
|
||||
|
||||
typedef void (*event_callback)(event, ios_base&, int index);
|
||||
// void register_callback(event_call_back fn, int index);
|
||||
|
||||
virtual _UCXXEXPORT ~ios_base() {
|
||||
/* would run erase_event callbacks here */
|
||||
}
|
||||
|
||||
//We are going to wrap stdio so we don't need implementation of the following:
|
||||
inline static bool sync_with_stdio(bool = true) { return true; }
|
||||
|
||||
protected:
|
||||
_UCXXEXPORT ios_base() : mLocale(), mformat(dec | skipws ), mstate(goodbit),
|
||||
mmode(), mdir(), mprecision(6), mwidth(0)
|
||||
#ifdef __UCLIBCXX_SUPPORT_CDIR__
|
||||
,mInit()
|
||||
#endif
|
||||
{
|
||||
|
||||
}
|
||||
locale mLocale;
|
||||
fmtflags mformat;
|
||||
iostate mstate;
|
||||
openmode mmode;
|
||||
seekdir mdir;
|
||||
streamsize mprecision;
|
||||
streamsize mwidth;
|
||||
#ifdef __UCLIBCXX_SUPPORT_CDIR__
|
||||
Init mInit;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
//ios_base manipulators
|
||||
|
||||
|
||||
inline ios_base& boolalpha (ios_base& str){
|
||||
str.setf(ios_base::boolalpha);
|
||||
return str;
|
||||
}
|
||||
inline ios_base& noboolalpha(ios_base& str){
|
||||
str.unsetf(ios_base::boolalpha);
|
||||
return str;
|
||||
}
|
||||
inline ios_base& showbase (ios_base& str){
|
||||
str.setf(ios_base::showbase);
|
||||
return str;
|
||||
}
|
||||
inline ios_base& noshowbase (ios_base& str){
|
||||
str.unsetf(ios_base::showbase);
|
||||
return str;
|
||||
}
|
||||
inline ios_base& showpoint (ios_base& str){
|
||||
str.setf(ios_base::showpoint);
|
||||
return str;
|
||||
}
|
||||
inline ios_base& noshowpoint(ios_base& str){
|
||||
str.unsetf(ios_base::showpoint);
|
||||
return str;
|
||||
}
|
||||
inline ios_base& showpos (ios_base& str){
|
||||
str.setf(ios_base::showpos);
|
||||
return str;
|
||||
}
|
||||
inline ios_base& noshowpos (ios_base& str){
|
||||
str.unsetf(ios_base::showpos);
|
||||
return str;
|
||||
}
|
||||
inline ios_base& skipws (ios_base& str){
|
||||
str.setf(ios_base::skipws);
|
||||
return str;
|
||||
}
|
||||
inline ios_base& noskipws (ios_base& str){
|
||||
str.unsetf(ios_base::skipws);
|
||||
return str;
|
||||
}
|
||||
inline ios_base& uppercase (ios_base& str){
|
||||
str.setf(ios_base::uppercase);
|
||||
return str;
|
||||
}
|
||||
inline ios_base& nouppercase(ios_base& str){
|
||||
str.unsetf(ios_base::uppercase);
|
||||
return str;
|
||||
}
|
||||
|
||||
inline ios_base& unitbuf (ios_base& str){
|
||||
str.setf(ios_base::unitbuf);
|
||||
return str;
|
||||
}
|
||||
inline ios_base& nounitbuf (ios_base& str){
|
||||
str.unsetf(ios_base::unitbuf);
|
||||
return str;
|
||||
}
|
||||
inline ios_base& internal (ios_base& str){
|
||||
str.setf(ios_base::internal, ios_base::adjustfield);
|
||||
return str;
|
||||
}
|
||||
inline ios_base& left (ios_base& str){
|
||||
str.setf(ios_base::left, ios_base::adjustfield);
|
||||
return str;
|
||||
}
|
||||
inline ios_base& right (ios_base& str){
|
||||
str.setf(ios_base::right, ios_base::adjustfield);
|
||||
return str;
|
||||
}
|
||||
|
||||
inline ios_base& dec (ios_base& str){
|
||||
str.setf(ios_base::dec, ios_base::basefield);
|
||||
return str;
|
||||
}
|
||||
inline ios_base& hex (ios_base& str){
|
||||
str.setf(ios_base::hex, ios_base::basefield);
|
||||
return str;
|
||||
}
|
||||
inline ios_base& oct (ios_base& str){
|
||||
str.setf(ios_base::oct, ios_base::basefield);
|
||||
return str;
|
||||
}
|
||||
|
||||
inline ios_base& fixed (ios_base& str){
|
||||
str.setf(ios_base::fixed, ios_base::floatfield);
|
||||
return str;
|
||||
}
|
||||
inline ios_base& scientific (ios_base& str){
|
||||
str.setf(ios_base::scientific, ios_base::floatfield);
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
//basic_ios class definition
|
||||
|
||||
|
||||
template <class charT, class traits > class _UCXXEXPORT basic_ios
|
||||
: public ios_base
|
||||
{
|
||||
public:
|
||||
// Types:
|
||||
typedef charT char_type;
|
||||
typedef typename traits::int_type int_type;
|
||||
typedef typename traits::pos_type pos_type;
|
||||
typedef typename traits::off_type off_type;
|
||||
typedef traits traits_type;
|
||||
|
||||
_UCXXEXPORT operator void*() const{
|
||||
if(fail() ){
|
||||
return 0;
|
||||
}
|
||||
return (void *)(1); //Must return a non-NULL pointer (though it can be *any* pointer)
|
||||
}
|
||||
|
||||
_UCXXEXPORT bool operator!() const{
|
||||
return fail();
|
||||
}
|
||||
_UCXXEXPORT iostate rdstate() const{
|
||||
return mstate;
|
||||
}
|
||||
_UCXXEXPORT void clear(iostate state = goodbit){
|
||||
if(rdbuf()!=0){
|
||||
mstate = state;
|
||||
}else{
|
||||
mstate = state|ios_base::badbit;
|
||||
}
|
||||
}
|
||||
_UCXXEXPORT void setstate(iostate state) {
|
||||
clear(rdstate() | state);
|
||||
#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__
|
||||
if(rdstate() & throw_mask){
|
||||
throw failure();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
_UCXXEXPORT bool good() const{
|
||||
return (rdstate() == 0);
|
||||
}
|
||||
_UCXXEXPORT bool eof() const{
|
||||
if(rdstate() & eofbit){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
_UCXXEXPORT bool fail() const{
|
||||
if( mstate & (failbit | badbit) ){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
_UCXXEXPORT bool bad() const{
|
||||
if(mstate & badbit){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
_UCXXEXPORT iostate exceptions() const{
|
||||
return throw_mask;
|
||||
}
|
||||
_UCXXEXPORT void exceptions(iostate except){
|
||||
throw_mask = except;
|
||||
}
|
||||
|
||||
explicit _UCXXEXPORT basic_ios(basic_streambuf<charT,traits>* sb)
|
||||
: fill_char(' '), mtied(0), mstreambuf(0), throw_mask(0) {
|
||||
init(sb);
|
||||
}
|
||||
|
||||
basic_ios() : mtied(0), mstreambuf(0){ }
|
||||
|
||||
virtual _UCXXEXPORT ~basic_ios(){
|
||||
}
|
||||
|
||||
_UCXXEXPORT basic_ostream<charT,traits>* tie() const{
|
||||
return mtied;
|
||||
}
|
||||
_UCXXEXPORT basic_ostream<charT,traits>* tie(basic_ostream<charT,traits>* tiestr){
|
||||
basic_ostream<charT,traits>* retval= mtied;
|
||||
mtied = tiestr;
|
||||
return retval;
|
||||
}
|
||||
_UCXXEXPORT basic_streambuf<charT,traits>* rdbuf() const{
|
||||
return mstreambuf;
|
||||
}
|
||||
_UCXXEXPORT basic_streambuf<charT,traits>* rdbuf(basic_streambuf<charT,traits>* sb){
|
||||
basic_streambuf<charT,traits>* retval = mstreambuf;
|
||||
mstreambuf = sb;
|
||||
return retval;
|
||||
}
|
||||
_UCXXEXPORT basic_ios& copyfmt(const basic_ios& rhs);
|
||||
_UCXXEXPORT char_type fill() const{
|
||||
return fill_char;
|
||||
}
|
||||
_UCXXEXPORT char_type fill(char_type ch){
|
||||
char_type temp = fill_char;
|
||||
fill_char = ch;
|
||||
return temp;
|
||||
}
|
||||
|
||||
_UCXXEXPORT locale imbue(const locale& loc){
|
||||
return ios_base::imbue(loc);
|
||||
}
|
||||
_UCXXEXPORT char narrow(char_type c, char dfault) const;
|
||||
_UCXXEXPORT char_type widen(char c) const;
|
||||
|
||||
protected:
|
||||
char_type fill_char;
|
||||
basic_ostream<charT,traits>* mtied;
|
||||
basic_streambuf<charT,traits>* mstreambuf;
|
||||
iostate throw_mask;
|
||||
_UCXXEXPORT basic_ios(const basic_ios<charT,traits> &){ }
|
||||
_UCXXEXPORT basic_ios<charT,traits> & operator=(const basic_ios<charT,traits> &){ return *this; }
|
||||
_UCXXEXPORT void init(basic_streambuf<charT,traits>* sb){
|
||||
ios_base::mformat = skipws|dec;
|
||||
mstreambuf = sb;
|
||||
mstate = goodbit;
|
||||
throw_mask = goodbit;
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef __UCLIBCXX_EXPAND_IOS_CHAR__
|
||||
#ifndef __UCLIBCXX_COMPILE_IOS__
|
||||
|
||||
template <> _UCXXEXPORT void basic_ios<char, char_traits<char> >::clear(iostate state);
|
||||
template <> _UCXXEXPORT void basic_ios<char, char_traits<char> >::setstate(iostate state);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
template <class charT, class traits>
|
||||
inline char basic_ios<charT, traits>::narrow(char_type c, char dfault) const
|
||||
{
|
||||
return dfault;
|
||||
}
|
||||
|
||||
template <>
|
||||
inline char basic_ios<char, char_traits<char> >::narrow(char_type c, char) const
|
||||
{
|
||||
return c;
|
||||
}
|
||||
|
||||
#ifdef __UCLIBCXX_HAS_WCHAR__
|
||||
|
||||
template <>
|
||||
inline char basic_ios<wchar_t, char_traits<wchar_t> >::narrow(char_type c, char dfault) const
|
||||
{
|
||||
char retval = wctob (c);
|
||||
if(retval == EOF){
|
||||
retval = dfault;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
#endif //__UCLIBCXX_HAS_WCHAR__
|
||||
|
||||
template <class charT, class traits>
|
||||
inline typename basic_ios<charT, traits>::char_type
|
||||
basic_ios<charT, traits>::widen(char c) const
|
||||
{
|
||||
return c;
|
||||
}
|
||||
|
||||
template <>
|
||||
inline basic_ios<char, char_traits<char> >::char_type
|
||||
basic_ios<char, char_traits<char> >::widen(char c) const
|
||||
{
|
||||
return c;
|
||||
}
|
||||
|
||||
#ifdef __UCLIBCXX_HAS_WCHAR__
|
||||
|
||||
template <>
|
||||
inline basic_ios<wchar_t, char_traits<wchar_t> >::char_type
|
||||
basic_ios<wchar_t, char_traits<wchar_t> >::widen(char c) const
|
||||
{
|
||||
return btowc(c);
|
||||
}
|
||||
|
||||
#endif //__UCLIBCXX_HAS_WCHAR__
|
||||
|
||||
|
||||
template <class stateT> class _UCXXEXPORT fpos{
|
||||
public:
|
||||
_UCXXEXPORT fpos(stateT s){
|
||||
st = s;
|
||||
}
|
||||
_UCXXEXPORT stateT state() const{
|
||||
return st;
|
||||
}
|
||||
_UCXXEXPORT void state(stateT s){
|
||||
st = s;
|
||||
}
|
||||
_UCXXEXPORT bool operator==(const fpos &rhs){
|
||||
return st == rhs.st;
|
||||
}
|
||||
_UCXXEXPORT bool operator!=(const fpos &rhs){
|
||||
return st != rhs.st;
|
||||
}
|
||||
_UCXXEXPORT fpos & operator+(const streamoff & o){
|
||||
st += o;
|
||||
return *this;
|
||||
}
|
||||
_UCXXEXPORT fpos & operator-(const streamoff & o){
|
||||
st -= o;
|
||||
return *this;
|
||||
}
|
||||
_UCXXEXPORT streamoff operator-(const fpos & rhs){
|
||||
return st - rhs.st;
|
||||
}
|
||||
|
||||
private:
|
||||
stateT st;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#pragma GCC visibility pop
|
||||
|
||||
#endif
|
||||
|
||||
188
libraries/ArduinoSTL/src/ios.cpp
Normal file
188
libraries/ArduinoSTL/src/ios.cpp
Normal file
@@ -0,0 +1,188 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#define __UCLIBCXX_COMPILE_IOS__ 1
|
||||
|
||||
#include "ios"
|
||||
#include "ostream"
|
||||
#include "istream"
|
||||
#include "cstdio"
|
||||
|
||||
namespace std{
|
||||
|
||||
|
||||
#ifdef __UCLIBCXX_SUPPORT_CDIR__
|
||||
_UCXXLOCAL int ios_base::Init::init_cnt = 0; //Needed to ensure the static value is created
|
||||
|
||||
//Create buffers first
|
||||
#ifdef __UCLIBCXX_SUPPORT_COUT__
|
||||
_UCXXEXPORT filebuf _cout_filebuf;
|
||||
#endif
|
||||
#ifdef __UCLIBCXX_SUPPORT_CIN__
|
||||
_UCXXEXPORT filebuf _cin_filebuf;
|
||||
#endif
|
||||
#ifdef __UCLIBCXX_SUPPORT_CERR__
|
||||
_UCXXEXPORT filebuf _cerr_filebuf;
|
||||
#endif
|
||||
#ifdef __UCLIBCXX_SUPPORT_CLOG__
|
||||
_UCXXEXPORT filebuf _clog_filebuf;
|
||||
#endif
|
||||
#ifdef __UCLIBCXX_SUPPORT_WCOUT__
|
||||
_UCXXEXPORT wfilebuf _wcout_filebuf;
|
||||
#endif
|
||||
#ifdef __UCLIBCXX_SUPPORT_WCIN__
|
||||
_UCXXEXPORT wfilebuf _wcin_filebuf;
|
||||
#endif
|
||||
#ifdef __UCLIBCXX_SUPPORT_WCERR__
|
||||
_UCXXEXPORT wfilebuf _wcerr_filebuf;
|
||||
#endif
|
||||
#ifdef __UCLIBCXX_SUPPORT_WCLOG__
|
||||
_UCXXEXPORT wfilebuf _wclog_filebuf;
|
||||
#endif
|
||||
|
||||
//Then create streams
|
||||
#ifdef __UCLIBCXX_SUPPORT_COUT__
|
||||
_UCXXEXPORT ostream cout(&_cout_filebuf);
|
||||
#endif
|
||||
#ifdef __UCLIBCXX_SUPPORT_CIN__
|
||||
_UCXXEXPORT istream cin(&_cin_filebuf);
|
||||
#endif
|
||||
#ifdef __UCLIBCXX_SUPPORT_CERR__
|
||||
_UCXXEXPORT ostream cerr(&_cerr_filebuf);
|
||||
#endif
|
||||
#ifdef __UCLIBCXX_SUPPORT_CLOG__
|
||||
_UCXXEXPORT ostream clog(&_clog_filebuf);
|
||||
#endif
|
||||
#ifdef __UCLIBCXX_SUPPORT_WCOUT__
|
||||
_UCXXEXPORT wostream wcout(&_wcout_filebuf);
|
||||
#endif
|
||||
#ifdef __UCLIBCXX_SUPPORT_WCIN__
|
||||
_UCXXEXPORT wistream wcin(&_wcin_filebuf);
|
||||
#endif
|
||||
#ifdef __UCLIBCXX_SUPPORT_WCERR__
|
||||
_UCXXEXPORT wostream wcerr(&_wcerr_filebuf);
|
||||
#endif
|
||||
#ifdef __UCLIBCXX_SUPPORT_WCLOG__
|
||||
_UCXXEXPORT wostream wclog(&_wclog_filebuf);
|
||||
#endif
|
||||
|
||||
|
||||
_UCXXEXPORT ios_base::Init::Init(){
|
||||
if(init_cnt == 0){ //Need to construct cout et al
|
||||
#ifdef __UCLIBCXX_SUPPORT_COUT__
|
||||
_cout_filebuf.fp = stdout;
|
||||
_cout_filebuf.openedFor = ios_base::out;
|
||||
#endif
|
||||
#ifdef __UCLIBCXX_SUPPORT_CERR__
|
||||
_cerr_filebuf.fp = stderr;
|
||||
_cerr_filebuf.openedFor = ios_base::out;
|
||||
cerr.mformat |= ios_base::unitbuf;
|
||||
#endif
|
||||
#ifdef __UCLIBCXX_SUPPORT_CLOG__
|
||||
_clog_filebuf.fp = stderr;
|
||||
_clog_filebuf.openedFor = ios_base::out;
|
||||
#endif
|
||||
#ifdef __UCLIBCXX_SUPPORT_CIN__
|
||||
_cin_filebuf.fp = stdin;
|
||||
_cin_filebuf.openedFor = ios_base::in;
|
||||
|
||||
#ifdef __UCLIBCXX_SUPPORT_COUT__
|
||||
cin.tie(&cout);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#ifdef __UCLIBCXX_SUPPORT_WCOUT__
|
||||
_wcout_filebuf.fp = stdout;
|
||||
_wcout_filebuf.openedFor = ios_base::out;
|
||||
#endif
|
||||
#ifdef __UCLIBCXX_SUPPORT_WCERR__
|
||||
_wcerr_filebuf.fp = stderr;
|
||||
_wcerr_filebuf.openedFor = ios_base::out;
|
||||
wcerr.mformat |= ios_base::unitbuf;
|
||||
#endif
|
||||
#ifdef __UCLIBCXX_SUPPORT_WCLOG__
|
||||
_wclog_filebuf.fp = stderr;
|
||||
_wclog_filebuf.openedFor = ios_base::out;
|
||||
#endif
|
||||
#ifdef __UCLIBCXX_SUPPORT_WCIN__
|
||||
_wcin_filebuf.fp = stdin;
|
||||
_wcin_filebuf.openedFor = ios_base::in;
|
||||
|
||||
#ifdef __UCLIBCXX_SUPPORT_WCOUT__
|
||||
wcin.tie(&wcout);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
init_cnt++;
|
||||
}
|
||||
|
||||
_UCXXEXPORT ios_base::Init::~Init(){
|
||||
--init_cnt;
|
||||
if(init_cnt==0){
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __UCLIBCXX_EXPAND_IOS_CHAR__
|
||||
|
||||
template _UCXXEXPORT void basic_ios<char, char_traits<char> >::clear(iostate state);
|
||||
template _UCXXEXPORT void basic_ios<char, char_traits<char> >::setstate(iostate state);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
_UCXXEXPORT ios_base::fmtflags ios_base::flags(fmtflags fmtfl){
|
||||
fmtflags temp = mformat;
|
||||
mformat = fmtfl;
|
||||
return temp;
|
||||
}
|
||||
|
||||
_UCXXEXPORT ios_base::fmtflags ios_base::setf(fmtflags fmtfl){
|
||||
return flags(flags() | fmtfl);
|
||||
}
|
||||
|
||||
_UCXXEXPORT ios_base::fmtflags ios_base::setf(fmtflags fmtfl, fmtflags mask ){
|
||||
return flags( (flags()& ~mask) | (fmtfl & mask));
|
||||
}
|
||||
|
||||
_UCXXEXPORT streamsize ios_base::precision(streamsize prec){
|
||||
streamsize temp = mprecision;
|
||||
mprecision = prec;
|
||||
return temp;
|
||||
}
|
||||
|
||||
_UCXXEXPORT streamsize ios_base::width(streamsize wide){
|
||||
streamsize temp = mwidth;
|
||||
mwidth = wide;
|
||||
return temp;
|
||||
}
|
||||
|
||||
_UCXXEXPORT locale ios_base::imbue(const locale& loc){
|
||||
locale retval = mLocale;
|
||||
mLocale = loc;
|
||||
return retval;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
114
libraries/ArduinoSTL/src/iosfwd
Normal file
114
libraries/ArduinoSTL/src/iosfwd
Normal file
@@ -0,0 +1,114 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "basic_definitions"
|
||||
#include "char_traits"
|
||||
#include "memory"
|
||||
|
||||
|
||||
#ifndef __HEADER_STD_IOSFWD
|
||||
#define __HEADER_STD_IOSFWD 1
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
|
||||
namespace std {
|
||||
class ios_base;
|
||||
template<> class char_traits<char>;
|
||||
|
||||
#ifdef __UCLIBCXX_HAS_WCHAR__
|
||||
template<> class char_traits<wchar_t>;
|
||||
#endif
|
||||
|
||||
template <class charT, class traits = char_traits<charT> > class basic_ios;
|
||||
|
||||
template <class charT, class traits = char_traits<charT> > class basic_streambuf;
|
||||
template <class charT, class traits = char_traits<charT> > class basic_istream;
|
||||
template <class charT, class traits = char_traits<charT> > class basic_ostream;
|
||||
template <class charT, class traits = char_traits<charT> > class basic_iostream;
|
||||
|
||||
template <class charT, class traits = char_traits<charT>,
|
||||
class Allocator = allocator<charT> > class basic_stringbuf;
|
||||
|
||||
template <class charT, class traits = char_traits<charT>,
|
||||
class Allocator = allocator<charT> > class basic_istringstream;
|
||||
|
||||
template <class charT, class traits = char_traits<charT>,
|
||||
class Allocator = allocator<charT> > class basic_ostringstream;
|
||||
|
||||
template <class charT, class traits = char_traits<charT>,
|
||||
class Allocator = allocator<charT> > class basic_stringstream;
|
||||
|
||||
template <class charT, class traits = char_traits<charT> > class basic_filebuf;
|
||||
|
||||
template <class charT, class traits = char_traits<charT> > class basic_ifstream;
|
||||
|
||||
template <class charT, class traits = char_traits<charT> > class basic_ofstream;
|
||||
|
||||
template <class charT, class traits = char_traits<charT> > class basic_fstream;
|
||||
|
||||
template <class charT, class traits = char_traits<charT> > class basic_istreambuf_iterator;
|
||||
|
||||
template <class charT, class traits = char_traits<charT> > class basic_ostreambuf_iterator;
|
||||
|
||||
typedef basic_ios<char> ios;
|
||||
#ifdef __UCLIBCXX_HAS_WCHAR__
|
||||
typedef basic_ios<wchar_t> wios;
|
||||
#endif
|
||||
|
||||
typedef basic_streambuf<char> streambuf;
|
||||
typedef basic_istream<char> istream;
|
||||
typedef basic_ostream<char> ostream;
|
||||
typedef basic_iostream<char> iostream;
|
||||
|
||||
typedef basic_stringbuf<char> stringbuf;
|
||||
typedef basic_istringstream<char> istringstream;
|
||||
typedef basic_ostringstream<char> ostringstream;
|
||||
typedef basic_stringstream<char> stringstream;
|
||||
|
||||
typedef basic_filebuf<char> filebuf;
|
||||
typedef basic_ifstream<char> ifstream;
|
||||
typedef basic_ofstream<char> ofstream;
|
||||
typedef basic_fstream<char> fstream;
|
||||
#ifdef __UCLIBCXX_HAS_WCHAR__
|
||||
typedef basic_streambuf<wchar_t> wstreambuf;
|
||||
typedef basic_istream<wchar_t> wistream;
|
||||
typedef basic_ostream<wchar_t> wostream;
|
||||
typedef basic_iostream<wchar_t> wiostream;
|
||||
|
||||
typedef basic_stringbuf<wchar_t> wstringbuf;
|
||||
typedef basic_istringstream<wchar_t> wistringstream;
|
||||
typedef basic_ostringstream<wchar_t> wostringstream;
|
||||
typedef basic_stringstream<wchar_t> wstringstream;
|
||||
|
||||
typedef basic_filebuf<wchar_t> wfilebuf;
|
||||
typedef basic_ifstream<wchar_t> wifstream;
|
||||
typedef basic_ofstream<wchar_t> wofstream;
|
||||
typedef basic_fstream<wchar_t> wfstream;
|
||||
#endif
|
||||
|
||||
template <class state> class fpos;
|
||||
typedef fpos<char_traits<char>::state_type> streampos;
|
||||
#ifdef __UCLIBCXX_HAS_WCHAR__
|
||||
typedef fpos<char_traits<wchar_t>::state_type> wstreampos;
|
||||
#endif
|
||||
}
|
||||
|
||||
#pragma GCC visibility pop
|
||||
|
||||
#endif
|
||||
100
libraries/ArduinoSTL/src/iostream
Normal file
100
libraries/ArduinoSTL/src/iostream
Normal file
@@ -0,0 +1,100 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "basic_definitions"
|
||||
|
||||
#ifndef __HEADER_STD_IOSTREAM
|
||||
#define __HEADER_STD_IOSTREAM 1
|
||||
|
||||
#include "iosfwd"
|
||||
#include "ios"
|
||||
#include "istream"
|
||||
#include "ostream"
|
||||
#include "string_iostream"
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
|
||||
namespace std{
|
||||
#ifdef __UCLIBCXX_SUPPORT_CIN__
|
||||
extern istream cin;
|
||||
#endif
|
||||
#ifdef __UCLIBCXX_SUPPORT_COUT__
|
||||
extern ostream cout;
|
||||
#endif
|
||||
#ifdef __UCLIBCXX_SUPPORT_CERR__
|
||||
extern ostream cerr;
|
||||
#endif
|
||||
#ifdef __UCLIBCXX_SUPPORT_CLOG__
|
||||
extern ostream clog;
|
||||
#endif
|
||||
#ifdef __UCLIBCXX_SUPPORT_WCIN__
|
||||
extern wistream wcin;
|
||||
#endif
|
||||
#ifdef __UCLIBCXX_SUPPORT_WCOUT__
|
||||
extern wostream wcout;
|
||||
#endif
|
||||
#ifdef __UCLIBCXX_SUPPORT_WCERR__
|
||||
extern wostream wcerr;
|
||||
#endif
|
||||
#ifdef __UCLIBCXX_SUPPORT_WCLOG__
|
||||
extern wostream wclog;
|
||||
#endif
|
||||
|
||||
|
||||
template <class charT, class traits> class _UCXXEXPORT basic_iostream :
|
||||
public basic_istream<charT,traits>, public basic_ostream<charT,traits>
|
||||
{
|
||||
public:
|
||||
// constructor/destructor
|
||||
explicit _UCXXEXPORT basic_iostream(basic_streambuf<charT,traits>* sb);
|
||||
virtual _UCXXEXPORT ~basic_iostream(); //Below
|
||||
};
|
||||
|
||||
template <class charT, class traits> _UCXXEXPORT
|
||||
basic_iostream<charT, traits>:: basic_iostream(basic_streambuf<charT,traits>* sb)
|
||||
: basic_ios<charT, traits>(sb), basic_istream<charT,traits>(sb), basic_ostream<charT,traits>(sb)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
template <class charT, class traits> _UCXXEXPORT basic_iostream<charT, traits>::~basic_iostream(){
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__
|
||||
#ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__
|
||||
#ifndef __UCLIBCXX_COMPILE_IOSTREAM__
|
||||
|
||||
template <> _UCXXEXPORT basic_iostream<char, char_traits<char> >::
|
||||
basic_iostream(basic_streambuf<char, char_traits<char> >* sb);
|
||||
template <> _UCXXEXPORT basic_iostream<char, char_traits<char> >::~basic_iostream();
|
||||
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#pragma GCC visibility pop
|
||||
|
||||
#endif
|
||||
38
libraries/ArduinoSTL/src/iostream.cpp
Normal file
38
libraries/ArduinoSTL/src/iostream.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#define __UCLIBCXX_COMPILE_IOSTREAM__ 1
|
||||
|
||||
#include "iostream"
|
||||
|
||||
namespace std{
|
||||
|
||||
#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__
|
||||
#ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__
|
||||
|
||||
template _UCXXEXPORT basic_iostream<char, char_traits<char> >::
|
||||
basic_iostream(basic_streambuf<char, char_traits<char> >* sb);
|
||||
template _UCXXEXPORT basic_iostream<char, char_traits<char> >::~basic_iostream();
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
631
libraries/ArduinoSTL/src/istream
Normal file
631
libraries/ArduinoSTL/src/istream
Normal file
@@ -0,0 +1,631 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc C++ Library. This library 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, or (at your option)
|
||||
any later version.
|
||||
|
||||
This library 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 library; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
USA.
|
||||
*/
|
||||
|
||||
#include "ios"
|
||||
#include "cctype"
|
||||
#include "streambuf"
|
||||
#include "istream_helpers"
|
||||
#include "ostream"
|
||||
|
||||
#ifndef __STD_HEADER_ISTREAM
|
||||
#define __STD_HEADER_ISTREAM 1
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
|
||||
namespace std{
|
||||
|
||||
typedef basic_istream<char> istream;
|
||||
|
||||
#ifdef __UCLIBCXX_HAS_WCHAR__
|
||||
typedef basic_istream<wchar_t> wistream;
|
||||
#endif
|
||||
|
||||
template <class charT, class traits> basic_istream<charT,traits>& ws(basic_istream<charT,traits>& is);
|
||||
|
||||
template <class charT, class traits> class _UCXXEXPORT basic_istream :
|
||||
virtual public basic_ios<charT,traits>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef charT char_type;
|
||||
typedef typename traits::int_type int_type;
|
||||
typedef typename traits::pos_type pos_type;
|
||||
typedef typename traits::off_type off_type;
|
||||
typedef basic_streambuf<charT,traits> streambuf_type;
|
||||
typedef traits traits_type;
|
||||
|
||||
explicit basic_istream(basic_streambuf<charT,traits>* sb)
|
||||
: basic_ios<charT, traits>(sb), count_last_ufmt_input(0)
|
||||
{
|
||||
basic_ios<charT, traits>::init(sb);
|
||||
}
|
||||
virtual ~basic_istream() { }
|
||||
|
||||
class sentry;
|
||||
|
||||
basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>& (*pf)(basic_istream<charT,traits>&));
|
||||
basic_istream<charT,traits>& operator>>(basic_ios<charT,traits>& (*pf)(basic_ios<charT,traits>&));
|
||||
basic_istream<charT,traits>& operator>>(ios_base& (*pf)(ios_base&));
|
||||
basic_istream<charT,traits>& operator>>(bool& n);
|
||||
basic_istream<charT,traits>& operator>>(short& n);
|
||||
basic_istream<charT,traits>& operator>>(unsigned short& n);
|
||||
basic_istream<charT,traits>& operator>>(int& n);
|
||||
basic_istream<charT,traits>& operator>>(unsigned int& n);
|
||||
basic_istream<charT,traits>& operator>>(long& n);
|
||||
basic_istream<charT,traits>& operator>>(unsigned long& n);
|
||||
basic_istream<charT,traits>& operator>>(void*& p);
|
||||
basic_istream<charT,traits>& operator>>(basic_streambuf<char_type,traits>* sb);
|
||||
|
||||
#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
|
||||
basic_istream<charT,traits>& operator>>(long long& n);
|
||||
basic_istream<charT,traits>& operator>>(unsigned long long& n);
|
||||
#endif
|
||||
|
||||
#ifdef __UCLIBCXX_HAS_FLOATS__
|
||||
basic_istream<charT,traits>& operator>>(float& f);
|
||||
basic_istream<charT,traits>& operator>>(double& f);
|
||||
basic_istream<charT,traits>& operator>>(long double& f);
|
||||
#endif
|
||||
|
||||
_UCXXEXPORT streamsize gcount() const{
|
||||
return count_last_ufmt_input;
|
||||
}
|
||||
|
||||
_UCXXEXPORT int_type get(); //below
|
||||
_UCXXEXPORT basic_istream<charT,traits>& get(char_type& c); //Below
|
||||
|
||||
_UCXXEXPORT basic_istream<charT,traits>& get(char_type* s, streamsize n){
|
||||
return get(s, n, basic_ios<charT,traits>::widen('\n'));
|
||||
}
|
||||
|
||||
_UCXXEXPORT basic_istream<charT,traits>& get(char_type* s, streamsize n, char_type delim){
|
||||
sentry(*this, true);
|
||||
streamsize i = 0;
|
||||
int_type c;
|
||||
for(i=0;i<n-1;++i){
|
||||
c = basic_ios<charT, traits>::mstreambuf->sgetc();
|
||||
basic_ios<charT, traits>::mstreambuf->sbumpc();
|
||||
if(c == traits::eof() ){
|
||||
if(i==0){
|
||||
basic_ios<charT,traits>::setstate(ios_base::failbit);
|
||||
}else{
|
||||
basic_ios<charT,traits>::setstate(ios_base::eofbit);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if(c == delim){
|
||||
if(i==0){
|
||||
basic_ios<charT,traits>::setstate(ios_base::failbit);
|
||||
}
|
||||
basic_ios<charT, traits>::mstreambuf->sputbackc(c);
|
||||
break;
|
||||
}
|
||||
s[i] = c;
|
||||
}
|
||||
s[i] = traits::eos();
|
||||
count_last_ufmt_input = i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
_UCXXEXPORT basic_istream<charT,traits>& get(basic_streambuf<char_type,traits>& sb){
|
||||
return get(sb, basic_ios<charT,traits>::widen('\n'));
|
||||
}
|
||||
|
||||
_UCXXEXPORT basic_istream<charT,traits>& get(basic_streambuf<char_type,traits>& sb, char_type delim){
|
||||
sentry(*this, true);
|
||||
streamsize i = 0;
|
||||
int_type c;
|
||||
while(1){ //We will exit internally based upon error conditions
|
||||
c = basic_ios<charT, traits>::mstreambuf->sgetc();
|
||||
if(c == traits::eof()){
|
||||
if(i==0){
|
||||
basic_ios<charT,traits>::setstate(ios_base::failbit);
|
||||
}else{
|
||||
basic_ios<charT,traits>::setstate(ios_base::eofbit);
|
||||
}
|
||||
count_last_ufmt_input = i;
|
||||
return *this;
|
||||
}
|
||||
if(c == delim){
|
||||
if(i==0){
|
||||
basic_ios<charT,traits>::setstate(ios_base::failbit);
|
||||
}
|
||||
count_last_ufmt_input = i;
|
||||
return *this;
|
||||
}
|
||||
if(sb.sputc(c) != c){ //Error doing output
|
||||
count_last_ufmt_input = i;
|
||||
return *this;
|
||||
}
|
||||
++i;
|
||||
basic_ios<charT, traits>::mstreambuf->sbumpc();
|
||||
}
|
||||
}
|
||||
|
||||
_UCXXEXPORT basic_istream<charT,traits>& getline(char_type* s, streamsize n){
|
||||
return getline(s, n, basic_ios<charT,traits>::widen('\n'));
|
||||
}
|
||||
|
||||
_UCXXEXPORT basic_istream<charT,traits>& getline(char_type* s, streamsize n, char_type delim){
|
||||
sentry(*this, true);
|
||||
streamsize i = 0;
|
||||
int_type c;
|
||||
for(i=0;i<n-1;++i){
|
||||
c = basic_ios<charT, traits>::mstreambuf->sgetc();
|
||||
if(c == traits::eof() ){
|
||||
if( basic_ios<charT,traits>::eof() ){
|
||||
basic_ios<charT,traits>::setstate(ios_base::failbit);
|
||||
}else{
|
||||
basic_ios<charT,traits>::setstate(ios_base::eofbit);
|
||||
}
|
||||
count_last_ufmt_input = i;
|
||||
s[i] = traits::eos();
|
||||
return *this;
|
||||
}
|
||||
if(basic_ios<charT, traits>::mstreambuf->sbumpc()==traits::eof() ){
|
||||
basic_ios<charT,traits>::setstate(ios_base::eofbit);
|
||||
}
|
||||
if(c == delim){
|
||||
count_last_ufmt_input = i+1;
|
||||
s[i] = traits::eos();
|
||||
return *this;
|
||||
}
|
||||
s[i] = c;
|
||||
}
|
||||
s[n-1] = traits::eos();
|
||||
return *this;
|
||||
}
|
||||
|
||||
_UCXXEXPORT basic_istream<charT,traits>& ignore (streamsize n = 1, int_type delim = traits::eof()){
|
||||
sentry(*this, true);
|
||||
streamsize i;
|
||||
int_type c;
|
||||
for(i=0;i<n;++i){
|
||||
c = basic_ios<charT, traits>::mstreambuf->sgetc();
|
||||
if(c == traits::eof()){
|
||||
basic_ios<charT,traits>::setstate(ios_base::eofbit);
|
||||
return *this;
|
||||
}
|
||||
basic_ios<charT, traits>::mstreambuf->sbumpc();
|
||||
if(c == delim){
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
_UCXXEXPORT int_type peek(){
|
||||
if(basic_ios<charT,traits>::good() == false){
|
||||
return traits::eof();
|
||||
}else{
|
||||
int_type c = basic_ios<charT, traits>::mstreambuf->sgetc();
|
||||
if(c == traits::eof()){
|
||||
basic_ios<charT,traits>::setstate(ios_base::eofbit);
|
||||
}
|
||||
return basic_ios<charT, traits>::mstreambuf->sgetc();
|
||||
}
|
||||
}
|
||||
|
||||
_UCXXEXPORT basic_istream<charT,traits>& read (char_type* s, streamsize n){
|
||||
sentry(*this, true);
|
||||
streamsize i;
|
||||
int_type c;
|
||||
for(i=0;i<n;++i){
|
||||
c = basic_ios<charT, traits>::mstreambuf->sgetc();
|
||||
|
||||
if(c == traits::eof()){
|
||||
basic_ios<charT,traits>::setstate(ios_base::failbit);
|
||||
basic_ios<charT,traits>::setstate(ios_base::eofbit);
|
||||
count_last_ufmt_input = i;
|
||||
return *this;
|
||||
}
|
||||
basic_ios<charT, traits>::mstreambuf->sbumpc();
|
||||
s[i] = c;
|
||||
}
|
||||
count_last_ufmt_input = n;
|
||||
return *this;
|
||||
}
|
||||
|
||||
_UCXXEXPORT streamsize readsome(char_type* s, streamsize n){
|
||||
sentry(*this, true);
|
||||
if(!basic_ios<charT,traits>::good()){
|
||||
count_last_ufmt_input = 0;
|
||||
basic_ios<charT,traits>::setstate(ios_base::failbit);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( basic_ios<charT, traits>::mstreambuf->in_avail() == -1){
|
||||
count_last_ufmt_input=0;
|
||||
basic_ios<charT,traits>::setstate(ios_base::eofbit);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(n > basic_ios<charT, traits>::mstreambuf->in_avail() ){
|
||||
n = basic_ios<charT, traits>::mstreambuf->in_avail();
|
||||
}
|
||||
|
||||
streamsize i;
|
||||
int_type c;
|
||||
|
||||
for(i=0;i<n;++i){
|
||||
c = basic_ios<charT, traits>::mstreambuf->sgetc();
|
||||
basic_ios<charT, traits>::mstreambuf->sbumpc();
|
||||
s[i] = c;
|
||||
}
|
||||
count_last_ufmt_input = n;
|
||||
return n;
|
||||
}
|
||||
|
||||
_UCXXEXPORT basic_istream<charT,traits>& putback(char_type c){
|
||||
sentry(*this, true);
|
||||
if(!basic_ios<charT,traits>::good()){
|
||||
basic_ios<charT,traits>::setstate(ios_base::failbit);
|
||||
return *this;
|
||||
}
|
||||
if(basic_ios<charT, traits>::mstreambuf == 0){
|
||||
basic_ios<charT,traits>::setstate(ios_base::badbit);
|
||||
return *this;
|
||||
}
|
||||
if(basic_ios<charT, traits>::mstreambuf->sputbackc(c) == traits::eof()){
|
||||
basic_ios<charT,traits>::setstate(ios_base::badbit);
|
||||
return *this;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
_UCXXEXPORT basic_istream<charT,traits>& unget(){
|
||||
sentry(*this, true);
|
||||
if(!basic_ios<charT,traits>::good()){
|
||||
basic_ios<charT,traits>::setstate(ios_base::failbit);
|
||||
return *this;
|
||||
}
|
||||
if(basic_ios<charT, traits>::mstreambuf == 0){
|
||||
basic_ios<charT,traits>::setstate(ios_base::failbit);
|
||||
return *this;
|
||||
}
|
||||
if(basic_ios<charT, traits>::mstreambuf->sungetc() == traits::eof()){
|
||||
basic_ios<charT,traits>::setstate(ios_base::failbit);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
_UCXXEXPORT int sync(){
|
||||
sentry(*this, true);
|
||||
if(basic_ios<charT, traits>::mstreambuf == 0){
|
||||
return -1;
|
||||
}
|
||||
if(basic_ios<charT, traits>::mstreambuf->pubsync() == -1){
|
||||
basic_ios<charT,traits>::setstate(ios_base::badbit);
|
||||
return traits::eof();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
_UCXXEXPORT pos_type tellg(){
|
||||
if(basic_ios<charT,traits>::fail() !=false){
|
||||
return pos_type(-1);
|
||||
}
|
||||
return basic_ios<charT, traits>::mstreambuf->pubseekoff(0, ios_base::cur, ios_base::in);
|
||||
}
|
||||
|
||||
_UCXXEXPORT basic_istream<charT,traits>& seekg(pos_type pos){
|
||||
if(basic_ios<charT,traits>::fail() !=true){
|
||||
basic_ios<charT, traits>::mstreambuf->pubseekpos(pos);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
_UCXXEXPORT basic_istream<charT,traits>& seekg(off_type off, ios_base::seekdir dir){
|
||||
if(basic_ios<charT,traits>::fail() !=true){
|
||||
basic_ios<charT, traits>::mstreambuf->pubseekoff(off, dir);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
protected:
|
||||
_UCXXEXPORT basic_istream(const basic_istream<charT,traits> &): basic_ios<charT, traits>() { }
|
||||
_UCXXEXPORT basic_istream<charT,traits> & operator=(const basic_istream<charT,traits> &){ return *this; }
|
||||
streamsize count_last_ufmt_input;
|
||||
|
||||
};
|
||||
|
||||
template <class charT,class traits>
|
||||
class _UCXXEXPORT basic_istream<charT,traits>::sentry
|
||||
{
|
||||
bool ok;
|
||||
public:
|
||||
explicit _UCXXEXPORT sentry(basic_istream<charT,traits>& os, bool noskipws = false)
|
||||
: ok(false){
|
||||
if(os.good() !=0){ //Prepare for output
|
||||
}
|
||||
|
||||
//Flush any tied buffer
|
||||
if(os.tie() != 0){
|
||||
os.tie()->flush();
|
||||
}
|
||||
if(!noskipws){
|
||||
__skipws(os);
|
||||
}
|
||||
|
||||
ok = true;
|
||||
}
|
||||
_UCXXEXPORT ~sentry() { }
|
||||
_UCXXEXPORT operator bool() {
|
||||
return ok;
|
||||
}
|
||||
};
|
||||
|
||||
//Template implementations of basic_istream functions which may be partially specialized
|
||||
//For code reduction
|
||||
|
||||
template <class charT, class traits>
|
||||
_UCXXEXPORT typename basic_istream<charT,traits>::int_type basic_istream<charT,traits>::get(){
|
||||
sentry(*this, true);
|
||||
int_type retval = basic_ios<charT, traits>::mstreambuf->sgetc();
|
||||
if(retval == traits::eof()){
|
||||
count_last_ufmt_input = 0;
|
||||
basic_ios<charT,traits>::setstate(ios_base::eofbit);
|
||||
}else{
|
||||
count_last_ufmt_input = 1;
|
||||
basic_ios<charT, traits>::mstreambuf->sbumpc();
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
template <class charT, class traits>
|
||||
_UCXXEXPORT basic_istream<charT,traits>& basic_istream<charT,traits>::get(char_type& c){
|
||||
sentry(*this, true);
|
||||
int_type retval = basic_ios<charT, traits>::mstreambuf->sgetc();
|
||||
if(retval == traits::eof()){
|
||||
count_last_ufmt_input = 0;
|
||||
basic_ios<charT,traits>::setstate(ios_base::eofbit);
|
||||
basic_ios<charT,traits>::setstate(ios_base::failbit);
|
||||
}else{
|
||||
count_last_ufmt_input = 1;
|
||||
c = traits::to_char_type(retval);
|
||||
basic_ios<charT, traits>::mstreambuf->sbumpc();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template <class charT, class traits> _UCXXEXPORT basic_istream<charT,traits>&
|
||||
basic_istream<charT,traits>::operator>>(bool& n)
|
||||
{
|
||||
sentry(*this);
|
||||
__istream_readin<traits, charT, bool>::readin(*this, n);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class charT, class traits> _UCXXEXPORT basic_istream<charT,traits>&
|
||||
basic_istream<charT,traits>::operator>>(short& n)
|
||||
{
|
||||
sentry(*this);
|
||||
__istream_readin<traits, charT, short>::readin(*this, n);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class charT, class traits> _UCXXEXPORT basic_istream<charT,traits>&
|
||||
basic_istream<charT,traits>::operator>>(unsigned short& n)
|
||||
{
|
||||
sentry(*this);
|
||||
__istream_readin<traits, charT, unsigned short>::readin(*this, n);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class charT, class traits> _UCXXEXPORT basic_istream<charT,traits>& basic_istream<charT,traits>::operator>>(int& n){
|
||||
sentry(*this);
|
||||
__istream_readin<traits, charT, int>::readin(*this, n);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class charT, class traits> _UCXXEXPORT basic_istream<charT,traits>& basic_istream<charT,traits>::operator>>(unsigned int& n){
|
||||
sentry(*this);
|
||||
__istream_readin<traits, charT, unsigned int>::readin(*this, n);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class charT, class traits> _UCXXEXPORT basic_istream<charT,traits>& basic_istream<charT,traits>::operator>>(long int& n){
|
||||
sentry(*this);
|
||||
__istream_readin<traits, charT, long int>::readin(*this, n);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class charT, class traits> _UCXXEXPORT basic_istream<charT,traits>&
|
||||
basic_istream<charT,traits>::operator>>(unsigned long int& n)
|
||||
{
|
||||
sentry(*this);
|
||||
__istream_readin<traits, charT, unsigned long int>::readin(*this, n);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
|
||||
template <class charT, class traits> _UCXXEXPORT basic_istream<charT,traits>&
|
||||
basic_istream<charT,traits>::operator>>(long long& n)
|
||||
{
|
||||
sentry(*this);
|
||||
__istream_readin<traits, charT, long long>::readin(*this, n);
|
||||
return *this;
|
||||
}
|
||||
template <class charT, class traits> _UCXXEXPORT basic_istream<charT,traits>&
|
||||
basic_istream<charT,traits>::operator>>(unsigned long long& n)
|
||||
{
|
||||
sentry(*this);
|
||||
__istream_readin<traits, charT, unsigned long long>::readin(*this, n);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
#ifdef __UCLIBCXX_HAS_FLOATS__
|
||||
template <class charT, class traits> _UCXXEXPORT basic_istream<charT,traits>&
|
||||
basic_istream<charT,traits>::operator>>(float& f)
|
||||
{
|
||||
sentry(*this);
|
||||
__istream_readin<traits, charT, float>::readin(*this, f);
|
||||
return *this;
|
||||
}
|
||||
template <class charT, class traits> _UCXXEXPORT basic_istream<charT,traits>&
|
||||
basic_istream<charT,traits>::operator>>(double& f)
|
||||
{
|
||||
sentry(*this);
|
||||
__istream_readin<traits, charT, double>::readin(*this, f);
|
||||
return *this;
|
||||
}
|
||||
template <class charT, class traits> _UCXXEXPORT basic_istream<charT,traits>&
|
||||
basic_istream<charT,traits>::operator>>(long double& f)
|
||||
{
|
||||
sentry(*this);
|
||||
__istream_readin<traits, charT, long double>::readin(*this, f);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
template <class charT, class traits> _UCXXEXPORT basic_istream<charT,traits>&
|
||||
basic_istream<charT,traits>::operator>>(void *& n)
|
||||
{
|
||||
sentry(*this);
|
||||
__istream_readin<traits, charT, void*>::readin(*this, n);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class charT, class traits> _UCXXEXPORT basic_istream<charT,traits>&
|
||||
operator>>(basic_istream<charT,traits>& is, charT& c)
|
||||
{
|
||||
typename basic_istream<charT,traits>::sentry s(is);
|
||||
is.get(c);
|
||||
return is;
|
||||
}
|
||||
|
||||
template<class traits> _UCXXEXPORT basic_istream<char,traits>&
|
||||
operator>>(basic_istream<char,traits>& is, unsigned char& c)
|
||||
{
|
||||
typename basic_istream<char,traits>::sentry s(is);
|
||||
char b;
|
||||
is.get(b);
|
||||
c = b;
|
||||
return is;
|
||||
}
|
||||
template<class traits> _UCXXEXPORT basic_istream<char,traits>&
|
||||
operator>>(basic_istream<char,traits>& is, signed char& c)
|
||||
{
|
||||
typename basic_istream<char,traits>::sentry s(is);
|
||||
is.get(c);
|
||||
return is;
|
||||
}
|
||||
|
||||
template<class charT, class traits> _UCXXEXPORT basic_istream<charT,traits>&
|
||||
operator>>(basic_istream<charT,traits>& is, charT* c)
|
||||
{
|
||||
typename basic_istream<charT,traits>::sentry s(is);
|
||||
int n = is.width();
|
||||
if(n == 0){
|
||||
n = __STRING_MAX_UNITS;
|
||||
}
|
||||
is.get(c, n);
|
||||
return is;
|
||||
|
||||
}
|
||||
template<class traits> _UCXXEXPORT basic_istream<char,traits>&
|
||||
operator>>(basic_istream<char,traits>& is, unsigned char* c)
|
||||
{
|
||||
typename basic_istream<char,traits>::sentry s(is);
|
||||
int n = is.width();
|
||||
if(n == 0){
|
||||
n = __STRING_MAX_UNITS;
|
||||
}
|
||||
is.get(c, n);
|
||||
return is;
|
||||
}
|
||||
template<class traits> _UCXXEXPORT basic_istream<char,traits>&
|
||||
operator>>(basic_istream<char,traits>& is, signed char* c)
|
||||
{
|
||||
typename basic_istream<char,traits>::sentry s(is);
|
||||
int n = is.width();
|
||||
if(n == 0){
|
||||
n = __STRING_MAX_UNITS;
|
||||
}
|
||||
is.get(c, n);
|
||||
return is;
|
||||
}
|
||||
|
||||
template <class charT, class traits> _UCXXEXPORT basic_istream<charT,traits>&
|
||||
basic_istream<charT,traits>::operator>>(basic_istream<charT,traits>& (*pf)(basic_istream<charT,traits>&))
|
||||
{
|
||||
sentry(*this);
|
||||
pf(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class charT, class traits> _UCXXEXPORT basic_istream<charT,traits>&
|
||||
basic_istream<charT,traits>::operator>>(basic_ios<charT,traits>& (*pf)(basic_ios<charT,traits>&))
|
||||
{
|
||||
sentry(*this);
|
||||
pf(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class charT, class traits> _UCXXEXPORT basic_istream<charT,traits>&
|
||||
basic_istream<charT,traits>::operator>>(ios_base& (*pf)(ios_base&))
|
||||
{
|
||||
sentry(*this);
|
||||
pf(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class charT, class traits> _UCXXEXPORT basic_istream<charT,traits>&
|
||||
ws(basic_istream<charT,traits>& is)
|
||||
{
|
||||
__skipws(is);
|
||||
return is;
|
||||
}
|
||||
|
||||
|
||||
#ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__
|
||||
#ifndef __UCLIBCXX_COMPILE_ISTREAM__
|
||||
|
||||
|
||||
template <> _UCXXEXPORT istream & basic_istream<char, char_traits<char> >::get(char & c);
|
||||
template <> _UCXXEXPORT istream::int_type basic_istream<char, char_traits<char> >::get();
|
||||
|
||||
template <> _UCXXEXPORT istream & istream::operator>>(bool &n);
|
||||
template <> _UCXXEXPORT istream & istream::operator>>(short &n);
|
||||
template <> _UCXXEXPORT istream & istream::operator>>(unsigned short &n);
|
||||
template <> _UCXXEXPORT istream & istream::operator>>(int &n);
|
||||
template <> _UCXXEXPORT istream & istream::operator>>(unsigned int &n);
|
||||
template <> _UCXXEXPORT istream & istream::operator>>(long unsigned &n);
|
||||
template <> _UCXXEXPORT istream & istream::operator>>(long int &n);
|
||||
template <> _UCXXEXPORT istream & istream::operator>>(void *& p);
|
||||
|
||||
#ifdef __UCLIBCXX_HAS_FLOATS__
|
||||
template <> _UCXXEXPORT istream & istream::operator>>(float &f);
|
||||
template <> _UCXXEXPORT istream & istream::operator>>(double &f);
|
||||
template <> _UCXXEXPORT istream & istream::operator>>(long double &f);
|
||||
#endif
|
||||
|
||||
template <> _UCXXEXPORT istream & operator>>(istream & is, char & c);
|
||||
|
||||
template <> _UCXXEXPORT void __skipws(basic_istream<char,char_traits<char> >& is);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#pragma GCC visibility pop
|
||||
|
||||
#endif
|
||||
|
||||
75
libraries/ArduinoSTL/src/istream.cpp
Normal file
75
libraries/ArduinoSTL/src/istream.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#define __UCLIBCXX_COMPILE_ISTREAM__ 1
|
||||
|
||||
#include "istream"
|
||||
|
||||
|
||||
namespace std{
|
||||
|
||||
#ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__
|
||||
|
||||
template <> _UCXXEXPORT string _readToken<char, char_traits<char> >(istream & stream)
|
||||
{
|
||||
string temp;
|
||||
char_traits<char>::int_type c;
|
||||
while(true){
|
||||
c = stream.rdbuf()->sgetc();
|
||||
if(c != char_traits<char>::eof() && isspace(c) == false){
|
||||
stream.rdbuf()->sbumpc();
|
||||
temp.append(1, char_traits<char>::to_char_type(c));
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (temp.size() == 0)
|
||||
stream.setstate(ios_base::eofbit|ios_base::failbit);
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
template _UCXXEXPORT istream::int_type istream::get();
|
||||
template _UCXXEXPORT istream & istream::get(char &c);
|
||||
|
||||
template _UCXXEXPORT istream & istream::operator>>(bool &n);
|
||||
template _UCXXEXPORT istream & istream::operator>>(short &n);
|
||||
template _UCXXEXPORT istream & istream::operator>>(unsigned short &n);
|
||||
template _UCXXEXPORT istream & istream::operator>>(int &n);
|
||||
template _UCXXEXPORT istream & istream::operator>>(unsigned int &n);
|
||||
template _UCXXEXPORT istream & istream::operator>>(long unsigned &n);
|
||||
template _UCXXEXPORT istream & istream::operator>>(long int &n);
|
||||
template _UCXXEXPORT istream & istream::operator>>(void *& p);
|
||||
template _UCXXEXPORT istream & operator>>(istream & is, char & c);
|
||||
|
||||
|
||||
#ifdef __UCLIBCXX_HAS_FLOATS__
|
||||
template _UCXXEXPORT istream & istream::operator>>(float &f);
|
||||
template _UCXXEXPORT istream & istream::operator>>(double &f);
|
||||
template _UCXXEXPORT istream & istream::operator>>(long double &f);
|
||||
#endif
|
||||
|
||||
template _UCXXEXPORT void __skipws(basic_istream<char, char_traits<char> >& is);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
465
libraries/ArduinoSTL/src/istream_helpers
Normal file
465
libraries/ArduinoSTL/src/istream_helpers
Normal file
@@ -0,0 +1,465 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "ios"
|
||||
#include "cctype"
|
||||
|
||||
#include "string"
|
||||
|
||||
#ifndef __STD_HEADER_ISTREAM_HELPERS
|
||||
#define __STD_HEADER_ISTREAM_HELPERS 1
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
|
||||
namespace std{
|
||||
|
||||
|
||||
/* We are making the following template class for serveral reasons. Firstly,
|
||||
* we want to keep the main istream code neat and tidy. Secondly, we want it
|
||||
* to be easy to do partial specialization of the istream code so that it can
|
||||
* be expanded and put into the library. This will allow us to make application
|
||||
* code smaller at the expense of increased library size. This is a fair
|
||||
* trade-off when there are multiple applications being compiled. Also, this
|
||||
* feature will be used optionally via configuration options. It will also
|
||||
* allow us to keep the code bases in sync, dramatically simplifying the
|
||||
* maintenance required. We specialized for char because wchar and others
|
||||
* require different scanf functions
|
||||
*/
|
||||
|
||||
template <class C, class traits> _UCXXEXPORT
|
||||
basic_string<C, traits> _readToken(basic_istream<C, traits>& stream)
|
||||
{
|
||||
basic_string<C, traits> temp;
|
||||
typename traits::int_type c;
|
||||
while(true){
|
||||
c = stream.rdbuf()->sgetc();
|
||||
if(c != traits::eof() && isspace(c) == false){
|
||||
stream.rdbuf()->sbumpc();
|
||||
temp.append(1, traits::to_char_type(c));
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (temp.size() == 0)
|
||||
stream.setstate(ios_base::eofbit|ios_base::failbit);
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
template <class C, class traits> _UCXXEXPORT
|
||||
basic_string<C, traits> _readTokenDecimal(basic_istream<C, traits>& stream)
|
||||
{
|
||||
basic_string<C, traits> temp;
|
||||
typename traits::int_type c;
|
||||
while(true){
|
||||
c = stream.rdbuf()->sgetc();
|
||||
if(c != traits::eof() && isspace(c) == false && (
|
||||
isdigit(c) ||
|
||||
c == '.' ||
|
||||
c == ',' ||
|
||||
((c == '-' || c == '+') && temp.size() == 0) )
|
||||
){
|
||||
stream.rdbuf()->sbumpc();
|
||||
temp.append(1, traits::to_char_type(c));
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (temp.size() == 0)
|
||||
stream.setstate(ios_base::eofbit|ios_base::failbit);
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
#ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__
|
||||
|
||||
template <> _UCXXEXPORT string _readToken<char, char_traits<char> >(istream & stream);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
template <class traits, class charT, class dataType> class _UCXXEXPORT __istream_readin{
|
||||
public:
|
||||
static void readin(basic_istream<charT,traits>& stream, dataType & var);
|
||||
};
|
||||
|
||||
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, bool>{
|
||||
public:
|
||||
inline static void readin(basic_istream<char, traits >& stream, bool & var)
|
||||
{
|
||||
/* 22.4.2.1.2.4 */
|
||||
basic_string<char, traits > temp;
|
||||
temp = _readToken( stream);
|
||||
if (stream.flags() & ios_base::boolalpha) {
|
||||
if (temp == "true") // truename()
|
||||
var = true;
|
||||
else {
|
||||
var = false;
|
||||
if (temp != "false") // falsename()
|
||||
stream.setstate(ios_base::failbit);
|
||||
}
|
||||
} else {
|
||||
long int i = 0;
|
||||
int ret;
|
||||
if (stream.flags() & ios_base::dec) {
|
||||
ret = sscanf(temp.c_str(), "%ld", &i );
|
||||
} else {
|
||||
if (stream.flags() & ios_base::oct) {
|
||||
ret = sscanf(temp.c_str(), "%lo", (unsigned long int *)(&i));
|
||||
} else if (stream.flags() & ios_base::hex) {
|
||||
if (stream.flags() & ios_base::uppercase) {
|
||||
ret = sscanf(temp.c_str(), "%lX", (unsigned long int *)(&i));
|
||||
} else {
|
||||
ret = sscanf(temp.c_str(), "%lx", (unsigned long int *)(&i));
|
||||
}
|
||||
} else {
|
||||
ret = sscanf(temp.c_str(), "%li", &i);
|
||||
}
|
||||
}
|
||||
if (ret != 1 || i >> 1)
|
||||
stream.setstate(ios_base::failbit);
|
||||
var = ret == 1 && bool(i);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, short>{
|
||||
public:
|
||||
inline static void readin(basic_istream<char, traits >& stream, short & var)
|
||||
{
|
||||
basic_string<char, traits > temp;
|
||||
|
||||
if(stream.flags() & ios_base::dec){
|
||||
temp = _readTokenDecimal( stream);
|
||||
sscanf(temp.c_str(), "%hd", &var );
|
||||
}else{
|
||||
temp = _readToken( stream);
|
||||
if( stream.flags() & ios_base::oct){
|
||||
sscanf(temp.c_str(), "%ho", (unsigned short int *)(&var) );
|
||||
}else if(stream.flags() & ios_base::hex){
|
||||
if(stream.flags() & ios_base::uppercase){
|
||||
sscanf(temp.c_str(), "%hX", (unsigned short int *)(&var) );
|
||||
}else{
|
||||
sscanf(temp.c_str(), "%hx", (unsigned short int *)(&var) );
|
||||
}
|
||||
}else{
|
||||
sscanf(temp.c_str(), "%hi", &var);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, unsigned short>{
|
||||
public:
|
||||
inline static void readin(basic_istream<char, traits >& stream, unsigned short & var)
|
||||
{
|
||||
basic_string<char, traits > temp;
|
||||
|
||||
if(stream.flags() & ios_base::dec){
|
||||
temp = _readTokenDecimal( stream);
|
||||
sscanf(temp.c_str(), "%hu", &var );
|
||||
}else{
|
||||
temp = _readToken( stream);
|
||||
if( stream.flags() & ios_base::oct){
|
||||
sscanf(temp.c_str(), "%ho", &var);
|
||||
}else if(stream.flags() & ios_base::hex){
|
||||
if(stream.flags() & ios_base::uppercase){
|
||||
sscanf(temp.c_str(), "%hX", &var );
|
||||
}else{
|
||||
sscanf(temp.c_str(), "%hx", &var);
|
||||
}
|
||||
}else{
|
||||
sscanf(temp.c_str(), "%hi", (signed short int*)(&var) );
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, int>{
|
||||
public:
|
||||
inline static void readin(basic_istream<char, traits >& stream, int & var)
|
||||
{
|
||||
basic_string<char, traits > temp;
|
||||
|
||||
if(stream.flags() & ios_base::dec){
|
||||
temp = _readTokenDecimal( stream);
|
||||
sscanf(temp.c_str(), "%d", &var );
|
||||
}else{
|
||||
temp = _readToken( stream);
|
||||
if( stream.flags() & ios_base::oct){
|
||||
sscanf(temp.c_str(), "%o", (unsigned int *)(&var) );
|
||||
}else if(stream.flags() & ios_base::hex){
|
||||
if(stream.flags() & ios_base::uppercase){
|
||||
sscanf(temp.c_str(), "%X", (unsigned int *)(&var) );
|
||||
}else{
|
||||
sscanf(temp.c_str(), "%x", (unsigned int *)(&var) );
|
||||
}
|
||||
}else{
|
||||
sscanf(temp.c_str(), "%i", &var);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, unsigned int>{
|
||||
public:
|
||||
inline static void readin(basic_istream<char, traits >& stream, unsigned int & var)
|
||||
{
|
||||
basic_string<char, traits > temp;
|
||||
|
||||
if(stream.flags() & ios_base::dec){
|
||||
temp = _readTokenDecimal( stream);
|
||||
sscanf(temp.c_str(), "%u", &var );
|
||||
}else{
|
||||
temp = _readToken( stream);
|
||||
if( stream.flags() & ios_base::oct){
|
||||
sscanf(temp.c_str(), "%o", (unsigned int *)(&var) );
|
||||
}else if(stream.flags() & ios_base::hex){
|
||||
if(stream.flags() & ios_base::uppercase){
|
||||
sscanf(temp.c_str(), "%X", (unsigned int *)(&var) );
|
||||
}else{
|
||||
sscanf(temp.c_str(), "%x", (unsigned int *)(&var) );
|
||||
}
|
||||
}else{
|
||||
sscanf(temp.c_str(), "%i", (int *)(&var) );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, long int>{
|
||||
public:
|
||||
inline static void readin(basic_istream<char, traits >& stream, long int & var)
|
||||
{
|
||||
basic_string<char, traits > temp;
|
||||
|
||||
if(stream.flags() & ios_base::dec){
|
||||
temp = _readTokenDecimal( stream);
|
||||
sscanf(temp.c_str(), "%ld", &var );
|
||||
}else{
|
||||
temp = _readToken( stream);
|
||||
if( stream.flags() & ios_base::oct){
|
||||
sscanf(temp.c_str(), "%lo", (unsigned long int *)(&var) );
|
||||
}else if(stream.flags() & ios_base::hex){
|
||||
if(stream.flags() & ios_base::uppercase){
|
||||
sscanf(temp.c_str(), "%lX", (unsigned long int *)(&var) );
|
||||
}else{
|
||||
sscanf(temp.c_str(), "%lx", (unsigned long int *)(&var) );
|
||||
}
|
||||
}else{
|
||||
sscanf(temp.c_str(), "%li", (long int *)(&var) );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, unsigned long int>{
|
||||
public:
|
||||
inline static void readin(basic_istream<char, traits >& stream, unsigned long int & var)
|
||||
{
|
||||
basic_string<char, traits > temp;
|
||||
|
||||
if(stream.flags() & ios_base::dec){
|
||||
temp = _readTokenDecimal( stream);
|
||||
sscanf(temp.c_str(), "%lu", &var );
|
||||
}else{
|
||||
temp = _readToken( stream);
|
||||
if( stream.flags() & ios_base::oct){
|
||||
sscanf(temp.c_str(), "%lo", &var );
|
||||
}else if(stream.flags() & ios_base::hex){
|
||||
if(stream.flags() & ios_base::uppercase){
|
||||
sscanf(temp.c_str(), "%lX", &var );
|
||||
}else{
|
||||
sscanf(temp.c_str(), "%lx", &var);
|
||||
}
|
||||
}else{
|
||||
sscanf(temp.c_str(), "%li", (long int *)(&var) );
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
|
||||
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, long long>{
|
||||
public:
|
||||
inline static void readin(basic_istream<char, traits >& stream, long long & var)
|
||||
{
|
||||
basic_string<char, traits > temp;
|
||||
|
||||
if(stream.flags() & ios_base::dec){
|
||||
temp = _readTokenDecimal( stream);
|
||||
sscanf(temp.c_str(), "%lld", &var );
|
||||
}else{
|
||||
temp = _readToken( stream);
|
||||
if( stream.flags() & ios_base::oct){
|
||||
sscanf(temp.c_str(), "%llo", (unsigned long long *)&var );
|
||||
}else if(stream.flags() & ios_base::hex){
|
||||
if(stream.flags() & ios_base::uppercase){
|
||||
scanf(temp.c_str(), "%llX", (unsigned long long *)&var );
|
||||
}else{
|
||||
sscanf(temp.c_str(), "%llx", (unsigned long long *)&var);
|
||||
}
|
||||
}else{
|
||||
sscanf(temp.c_str(), "%lli", (&var) );
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, unsigned long long>{
|
||||
public:
|
||||
inline static void readin(basic_istream<char, traits >& stream, unsigned long long & var)
|
||||
{
|
||||
basic_string<char, traits > temp;
|
||||
|
||||
if(stream.flags() & ios_base::dec){
|
||||
temp = _readTokenDecimal( stream);
|
||||
sscanf(temp.c_str(), "%llu", &var );
|
||||
}else{
|
||||
temp = _readToken( stream);
|
||||
if( stream.flags() & ios_base::oct){
|
||||
sscanf(temp.c_str(), "%llo", &var );
|
||||
}else if(stream.flags() & ios_base::hex){
|
||||
if(stream.flags() & ios_base::uppercase){
|
||||
scanf(temp.c_str(), "%llX", &var );
|
||||
}else{
|
||||
sscanf(temp.c_str(), "%llx", &var);
|
||||
}
|
||||
}else{
|
||||
sscanf(temp.c_str(), "%lli", (long long *)(&var) );
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef __UCLIBCXX_HAS_FLOATS__
|
||||
|
||||
// NB: The Arduino AVR compiler contains an implementation of printf() and scanf()
|
||||
// that lacks support for floating point numbers. Also, the AVR C library doesn't
|
||||
// support the double datatype. In AVR it's the same as float.
|
||||
|
||||
|
||||
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, float>{
|
||||
public:
|
||||
inline static void readin(basic_istream<char, traits >& stream, float & var)
|
||||
{
|
||||
basic_string<char, traits > temp;
|
||||
temp = _readTokenDecimal(stream);
|
||||
bool isneg=false;
|
||||
if (temp[0] == '-') {
|
||||
isneg=true;
|
||||
temp.erase(0,1);
|
||||
}else if (temp[0] == '+') {
|
||||
isneg=false;
|
||||
temp.erase(0,1);
|
||||
}
|
||||
unsigned int dec = temp.find('.', 0);
|
||||
if (dec == string::npos) {
|
||||
var = atol(temp.c_str());
|
||||
}else{
|
||||
var = atol(temp.substr(0,dec).c_str());
|
||||
var += ((double) atoi(temp.substr(dec+1).c_str())) / pow(10.0,temp.size()-dec-1);
|
||||
}
|
||||
if (isneg)
|
||||
var = -var;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, double>{
|
||||
public:
|
||||
inline static void readin(basic_istream<char, traits >& stream, double & var)
|
||||
{
|
||||
basic_string<char, traits > temp;
|
||||
temp = _readTokenDecimal(stream);
|
||||
bool isneg=false;
|
||||
if (temp[0] == '-') {
|
||||
isneg=true;
|
||||
temp.erase(0,1);
|
||||
}else if (temp[0] == '+') {
|
||||
isneg=false;
|
||||
temp.erase(0,1);
|
||||
}
|
||||
unsigned int dec = temp.find('.', 0);
|
||||
if (dec == string::npos) {
|
||||
var = atol(temp.c_str());
|
||||
}else{
|
||||
var = atol(temp.substr(0,dec).c_str());
|
||||
var += ((double) atoi(temp.substr(dec+1).c_str())) / pow(10.0,temp.size()-dec-1);
|
||||
}
|
||||
if (isneg)
|
||||
var = -var;
|
||||
}
|
||||
};
|
||||
|
||||
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, long double>{
|
||||
public:
|
||||
inline static void readin(basic_istream<char, traits >& stream, long double & var)
|
||||
{
|
||||
basic_string<char, traits > temp;
|
||||
temp = _readTokenDecimal( stream);
|
||||
sscanf(temp.c_str(), "%Lg", &var);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // ifdef __UCLIBCXX_HAS_FLOATS__
|
||||
|
||||
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, void*>{
|
||||
public:
|
||||
inline static void readin(basic_istream<char, traits >& stream, void* & var)
|
||||
{
|
||||
basic_string<char, traits > temp;
|
||||
temp = _readToken( stream);
|
||||
sscanf(temp.c_str(), "%p", &var);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<class charT, class traits> void __skipws(basic_istream<charT,traits>& is){
|
||||
const typename basic_istream<charT,traits>::int_type eof = traits::eof();
|
||||
typename basic_istream<charT,traits>::int_type c;
|
||||
//While the next character normally read doesn't equal eof
|
||||
//and that character is a space, advance to the next read position
|
||||
//Thus itterating through all whitespace until we get to the meaty stuff
|
||||
while (
|
||||
!traits::eq_int_type((c = is.rdbuf()->sgetc()), eof)
|
||||
&& isspace(c)
|
||||
) {
|
||||
is.rdbuf()->sbumpc();
|
||||
}
|
||||
if(traits::eq_int_type(c, eof)){
|
||||
is.setstate(ios_base::eofbit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma GCC visibility pop
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
235
libraries/ArduinoSTL/src/iterator
Normal file
235
libraries/ArduinoSTL/src/iterator
Normal file
@@ -0,0 +1,235 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "basic_definitions"
|
||||
#include "iosfwd"
|
||||
#include "cstddef"
|
||||
#include "char_traits"
|
||||
#include "iterator_base"
|
||||
|
||||
|
||||
|
||||
#ifndef __STD_HEADER_ITERATOR
|
||||
#define __STD_HEADER_ITERATOR 1
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
|
||||
namespace std{
|
||||
|
||||
// subclause _lib.stream.iterators_, stream iterators:
|
||||
template <class T, class charT = char, class traits = char_traits<charT>, class Distance = ptrdiff_t> class istream_iterator;
|
||||
template <class T, class charT, class traits, class Distance> bool
|
||||
operator==(const istream_iterator<T,charT,traits,Distance>& x, const istream_iterator<T,charT,traits,Distance>& y);
|
||||
template <class T, class charT, class traits, class Distance> bool
|
||||
operator!=(const istream_iterator<T,charT,traits,Distance>& x, const istream_iterator<T,charT,traits,Distance>& y);
|
||||
template <class T, class charT = char, class traits = char_traits<charT> > class ostream_iterator;
|
||||
template<class charT, class traits = char_traits<charT> > class istreambuf_iterator;
|
||||
template <class charT, class traits> bool
|
||||
operator==(const istreambuf_iterator<charT,traits>& a, const istreambuf_iterator<charT,traits>& b);
|
||||
template <class charT, class traits> bool
|
||||
operator!=(const istreambuf_iterator<charT,traits>& a, const istreambuf_iterator<charT,traits>& b);
|
||||
template <class charT, class traits = char_traits<charT> > class ostreambuf_iterator;
|
||||
|
||||
|
||||
template < class T, class charT, class traits, class Distance > class _UCXXEXPORT istream_iterator
|
||||
: public iterator<input_iterator_tag,T,Distance,const T*, const T&>
|
||||
{
|
||||
public:
|
||||
typedef charT char_type;
|
||||
typedef traits traits_type;
|
||||
typedef basic_istream<charT,traits> istream_type;
|
||||
istream_iterator() : in_stream(0), value(0) {}
|
||||
istream_iterator(istream_type& s) : in_stream(&s), value() {
|
||||
*in_stream >> value;
|
||||
}
|
||||
istream_iterator(const istream_iterator<T,charT,traits,Distance>& x)
|
||||
: in_stream(x.in_stream), value(x.value)
|
||||
{ }
|
||||
~istream_iterator() { }
|
||||
const T& operator*() const{
|
||||
return value;
|
||||
}
|
||||
const T* operator->() const{
|
||||
return &value;
|
||||
}
|
||||
istream_iterator<T,charT,traits,Distance>& operator++() {
|
||||
*in_stream >> value;
|
||||
return *this;
|
||||
}
|
||||
istream_iterator<T,charT,traits,Distance> operator++(int){
|
||||
istream_iterator<T,charT,traits,Distance> tmp = *this;
|
||||
*in_stream >> value;
|
||||
return (tmp);
|
||||
}
|
||||
bool m_equal(const istream_iterator<T,charT,traits,Distance>& x) const{
|
||||
return (in_stream == x.in_stream);
|
||||
}
|
||||
private:
|
||||
basic_istream<charT,traits>* in_stream;
|
||||
T value;
|
||||
};
|
||||
|
||||
template <class T, class charT, class traits, class Distance> _UCXXEXPORT
|
||||
bool operator==(const istream_iterator<T,charT,traits,Distance>& x,
|
||||
const istream_iterator<T,charT,traits,Distance>& y)
|
||||
{
|
||||
return x.m_equal(y);
|
||||
}
|
||||
|
||||
template <class T, class charT, class traits, class Distance> _UCXXEXPORT
|
||||
bool operator!=(const istream_iterator<T,charT,traits,Distance>& x,
|
||||
const istream_iterator<T,charT,traits,Distance>& y)
|
||||
{
|
||||
return !(x == y);
|
||||
}
|
||||
|
||||
template <class T, class charT, class traits> class _UCXXEXPORT ostream_iterator
|
||||
: public iterator<output_iterator_tag,void,void,void,void>
|
||||
{
|
||||
public:
|
||||
typedef charT char_type;
|
||||
typedef traits traits_type;
|
||||
typedef basic_ostream<charT,traits> ostream_type;
|
||||
|
||||
ostream_iterator(ostream_type& s) : out_stream(&s), delim(0) { }
|
||||
ostream_iterator(ostream_type& s, const charT* delimiter) : out_stream(&s), delim(delimiter) { }
|
||||
ostream_iterator(const ostream_iterator<T,charT,traits>& x) : out_stream(x.out_stream), delim(x.delim) { }
|
||||
~ostream_iterator() { }
|
||||
ostream_iterator<T,charT,traits>& operator=(const T& value){
|
||||
*out_stream << value;
|
||||
if(delim != 0){
|
||||
*out_stream << delim;
|
||||
}
|
||||
return (*this);
|
||||
}
|
||||
ostream_iterator<T,charT,traits>& operator*(){ return *this; }
|
||||
ostream_iterator<T,charT,traits>& operator++() { return *this; }
|
||||
ostream_iterator<T,charT,traits> operator++(int) { return *this; }
|
||||
private:
|
||||
basic_ostream<charT,traits>* out_stream;
|
||||
const char* delim;
|
||||
};
|
||||
|
||||
template<class charT, class traits > class _UCXXEXPORT istreambuf_iterator :
|
||||
public iterator<input_iterator_tag, charT, typename traits::off_type, charT*, charT&>
|
||||
{
|
||||
public:
|
||||
typedef charT char_type;
|
||||
typedef traits traits_type;
|
||||
typedef typename traits::int_type int_type;
|
||||
typedef basic_streambuf<charT,traits> streambuf_type;
|
||||
typedef basic_istream<charT,traits> istream_type;
|
||||
|
||||
class _UCXXEXPORT proxy{
|
||||
charT val;
|
||||
basic_streambuf<charT, traits> * buf;
|
||||
|
||||
proxy(charT v, basic_streambuf<charT, traits> * b) : val(v), buf(b) { }
|
||||
public:
|
||||
charT operator*() { return val; }
|
||||
};
|
||||
|
||||
istreambuf_iterator() _UCXX_USE_NOEXCEPT : sbuf(0) { }
|
||||
istreambuf_iterator(istream_type& s) _UCXX_USE_NOEXCEPT : sbuf(s.rdbuf()) { }
|
||||
istreambuf_iterator(streambuf_type* s) _UCXX_USE_NOEXCEPT : sbuf(s) { }
|
||||
istreambuf_iterator(const proxy& p) _UCXX_USE_NOEXCEPT : sbuf(&p.buf) { }
|
||||
|
||||
charT operator*() const{
|
||||
return sbuf->sgetc();
|
||||
}
|
||||
istreambuf_iterator<charT,traits>& operator++(){
|
||||
sbuf->sbumpc();
|
||||
return *this;
|
||||
}
|
||||
istreambuf_iterator<charT,traits> operator++(int){
|
||||
istreambuf_iterator<charT,traits> tmp = *this;
|
||||
sbuf->sbumpc();
|
||||
return(tmp);
|
||||
}
|
||||
|
||||
bool equal(const istreambuf_iterator& b) const{
|
||||
return sbuf == b.sbuf || (is_eof() && b.is_eof());
|
||||
}
|
||||
private:
|
||||
streambuf_type* sbuf;
|
||||
inline bool is_eof() const{
|
||||
return sbuf == 0 || sbuf->sgetc() == traits_type::eof();
|
||||
}
|
||||
};
|
||||
|
||||
template <class charT, class traits> _UCXXEXPORT bool
|
||||
operator==(const istreambuf_iterator<charT,traits>& a,
|
||||
const istreambuf_iterator<charT,traits>& b)
|
||||
{
|
||||
return a.equal(b);
|
||||
}
|
||||
|
||||
template <class charT, class traits> bool _UCXXEXPORT
|
||||
operator!=(const istreambuf_iterator<charT,traits>& a,
|
||||
const istreambuf_iterator<charT,traits>& b)
|
||||
{
|
||||
return !a.equal(b);
|
||||
}
|
||||
|
||||
template <class charT, class traits> class _UCXXEXPORT ostreambuf_iterator
|
||||
: iterator<output_iterator_tag,void,void,void,void>
|
||||
{
|
||||
public:
|
||||
typedef charT char_type;
|
||||
typedef traits traits_type;
|
||||
typedef basic_streambuf<charT,traits> streambuf_type;
|
||||
typedef basic_ostream<charT,traits> ostream_type;
|
||||
public:
|
||||
ostreambuf_iterator(ostream_type& s) _UCXX_USE_NOEXCEPT : sbuf(s.rdbuf()), f(false) { }
|
||||
ostreambuf_iterator(streambuf_type* s) _UCXX_USE_NOEXCEPT : sbuf(s), f(false) { }
|
||||
ostreambuf_iterator& operator=(charT c){
|
||||
if(failed() == false){
|
||||
if(sbuf->sputc(c) == traits::eof()){
|
||||
f = true;
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
ostreambuf_iterator& operator*(){
|
||||
return *this;
|
||||
}
|
||||
ostreambuf_iterator& operator++() { return *this; }
|
||||
ostreambuf_iterator operator++(int) { return *this; }
|
||||
bool failed() const _UCXX_USE_NOEXCEPT{
|
||||
return f;
|
||||
}
|
||||
|
||||
private:
|
||||
streambuf_type* sbuf;
|
||||
bool f;
|
||||
};
|
||||
|
||||
template< class C >
|
||||
auto begin( C& c ) -> decltype(c.begin()) { return c.begin(); }
|
||||
|
||||
template< class C >
|
||||
auto end( C& c ) -> decltype(c.end()) { return c.end(); }
|
||||
|
||||
}
|
||||
|
||||
#pragma GCC visibility pop
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
28
libraries/ArduinoSTL/src/iterator.cpp
Normal file
28
libraries/ArduinoSTL/src/iterator.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "iterator"
|
||||
|
||||
namespace std{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
305
libraries/ArduinoSTL/src/iterator_base
Normal file
305
libraries/ArduinoSTL/src/iterator_base
Normal file
@@ -0,0 +1,305 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "basic_definitions"
|
||||
|
||||
#ifndef __STD_HEADER_ITERATOR_BASE
|
||||
#define __STD_HEADER_ITERATOR_BASE 1
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
|
||||
namespace std{
|
||||
template<class Iterator> struct iterator_traits;
|
||||
template<class T> struct iterator_traits<T*>;
|
||||
|
||||
template<class Category, class T, class Distance = ptrdiff_t, class Pointer = T*, class Reference = T&> struct iterator;
|
||||
|
||||
struct _UCXXEXPORT input_iterator_tag {};
|
||||
struct _UCXXEXPORT output_iterator_tag {};
|
||||
struct _UCXXEXPORT forward_iterator_tag: public input_iterator_tag {};
|
||||
struct _UCXXEXPORT bidirectional_iterator_tag: public forward_iterator_tag {};
|
||||
struct _UCXXEXPORT random_access_iterator_tag: public bidirectional_iterator_tag {};
|
||||
|
||||
template <class InputIterator, class Distance> _UCXXEXPORT void advance(InputIterator& i, Distance n){
|
||||
while(n > 0){
|
||||
--n;
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
template <class InputIterator> _UCXXEXPORT typename iterator_traits<InputIterator>::difference_type
|
||||
distance(InputIterator first, InputIterator last)
|
||||
{
|
||||
typename iterator_traits<InputIterator>::difference_type d = 0;
|
||||
while(first++ !=last){
|
||||
d++;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
// subclause _lib.predef.iterators_, predefined iterators:
|
||||
template <class Iterator> class reverse_iterator;
|
||||
template <class Iterator> bool operator==(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y);
|
||||
template <class Iterator> bool operator<(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y);
|
||||
template <class Iterator> bool operator!=(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y);
|
||||
template <class Iterator> bool operator>(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y);
|
||||
template <class Iterator> bool operator>=(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y);
|
||||
template <class Iterator> bool operator<=(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y);
|
||||
template <class Iterator> typename reverse_iterator<Iterator>::difference_type
|
||||
operator-( const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y);
|
||||
template <class Iterator> reverse_iterator<Iterator>
|
||||
operator+( typename reverse_iterator<Iterator>::difference_type n, const reverse_iterator<Iterator>& x);
|
||||
template <class Container> class back_insert_iterator;
|
||||
template <class Container> back_insert_iterator<Container> back_inserter(Container& x);
|
||||
template <class Container> class front_insert_iterator;
|
||||
template <class Container> front_insert_iterator<Container> front_inserter(Container& x);
|
||||
template <class Container> class insert_iterator;
|
||||
template <class Container, class Iterator>
|
||||
insert_iterator<Container> inserter(Container& x, Iterator i);
|
||||
|
||||
//Actual Template definitions
|
||||
|
||||
template<class Iterator> struct _UCXXEXPORT iterator_traits {
|
||||
typedef typename Iterator::difference_type difference_type;
|
||||
typedef typename Iterator::value_type value_type;
|
||||
typedef typename Iterator::pointer pointer;
|
||||
typedef typename Iterator::reference reference;
|
||||
typedef typename Iterator::iterator_category iterator_category;
|
||||
};
|
||||
|
||||
//Pointer specialization - required by standard
|
||||
template<class T> struct _UCXXEXPORT iterator_traits<T*> {
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T value_type;
|
||||
typedef T* pointer;
|
||||
typedef T& reference;
|
||||
typedef random_access_iterator_tag iterator_category;
|
||||
};
|
||||
|
||||
//Specialization recomended by standard
|
||||
/* template<class T> struct _UCXXEXPORT iterator_traits<T __far*> {
|
||||
typedef long difference_type;
|
||||
typedef T value_type;
|
||||
typedef T __far* pointer;
|
||||
typedef T __far& reference;
|
||||
typedef random_access_iterator_tag iterator_category;
|
||||
};*/
|
||||
|
||||
/* template <class BidirectionalIterator> _UCXXEXPORT void
|
||||
reverse(BidirectionalIterator first, BidirectionalIterator last)
|
||||
{
|
||||
typename iterator_traits<BidirectionalIterator>::difference_type n = distance(first, last);
|
||||
--n;
|
||||
while(n > 0){
|
||||
typename iterator_traits<BidirectionalIterator>::value_type tmp = *first;
|
||||
*first++ = * --last;
|
||||
*last = tmp;
|
||||
n -= 2;
|
||||
}
|
||||
};*/
|
||||
|
||||
|
||||
template <class Category, class T, class Distance, class Pointer, class Reference>
|
||||
struct _UCXXEXPORT iterator
|
||||
{
|
||||
typedef T value_type;
|
||||
typedef Distance difference_type;
|
||||
typedef Pointer pointer;
|
||||
typedef Reference reference;
|
||||
typedef Category iterator_category;
|
||||
};
|
||||
|
||||
|
||||
template <class Iterator> class _UCXXEXPORT reverse_iterator
|
||||
: public iterator<typename iterator_traits<Iterator>::iterator_category,
|
||||
typename iterator_traits<Iterator>::value_type, typename iterator_traits<Iterator>::difference_type,
|
||||
typename iterator_traits<Iterator>::pointer, typename iterator_traits<Iterator>::reference>
|
||||
{
|
||||
protected:
|
||||
Iterator current;
|
||||
friend bool operator== <Iterator>(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y);
|
||||
friend bool operator< <Iterator>(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y);
|
||||
|
||||
public:
|
||||
typedef Iterator iterator_type;
|
||||
|
||||
reverse_iterator() : current(){}
|
||||
explicit reverse_iterator(Iterator x) : current(x) { }
|
||||
template<class U> reverse_iterator(const reverse_iterator<U> &x) : current(x.base()){}
|
||||
|
||||
Iterator base() const { return current; } // explicit
|
||||
|
||||
typename iterator_traits<Iterator>::reference operator*() const { Iterator tmp = current; return *--tmp; }
|
||||
typename iterator_traits<Iterator>::pointer operator->() const { return &(operator*()); }
|
||||
typename iterator_traits<Iterator>::reference operator[](typename iterator_traits<Iterator>::difference_type n) const{
|
||||
return current[-n-1];
|
||||
}
|
||||
|
||||
reverse_iterator& operator++(){ --current; return *this; }
|
||||
reverse_iterator operator++(int) {reverse_iterator tmp = *this; --current; return tmp; }
|
||||
reverse_iterator& operator--() { ++ current; return *this; }
|
||||
reverse_iterator operator--(int) {reverse_iterator tmp = *this; ++current; return tmp; }
|
||||
|
||||
reverse_iterator operator+ (typename iterator_traits<Iterator>::difference_type n) const{
|
||||
reverse_iterator retval( *this );
|
||||
retval+=n;
|
||||
return retval;
|
||||
}
|
||||
reverse_iterator& operator+=(typename iterator_traits<Iterator>::difference_type n){
|
||||
current -= n;
|
||||
return *this;
|
||||
}
|
||||
reverse_iterator operator- (typename iterator_traits<Iterator>::difference_type n) const{
|
||||
reverse_iterator retval( *this );
|
||||
retval-=n;
|
||||
return retval;
|
||||
}
|
||||
reverse_iterator& operator-=(typename iterator_traits<Iterator>::difference_type n){
|
||||
current += n;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <class Iterator> _UCXXEXPORT bool
|
||||
operator==(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y)
|
||||
{
|
||||
return x.base() == y.base();
|
||||
}
|
||||
template <class Iterator> _UCXXEXPORT bool
|
||||
operator<(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y)
|
||||
{
|
||||
return x.base() < y.base();
|
||||
}
|
||||
template <class Iterator> _UCXXEXPORT bool
|
||||
operator!=(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y)
|
||||
{
|
||||
return x.base() != y.base();
|
||||
}
|
||||
template <class Iterator> _UCXXEXPORT bool
|
||||
operator>(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y)
|
||||
{
|
||||
return x.base() > y.base();
|
||||
}
|
||||
template <class Iterator> _UCXXEXPORT bool
|
||||
operator>=(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y)
|
||||
{
|
||||
return x.base() >= y.base();
|
||||
}
|
||||
template <class Iterator> _UCXXEXPORT bool
|
||||
operator<=(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y)
|
||||
{
|
||||
return x.base() <= y.base();
|
||||
}
|
||||
template <class Iterator> _UCXXEXPORT typename reverse_iterator<Iterator>::difference_type
|
||||
operator-( const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y)
|
||||
{
|
||||
return y.base() - x.base();
|
||||
}
|
||||
template <class Iterator> _UCXXEXPORT reverse_iterator<Iterator>
|
||||
operator+(typename reverse_iterator<Iterator>::difference_type n, const reverse_iterator<Iterator>& x)
|
||||
{
|
||||
return reverse_iterator<Iterator> (x.base() - n);
|
||||
}
|
||||
|
||||
template <class Container> class _UCXXEXPORT back_insert_iterator :
|
||||
public iterator<output_iterator_tag,void,void,void,void>
|
||||
{
|
||||
protected:
|
||||
Container& container;
|
||||
public:
|
||||
typedef Container container_type;
|
||||
explicit back_insert_iterator(Container& x):container(x) {}
|
||||
back_insert_iterator<Container>& operator=(const typename Container::value_type& value){
|
||||
container.push_back(value);
|
||||
return *this;
|
||||
}
|
||||
back_insert_iterator<Container>& operator*(){
|
||||
return *this;
|
||||
}
|
||||
back_insert_iterator<Container>& operator++(){
|
||||
return *this;
|
||||
}
|
||||
back_insert_iterator<Container> operator++(int){
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
template <class Container> _UCXXEXPORT back_insert_iterator<Container>
|
||||
back_inserter(Container& x)
|
||||
{
|
||||
return back_insert_iterator<Container>(x);
|
||||
}
|
||||
|
||||
template <class Container> class _UCXXEXPORT front_insert_iterator
|
||||
: public iterator<output_iterator_tag,void,void,void,void>
|
||||
{
|
||||
protected:
|
||||
Container& container;
|
||||
public:
|
||||
typedef Container container_type;
|
||||
explicit front_insert_iterator(Container& x): container(x) {}
|
||||
front_insert_iterator<Container>& operator=(const typename Container::value_type& value){
|
||||
container.push_front(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
front_insert_iterator<Container>& operator*() { return *this; }
|
||||
front_insert_iterator<Container>& operator++() { return *this; }
|
||||
front_insert_iterator<Container> operator++(int) { return *this; }
|
||||
};
|
||||
|
||||
template <class Container> _UCXXEXPORT front_insert_iterator<Container>
|
||||
front_inserter(Container& x)
|
||||
{
|
||||
return front_insert_iterator<Container>(x);
|
||||
}
|
||||
|
||||
template <class Container> class _UCXXEXPORT insert_iterator
|
||||
: public iterator<output_iterator_tag,void,void,void,void>
|
||||
{
|
||||
protected:
|
||||
Container& container;
|
||||
typename Container::iterator iter;
|
||||
public:
|
||||
typedef Container container_type;
|
||||
insert_iterator(Container& x, typename Container::iterator i) : container(x), iter(i) {}
|
||||
insert_iterator<Container>& operator=(const typename Container::value_type& value){
|
||||
iter = container.insert(iter, value);
|
||||
++iter;
|
||||
return *this;
|
||||
}
|
||||
insert_iterator<Container>& operator*() { return *this; }
|
||||
insert_iterator<Container>& operator++() { return *this; }
|
||||
insert_iterator<Container> operator++(int) { return *this; }
|
||||
};
|
||||
|
||||
template <class Container, class Iterator> _UCXXEXPORT insert_iterator<Container>
|
||||
inserter(Container& x, Iterator i)
|
||||
{
|
||||
return insert_iterator<Container>(x,typename Container::iterator(i));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#pragma GCC visibility pop
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
663
libraries/ArduinoSTL/src/limits
Normal file
663
libraries/ArduinoSTL/src/limits
Normal file
@@ -0,0 +1,663 @@
|
||||
/* Copyright (C) 2006 Garrett A. Kajmowicz
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "climits"
|
||||
|
||||
#ifndef __STD_HEADER_LIMITS
|
||||
#define __STD_HEADER_LIMITS 1
|
||||
|
||||
#warning limits header is nowhere complete or accurate
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
|
||||
namespace std{
|
||||
|
||||
enum float_round_style{
|
||||
round_indeterminate =-1,
|
||||
round_toward_zero = 0,
|
||||
round_to_nearest = 1,
|
||||
round_toward_infinity = 2,
|
||||
round_toward_neg_infinity = 3
|
||||
};
|
||||
|
||||
template <int bitsize> struct __bits_to_base_10{
|
||||
static const int size = -1;
|
||||
};
|
||||
template <> struct __bits_to_base_10<7>{
|
||||
static const int size = 2;
|
||||
};
|
||||
template <> struct __bits_to_base_10<8>{
|
||||
static const int size = 2;
|
||||
};
|
||||
template <> struct __bits_to_base_10<9>{
|
||||
static const int size = 2;
|
||||
};
|
||||
template <> struct __bits_to_base_10<10>{
|
||||
static const int size = 3;
|
||||
};
|
||||
template <> struct __bits_to_base_10<15>{
|
||||
static const int size = 4;
|
||||
};
|
||||
template <> struct __bits_to_base_10<16>{
|
||||
static const int size = 4;
|
||||
};
|
||||
template <> struct __bits_to_base_10<17>{
|
||||
static const int size = 5;
|
||||
};
|
||||
template <> struct __bits_to_base_10<18>{
|
||||
static const int size = 5;
|
||||
};
|
||||
template <> struct __bits_to_base_10<31>{
|
||||
static const int size = 9;
|
||||
};
|
||||
template <> struct __bits_to_base_10<32>{
|
||||
static const int size = 9;
|
||||
};
|
||||
template <> struct __bits_to_base_10<35>{
|
||||
static const int size = 10;
|
||||
};
|
||||
template <> struct __bits_to_base_10<36>{
|
||||
static const int size = 10;
|
||||
};
|
||||
template <> struct __bits_to_base_10<63>{
|
||||
static const int size = 18;
|
||||
};
|
||||
template <> struct __bits_to_base_10<64>{
|
||||
static const int size = 19;
|
||||
};
|
||||
template <> struct __bits_to_base_10<71>{
|
||||
static const int size = 21;
|
||||
};
|
||||
template <> struct __bits_to_base_10<72>{
|
||||
static const int size = 21;
|
||||
};
|
||||
template <> struct __bits_to_base_10<79>{
|
||||
static const int size = 23;
|
||||
};
|
||||
template <> struct __bits_to_base_10<80>{
|
||||
static const int size = 24;
|
||||
};
|
||||
template <> struct __bits_to_base_10<127>{
|
||||
static const int size = 38;
|
||||
};
|
||||
template <> struct __bits_to_base_10<128>{
|
||||
static const int size = 38;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
template <class T> class numeric_limits {
|
||||
public:
|
||||
// General -- meaningful for all specializations.
|
||||
|
||||
static const bool is_specialized = false;
|
||||
static T min();
|
||||
static T max();
|
||||
static const int radix;
|
||||
static const int digits;
|
||||
static const int digits10;
|
||||
static const bool is_signed;
|
||||
static const bool is_integer;
|
||||
static const bool is_exact;
|
||||
static const bool traps;
|
||||
static const bool is_modulo;
|
||||
static const bool is_bounded;
|
||||
|
||||
// Floating point specific.
|
||||
|
||||
static T epsilon();
|
||||
static T round_error();
|
||||
static const int min_exponent10;
|
||||
static const int max_exponent10;
|
||||
static const int min_exponent;
|
||||
|
||||
static const int max_exponent;
|
||||
static const bool has_infinity;
|
||||
static const bool has_quiet_NaN;
|
||||
static const bool has_signaling_NaN;
|
||||
static const bool is_iec559;
|
||||
static const bool has_denorm;
|
||||
static const bool tinyness_before;
|
||||
static const float_round_style round_style;
|
||||
static T denorm_min();
|
||||
static T infinity();
|
||||
static T quiet_NaN();
|
||||
static T signaling_NaN();
|
||||
};
|
||||
|
||||
template <> class numeric_limits<bool> {
|
||||
public:
|
||||
typedef bool T;
|
||||
// General -- meaningful for all specializations.
|
||||
static const bool is_specialized = true;
|
||||
static T min(){
|
||||
return false;
|
||||
}
|
||||
static T max(){
|
||||
return true;
|
||||
}
|
||||
static const int radix = 2;
|
||||
static const int digits = 1;
|
||||
static const int digits10 = 0;
|
||||
static const bool is_signed = false;
|
||||
static const bool is_integer = true;
|
||||
static const bool is_exact = true;
|
||||
static const bool traps = false;
|
||||
static const bool is_modulo = false;
|
||||
static const bool is_bounded = true;
|
||||
|
||||
// Floating point specific.
|
||||
|
||||
static T epsilon(){
|
||||
return 0;
|
||||
}
|
||||
static T round_error(){
|
||||
return 0;
|
||||
}
|
||||
static const int min_exponent10 = 0;
|
||||
static const int max_exponent10 = 0;
|
||||
static const int min_exponent = 0;
|
||||
|
||||
static const int max_exponent = 0;
|
||||
static const bool has_infinity = false;
|
||||
static const bool has_quiet_NaN = false;
|
||||
static const bool has_signaling_NaN = false;
|
||||
static const bool is_iec559 = false;
|
||||
static const bool has_denorm = false;
|
||||
static const bool tinyness_before = false;
|
||||
static const float_round_style round_style = round_indeterminate;
|
||||
static T denorm_min();
|
||||
static T infinity();
|
||||
static T quiet_NaN();
|
||||
static T signaling_NaN();
|
||||
};
|
||||
|
||||
template <> class numeric_limits<unsigned char> {
|
||||
public:
|
||||
typedef unsigned char T;
|
||||
// General -- meaningful for all specializations.
|
||||
static const bool is_specialized = true;
|
||||
static T min(){
|
||||
return 0;
|
||||
}
|
||||
static T max(){
|
||||
return UCHAR_MAX;
|
||||
}
|
||||
static const int radix = 2;
|
||||
static const int digits = CHAR_BIT;
|
||||
static const int digits10 = __bits_to_base_10<digits>::size;
|
||||
static const bool is_signed = false;
|
||||
static const bool is_integer = true;
|
||||
static const bool is_exact = true;
|
||||
static const bool traps = false;
|
||||
static const bool is_modulo = true;
|
||||
static const bool is_bounded = true;
|
||||
|
||||
// Floating point specific.
|
||||
|
||||
static T epsilon(){
|
||||
return 0;
|
||||
}
|
||||
static T round_error(){
|
||||
return 0;
|
||||
}
|
||||
static const int min_exponent10 = 0;
|
||||
static const int max_exponent10 = 0;
|
||||
static const int min_exponent = 0;
|
||||
|
||||
static const int max_exponent = 0;
|
||||
static const bool has_infinity = false;
|
||||
static const bool has_quiet_NaN = false;
|
||||
static const bool has_signaling_NaN = false;
|
||||
static const bool is_iec559 = false;
|
||||
static const bool has_denorm = false;
|
||||
static const bool tinyness_before = false;
|
||||
static const float_round_style round_style = round_indeterminate;
|
||||
static T denorm_min();
|
||||
static T infinity();
|
||||
static T quiet_NaN();
|
||||
static T signaling_NaN();
|
||||
};
|
||||
|
||||
template <> class numeric_limits<signed char> {
|
||||
public:
|
||||
typedef signed char T;
|
||||
// General -- meaningful for all specializations.
|
||||
static const bool is_specialized = true;
|
||||
static T min(){
|
||||
return SCHAR_MIN;
|
||||
}
|
||||
static T max(){
|
||||
return SCHAR_MAX;
|
||||
}
|
||||
static const int radix = 2;
|
||||
static const int digits = CHAR_BIT - 1;
|
||||
static const int digits10 = __bits_to_base_10<digits>::size;
|
||||
static const bool is_signed = true;
|
||||
static const bool is_integer = true;
|
||||
static const bool is_exact = true;
|
||||
static const bool traps = false;
|
||||
static const bool is_modulo = true;
|
||||
static const bool is_bounded = true;
|
||||
|
||||
// Floating point specific.
|
||||
|
||||
static T epsilon(){
|
||||
return 0;
|
||||
}
|
||||
static T round_error(){
|
||||
return 0;
|
||||
}
|
||||
static const int min_exponent10 = 0;
|
||||
static const int max_exponent10 = 0;
|
||||
static const int min_exponent = 0;
|
||||
|
||||
static const int max_exponent = 0;
|
||||
static const bool has_infinity = false;
|
||||
static const bool has_quiet_NaN = false;
|
||||
static const bool has_signaling_NaN = false;
|
||||
static const bool is_iec559 = false;
|
||||
static const bool has_denorm = false;
|
||||
static const bool tinyness_before = false;
|
||||
static const float_round_style round_style = round_indeterminate;
|
||||
static T denorm_min();
|
||||
static T infinity();
|
||||
static T quiet_NaN();
|
||||
static T signaling_NaN();
|
||||
};
|
||||
|
||||
template <> class numeric_limits<char> {
|
||||
public:
|
||||
typedef char T;
|
||||
// General -- meaningful for all specializations.
|
||||
static const bool is_specialized = true;
|
||||
static T min(){
|
||||
return CHAR_MIN;
|
||||
}
|
||||
static T max(){
|
||||
return CHAR_MAX;
|
||||
}
|
||||
static const int radix = 2;
|
||||
static const int digits = (CHAR_MIN != 0) ? CHAR_BIT - 1 : CHAR_BIT;
|
||||
static const int digits10 = __bits_to_base_10<digits>::size;
|
||||
static const bool is_signed = (CHAR_MIN != 0);
|
||||
static const bool is_integer = true;
|
||||
static const bool is_exact = true;
|
||||
static const bool traps = false;
|
||||
static const bool is_modulo = true;
|
||||
static const bool is_bounded = true;
|
||||
|
||||
// Floating point specific.
|
||||
|
||||
static T epsilon(){
|
||||
return 0;
|
||||
}
|
||||
static T round_error(){
|
||||
return 0;
|
||||
}
|
||||
static const int min_exponent10 = 0;
|
||||
static const int max_exponent10 = 0;
|
||||
static const int min_exponent = 0;
|
||||
|
||||
static const int max_exponent = 0;
|
||||
static const bool has_infinity = false;
|
||||
static const bool has_quiet_NaN = false;
|
||||
static const bool has_signaling_NaN = false;
|
||||
static const bool is_iec559 = false;
|
||||
static const bool has_denorm = false;
|
||||
static const bool tinyness_before = false;
|
||||
static const float_round_style round_style = round_indeterminate;
|
||||
static T denorm_min();
|
||||
static T infinity();
|
||||
static T quiet_NaN();
|
||||
static T signaling_NaN();
|
||||
};
|
||||
|
||||
template <> class numeric_limits<unsigned short> {
|
||||
public:
|
||||
typedef unsigned short T;
|
||||
// General -- meaningful for all specializations.
|
||||
static const bool is_specialized = true;
|
||||
static T min(){
|
||||
return 0;
|
||||
}
|
||||
static T max(){
|
||||
return USHRT_MAX;
|
||||
}
|
||||
static const int radix = 2;
|
||||
static const int digits = CHAR_BIT * sizeof(T);
|
||||
static const int digits10 = __bits_to_base_10<digits>::size;
|
||||
static const bool is_signed = false;
|
||||
static const bool is_integer = true;
|
||||
static const bool is_exact = true;
|
||||
static const bool traps = false;
|
||||
static const bool is_modulo = true;
|
||||
static const bool is_bounded = true;
|
||||
|
||||
// Floating point specific.
|
||||
|
||||
static T epsilon(){
|
||||
return 0;
|
||||
}
|
||||
static T round_error(){
|
||||
return 0;
|
||||
}
|
||||
static const int min_exponent10 = 0;
|
||||
static const int max_exponent10 = 0;
|
||||
static const int min_exponent = 0;
|
||||
|
||||
static const int max_exponent = 0;
|
||||
static const bool has_infinity = false;
|
||||
static const bool has_quiet_NaN = false;
|
||||
static const bool has_signaling_NaN = false;
|
||||
static const bool is_iec559 = false;
|
||||
static const bool has_denorm = false;
|
||||
static const bool tinyness_before = false;
|
||||
static const float_round_style round_style = round_indeterminate;
|
||||
static T denorm_min();
|
||||
static T infinity();
|
||||
static T quiet_NaN();
|
||||
static T signaling_NaN();
|
||||
};
|
||||
|
||||
template <> class numeric_limits<signed short> {
|
||||
public:
|
||||
typedef signed short T;
|
||||
// General -- meaningful for all specializations.
|
||||
static const bool is_specialized = true;
|
||||
static T min(){
|
||||
return SHRT_MIN;
|
||||
}
|
||||
static T max(){
|
||||
return SHRT_MAX;
|
||||
}
|
||||
static const int radix = 2;
|
||||
static const int digits = CHAR_BIT * sizeof(T);
|
||||
static const int digits10 = __bits_to_base_10<digits>::size;
|
||||
static const bool is_signed = true;
|
||||
static const bool is_integer = true;
|
||||
static const bool is_exact = true;
|
||||
static const bool traps = false;
|
||||
static const bool is_modulo = true;
|
||||
static const bool is_bounded = true;
|
||||
|
||||
// Floating point specific.
|
||||
|
||||
static T epsilon(){
|
||||
return 0;
|
||||
}
|
||||
static T round_error(){
|
||||
return 0;
|
||||
}
|
||||
static const int min_exponent10 = 0;
|
||||
static const int max_exponent10 = 0;
|
||||
static const int min_exponent = 0;
|
||||
|
||||
static const int max_exponent = 0;
|
||||
static const bool has_infinity = false;
|
||||
static const bool has_quiet_NaN = false;
|
||||
static const bool has_signaling_NaN = false;
|
||||
static const bool is_iec559 = false;
|
||||
static const bool has_denorm = false;
|
||||
static const bool tinyness_before = false;
|
||||
static const float_round_style round_style = round_indeterminate;
|
||||
static T denorm_min();
|
||||
static T infinity();
|
||||
static T quiet_NaN();
|
||||
static T signaling_NaN();
|
||||
};
|
||||
|
||||
template <> class numeric_limits<unsigned int> {
|
||||
public:
|
||||
typedef unsigned int T;
|
||||
// General -- meaningful for all specializations.
|
||||
static const bool is_specialized = true;
|
||||
static T min(){
|
||||
return 0;
|
||||
}
|
||||
static T max(){
|
||||
return UINT_MAX;
|
||||
}
|
||||
static const int radix = 2;
|
||||
static const int digits = CHAR_BIT * sizeof(T);
|
||||
static const int digits10 = __bits_to_base_10<digits>::size;
|
||||
static const bool is_signed = false;
|
||||
static const bool is_integer = true;
|
||||
static const bool is_exact = true;
|
||||
static const bool traps = false;
|
||||
static const bool is_modulo = true;
|
||||
static const bool is_bounded = true;
|
||||
|
||||
// Floating point specific.
|
||||
|
||||
static T epsilon(){
|
||||
return 0;
|
||||
}
|
||||
static T round_error(){
|
||||
return 0;
|
||||
}
|
||||
static const int min_exponent10 = 0;
|
||||
static const int max_exponent10 = 0;
|
||||
static const int min_exponent = 0;
|
||||
|
||||
static const int max_exponent = 0;
|
||||
static const bool has_infinity = false;
|
||||
static const bool has_quiet_NaN = false;
|
||||
static const bool has_signaling_NaN = false;
|
||||
static const bool is_iec559 = false;
|
||||
static const bool has_denorm = false;
|
||||
static const bool tinyness_before = false;
|
||||
static const float_round_style round_style = round_indeterminate;
|
||||
static T denorm_min();
|
||||
static T infinity();
|
||||
static T quiet_NaN();
|
||||
static T signaling_NaN();
|
||||
};
|
||||
|
||||
template <> class numeric_limits<signed int> {
|
||||
public:
|
||||
typedef signed int T;
|
||||
// General -- meaningful for all specializations.
|
||||
static const bool is_specialized = true;
|
||||
static T min(){
|
||||
return INT_MIN;
|
||||
}
|
||||
static T max(){
|
||||
return INT_MAX;
|
||||
}
|
||||
static const int radix = 2;
|
||||
static const int digits = CHAR_BIT * sizeof(T);
|
||||
static const int digits10 = __bits_to_base_10<digits>::size;
|
||||
static const bool is_signed = true;
|
||||
static const bool is_integer = true;
|
||||
static const bool is_exact = true;
|
||||
static const bool traps = false;
|
||||
static const bool is_modulo = true;
|
||||
static const bool is_bounded = true;
|
||||
|
||||
// Floating point specific.
|
||||
|
||||
static T epsilon(){
|
||||
return 0;
|
||||
}
|
||||
static T round_error(){
|
||||
return 0;
|
||||
}
|
||||
static const int min_exponent10 = 0;
|
||||
static const int max_exponent10 = 0;
|
||||
static const int min_exponent = 0;
|
||||
|
||||
static const int max_exponent = 0;
|
||||
static const bool has_infinity = false;
|
||||
static const bool has_quiet_NaN = false;
|
||||
static const bool has_signaling_NaN = false;
|
||||
static const bool is_iec559 = false;
|
||||
static const bool has_denorm = false;
|
||||
static const bool tinyness_before = false;
|
||||
static const float_round_style round_style = round_indeterminate;
|
||||
static T denorm_min();
|
||||
static T infinity();
|
||||
static T quiet_NaN();
|
||||
static T signaling_NaN();
|
||||
};
|
||||
|
||||
template <> class numeric_limits<unsigned long int> {
|
||||
public:
|
||||
typedef unsigned long int T;
|
||||
// General -- meaningful for all specializations.
|
||||
static const bool is_specialized = true;
|
||||
static T min(){
|
||||
return 0;
|
||||
}
|
||||
static T max(){
|
||||
return ULONG_MAX;
|
||||
}
|
||||
static const int radix = 2;
|
||||
static const int digits = CHAR_BIT * sizeof(T);
|
||||
static const int digits10 = __bits_to_base_10<digits>::size;
|
||||
static const bool is_signed = false;
|
||||
static const bool is_integer = true;
|
||||
static const bool is_exact = true;
|
||||
static const bool traps = false;
|
||||
static const bool is_modulo = true;
|
||||
static const bool is_bounded = true;
|
||||
|
||||
// Floating point specific.
|
||||
|
||||
static T epsilon(){
|
||||
return 0;
|
||||
}
|
||||
static T round_error(){
|
||||
return 0;
|
||||
}
|
||||
static const int min_exponent10 = 0;
|
||||
static const int max_exponent10 = 0;
|
||||
static const int min_exponent = 0;
|
||||
|
||||
static const int max_exponent = 0;
|
||||
static const bool has_infinity = false;
|
||||
static const bool has_quiet_NaN = false;
|
||||
static const bool has_signaling_NaN = false;
|
||||
static const bool is_iec559 = false;
|
||||
static const bool has_denorm = false;
|
||||
static const bool tinyness_before = false;
|
||||
static const float_round_style round_style = round_indeterminate;
|
||||
static T denorm_min();
|
||||
static T infinity();
|
||||
static T quiet_NaN();
|
||||
static T signaling_NaN();
|
||||
};
|
||||
|
||||
template <> class numeric_limits<signed long int> {
|
||||
public:
|
||||
typedef signed long int T;
|
||||
// General -- meaningful for all specializations.
|
||||
static const bool is_specialized = true;
|
||||
static T min(){
|
||||
return LONG_MIN;
|
||||
}
|
||||
static T max(){
|
||||
return LONG_MAX;
|
||||
}
|
||||
static const int radix = 2;
|
||||
static const int digits = CHAR_BIT * sizeof(T);
|
||||
static const int digits10 = __bits_to_base_10<digits>::size;
|
||||
static const bool is_signed = true;
|
||||
static const bool is_integer = true;
|
||||
static const bool is_exact = true;
|
||||
static const bool traps = false;
|
||||
static const bool is_modulo = true;
|
||||
static const bool is_bounded = true;
|
||||
|
||||
// Floating point specific.
|
||||
|
||||
static T epsilon(){
|
||||
return 0;
|
||||
}
|
||||
static T round_error(){
|
||||
return 0;
|
||||
}
|
||||
static const int min_exponent10 = 0;
|
||||
static const int max_exponent10 = 0;
|
||||
static const int min_exponent = 0;
|
||||
|
||||
static const int max_exponent = 0;
|
||||
static const bool has_infinity = false;
|
||||
static const bool has_quiet_NaN = false;
|
||||
static const bool has_signaling_NaN = false;
|
||||
static const bool is_iec559 = false;
|
||||
static const bool has_denorm = false;
|
||||
static const bool tinyness_before = false;
|
||||
static const float_round_style round_style = round_indeterminate;
|
||||
static T denorm_min();
|
||||
static T infinity();
|
||||
static T quiet_NaN();
|
||||
static T signaling_NaN();
|
||||
};
|
||||
|
||||
template <> class numeric_limits<double> {
|
||||
public:
|
||||
typedef double numeric_type;
|
||||
|
||||
static const bool is_specialized = true;
|
||||
static numeric_type min () { return __DBL_MIN__; }
|
||||
static numeric_type max () { return __DBL_MAX__; }
|
||||
static const int radix = __FLT_RADIX__;
|
||||
static const int digits = __DBL_MANT_DIG__;
|
||||
static const int digits10 = __DBL_DIG__;
|
||||
static const bool is_signed = true;
|
||||
static const bool is_integer = false;
|
||||
static const bool is_exact = false;
|
||||
static const bool traps = false; // this is a guess
|
||||
static const bool is_modulo = false;
|
||||
static const bool is_bounded = true;
|
||||
|
||||
// Floating point specific.
|
||||
|
||||
static numeric_type epsilon () { return __DBL_EPSILON__; }
|
||||
static numeric_type round_error () { return 0.5; }
|
||||
static const int min_exponent10 = -1; //How do I properly get this?
|
||||
static const int max_exponent10 = -1; //How do I properly get this?
|
||||
static const int min_exponent = -1; //How do I properly get this?
|
||||
static const int max_exponent = -1; //How do I properly get this?
|
||||
static const bool has_infinity = false; //I don't know, so until I can find out, I'm saying no
|
||||
static const bool has_quiet_NaN = false; //I don't know, so until I can find out, I'm saying no
|
||||
static const bool has_signaling_NaN = false; //I don't know, so until I can find out, I'm saying no
|
||||
static const bool has_denorm = false; //I don't know, so until I can find out, I'm saying no
|
||||
|
||||
static const bool is_iec559 = false; //I don't know, so until I can find out, I'm saying no
|
||||
static const bool tinyness_before = false; // more questions
|
||||
static const float_round_style round_style = round_to_nearest; // more questions
|
||||
static numeric_type denorm_min () { return -1; } //How do I properly get this?
|
||||
static numeric_type infinity () { return -1; } //How do I properly get this?
|
||||
static numeric_type quiet_NaN () { return -1; } //How do I properly get this?
|
||||
static numeric_type signaling_NaN () { return -1; } //How do I properly get this?
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#pragma GCC visibility pop
|
||||
|
||||
#endif
|
||||
25
libraries/ArduinoSTL/src/limits.cpp
Normal file
25
libraries/ArduinoSTL/src/limits.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
/* Copyright (C) 2006 Garrett A. Kajmowicz
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "limits"
|
||||
|
||||
namespace std{
|
||||
|
||||
|
||||
}
|
||||
937
libraries/ArduinoSTL/src/list
Normal file
937
libraries/ArduinoSTL/src/list
Normal file
@@ -0,0 +1,937 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "memory"
|
||||
#include "iterator"
|
||||
#include "algorithm"
|
||||
#include "initializer_list"
|
||||
|
||||
#ifndef __STD_HEADER_LIST
|
||||
#define __STD_HEADER_LIST 1
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
|
||||
namespace std{
|
||||
|
||||
template <class T, class Allocator = allocator<T> > class _UCXXEXPORT list {
|
||||
public:
|
||||
typedef typename Allocator::reference reference;
|
||||
typedef typename Allocator::const_reference const_reference;
|
||||
typedef typename Allocator::size_type size_type;
|
||||
typedef typename Allocator::difference_type difference_type;
|
||||
typedef T value_type;
|
||||
typedef Allocator allocator_type;
|
||||
typedef typename Allocator::pointer pointer;
|
||||
typedef typename Allocator::const_pointer const_pointer;
|
||||
|
||||
protected:
|
||||
class node;
|
||||
class iter_list;
|
||||
|
||||
node * list_start;
|
||||
node * list_end;
|
||||
size_type elements;
|
||||
Allocator a;
|
||||
|
||||
public:
|
||||
|
||||
typedef iter_list iterator;
|
||||
typedef iter_list const_iterator;
|
||||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
|
||||
explicit list(const Allocator& = Allocator());
|
||||
explicit list(size_type n, const T& value = T(), const Allocator& = Allocator());
|
||||
template <class InputIterator> list(InputIterator first, InputIterator last,
|
||||
const Allocator& al= Allocator());
|
||||
list(const list<T,Allocator>& x);
|
||||
~list();
|
||||
|
||||
list<T,Allocator>& operator=(const list<T,Allocator>& x){
|
||||
if(&x == this){
|
||||
return *this;
|
||||
}
|
||||
clear();
|
||||
iterator i = x.begin();
|
||||
while(i != x.end()){
|
||||
push_back(*i);
|
||||
++i;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
list<T,Allocator>& operator=(const std::initializer_list<T>& x){
|
||||
clear();
|
||||
auto i = x.begin();
|
||||
while(i != x.end()){
|
||||
push_back(*i);
|
||||
++i;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class InputIterator> void assign(InputIterator first, InputIterator last);
|
||||
template <class Size, class U> void assign(Size n, const U& u = U());
|
||||
allocator_type get_allocator() const;
|
||||
|
||||
iterator begin();
|
||||
const_iterator begin() const;
|
||||
iterator end();
|
||||
const_iterator end() const;
|
||||
reverse_iterator rbegin();
|
||||
const_reverse_iterator rbegin() const;
|
||||
reverse_iterator rend();
|
||||
const_reverse_iterator rend() const;
|
||||
|
||||
bool empty() const;
|
||||
size_type size() const;
|
||||
size_type max_size() const;
|
||||
void resize(size_type sz, T c = T());
|
||||
|
||||
reference front();
|
||||
const_reference front() const;
|
||||
reference back();
|
||||
const_reference back() const;
|
||||
|
||||
void push_front(const T& x);
|
||||
void pop_front();
|
||||
void push_back(const T& x);
|
||||
void pop_back();
|
||||
iterator insert(iterator position, const T& x = T());
|
||||
void insert(iterator position, size_type n, const T& x);
|
||||
template <class InputIterator> void insert(iterator position, InputIterator first, InputIterator last);
|
||||
iterator erase(iterator position);
|
||||
iterator erase(iterator position, iterator last);
|
||||
void swap(list<T,Allocator>&);
|
||||
void clear();
|
||||
|
||||
void splice(iterator position, list<T,Allocator>& x);
|
||||
void splice(iterator position, list<T,Allocator>& x, iterator i);
|
||||
void splice(iterator position, list<T,Allocator>& x, iterator first, iterator last);
|
||||
void remove(const T& value);
|
||||
template <class Predicate> void remove_if(Predicate pred);
|
||||
void unique();
|
||||
template <class BinaryPredicate> void unique(BinaryPredicate binary_pred);
|
||||
void merge(list<T,Allocator>& x);
|
||||
template <class Compare> void merge(list<T,Allocator>& x, Compare comp);
|
||||
void sort();
|
||||
template <class Compare> void sort(Compare comp);
|
||||
void reverse();
|
||||
protected:
|
||||
void swap_nodes(node * x, node * y);
|
||||
};
|
||||
|
||||
|
||||
//Implementations of List
|
||||
|
||||
//List node
|
||||
template <class T, class Allocator> class _UCXXEXPORT list<T, Allocator>::node{
|
||||
public:
|
||||
node * previous;
|
||||
node * next;
|
||||
T * val;
|
||||
|
||||
node(): previous(0), next(0), val(0){ }
|
||||
node(const T & t ): previous(0), next(0), val(0) {
|
||||
val = new T(t);
|
||||
//FIXME use allocator somehow but only call constructor once
|
||||
}
|
||||
node(const T & t, node * p, node * n): previous(p), next(n), val(0) {
|
||||
val = new T(t);
|
||||
}
|
||||
~node(){ }
|
||||
};
|
||||
|
||||
//List iterator
|
||||
template <class T, class Allocator> class _UCXXEXPORT list<T, Allocator>::iter_list
|
||||
: public std::iterator<
|
||||
bidirectional_iterator_tag,
|
||||
T,
|
||||
typename Allocator::difference_type,
|
||||
typename Allocator::pointer,
|
||||
typename Allocator::reference
|
||||
>
|
||||
{
|
||||
private:
|
||||
node * current;
|
||||
public:
|
||||
iter_list():current(0) { }
|
||||
iter_list( typename list<T, Allocator>::node * n): current(n) { }
|
||||
iter_list(const list<T, Allocator>::iter_list & l): current(l.current) { }
|
||||
~iter_list(){ }
|
||||
|
||||
iter_list & operator=(const list<T, Allocator>::iter_list & right ){
|
||||
current = right.current;
|
||||
return *this;
|
||||
}
|
||||
|
||||
T & operator*(){
|
||||
return *(current->val);
|
||||
}
|
||||
T * operator->(){
|
||||
return current->val;
|
||||
}
|
||||
const T & operator*() const{
|
||||
return *current->val;
|
||||
}
|
||||
const T * operator->() const{
|
||||
return current->val;
|
||||
}
|
||||
|
||||
bool operator==(const list<T, Allocator>::iter_list & right) const {
|
||||
return (current == right.current);
|
||||
}
|
||||
|
||||
bool operator!=(const list<T, Allocator>::iter_list & right) const {
|
||||
return (current != right.current);
|
||||
}
|
||||
|
||||
iter_list & operator++(){
|
||||
current = current->next;
|
||||
return *this;
|
||||
}
|
||||
|
||||
iter_list operator++(int){
|
||||
iter_list temp(current);
|
||||
current = current->next;
|
||||
return temp;
|
||||
}
|
||||
iter_list & operator--(){
|
||||
current = current->previous;
|
||||
return *this;
|
||||
}
|
||||
|
||||
iter_list operator--(int){
|
||||
iter_list temp(current);
|
||||
current = current->previous;
|
||||
return temp;
|
||||
}
|
||||
node * link_struct(){
|
||||
return current;
|
||||
}
|
||||
iter_list & operator+=(unsigned int n){
|
||||
for(unsigned int i = 0; i < n; ++i){
|
||||
current = current->next;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
iter_list & operator-=(unsigned int n){
|
||||
for(unsigned int i = 0; i < n; ++i){
|
||||
current = current->previous;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<class T, class Allocator> list<T, Allocator>::list(const Allocator& al)
|
||||
:list_start(0), list_end(0), elements(0), a(al)
|
||||
{
|
||||
//End node
|
||||
list_start = new node();
|
||||
list_end = list_start;
|
||||
return;
|
||||
}
|
||||
|
||||
template<class T, class Allocator> list<T, Allocator>::list
|
||||
(typename Allocator::size_type n, const T& value, const Allocator& al)
|
||||
:list_start(0), list_end(0), elements(0), a(al)
|
||||
{
|
||||
//End node
|
||||
list_start = new node();
|
||||
list_end = list_start;
|
||||
|
||||
for(typename Allocator::size_type i = 0; i < n ; ++i){
|
||||
push_back(value);
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, class Allocator> template <class InputIterator>
|
||||
list<T, Allocator>::list
|
||||
(InputIterator first, InputIterator last, const Allocator& al)
|
||||
: list_start(0), list_end(0), elements(0), a(al)
|
||||
{
|
||||
list_start = new node();
|
||||
list_end = list_start;
|
||||
while(first != last){
|
||||
push_back(*first);
|
||||
++first;
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, class Allocator> list<T, Allocator>::list(const list<T,Allocator>& x)
|
||||
: list_start(0), list_end(0), elements(0), a(x.a)
|
||||
{
|
||||
list_start = new node();
|
||||
list_end = list_start;
|
||||
|
||||
iterator i = x.begin();
|
||||
while(i != x.end()){
|
||||
push_back( *i);
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, class Allocator> list<T, Allocator>::~list(){
|
||||
while(elements > 0){
|
||||
pop_front();
|
||||
}
|
||||
delete list_start->val;
|
||||
#if UCLIBCXX_DEBUG
|
||||
list_start->val = 0;
|
||||
#endif
|
||||
delete list_start;
|
||||
#if UCLIBCXX_DEBUG
|
||||
list_start = 0;
|
||||
list_end = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Allocator> void list<T, Allocator>::swap_nodes(node * x, node * y){
|
||||
T * v = x->val;
|
||||
x->val = y->val;
|
||||
y->val = v;
|
||||
}
|
||||
|
||||
template<class T, class Allocator> typename list<T, Allocator>::iterator
|
||||
list<T, Allocator>::begin()
|
||||
{
|
||||
return iterator(list_start);
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Allocator> typename list<T, Allocator>::const_iterator
|
||||
list<T, Allocator>::begin() const
|
||||
{
|
||||
return const_iterator(list_start);
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Allocator> typename list<T, Allocator>::iterator
|
||||
list<T, Allocator>::end()
|
||||
{
|
||||
return iterator(list_end);
|
||||
}
|
||||
|
||||
template<class T, class Allocator> typename list<T, Allocator>::const_iterator
|
||||
list<T, Allocator>::end() const
|
||||
{
|
||||
return const_iterator(list_end);
|
||||
}
|
||||
|
||||
template<class T, class Allocator> typename list<T, Allocator>::reverse_iterator
|
||||
list<T, Allocator>::rbegin()
|
||||
{
|
||||
return reverse_iterator(end());
|
||||
}
|
||||
|
||||
template<class T, class Allocator> typename list<T, Allocator>::const_reverse_iterator
|
||||
list<T, Allocator>::rbegin() const
|
||||
{
|
||||
return const_reverse_iterator(end());
|
||||
}
|
||||
|
||||
template<class T, class Allocator> typename list<T, Allocator>::reverse_iterator
|
||||
list<T, Allocator>::rend()
|
||||
{
|
||||
return reverse_iterator(begin());
|
||||
}
|
||||
|
||||
template<class T, class Allocator> typename list<T, Allocator>::const_reverse_iterator
|
||||
list<T, Allocator>::rend() const
|
||||
{
|
||||
return const_reverse_iterator(begin());
|
||||
}
|
||||
|
||||
template<class T, class Allocator> bool list<T, Allocator>::empty() const{
|
||||
return (elements == 0);
|
||||
}
|
||||
template<class T, class Allocator> typename list<T, Allocator>::size_type list<T, Allocator>::size() const{
|
||||
return elements;
|
||||
}
|
||||
template<class T, class Allocator> typename list<T, Allocator>::size_type list<T, Allocator>::max_size() const{
|
||||
return ((size_type)(-1)) / (sizeof(T) + sizeof(node));
|
||||
}
|
||||
template<class T, class Allocator> void list<T, Allocator>::resize(typename Allocator::size_type sz, T c){
|
||||
// if(sz > elements){
|
||||
for(typename Allocator::size_type i = elements; i < sz; ++i){
|
||||
push_back(c);
|
||||
}
|
||||
// }
|
||||
// if(sz < elements){
|
||||
for(typename Allocator::size_type i = elements; i > sz; --i){
|
||||
pop_back();
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
template<class T, class Allocator> typename list<T, Allocator>::reference list<T, Allocator>::front(){
|
||||
return *(list_start->val);
|
||||
}
|
||||
template<class T, class Allocator> typename list<T, Allocator>::const_reference list<T, Allocator>::front() const{
|
||||
return *(list_start->val);
|
||||
}
|
||||
template<class T, class Allocator> typename list<T, Allocator>::reference list<T, Allocator>::back(){
|
||||
return *(list_end->previous->val);
|
||||
}
|
||||
template<class T, class Allocator> typename list<T, Allocator>::const_reference list<T, Allocator>::back() const{
|
||||
return *(list_end->previous->val);
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Allocator> void list<T, Allocator>::push_front(const T& x){
|
||||
node * temp = new node(x);
|
||||
list_start->previous = temp;
|
||||
temp->previous = 0;
|
||||
temp->next = list_start;
|
||||
list_start = temp;
|
||||
++elements;
|
||||
}
|
||||
|
||||
template<class T, class Allocator> void list<T, Allocator>::pop_front(){
|
||||
if(elements > 0){
|
||||
list_start = list_start->next;
|
||||
delete list_start->previous->val;
|
||||
#if UCLIBCXX_DEBUG
|
||||
list_start->previous->val = 0;
|
||||
list_start->previous->next = 0;
|
||||
list_start->previous->previous = 0;
|
||||
#endif
|
||||
delete list_start->previous;
|
||||
list_start->previous = 0;
|
||||
--elements;
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, class Allocator> void list<T, Allocator>::push_back(const T& x){
|
||||
if(elements == 0){
|
||||
//The list is completely empty
|
||||
list_start = new node(x);
|
||||
list_end->previous = list_start;
|
||||
list_start->previous = 0;
|
||||
list_start->next = list_end;
|
||||
elements = 1;
|
||||
}else{
|
||||
node * temp = new node(x);
|
||||
temp->previous = list_end->previous;
|
||||
temp->next = list_end;
|
||||
list_end->previous->next = temp;
|
||||
list_end->previous = temp;
|
||||
++elements;
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, class Allocator> void list<T, Allocator>::pop_back(){
|
||||
if(elements > 0){
|
||||
node * temp = list_end->previous;
|
||||
if(temp == list_start){
|
||||
list_end->previous = 0;
|
||||
list_start = list_end;
|
||||
}else{
|
||||
temp->previous->next = temp->next;
|
||||
list_end->previous = temp->previous;
|
||||
}
|
||||
delete temp->val;
|
||||
#if UCLIBCXX_DEBUG
|
||||
temp->val = 0;
|
||||
temp->next = 0;
|
||||
temp->previous = 0;
|
||||
#endif
|
||||
delete temp;
|
||||
#if UCLIBCXX_DEBUG
|
||||
temp = 0;
|
||||
#endif
|
||||
--elements;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Allocator> typename list<T, Allocator>::iterator
|
||||
list<T, Allocator>::insert(iterator position, const T& x)
|
||||
{
|
||||
node * temp = new node(x);
|
||||
|
||||
temp->previous = position.link_struct()->previous;
|
||||
temp->next = position.link_struct();
|
||||
|
||||
if(temp->previous == 0){
|
||||
list_start = temp;
|
||||
}else{
|
||||
position.link_struct()->previous->next = temp;
|
||||
}
|
||||
|
||||
position.link_struct()->previous = temp;
|
||||
|
||||
++elements;
|
||||
--position;
|
||||
return position;
|
||||
}
|
||||
|
||||
template<class T, class Allocator> void list<T, Allocator>::insert(iterator position, size_type n, const T& x){
|
||||
for(typename list<T, Allocator>::size_type i = 0; i < n; ++i){
|
||||
position = insert(position, x);
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, class Allocator> template <class InputIterator> void
|
||||
list<T, Allocator>::insert(iterator position, InputIterator first, InputIterator last)
|
||||
{
|
||||
while(first !=last){
|
||||
insert(position, *first);
|
||||
++first;
|
||||
}
|
||||
}
|
||||
template<class T, class Allocator> typename list<T, Allocator>::iterator
|
||||
list<T, Allocator>::erase(iterator position)
|
||||
{
|
||||
if(position != end() ){
|
||||
node * temp = position.link_struct();
|
||||
if(temp == list_start){
|
||||
++position;
|
||||
temp->next->previous = 0;
|
||||
list_start = temp->next;
|
||||
}else{
|
||||
--position;
|
||||
temp->next->previous = temp->previous;
|
||||
temp->previous->next = temp->next;
|
||||
++position;
|
||||
}
|
||||
delete temp->val;
|
||||
#if UCLIBCXX_DEBUG
|
||||
temp->next = 0;
|
||||
temp->previous = 0;
|
||||
temp->val = 0;
|
||||
#endif
|
||||
delete temp;
|
||||
#if UCLIBCXX_DEBUG
|
||||
temp = 0;
|
||||
#endif
|
||||
--elements;
|
||||
}
|
||||
return position;
|
||||
}
|
||||
template<class T, class Allocator> typename list<T, Allocator>::iterator
|
||||
list<T, Allocator>::erase(iterator position, iterator last)
|
||||
{
|
||||
iterator temp = position;
|
||||
while(position !=last){
|
||||
position = erase(position);
|
||||
}
|
||||
return position;
|
||||
}
|
||||
template<class T, class Allocator> void list<T, Allocator>::swap(list<T,Allocator>& l){
|
||||
node * temp;
|
||||
size_type tempel;
|
||||
|
||||
temp = list_start;
|
||||
list_start = l.list_start;
|
||||
l.list_start = temp;
|
||||
|
||||
temp = list_end;
|
||||
list_end = l.list_end;
|
||||
l.list_end = temp;
|
||||
|
||||
tempel = elements;
|
||||
elements = l.elements;
|
||||
l.elements = tempel;
|
||||
}
|
||||
template<class T, class Allocator> void list<T, Allocator>::clear(){
|
||||
while(elements > 0){
|
||||
pop_front();
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, class Allocator>
|
||||
void list<T, Allocator>::splice(iterator position, list<T,Allocator>& x)
|
||||
{
|
||||
|
||||
//Can't add non-existant elements
|
||||
if(x.elements == 0){
|
||||
return;
|
||||
}
|
||||
|
||||
elements += x.elements;
|
||||
x.elements = 0;
|
||||
|
||||
|
||||
//Chaining to the begining
|
||||
if(position == begin()){
|
||||
x.list_end->previous->next = list_start;
|
||||
list_start->previous = x.list_end->previous;
|
||||
|
||||
list_start = x.list_start;
|
||||
|
||||
x.list_start = x.list_end;
|
||||
x.list_end->previous = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//Link everything we need
|
||||
x.list_start->previous = position.link_struct()->previous;
|
||||
position.link_struct()->previous->next = x.list_start;
|
||||
|
||||
position.link_struct()->previous = x.list_end->previous;
|
||||
x.list_end->previous->next = position.link_struct();
|
||||
|
||||
//Clean up the other list
|
||||
|
||||
x.list_start = x.list_end;
|
||||
x.list_end->previous=0;
|
||||
|
||||
}
|
||||
|
||||
template<class T, class Allocator>
|
||||
void list<T, Allocator>::splice(iterator position, list<T,Allocator>& x, iterator i)
|
||||
{
|
||||
//Invalid conditions
|
||||
if( x.elements == 0 || i == position || position.link_struct() == i.link_struct()->next ){
|
||||
return;
|
||||
}
|
||||
|
||||
//Do we need to adjust the begining pointer?
|
||||
if(i == x.begin()){
|
||||
x.list_start = x.list_start->next;
|
||||
x.list_start->previous = 0;
|
||||
}
|
||||
|
||||
|
||||
//Insert at begining special case
|
||||
if(position == begin()){
|
||||
if (i.link_struct()->previous != 0)
|
||||
i.link_struct()->previous->next = i.link_struct()->next;
|
||||
i.link_struct()->next->previous = i.link_struct()->previous;
|
||||
|
||||
i.link_struct()->previous = 0;
|
||||
i.link_struct()->next = position.link_struct();
|
||||
position.link_struct()->previous = i.link_struct();
|
||||
|
||||
list_start = i.link_struct();
|
||||
|
||||
--x.elements;
|
||||
++elements;
|
||||
return;
|
||||
}
|
||||
|
||||
if( i.link_struct()->previous != 0){
|
||||
i.link_struct()->previous->next = i.link_struct()->next;
|
||||
i.link_struct()->next->previous = i.link_struct()->previous;
|
||||
}else{
|
||||
i.link_struct()->next->previous = 0;
|
||||
x.list_start = i.link_struct()->next;
|
||||
}
|
||||
|
||||
i.link_struct()->previous = position.link_struct()->previous;
|
||||
position.link_struct()->previous->next = i.link_struct();
|
||||
|
||||
i.link_struct()->next = position.link_struct();
|
||||
position.link_struct()->previous = i.link_struct();
|
||||
|
||||
--x.elements;
|
||||
++elements;
|
||||
}
|
||||
|
||||
template<class T, class Allocator>
|
||||
void list<T, Allocator>::splice(iterator position, list<T,Allocator>& x,
|
||||
iterator first, iterator last)
|
||||
{
|
||||
if(x.elements == 0){
|
||||
return;
|
||||
}
|
||||
|
||||
iterator temp;
|
||||
while(first != last){
|
||||
temp = first;
|
||||
++first;
|
||||
splice(position, x, temp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Allocator> void list<T, Allocator>::remove(const T& value){
|
||||
iterator temp = begin();
|
||||
while( temp != end() ){
|
||||
if(*temp == value){
|
||||
temp = erase(temp);
|
||||
}else{
|
||||
++temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Allocator> template <class Predicate> void list<T, Allocator>::remove_if(Predicate pred){
|
||||
iterator temp = begin();
|
||||
while( temp != end() ){
|
||||
if( pred(*temp) ){
|
||||
temp = erase(temp);
|
||||
}else{
|
||||
++temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Allocator> void list<T, Allocator>::unique(){
|
||||
equal_to<typename iterator_traits<iterator>::value_type> p;
|
||||
unique(p);
|
||||
}
|
||||
|
||||
template<class T, class Allocator> template <class BinaryPredicate>
|
||||
void list<T, Allocator>::unique(BinaryPredicate binary_pred)
|
||||
{
|
||||
iterator temp1 = begin();
|
||||
iterator temp2;
|
||||
++temp1;
|
||||
while( temp1 != end() ){
|
||||
temp2 = temp1;
|
||||
--temp2;
|
||||
if( binary_pred(*temp1, *temp2) ){
|
||||
erase(temp1);
|
||||
temp1 = temp2;
|
||||
}
|
||||
++temp1;
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, class Allocator> void list<T, Allocator>::merge(list<T,Allocator>& x){
|
||||
less<typename iterator_traits<typename list<T, Allocator>::iterator>::value_type> c;
|
||||
merge(x, c);
|
||||
}
|
||||
|
||||
template<class T, class Allocator> template <class Compare>
|
||||
void list<T, Allocator>::merge(list<T,Allocator>& x, Compare comp)
|
||||
{
|
||||
iterator source = x.begin();
|
||||
iterator temp;
|
||||
iterator dest = begin();
|
||||
|
||||
while(source != x.end()){
|
||||
while( dest != end() && comp (*dest, *source) ){
|
||||
++dest;
|
||||
}
|
||||
++elements;
|
||||
--x.elements;
|
||||
|
||||
temp = source;
|
||||
++temp;
|
||||
|
||||
if(dest == begin()){
|
||||
dest.link_struct()->previous = source.link_struct();
|
||||
source.link_struct()->next = dest.link_struct();
|
||||
source.link_struct()->previous = 0;
|
||||
list_start = source.link_struct();
|
||||
}else{
|
||||
source.link_struct()->previous = dest.link_struct()->previous;
|
||||
dest.link_struct()->previous->next = source.link_struct();
|
||||
source.link_struct()->next = dest.link_struct();
|
||||
dest.link_struct()->previous = source.link_struct();
|
||||
}
|
||||
source = temp;
|
||||
}
|
||||
|
||||
//Fix up x;
|
||||
x.list_start = x.list_end;
|
||||
x.list_start->previous = 0;
|
||||
}
|
||||
|
||||
template<class T, class Allocator> void list<T, Allocator>::sort(){
|
||||
less<typename iterator_traits<typename list<T, Allocator>::iterator>::value_type> c;
|
||||
sort(c);
|
||||
}
|
||||
|
||||
template<class T, class Allocator> template <class Compare>
|
||||
void list<T, Allocator>::sort(Compare comp)
|
||||
{
|
||||
typename list<T, Allocator>::iterator i, j, k;
|
||||
|
||||
//FIXME - bubble sort
|
||||
|
||||
if(elements == 0){
|
||||
return;
|
||||
}
|
||||
|
||||
i = end();
|
||||
--i;
|
||||
while(i != begin()){
|
||||
j = begin();
|
||||
k = j;
|
||||
++k;
|
||||
while(j != i){
|
||||
if( comp(*k, *j) ){
|
||||
swap_nodes(k.link_struct(), j.link_struct());
|
||||
}
|
||||
++j;
|
||||
++k;
|
||||
}
|
||||
--i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Allocator> void list<T, Allocator>::reverse(){
|
||||
if(elements == 0){
|
||||
return;
|
||||
}
|
||||
|
||||
node * current;
|
||||
node * following;
|
||||
node * temp;
|
||||
|
||||
//Need to move the list_end element to the begining
|
||||
|
||||
temp = list_end;
|
||||
list_end = temp->previous;
|
||||
list_end->next = 0;
|
||||
|
||||
list_start->previous = temp;
|
||||
temp->previous = 0;
|
||||
temp->next = list_start;
|
||||
list_start = temp;
|
||||
|
||||
current = list_start;
|
||||
|
||||
while( current != list_end ){
|
||||
following = current->next;
|
||||
|
||||
//Swap the values pointed to/at with the current node
|
||||
temp = current->next;
|
||||
current->next = current->previous;
|
||||
current->previous = temp;
|
||||
|
||||
current = following;
|
||||
}
|
||||
|
||||
//Swap pointers on the end node
|
||||
temp = list_end->next;
|
||||
list_end->next = list_end->previous;
|
||||
list_end->previous = temp;
|
||||
|
||||
|
||||
//Swap the fixed pointers
|
||||
temp = list_start;
|
||||
list_start = list_end;
|
||||
list_end = temp;
|
||||
|
||||
}
|
||||
|
||||
template <class T, class Allocator>
|
||||
bool operator==(const list<T,Allocator>& x, const list<T,Allocator>& y){
|
||||
if(x.size() != y.size()){
|
||||
return false;
|
||||
}
|
||||
typename list<T,Allocator>::const_iterator i = x.begin();
|
||||
typename list<T,Allocator>::const_iterator j = y.begin();
|
||||
|
||||
while(i != x.end()){
|
||||
if( *i != *j){
|
||||
return false;
|
||||
}
|
||||
++i;
|
||||
++j;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class T, class Allocator>
|
||||
bool operator< (const list<T,Allocator>& x, const list<T,Allocator>& y){
|
||||
typename list<T,Allocator>::const_iterator i = x.begin();
|
||||
typename list<T,Allocator>::const_iterator j = y.begin();
|
||||
while(i != x.end() && j != y.end()){
|
||||
if( *i < *j){
|
||||
return true;
|
||||
}
|
||||
if(*j < *i){
|
||||
return false;
|
||||
}
|
||||
++i;
|
||||
++j;
|
||||
}
|
||||
return (i == x.end() && j != y.end());
|
||||
}
|
||||
|
||||
template <class T, class Allocator>
|
||||
bool operator!=(const list<T,Allocator>& x, const list<T,Allocator>& y){
|
||||
return !(x == y);
|
||||
}
|
||||
|
||||
template <class T, class Allocator>
|
||||
bool operator> (const list<T,Allocator>& x, const list<T,Allocator>& y){
|
||||
typename list<T,Allocator>::const_iterator i = x.begin();
|
||||
typename list<T,Allocator>::const_iterator j = y.begin();
|
||||
while(i != x.end() && j != y.end()){
|
||||
if( *i > *j){
|
||||
return true;
|
||||
}
|
||||
if( *j > *i){
|
||||
return false;
|
||||
}
|
||||
++i;
|
||||
++j;
|
||||
}
|
||||
return (i != x.end() && j == y.end());
|
||||
}
|
||||
|
||||
template <class T, class Allocator>
|
||||
bool operator>=(const list<T,Allocator>& x, const list<T,Allocator>& y){
|
||||
typename list<T,Allocator>::const_iterator i = x.begin();
|
||||
typename list<T,Allocator>::const_iterator j = y.begin();
|
||||
while(i != x.end() && j != y.end()){
|
||||
if( *i >= *j){
|
||||
return true;
|
||||
}
|
||||
if(*j >= *i){
|
||||
return false;
|
||||
}
|
||||
++i;
|
||||
++j;
|
||||
}
|
||||
return (i != x.end() && j == y.end());
|
||||
}
|
||||
|
||||
template <class T, class Allocator>
|
||||
bool operator<=(const list<T,Allocator>& x, const list<T,Allocator>& y){
|
||||
typename list<T,Allocator>::const_iterator i = x.begin();
|
||||
typename list<T,Allocator>::const_iterator j = y.begin();
|
||||
while(i != x.end() && j != y.end()){
|
||||
if( *i <= *j){
|
||||
return true;
|
||||
}
|
||||
if(*j <= *i){
|
||||
return false;
|
||||
}
|
||||
++i;
|
||||
++j;
|
||||
}
|
||||
return (i == x.end());
|
||||
}
|
||||
|
||||
template <class T, class Allocator>
|
||||
void swap(list<T,Allocator>& x, list<T,Allocator>& y){
|
||||
x.swap(y);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#pragma GCC visibility pop
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
29
libraries/ArduinoSTL/src/list.cpp
Normal file
29
libraries/ArduinoSTL/src/list.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "list"
|
||||
|
||||
namespace std{
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
83
libraries/ArduinoSTL/src/locale
Normal file
83
libraries/ArduinoSTL/src/locale
Normal file
@@ -0,0 +1,83 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "basic_definitions"
|
||||
#include "cstddef"
|
||||
#include "string"
|
||||
|
||||
#ifndef __HEADER_STD_LOCALE
|
||||
#define __HEADER_STD_LOCALE 1
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
|
||||
namespace std{
|
||||
class _UCXXEXPORT locale {
|
||||
public:
|
||||
// types:
|
||||
class facet;
|
||||
class id;
|
||||
typedef unsigned char category;
|
||||
|
||||
static const category
|
||||
none = 0,
|
||||
collate = 0x01, ctype = 0x02,
|
||||
monetary = 0x04, numeric = 0x08,
|
||||
time = 0x10, messages = 0x20,
|
||||
all = collate | ctype | monetary | numeric | time | messages;
|
||||
|
||||
// construct/copy/destroy:
|
||||
locale() _UCXX_USE_NOEXCEPT{
|
||||
return;
|
||||
}
|
||||
locale(const locale& other) _UCXX_USE_NOEXCEPT{
|
||||
(void)other;
|
||||
return;
|
||||
}
|
||||
locale(const char *) _UCXX_USE_NOEXCEPT{
|
||||
return;
|
||||
}
|
||||
~locale() _UCXX_USE_NOEXCEPT{
|
||||
return;
|
||||
}
|
||||
|
||||
const locale& operator=(const locale&) _UCXX_USE_NOEXCEPT{
|
||||
return *this;
|
||||
}
|
||||
std::string name() const { return "C"; }
|
||||
};
|
||||
|
||||
class _UCXXEXPORT locale::facet {
|
||||
friend class locale;
|
||||
explicit facet(size_t = 0){
|
||||
return;
|
||||
}
|
||||
virtual ~facet(){
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
class _UCXXEXPORT locale::id {
|
||||
id(){ }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#pragma GCC visibility pop
|
||||
|
||||
#endif
|
||||
29
libraries/ArduinoSTL/src/locale.cpp
Normal file
29
libraries/ArduinoSTL/src/locale.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "locale"
|
||||
#include "cstring"
|
||||
#include "string"
|
||||
#include "stdexcept"
|
||||
#include "cctype"
|
||||
|
||||
namespace std{
|
||||
|
||||
}
|
||||
|
||||
269
libraries/ArduinoSTL/src/map
Normal file
269
libraries/ArduinoSTL/src/map
Normal file
@@ -0,0 +1,269 @@
|
||||
/* Copyright (C) 2004-2007 Garrett A. Kajmowicz
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "memory"
|
||||
#include "utility"
|
||||
#include "iterator"
|
||||
#include "associative_base"
|
||||
#include "initializer_list"
|
||||
|
||||
|
||||
#ifndef __STD_HEADER_MAP
|
||||
#define __STD_HEADER_MAP
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
|
||||
namespace std{
|
||||
|
||||
|
||||
template<class Key, class T, class Compare = less<Key>, class Allocator = allocator<T> > class map;
|
||||
template<class Key, class T, class Compare = less<Key>, class Allocator = allocator<T> > class multimap;
|
||||
|
||||
|
||||
//Compare the keys of the two items
|
||||
/* template<class Key, class T, class Compare, class Allocator> class _UCXXEXPORT
|
||||
__base_map<Key, T, Compare, Allocator>::value_compare : public binary_function<
|
||||
typename map<Key, T, Compare, Allocator>::value_type,
|
||||
typename map<Key, T, Compare, Allocator>::value_type,
|
||||
bool>
|
||||
{
|
||||
friend class __base_map<Key, T, Compare, Allocator>;
|
||||
protected:
|
||||
Compare comp;
|
||||
value_compare(Compare c) : comp(c) { }
|
||||
~value_compare() { }
|
||||
public:
|
||||
bool operator()(const value_type& x, const value_type& y) const {
|
||||
return comp(x.first, y.first);
|
||||
}
|
||||
};
|
||||
*/
|
||||
|
||||
// value_compare value_comp() const;
|
||||
|
||||
|
||||
|
||||
/* This is the implementation for the map container. As noted above, it deviates
|
||||
* from ISO spec by deriving from a base class in order to reduce code redundancy.
|
||||
* More code could be reduced by convirting to virtual functions (thus allowing
|
||||
* much of the erase and insert code to be duplicated), but that would deviate from
|
||||
* the specifications too much to be worth the risk.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
//Implementation of map
|
||||
|
||||
|
||||
template<class Key, class T, class Compare, class Allocator> class _UCXXEXPORT map
|
||||
: public __single_associative<Key, pair<Key, T>, Compare, Allocator>
|
||||
{
|
||||
//Default value of allocator does not meet C++ standard specs, but it works for this library
|
||||
//Deal with it
|
||||
|
||||
public:
|
||||
|
||||
typedef __single_associative<Key, pair<Key, T>, Compare, Allocator> base;
|
||||
typedef T mapped_type;
|
||||
typedef typename base::key_type key_type;
|
||||
typedef typename base::value_type value_type;
|
||||
typedef typename base::key_compare key_compare;
|
||||
typedef typename base::allocator_type allocator_type;
|
||||
typedef typename base::reference reference;
|
||||
typedef typename base::const_reference const_reference;
|
||||
typedef typename base::iterator iterator;
|
||||
typedef typename base::const_iterator const_iterator;
|
||||
typedef typename base::size_type size_type;
|
||||
typedef typename base::difference_type difference_type;
|
||||
typedef typename base::pointer pointer;
|
||||
typedef typename base::const_pointer const_pointer;
|
||||
typedef typename base::reverse_iterator reverse_iterator;
|
||||
typedef typename base::const_reverse_iterator const_reverse_iterator;
|
||||
|
||||
static const key_type v_t_k(const value_type v){
|
||||
return v.first;
|
||||
}
|
||||
|
||||
// using base::value_compare;
|
||||
|
||||
explicit map(const Compare& comp = Compare(), const Allocator& al = Allocator())
|
||||
: base(comp, al, v_t_k) { }
|
||||
|
||||
template <class InputIterator> map(InputIterator first, InputIterator last,
|
||||
const Compare& comp = Compare(), const Allocator& al = Allocator())
|
||||
: base(first, last, comp, al, v_t_k) { }
|
||||
|
||||
map(initializer_list<pair<Key, T>> in, const Compare& comp = Compare(),
|
||||
const Allocator& al = Allocator())
|
||||
: base(in.begin(), in.end(), comp, al, v_t_k) { }
|
||||
|
||||
map(const map<Key,T,Compare,Allocator>& x) : base(x) { }
|
||||
~map() { }
|
||||
|
||||
using base::operator=;
|
||||
using base::operator==;
|
||||
using base::operator!=;
|
||||
|
||||
using base::insert;
|
||||
using base::erase;
|
||||
|
||||
using base::begin;
|
||||
using base::end;
|
||||
using base::rbegin;
|
||||
using base::rend;
|
||||
|
||||
using base::empty;
|
||||
using base::size;
|
||||
using base::max_size;
|
||||
|
||||
using base::find;
|
||||
using base::count;
|
||||
using base::lower_bound;
|
||||
using base::upper_bound;
|
||||
using base::equal_range;
|
||||
using base::swap;
|
||||
|
||||
reference operator[](const key_type& k){
|
||||
iterator i = lower_bound(k);
|
||||
if (i == end() || base::c(k, i->first)) {
|
||||
i = insert(make_pair(k, T())).first;
|
||||
}
|
||||
return i->second;
|
||||
}
|
||||
|
||||
protected:
|
||||
using base::backing;
|
||||
};
|
||||
|
||||
|
||||
//Implementation of multimap
|
||||
|
||||
|
||||
template<class Key, class T, class Compare, class Allocator> class _UCXXEXPORT multimap
|
||||
: public __multi_associative<Key, pair<Key, T>, Compare, Allocator>
|
||||
|
||||
{
|
||||
//Default value of allocator does not meet C++ standard specs, but it works for this library
|
||||
//Deal with it
|
||||
public:
|
||||
|
||||
typedef __multi_associative<Key, pair<Key, T>, Compare, Allocator> base;
|
||||
typedef T mapped_type;
|
||||
typedef typename base::key_type key_type;
|
||||
typedef typename base::value_type value_type;
|
||||
typedef typename base::key_compare key_compare;
|
||||
typedef typename base::allocator_type allocator_type;
|
||||
typedef typename base::reference reference;
|
||||
typedef typename base::const_reference const_reference;
|
||||
typedef typename base::iterator iterator;
|
||||
typedef typename base::const_iterator const_iterator;
|
||||
typedef typename base::size_type size_type;
|
||||
typedef typename base::difference_type difference_type;
|
||||
typedef typename base::pointer pointer;
|
||||
typedef typename base::const_pointer const_pointer;
|
||||
typedef typename base::reverse_iterator reverse_iterator;
|
||||
typedef typename base::const_reverse_iterator const_reverse_iterator;
|
||||
|
||||
static const key_type v_t_k(const value_type v){
|
||||
return v.first;
|
||||
}
|
||||
|
||||
explicit multimap(const Compare& comp = Compare(), const Allocator& al = Allocator())
|
||||
: base(comp, al, v_t_k) { }
|
||||
|
||||
template <class InputIterator> multimap(InputIterator first, InputIterator last,
|
||||
const Compare& comp = Compare(), const Allocator& al = Allocator())
|
||||
: base(first, last, comp, al, v_t_k) { }
|
||||
|
||||
|
||||
multimap(const multimap<Key,T,Compare,Allocator>& x) : base(x) { }
|
||||
~multimap() { }
|
||||
|
||||
using base::operator=;
|
||||
using base::operator==;
|
||||
using base::operator!=;
|
||||
|
||||
using base::insert;
|
||||
using base::erase;
|
||||
|
||||
using base::begin;
|
||||
using base::end;
|
||||
using base::rbegin;
|
||||
using base::rend;
|
||||
|
||||
using base::empty;
|
||||
using base::size;
|
||||
using base::max_size;
|
||||
|
||||
using base::find;
|
||||
using base::count;
|
||||
using base::lower_bound;
|
||||
using base::upper_bound;
|
||||
using base::equal_range;
|
||||
using base::swap;
|
||||
|
||||
protected:
|
||||
|
||||
using base::c;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/* Non-member functions. These are at the end because they are not associated with any
|
||||
particular class. These will be implemented as I figure out exactly what all of
|
||||
them are supposed to do, and I have time.
|
||||
*/
|
||||
|
||||
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator<
|
||||
(const map<Key,T,Compare,Allocator>& x, const map<Key,T,Compare,Allocator>& y);
|
||||
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator!=
|
||||
(const map<Key,T,Compare,Allocator>& x, const map<Key,T,Compare,Allocator>& y);
|
||||
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator>
|
||||
(const map<Key,T,Compare,Allocator>& x, const map<Key,T,Compare,Allocator>& y);
|
||||
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator>=
|
||||
(const map<Key,T,Compare,Allocator>& x, const map<Key,T,Compare,Allocator>& y);
|
||||
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator<=
|
||||
(const map<Key,T,Compare,Allocator>& x, const map<Key,T,Compare,Allocator>& y);
|
||||
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT void swap
|
||||
(map<Key,T,Compare,Allocator>& x, map<Key,T,Compare,Allocator>& y);
|
||||
|
||||
|
||||
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator==
|
||||
(const multimap<Key,T,Compare,Allocator>& x, const multimap<Key,T,Compare,Allocator>& y);
|
||||
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator<
|
||||
(const multimap<Key,T,Compare,Allocator>& x, const multimap<Key,T,Compare,Allocator>& y);
|
||||
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator!=
|
||||
(const multimap<Key,T,Compare,Allocator>& x, const multimap<Key,T,Compare,Allocator>& y);
|
||||
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator>
|
||||
(const multimap<Key,T,Compare,Allocator>& x, const multimap<Key,T,Compare,Allocator>& y);
|
||||
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator>=
|
||||
(const multimap<Key,T,Compare,Allocator>& x, const multimap<Key,T,Compare,Allocator>& y);
|
||||
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator<=
|
||||
(const multimap<Key,T,Compare,Allocator>& x, const multimap<Key,T,Compare,Allocator>& y);
|
||||
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT void swap
|
||||
(multimap<Key,T,Compare,Allocator>& x, multimap<Key,T,Compare,Allocator>& y);
|
||||
|
||||
}
|
||||
|
||||
#pragma GCC visibility pop
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
33
libraries/ArduinoSTL/src/map.cpp
Normal file
33
libraries/ArduinoSTL/src/map.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "map"
|
||||
|
||||
namespace std{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
196
libraries/ArduinoSTL/src/memory
Normal file
196
libraries/ArduinoSTL/src/memory
Normal file
@@ -0,0 +1,196 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "new"
|
||||
#include "cstddef"
|
||||
#include "cstdlib"
|
||||
#include "iterator_base"
|
||||
#include "utility"
|
||||
#include "cstdio"
|
||||
|
||||
#ifndef HEADER_STD_MEMORY
|
||||
#define HEADER_STD_MEMORY 1
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
|
||||
namespace std{
|
||||
|
||||
template <class T> class allocator;
|
||||
// Specialize for void:
|
||||
|
||||
template <> class _UCXXEXPORT allocator<void> {
|
||||
public:
|
||||
typedef void* pointer;
|
||||
typedef const void* const_pointer;
|
||||
typedef void value_type;
|
||||
template <class U> struct rebind { typedef allocator<U> other; };
|
||||
};
|
||||
|
||||
template <class T> class _UCXXEXPORT allocator{
|
||||
public:
|
||||
typedef T value_type;
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
|
||||
typedef T* pointer;
|
||||
typedef const T* const_pointer;
|
||||
|
||||
typedef T& reference;
|
||||
typedef const T& const_reference;
|
||||
|
||||
pointer address(reference r) const { return &r; }
|
||||
const_pointer address(const_reference r) const { return &r; }
|
||||
|
||||
allocator() _UCXX_USE_NOEXCEPT{}
|
||||
template <class U> allocator(const allocator<U>& ) _UCXX_USE_NOEXCEPT;
|
||||
~allocator() _UCXX_USE_NOEXCEPT{}
|
||||
|
||||
//Space for n Ts
|
||||
pointer allocate(size_type n, typename allocator<void>::const_pointer = 0){
|
||||
return static_cast<T*>(::operator new( n * sizeof(T) ));
|
||||
}
|
||||
void deallocate(pointer p, size_type){
|
||||
::operator delete(p);
|
||||
}
|
||||
|
||||
//Use placement new to engage the constructor
|
||||
void construct(pointer p, const T& val) { new(static_cast<void*>(p)) T(val); }
|
||||
void destroy(pointer p){ (static_cast<T*>(p))->~T(); } //Call destructor
|
||||
|
||||
size_type max_size() const _UCXX_USE_NOEXCEPT;
|
||||
template<class U> struct rebind { typedef allocator<U> other; };
|
||||
|
||||
};
|
||||
|
||||
template <class Out, class T> class _UCXXEXPORT raw_storage_iterator
|
||||
: public iterator<output_iterator_tag, void, void, void, void>
|
||||
{
|
||||
Out p;
|
||||
|
||||
public:
|
||||
explicit raw_storage_iterator(Out pp) : p (pp) { }
|
||||
raw_storage_iterator & operator*() { return *this; }
|
||||
raw_storage_iterator & operator=(const T& val) {
|
||||
T* pp = &*p;
|
||||
new(pp) T(val);
|
||||
return *this;
|
||||
}
|
||||
|
||||
raw_storage_iterator & operator++() { ++p; return *this; }
|
||||
raw_storage_iterator operator++(int) {
|
||||
raw_storage_iterator t = *this;
|
||||
++p;
|
||||
return t;
|
||||
}
|
||||
};
|
||||
|
||||
template <class T> _UCXXEXPORT pair<T*, ptrdiff_t> get_temporary_buffer(ptrdiff_t n){
|
||||
pair<T*, ptrdiff_t> retval;
|
||||
retval.first = static_cast<T*>(malloc(n * sizeof(T)));
|
||||
if(retval.first == 0){
|
||||
retval.second = 0;
|
||||
}else{
|
||||
retval.second = n;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
template <class T> _UCXXEXPORT void return_temporary_buffer(T* p){
|
||||
free(p);
|
||||
}
|
||||
|
||||
|
||||
template <class T> class _UCXXEXPORT auto_ptr{
|
||||
|
||||
private:
|
||||
T * object;
|
||||
template <class Y> struct auto_ptr_ref{
|
||||
Y * p;
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
typedef T element_type;
|
||||
|
||||
explicit auto_ptr(T* p =0) _UCXX_USE_NOEXCEPT : object(p){ }
|
||||
auto_ptr(auto_ptr& p) _UCXX_USE_NOEXCEPT : object(p.release()){ }
|
||||
auto_ptr(auto_ptr_ref<T> r) _UCXX_USE_NOEXCEPT : object(r.p){
|
||||
r.p = 0;
|
||||
}
|
||||
template<class Y> auto_ptr(auto_ptr<Y>& p) _UCXX_USE_NOEXCEPT : object(p.release()){ }
|
||||
auto_ptr& operator=(auto_ptr& p) _UCXX_USE_NOEXCEPT{
|
||||
if(&p == this){
|
||||
return *this;
|
||||
}
|
||||
delete object;
|
||||
object = p.release();
|
||||
return *this;
|
||||
}
|
||||
template<class Y> auto_ptr& operator=(auto_ptr<Y>& p) _UCXX_USE_NOEXCEPT{
|
||||
if(&p == this){
|
||||
return *this;
|
||||
}
|
||||
delete object;
|
||||
object = p.release();
|
||||
return *this;
|
||||
}
|
||||
~auto_ptr(){
|
||||
delete object;
|
||||
}
|
||||
|
||||
T& operator*() const _UCXX_USE_NOEXCEPT{
|
||||
return *object;
|
||||
}
|
||||
T* operator->() const _UCXX_USE_NOEXCEPT{
|
||||
return object;
|
||||
}
|
||||
T* get() const _UCXX_USE_NOEXCEPT{
|
||||
return object;
|
||||
}
|
||||
T* release() _UCXX_USE_NOEXCEPT{
|
||||
T * temp(object);
|
||||
object = 0;
|
||||
return temp;
|
||||
}
|
||||
void reset(T * p=0) _UCXX_USE_NOEXCEPT{
|
||||
if(p != object){
|
||||
delete object;
|
||||
object = p;
|
||||
}
|
||||
}
|
||||
template<class Y> operator auto_ptr_ref<Y>() _UCXX_USE_NOEXCEPT{
|
||||
auto_ptr_ref<Y> retval;
|
||||
retval.p = object;
|
||||
object = 0;
|
||||
return retval;
|
||||
}
|
||||
template<class Y> operator auto_ptr<Y>() _UCXX_USE_NOEXCEPT{
|
||||
auto_ptr<Y> retval(object);
|
||||
object = 0;
|
||||
return retval;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} //namespace std
|
||||
|
||||
#pragma GCC visibility pop
|
||||
|
||||
#endif
|
||||
|
||||
70
libraries/ArduinoSTL/src/new
Normal file
70
libraries/ArduinoSTL/src/new
Normal file
@@ -0,0 +1,70 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "basic_definitions"
|
||||
#include "exception"
|
||||
#include "cstddef"
|
||||
|
||||
#ifndef __STD_NEW_OPERATOR
|
||||
#define __STD_NEW_OPERATOR 1
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
|
||||
namespace std{
|
||||
class _UCXXEXPORT bad_alloc : public exception {};
|
||||
|
||||
struct _UCXXEXPORT nothrow_t {};
|
||||
extern const nothrow_t nothrow;
|
||||
|
||||
typedef void (*new_handler)();
|
||||
_UCXXEXPORT new_handler set_new_handler(new_handler new_p) _UCXX_USE_NOEXCEPT;
|
||||
}
|
||||
|
||||
|
||||
_UCXXEXPORT void* operator new(std::size_t numBytes) _UCXX_THROW(std::bad_alloc);
|
||||
_UCXXEXPORT void operator delete(void* ptr) _UCXX_USE_NOEXCEPT;
|
||||
#ifdef __cpp_sized_deallocation
|
||||
_UCXXEXPORT void operator delete(void* ptr, std::size_t) _UCXX_USE_NOEXCEPT;
|
||||
#endif
|
||||
|
||||
_UCXXEXPORT void* operator new[](std::size_t numBytes) _UCXX_THROW(std::bad_alloc);
|
||||
_UCXXEXPORT void operator delete[](void * ptr) _UCXX_USE_NOEXCEPT;
|
||||
#ifdef __cpp_sized_deallocation
|
||||
_UCXXEXPORT void operator delete[](void * ptr, std::size_t) _UCXX_USE_NOEXCEPT;
|
||||
#endif
|
||||
|
||||
#ifndef NO_NOTHROW
|
||||
_UCXXEXPORT void* operator new(std::size_t numBytes, const std::nothrow_t& ) _UCXX_USE_NOEXCEPT;
|
||||
_UCXXEXPORT void operator delete(void* ptr, const std::nothrow_t& ) _UCXX_USE_NOEXCEPT;
|
||||
|
||||
_UCXXEXPORT void* operator new[](std::size_t numBytes, const std::nothrow_t& ) _UCXX_USE_NOEXCEPT;
|
||||
_UCXXEXPORT void operator delete[](void* ptr, const std::nothrow_t& ) _UCXX_USE_NOEXCEPT;
|
||||
#endif
|
||||
|
||||
/* Placement operators */
|
||||
inline void* operator new(std::size_t, void* ptr) _UCXX_USE_NOEXCEPT {return ptr; }
|
||||
inline void operator delete(void* , void *) _UCXX_USE_NOEXCEPT { }
|
||||
|
||||
inline void* operator new[](std::size_t, void *p) _UCXX_USE_NOEXCEPT { return p; }
|
||||
inline void operator delete[](void* , void *) _UCXX_USE_NOEXCEPT {}
|
||||
|
||||
#pragma GCC visibility pop
|
||||
|
||||
#endif
|
||||
|
||||
31
libraries/ArduinoSTL/src/new_handler.cpp
Normal file
31
libraries/ArduinoSTL/src/new_handler.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
/* Copyright (C) 2005 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "new"
|
||||
|
||||
const std::nothrow_t std::nothrow = { };
|
||||
|
||||
//Name selected to be compatable with g++ code
|
||||
std::new_handler __new_handler;
|
||||
|
||||
_UCXXEXPORT std::new_handler std::set_new_handler(std::new_handler new_p) _UCXX_USE_NOEXCEPT{
|
||||
std::new_handler retval = __new_handler;
|
||||
__new_handler = new_p;
|
||||
return retval;
|
||||
}
|
||||
41
libraries/ArduinoSTL/src/new_op.cpp
Normal file
41
libraries/ArduinoSTL/src/new_op.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
// Arduino 1.0 contains an implementation for this.
|
||||
#if ARDUINO < 100
|
||||
|
||||
#include <new>
|
||||
#include <cstdlib>
|
||||
#include <func_exception>
|
||||
|
||||
_UCXXEXPORT void* operator new(std::size_t numBytes) _UCXX_THROW(std::bad_alloc)
|
||||
{
|
||||
//C++ stardard 5.3.4.8 requires that a valid pointer be returned for
|
||||
//a call to new(0). Thus:
|
||||
if(numBytes == 0){
|
||||
numBytes = 1;
|
||||
}
|
||||
void * p = malloc(numBytes);
|
||||
if(p == 0){
|
||||
std::__throw_bad_alloc();
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
#endif
|
||||
28
libraries/ArduinoSTL/src/new_opnt.cpp
Normal file
28
libraries/ArduinoSTL/src/new_opnt.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "new"
|
||||
#include "cstdlib"
|
||||
#include "func_exception"
|
||||
|
||||
#ifndef NO_NOTHROW
|
||||
_UCXXEXPORT void* operator new(std::size_t numBytes, const std::nothrow_t& ) _UCXX_USE_NOEXCEPT{
|
||||
return malloc(numBytes);
|
||||
}
|
||||
#endif
|
||||
40
libraries/ArduinoSTL/src/new_opv.cpp
Normal file
40
libraries/ArduinoSTL/src/new_opv.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
// Arduino 1.0 contains an implementation for this.
|
||||
#if ARDUINO < 100
|
||||
|
||||
#include <new>
|
||||
#include <cstdlib>
|
||||
#include <func_exception>
|
||||
|
||||
_UCXXEXPORT void* operator new[](std::size_t numBytes)_UCXX_THROW(std::bad_alloc){
|
||||
//C++ stardard 5.3.4.8 requires that a valid pointer be returned for
|
||||
//a call to new(0). Thus:
|
||||
if(numBytes == 0){
|
||||
numBytes = 1;
|
||||
}
|
||||
void * p = malloc(numBytes);
|
||||
if(p == 0){
|
||||
std::__throw_bad_alloc();
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
#endif
|
||||
28
libraries/ArduinoSTL/src/new_opvnt.cpp
Normal file
28
libraries/ArduinoSTL/src/new_opvnt.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "new"
|
||||
#include "cstdlib"
|
||||
#include "func_exception"
|
||||
|
||||
#ifndef NO_NOTHROW
|
||||
_UCXXEXPORT void* operator new[](std::size_t numBytes, const std::nothrow_t& ) _UCXX_USE_NOEXCEPT{
|
||||
return malloc(numBytes);
|
||||
}
|
||||
#endif
|
||||
161
libraries/ArduinoSTL/src/numeric
Normal file
161
libraries/ArduinoSTL/src/numeric
Normal file
@@ -0,0 +1,161 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "basic_definitions"
|
||||
#include "exception"
|
||||
|
||||
#ifndef __STD_NUMERIC_HEADER
|
||||
#define __STD_NUMERIC_HEADER 1
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
|
||||
namespace std{
|
||||
template <class InputIterator, class T> _UCXXEXPORT
|
||||
T accumulate(InputIterator first, InputIterator last, T init)
|
||||
{
|
||||
while(first != last){
|
||||
init = init + *first;
|
||||
++first;
|
||||
}
|
||||
return init;
|
||||
}
|
||||
|
||||
template <class InputIterator, class T, class BinaryOperation> _UCXXEXPORT
|
||||
T accumulate(InputIterator first, InputIterator last, T init, BinaryOperation binary_op)
|
||||
{
|
||||
while(first != last){
|
||||
init = binary_op(init, *first);
|
||||
++first;
|
||||
}
|
||||
return init;
|
||||
}
|
||||
|
||||
|
||||
template <class InputIterator1, class InputIterator2, class T> _UCXXEXPORT
|
||||
T inner_product(InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2, T init)
|
||||
{
|
||||
while(first1 != last1){
|
||||
init = init + *first1 * *first2;
|
||||
++first1;
|
||||
++first2;
|
||||
}
|
||||
return init;
|
||||
}
|
||||
|
||||
template <class InputIterator1, class InputIterator2, class T,
|
||||
class BinaryOperation1, class BinaryOperation2> _UCXXEXPORT
|
||||
T inner_product(InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2, T init,
|
||||
BinaryOperation1 binary_op1,
|
||||
BinaryOperation2 binary_op2)
|
||||
{
|
||||
while(first1 != last1){
|
||||
init = binary_op1(init, binary_op2(*first1, *first2));
|
||||
++first1;
|
||||
++first2;
|
||||
}
|
||||
return init;
|
||||
}
|
||||
|
||||
template <class InputIterator, class OutputIterator> _UCXXEXPORT
|
||||
OutputIterator partial_sum(InputIterator first, InputIterator last,
|
||||
OutputIterator result)
|
||||
{
|
||||
OutputIterator temp(result);
|
||||
*result = *first;
|
||||
++first;
|
||||
++result;
|
||||
|
||||
while(first != last){
|
||||
*result = *first + *temp;
|
||||
temp = result;
|
||||
++first;
|
||||
++result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
template <class InputIterator, class OutputIterator, class BinaryOperation> _UCXXEXPORT
|
||||
OutputIterator partial_sum(InputIterator first, InputIterator last,
|
||||
OutputIterator result, BinaryOperation binary_op)
|
||||
{
|
||||
OutputIterator temp(result);
|
||||
*result = *first;
|
||||
++first;
|
||||
++result;
|
||||
|
||||
while(first != last){
|
||||
*result = binary_op(*first, *temp);
|
||||
temp = result;
|
||||
++first;
|
||||
++result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
template <class InputIterator, class OutputIterator> _UCXXEXPORT
|
||||
OutputIterator
|
||||
adjacent_difference(InputIterator first, InputIterator last,
|
||||
OutputIterator result)
|
||||
{
|
||||
OutputIterator temp(first);
|
||||
*result = *first;
|
||||
++first;
|
||||
++result;
|
||||
|
||||
while(first != last){
|
||||
*result = *first - *temp;
|
||||
temp = first;
|
||||
++first;
|
||||
++result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
template <class InputIterator, class OutputIterator, class BinaryOperation> _UCXXEXPORT
|
||||
OutputIterator
|
||||
adjacent_difference(InputIterator first, InputIterator last,
|
||||
OutputIterator result, BinaryOperation binary_op)
|
||||
{
|
||||
OutputIterator temp(first);
|
||||
*result = *first;
|
||||
++first;
|
||||
++result;
|
||||
|
||||
while(first != last){
|
||||
*result = binary_op(*first, *temp);
|
||||
temp = first;
|
||||
++first;
|
||||
++result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#pragma GCC visibility pop
|
||||
|
||||
#endif
|
||||
|
||||
27
libraries/ArduinoSTL/src/numeric.cpp
Normal file
27
libraries/ArduinoSTL/src/numeric.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "numeric"
|
||||
|
||||
namespace std{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
522
libraries/ArduinoSTL/src/ostream
Normal file
522
libraries/ArduinoSTL/src/ostream
Normal file
@@ -0,0 +1,522 @@
|
||||
/* Copyright (C) 2004-2008 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "basic_definitions"
|
||||
|
||||
#ifndef STD_HEADER_OSTREAM
|
||||
#define STD_HEADER_OSTREAM 1
|
||||
|
||||
#include "iosfwd"
|
||||
#include "streambuf"
|
||||
#include "cstdio"
|
||||
#include "ostream_helpers"
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
|
||||
namespace std {
|
||||
template <class charT, class traits > class basic_ostream;
|
||||
typedef basic_ostream<char> ostream;
|
||||
|
||||
#ifdef __UCLIBCXX_HAS_WCHAR__
|
||||
typedef basic_ostream<wchar_t> wostream;
|
||||
#endif
|
||||
|
||||
template <class charT, class traits> basic_ostream<charT,traits>& endl(basic_ostream<charT,traits>& os);
|
||||
template <class charT, class traits> basic_ostream<charT,traits>& ends(basic_ostream<charT,traits>& os);
|
||||
template <class charT, class traits> basic_ostream<charT,traits>& flush(basic_ostream<charT,traits>& os);
|
||||
|
||||
template <class charT, class traits > class _UCXXEXPORT basic_ostream
|
||||
: virtual public basic_ios<charT,traits>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef charT char_type;
|
||||
typedef typename traits::int_type int_type;
|
||||
typedef typename traits::pos_type pos_type;
|
||||
typedef typename traits::off_type off_type;
|
||||
typedef traits traits_type;
|
||||
|
||||
|
||||
_UCXXEXPORT basic_ostream(basic_streambuf<charT,traits>* sb)
|
||||
: basic_ios<charT, traits>(sb)
|
||||
{
|
||||
basic_ios<charT,traits>::init(sb);
|
||||
}
|
||||
virtual _UCXXEXPORT ~basic_ostream();
|
||||
|
||||
class sentry;
|
||||
|
||||
_UCXXEXPORT basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& (*pf)(basic_ostream<charT,traits>&)){
|
||||
return pf(*this);
|
||||
}
|
||||
_UCXXEXPORT basic_ostream<charT,traits>& operator<<(basic_ios<charT,traits>& (*pf)(basic_ios<charT,traits>&)){
|
||||
pf(*this);
|
||||
return *this;
|
||||
}
|
||||
_UCXXEXPORT basic_ostream<charT,traits>& operator<<(ios_base& (*pf)(ios_base&)){
|
||||
pf(*this);
|
||||
return *this;
|
||||
}
|
||||
basic_ostream<charT,traits>& operator<<(bool n);
|
||||
basic_ostream<charT,traits>& operator<<(short n);
|
||||
basic_ostream<charT,traits>& operator<<(unsigned short n);
|
||||
basic_ostream<charT,traits>& operator<<(int n);
|
||||
basic_ostream<charT,traits>& operator<<(unsigned int n);
|
||||
basic_ostream<charT,traits>& operator<<(long n);
|
||||
basic_ostream<charT,traits>& operator<<(unsigned long n);
|
||||
basic_ostream<charT,traits>& operator<<(float f);
|
||||
basic_ostream<charT,traits>& operator<<(double f);
|
||||
basic_ostream<charT,traits>& operator<<(long double f);
|
||||
basic_ostream<charT,traits>& operator<<(void* p);
|
||||
basic_ostream<charT,traits>& operator<<(basic_streambuf<char_type,traits>* sb);
|
||||
#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
|
||||
basic_ostream<charT,traits>& operator<<(long long n);
|
||||
basic_ostream<charT,traits>& operator<<(unsigned long long n);
|
||||
#endif
|
||||
|
||||
_UCXXEXPORT basic_ostream<charT,traits>& put(char_type c){
|
||||
if(basic_ostream<charT,traits>::traits_type::eq_int_type(
|
||||
basic_ios<charT, traits>::mstreambuf->sputc(c),
|
||||
basic_ostream<charT,traits>::traits_type::eof()))
|
||||
{
|
||||
basic_ios<charT,traits>::setstate(ios_base::eofbit);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
_UCXXEXPORT basic_ostream<charT,traits>& write(const char_type* s, streamsize n){
|
||||
if(basic_ostream<charT,traits>::traits_type::eq_int_type(
|
||||
basic_ios<charT, traits>::mstreambuf->sputn(s, n),
|
||||
basic_ostream<charT,traits>::traits_type::eof())
|
||||
){
|
||||
basic_ios<charT,traits>::setstate(ios_base::eofbit);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
_UCXXEXPORT basic_ostream<charT,traits>& flush(){
|
||||
if(basic_ios<charT, traits>::mstreambuf->pubsync() == -1){
|
||||
basic_ios<charT,traits>::setstate(ios_base::badbit);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
_UCXXEXPORT pos_type tellp(){
|
||||
if(basic_ios<charT,traits>::fail() != false){
|
||||
return pos_type(-1);
|
||||
}
|
||||
return basic_ios<charT,traits>::rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out);
|
||||
}
|
||||
_UCXXEXPORT basic_ostream<charT,traits>& seekp(pos_type pos){
|
||||
if( basic_ios<charT,traits>::fail() != true ){
|
||||
basic_ios<charT,traits>::rdbuf()->pubseekpos(pos);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
_UCXXEXPORT basic_ostream<charT,traits>& seekp(off_type off, ios_base::seekdir dir){
|
||||
if( basic_ios<charT,traits>::fail() != true){
|
||||
basic_ios<charT,traits>::rdbuf()->pubseekoff(off, dir);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
_UCXXEXPORT void printout(const char_type* s, streamsize n){
|
||||
streamsize extra = ios::width() - n;
|
||||
if ((ios::flags()&ios::adjustfield) == ios::right){
|
||||
while (extra > 0) {
|
||||
--extra;
|
||||
put(ios::fill());
|
||||
}
|
||||
}
|
||||
write(s, n);
|
||||
if ((ios::flags()&ios::adjustfield) == ios::left) {
|
||||
while (extra > 0) {
|
||||
--extra;
|
||||
put(ios::fill());
|
||||
}
|
||||
}
|
||||
// Width value only applies for the next output operation. Reset to zero.
|
||||
ios::width(0);
|
||||
}
|
||||
|
||||
protected:
|
||||
basic_ostream(const basic_ostream<charT,traits> &){ }
|
||||
basic_ostream<charT,traits> & operator=(const basic_ostream<charT,traits> &){ return *this; }
|
||||
};
|
||||
|
||||
//Implementations of template functions. To allow for partial specialization
|
||||
|
||||
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>::~basic_ostream(){ }
|
||||
|
||||
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>& basic_ostream<charT, traits>::operator<<(bool n){
|
||||
sentry s(*this);
|
||||
if( basic_ios<charT,traits>::flags() & ios_base::boolalpha){
|
||||
if(n){
|
||||
printout("true", 4);
|
||||
}else{
|
||||
printout("false", 5);
|
||||
}
|
||||
}else{
|
||||
if(n){
|
||||
printout("1", 1);
|
||||
}else{
|
||||
printout("0", 1);
|
||||
}
|
||||
}
|
||||
if(basic_ios<charT,traits>::flags() & ios_base::unitbuf){
|
||||
flush();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>&
|
||||
basic_ostream<charT, traits>::operator<<(unsigned short n){
|
||||
sentry s(*this);
|
||||
__ostream_printout<traits, charT, unsigned long int>::printout(*this, n);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>& basic_ostream<charT, traits>::operator<<(short n){
|
||||
sentry s(*this);
|
||||
__ostream_printout<traits, charT, long int>::printout(*this, n);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>& basic_ostream<charT, traits>::operator<<(int n){
|
||||
sentry s(*this);
|
||||
__ostream_printout<traits, charT, long int>::printout(*this, n);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>& basic_ostream<charT, traits>::operator<<(unsigned int n){
|
||||
sentry s(*this);
|
||||
__ostream_printout<traits, charT, unsigned long int>::printout(*this, n);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>& basic_ostream<charT, traits>::operator<<(long n){
|
||||
sentry s(*this);
|
||||
__ostream_printout<traits, charT, long >::printout(*this, n);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>&
|
||||
basic_ostream<charT, traits>::operator<<(unsigned long n)
|
||||
{
|
||||
sentry s(*this);
|
||||
__ostream_printout<traits, charT, unsigned long >::printout(*this, n);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
|
||||
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>& basic_ostream<charT, traits>::operator<<(long long n)
|
||||
{
|
||||
sentry s(*this);
|
||||
__ostream_printout<traits, charT, long long >::printout(*this, n);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>& basic_ostream<charT, traits>::operator<<(unsigned long long n)
|
||||
{
|
||||
sentry s(*this);
|
||||
__ostream_printout<traits, charT, unsigned long long >::printout(*this, n);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>& basic_ostream<charT, traits>::operator<<(float f){
|
||||
sentry s(*this);
|
||||
__ostream_printout<traits, charT, double >::printout(*this, f);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>& basic_ostream<charT, traits>::operator<<(double f){
|
||||
sentry s(*this);
|
||||
__ostream_printout<traits, charT, double >::printout(*this, f);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>& basic_ostream<charT, traits>::operator<<(long double f){
|
||||
sentry s(*this);
|
||||
__ostream_printout<traits, charT, long double >::printout(*this, f);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>& basic_ostream<charT, traits>::operator<<(void* p){
|
||||
sentry s(*this);
|
||||
char buffer[20];
|
||||
printout(buffer, snprintf(buffer, 20, "%p", p) );
|
||||
if(basic_ios<charT,traits>::flags() & ios_base::unitbuf){
|
||||
flush();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>&
|
||||
basic_ostream<charT, traits>::operator<<(basic_streambuf<charT,traits>* sb)
|
||||
{
|
||||
sentry s(*this);
|
||||
if(sb == 0){
|
||||
basic_ios<charT,traits>::setstate(ios_base::badbit);
|
||||
return *this;
|
||||
}
|
||||
|
||||
typename traits::int_type c;
|
||||
|
||||
while(basic_ios<charT,traits>::good() && (c = sb->sbumpc()) != traits::eof() ){
|
||||
put(c);
|
||||
}
|
||||
|
||||
if(basic_ios<charT,traits>::flags() & ios_base::unitbuf){
|
||||
flush();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/*Template Specializations*/
|
||||
|
||||
#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__
|
||||
#ifndef __UCLIBCXX_COMPILE_OSTREAM__
|
||||
|
||||
#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
|
||||
|
||||
template <> _UCXXEXPORT ostream::~basic_ostream();
|
||||
|
||||
#endif // __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
|
||||
|
||||
template <> _UCXXEXPORT ostream & ostream::flush();
|
||||
|
||||
template <> _UCXXEXPORT ostream & ostream::operator<<(bool n);
|
||||
template <> _UCXXEXPORT ostream & ostream::operator<<(short int n);
|
||||
template <> _UCXXEXPORT ostream & ostream::operator<<(unsigned short int n);
|
||||
template <> _UCXXEXPORT ostream & ostream::operator<<(int n);
|
||||
template <> _UCXXEXPORT ostream & ostream::operator<<(unsigned int n);
|
||||
template <> _UCXXEXPORT ostream & ostream::operator<<(long n);
|
||||
template <> _UCXXEXPORT ostream & ostream::operator<<(unsigned long n);
|
||||
template <> _UCXXEXPORT ostream & ostream::operator<<(float f);
|
||||
template <> _UCXXEXPORT ostream & ostream::operator<<(double f);
|
||||
template <> _UCXXEXPORT ostream & ostream::operator<<(long double f);
|
||||
template <> _UCXXEXPORT ostream & ostream::operator<<(void* p);
|
||||
template <> _UCXXEXPORT ostream & ostream::operator<<(basic_streambuf<char, char_traits<char> >* sb);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
template <class charT,class traits>
|
||||
class _UCXXEXPORT basic_ostream<charT,traits>::sentry
|
||||
{
|
||||
bool ok;
|
||||
public:
|
||||
explicit _UCXXEXPORT sentry(basic_ostream<charT,traits>& os): ok(true){
|
||||
if(os.good() !=0){ //Prepare for output
|
||||
}
|
||||
|
||||
//Flush any tied buffer
|
||||
if(os.tie() !=0 ){
|
||||
os.tie()->flush();
|
||||
}
|
||||
}
|
||||
_UCXXEXPORT ~sentry() { }
|
||||
_UCXXEXPORT operator bool() {
|
||||
return ok;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__
|
||||
#ifndef __UCLIBCXX_COMPILE_OSTREAM__
|
||||
#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
|
||||
|
||||
template <> _UCXXEXPORT ostream::sentry::sentry(ostream & os);
|
||||
template <> _UCXXEXPORT ostream::sentry::~sentry();
|
||||
|
||||
#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
//Non - class functions
|
||||
|
||||
|
||||
template<class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>&
|
||||
operator<<(basic_ostream<charT,traits>& out, charT c)
|
||||
{
|
||||
typename basic_ostream<charT,traits>::sentry s(out);
|
||||
out.put(c);
|
||||
return out;
|
||||
}
|
||||
|
||||
template<class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>&
|
||||
operator<<(basic_ostream<charT,traits>& out, char c)
|
||||
{
|
||||
typename basic_ostream<charT,traits>::sentry s(out);
|
||||
out.put(c);
|
||||
return out;
|
||||
}
|
||||
|
||||
template<class traits> _UCXXEXPORT basic_ostream<char,traits>&
|
||||
operator<<(basic_ostream<char,traits>& out, char c)
|
||||
{
|
||||
typename basic_ostream<char,traits>::sentry s(out);
|
||||
out.put(c);
|
||||
return out;
|
||||
}
|
||||
|
||||
// signed and unsigned
|
||||
template<class traits> _UCXXEXPORT basic_ostream<char,traits>&
|
||||
operator<<(basic_ostream<char,traits>& out, signed char c)
|
||||
{
|
||||
typename basic_ostream<char,traits>::sentry s(out);
|
||||
out.put(c);
|
||||
return out;
|
||||
}
|
||||
|
||||
template<class traits> _UCXXEXPORT basic_ostream<char,traits>&
|
||||
operator<<(basic_ostream<char,traits>& out, unsigned char c)
|
||||
{
|
||||
typename basic_ostream<char,traits>::sentry s(out);
|
||||
out.put(c);
|
||||
return out;
|
||||
}
|
||||
|
||||
template<class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>&
|
||||
operator<<(basic_ostream<charT,traits>& out, const charT* c)
|
||||
{
|
||||
typename basic_ostream<charT,traits>::sentry s(out);
|
||||
out.printout(c, traits::length(c) );
|
||||
return out;
|
||||
}
|
||||
|
||||
template<class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>&
|
||||
operator<<(basic_ostream<charT,traits>& out, const char* c)
|
||||
{
|
||||
typename basic_ostream<charT,traits>::sentry s(out);
|
||||
out.printout(c, char_traits<char>::length(c) );
|
||||
return out;
|
||||
}
|
||||
|
||||
// partial specializations
|
||||
template<class traits> _UCXXEXPORT basic_ostream<char,traits>&
|
||||
operator<<(basic_ostream<char,traits>& out, const char* c)
|
||||
{
|
||||
typename basic_ostream<char,traits>::sentry s(out);
|
||||
out.printout(c, traits::length(c));
|
||||
return out;
|
||||
}
|
||||
|
||||
#ifdef __UCLIBCXX_HAS_WCHAR__
|
||||
template<class traits> _UCXXEXPORT basic_ostream<wchar_t,traits>&
|
||||
operator<<(basic_ostream<wchar_t,traits>& out, const char* c)
|
||||
{
|
||||
typename basic_ostream<wchar_t, traits>::sentry s(out);
|
||||
size_t numChars = char_traits<char>::length(c);
|
||||
wchar_t * temp = new wchar_t[numChars];
|
||||
|
||||
for(size_t i=0; i < numChars; ++i){
|
||||
temp[i] = out.widen(c[i]);
|
||||
}
|
||||
|
||||
out.printout(temp, numChars);
|
||||
return out;
|
||||
}
|
||||
#endif
|
||||
|
||||
// signed and unsigned
|
||||
template<class traits> _UCXXEXPORT basic_ostream<char,traits>&
|
||||
operator<<(basic_ostream<char,traits>& out, const signed char* c)
|
||||
{
|
||||
typename basic_ostream<char,traits>::sentry s(out);
|
||||
out.printout(reinterpret_cast<const char *>(c), traits::length( reinterpret_cast<const char *>(c)));
|
||||
return out;
|
||||
}
|
||||
|
||||
template<class traits> _UCXXEXPORT basic_ostream<char,traits>&
|
||||
operator<<(basic_ostream<char,traits>& out, const unsigned char* c)
|
||||
{
|
||||
typename basic_ostream<char,traits>::sentry s(out);
|
||||
out.printout(reinterpret_cast<const char *>(c), traits::length( reinterpret_cast<const char *>(c)));
|
||||
return out;
|
||||
}
|
||||
|
||||
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>&
|
||||
endl(basic_ostream<charT,traits>& os)
|
||||
{
|
||||
typename basic_ostream<charT,traits>::sentry s(os);
|
||||
os.put('\n');
|
||||
os.flush();
|
||||
return os;
|
||||
}
|
||||
|
||||
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>&
|
||||
ends(basic_ostream<charT,traits>& os)
|
||||
{
|
||||
typename basic_ostream<charT,traits>::sentry s(os);
|
||||
os.put(traits::eos());
|
||||
return os;
|
||||
}
|
||||
|
||||
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>& flush(basic_ostream<charT,traits>& os){
|
||||
typename basic_ostream<charT,traits>::sentry s(os);
|
||||
os.flush();
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__
|
||||
#ifndef __UCLIBCXX_COMPILE_OSTREAM__
|
||||
template <> _UCXXEXPORT ostream & endl(ostream & os);
|
||||
template <> _UCXXEXPORT ostream & flush(ostream & os);
|
||||
template <> _UCXXEXPORT ostream & operator<<(ostream & out, char c);
|
||||
template <> _UCXXEXPORT ostream & operator<<(ostream & out, const char* c);
|
||||
template <> _UCXXEXPORT ostream & operator<<(ostream & out, unsigned char c);
|
||||
template <> _UCXXEXPORT ostream & operator<<(ostream & out, unsigned const char* c);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
|
||||
|
||||
//Support for output of long long data types
|
||||
|
||||
template<class Ch, class Tr> _UCXXEXPORT basic_ostream<Ch, Tr>&
|
||||
operator<<(basic_ostream<Ch, Tr>& os, signed long long int i)
|
||||
{
|
||||
typename basic_ostream<Ch, Tr>::sentry s(os);
|
||||
__ostream_printout<Tr, Ch, signed long long int>::printout(os, i);
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
template<class Ch, class Tr> _UCXXEXPORT basic_ostream<Ch, Tr>&
|
||||
operator<<(basic_ostream<Ch, Tr>& os, unsigned long long int i)
|
||||
{
|
||||
typename basic_ostream<Ch, Tr>::sentry s(os);
|
||||
__ostream_printout<Tr, Ch, unsigned long long int>::printout(os, i);
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
#endif // !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#pragma GCC visibility pop
|
||||
|
||||
#endif
|
||||
|
||||
65
libraries/ArduinoSTL/src/ostream.cpp
Normal file
65
libraries/ArduinoSTL/src/ostream.cpp
Normal file
@@ -0,0 +1,65 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#define __UCLIBCXX_COMPILE_OSTREAM__ 1
|
||||
|
||||
#include "ostream"
|
||||
|
||||
namespace std{
|
||||
|
||||
|
||||
#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__
|
||||
|
||||
#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
|
||||
template _UCXXEXPORT ostream::~basic_ostream();
|
||||
#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
|
||||
|
||||
template _UCXXEXPORT ostream & ostream::flush();
|
||||
|
||||
template _UCXXEXPORT ostream & ostream::operator<<(bool n);
|
||||
template _UCXXEXPORT ostream & ostream::operator<<(short int n);
|
||||
template _UCXXEXPORT ostream & ostream::operator<<(unsigned short int n);
|
||||
template _UCXXEXPORT ostream & ostream::operator<<(int n);
|
||||
template _UCXXEXPORT ostream & ostream::operator<<(unsigned int n);
|
||||
template _UCXXEXPORT ostream & ostream::operator<<(long n);
|
||||
template _UCXXEXPORT ostream & ostream::operator<<(unsigned long n);
|
||||
template _UCXXEXPORT ostream & ostream::operator<<(float f);
|
||||
template _UCXXEXPORT ostream & ostream::operator<<(double f);
|
||||
template _UCXXEXPORT ostream & ostream::operator<<(long double f);
|
||||
template _UCXXEXPORT ostream & ostream::operator<<(void* p);
|
||||
template _UCXXEXPORT ostream & ostream::operator<<(basic_streambuf<char, char_traits<char> >* sb);
|
||||
|
||||
#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
|
||||
|
||||
template _UCXXEXPORT ostream::sentry::sentry(ostream & os);
|
||||
template _UCXXEXPORT ostream::sentry::~sentry();
|
||||
|
||||
#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
|
||||
|
||||
template _UCXXEXPORT ostream & endl(ostream & os);
|
||||
template _UCXXEXPORT ostream & flush(ostream & os);
|
||||
template _UCXXEXPORT ostream & operator<<(ostream & out, char c);
|
||||
template _UCXXEXPORT ostream & operator<<(ostream & out, const char* c);
|
||||
template _UCXXEXPORT ostream & operator<<(ostream & out, unsigned char c);
|
||||
template _UCXXEXPORT ostream & operator<<(ostream & out, const unsigned char* c);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
503
libraries/ArduinoSTL/src/ostream_helpers
Normal file
503
libraries/ArduinoSTL/src/ostream_helpers
Normal file
@@ -0,0 +1,503 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "basic_definitions"
|
||||
#include "cstddef"
|
||||
#include "ios"
|
||||
#include "cctype"
|
||||
#include "string"
|
||||
#include <math.h> // for floor()
|
||||
|
||||
#ifndef __STD_HEADER_OSTREAM_HELPERS
|
||||
#define __STD_HEADER_OSTREAM_HELPERS 1
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
|
||||
namespace std{
|
||||
|
||||
int arduinoPrintFloat(double number, uint8_t digits, char *buffer, size_t buffer_size);
|
||||
|
||||
/* We are making the following template class for serveral reasons. Firstly,
|
||||
* we want to keep the main ostream code neat and tidy. Secondly, we want it
|
||||
* to be easy to do partial specialization of the ostream code so that it can
|
||||
* be expanded and put into the library. This will allow us to make application
|
||||
* code smaller at the expense of increased library size. This is a fair
|
||||
* trade-off when there are multiple applications being compiled. Also, this
|
||||
* feature will be used optionally via configuration options. It will also
|
||||
* allow us to keep the code bases in sync, dramatically simplifying the
|
||||
* maintenance required. We specialized for char because wchar and others
|
||||
* require different scanf functions
|
||||
*/
|
||||
|
||||
|
||||
|
||||
template <class traits, class charT, class dataType> class _UCXXEXPORT __ostream_printout{
|
||||
public:
|
||||
static void printout(basic_ostream<charT,traits>& stream, const dataType n);
|
||||
};
|
||||
|
||||
template <class traits> class _UCXXEXPORT __ostream_printout<traits, char, signed long int>{
|
||||
public:
|
||||
static void printout(basic_ostream<char, traits >& stream, const signed long int n)
|
||||
{
|
||||
char buffer[20];
|
||||
const char * c_ld = "%ld";
|
||||
const char * c_lo = "%lo";
|
||||
const char * c_lX = "%lX";
|
||||
const char * c_lx = "%lx";
|
||||
const char * c_hashlo = "%#lo";
|
||||
const char * c_hashlX = "%#lX";
|
||||
const char * c_hashlx = "%#lx";
|
||||
|
||||
const char * formatString=0;
|
||||
|
||||
if( stream.flags() & ios_base::dec){
|
||||
formatString = c_ld;
|
||||
}else if( stream.flags() & ios_base::oct){
|
||||
if( stream.flags() & ios_base::showbase){
|
||||
formatString = c_hashlo;
|
||||
}else{
|
||||
formatString = c_lo;
|
||||
}
|
||||
}else if (stream.flags() & ios_base::hex){
|
||||
if(stream.flags() & ios_base::showbase){
|
||||
if(stream.flags() & ios_base::uppercase){
|
||||
formatString = c_hashlX;
|
||||
}else{
|
||||
formatString = c_hashlx;
|
||||
}
|
||||
}else{
|
||||
if(stream.flags() & ios_base::uppercase){
|
||||
formatString = c_lX;
|
||||
}else{
|
||||
formatString = c_lx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stream.printout(buffer, snprintf(buffer, 20, formatString, n) );
|
||||
|
||||
if(stream.flags() & ios_base::unitbuf){
|
||||
stream.flush();
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
template <class traits> class _UCXXEXPORT __ostream_printout<traits, char, unsigned long int>{
|
||||
public:
|
||||
static void printout(basic_ostream<char, traits >& stream, const unsigned long int n)
|
||||
{
|
||||
char buffer[20];
|
||||
const char * c_lo = "%lo";
|
||||
const char * c_lu = "%lu";
|
||||
const char * c_lX = "%lX";
|
||||
const char * c_lx = "%lx";
|
||||
const char * c_hashlo = "%#lo";
|
||||
const char * c_hashlX = "%#lX";
|
||||
const char * c_hashlx = "%#lx";
|
||||
const char * formatString=0;
|
||||
|
||||
if( stream.flags() & ios_base::dec){
|
||||
formatString = c_lu;
|
||||
}else if( stream.flags() & ios_base::oct){
|
||||
if( stream.flags() & ios_base::showbase){
|
||||
formatString = c_hashlo;
|
||||
}else{
|
||||
formatString = c_lo;
|
||||
}
|
||||
}else if (stream.flags() & ios_base::hex){
|
||||
if(stream.flags() & ios_base::showbase){
|
||||
if(stream.flags() & ios_base::uppercase){
|
||||
formatString = c_hashlX;
|
||||
}else{
|
||||
formatString = c_hashlx;
|
||||
}
|
||||
}else{
|
||||
if(stream.flags() & ios_base::uppercase){
|
||||
formatString = c_lX;
|
||||
}else{
|
||||
formatString = c_lx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stream.printout(buffer, snprintf(buffer, 20, formatString, n));
|
||||
if(stream.flags() & ios_base::unitbuf){
|
||||
stream.flush();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
|
||||
|
||||
template <class traits> class _UCXXEXPORT __ostream_printout<traits, char, signed long long int>{
|
||||
public:
|
||||
static void printout(basic_ostream<char, traits >& stream, const signed long long int n)
|
||||
{
|
||||
char buffer[28];
|
||||
const char * lld = "%lld";
|
||||
const char * llo = "%llo";
|
||||
const char * llX = "%llX";
|
||||
const char * llx = "%llx";
|
||||
const char * hashllo = "%#llo";
|
||||
const char * hashllX = "%#llX";
|
||||
const char * hashllx = "%#llx";
|
||||
const char * formatString=0;
|
||||
|
||||
if( stream.flags() & ios_base::dec){
|
||||
formatString = lld;
|
||||
}else if( stream.flags() & ios_base::oct){
|
||||
if( stream.flags() & ios_base::showbase){
|
||||
formatString = hashllo;
|
||||
}else{
|
||||
formatString = llo;
|
||||
}
|
||||
}else if (stream.flags() & ios_base::hex){
|
||||
if(stream.flags() & ios_base::showbase){
|
||||
if(stream.flags() & ios_base::uppercase){
|
||||
formatString = hashllX;
|
||||
}else{
|
||||
formatString = hashllx;
|
||||
}
|
||||
}else{
|
||||
if(stream.flags() & ios_base::uppercase){
|
||||
formatString = llX;
|
||||
}else{
|
||||
formatString = llx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stream.printout(buffer, snprintf(buffer, 27, formatString, n) );
|
||||
|
||||
if(stream.flags() & ios_base::unitbuf){
|
||||
stream.flush();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <class traits> class _UCXXEXPORT __ostream_printout<traits, char, unsigned long long int>{
|
||||
public:
|
||||
static void printout(basic_ostream<char, traits >& stream, const unsigned long long int n)
|
||||
{
|
||||
char buffer[28];
|
||||
const char * llo = "%llo";
|
||||
const char * llu = "%llu";
|
||||
const char * llX = "%llX";
|
||||
const char * llx = "%llx";
|
||||
const char * hashllo = "%#llo";
|
||||
const char * hashllX = "%#llX";
|
||||
const char * hashllx = "%#llx";
|
||||
const char * formatString=0;
|
||||
|
||||
if( stream.flags() & ios_base::dec){
|
||||
formatString = llu;
|
||||
}else if( stream.flags() & ios_base::oct){
|
||||
if( stream.flags() & ios_base::showbase){
|
||||
formatString = hashllo;
|
||||
}else{
|
||||
formatString = llo;
|
||||
}
|
||||
}else if (stream.flags() & ios_base::hex){
|
||||
if(stream.flags() & ios_base::showbase){
|
||||
if(stream.flags() & ios_base::uppercase){
|
||||
formatString = hashllX;
|
||||
}else{
|
||||
formatString = hashllx;
|
||||
}
|
||||
}else{
|
||||
if(stream.flags() & ios_base::uppercase){
|
||||
formatString = llX;
|
||||
}else{
|
||||
formatString = llx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stream.printout(buffer, snprintf(buffer, 27, formatString, n) );
|
||||
|
||||
if(stream.flags() & ios_base::unitbuf){
|
||||
stream.flush();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif // !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
|
||||
|
||||
// FIXME: Improve printing of doubles and floats.
|
||||
|
||||
template <class traits> class _UCXXEXPORT __ostream_printout<traits, char, double>{
|
||||
public:
|
||||
static void printout(basic_ostream<char, traits >& stream, const double f)
|
||||
{
|
||||
char buffer[32];
|
||||
int length;
|
||||
length = arduinoPrintFloat(f, 2, &buffer[0], 32);
|
||||
|
||||
/*
|
||||
if(stream.flags() & ios_base::scientific){
|
||||
if(stream.flags() & ios_base::uppercase){
|
||||
length = snprintf(buffer, 32, "%*.*E", static_cast<int>(stream.width()),static_cast<int>(stream.precision()), f);
|
||||
}else{
|
||||
length = snprintf(buffer, 32, "%*.*e", static_cast<int>(stream.width()),static_cast<int>(stream.precision()), f);
|
||||
}
|
||||
} else if(stream.flags() & ios_base::fixed){
|
||||
length = snprintf(buffer, 32, "%*.*f",static_cast<int>(stream.width()),static_cast<int>(stream.precision()), f);
|
||||
} else {
|
||||
length = snprintf(buffer, 32, "%*.*g",static_cast<int>(stream.width()),static_cast<int>(stream.precision()), f);
|
||||
}
|
||||
*/
|
||||
stream.printout(buffer, length);
|
||||
if(stream.flags() & ios_base::unitbuf){
|
||||
stream.flush();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <class traits> class _UCXXEXPORT __ostream_printout<traits, char, float>{
|
||||
public:
|
||||
static void printout(basic_ostream<char, traits >& stream, const float f)
|
||||
{
|
||||
char buffer[32];
|
||||
int length;
|
||||
length = arduinoPrintFloat(f, 2, &buffer[0], 32);
|
||||
|
||||
/*
|
||||
if(stream.flags() & ios_base::scientific){
|
||||
if(stream.flags() & ios_base::uppercase){
|
||||
length = snprintf(buffer, 32, "%*.*LE", static_cast<int>(stream.width()), static_cast<int>(stream.precision()), f);
|
||||
}else{
|
||||
length = snprintf(buffer, 32, "%*.*Le", static_cast<int>(stream.width()), static_cast<int>(stream.precision()), f);
|
||||
}
|
||||
} else if(stream.flags() & ios_base::fixed){
|
||||
length = snprintf(buffer, 32, "%*.*Lf", static_cast<int>(stream.width()), static_cast<int>(stream.precision()), f);
|
||||
} else {
|
||||
length = snprintf(buffer, 32, "%*.*Lg", static_cast<int>(stream.width()), static_cast<int>(stream.precision()), f);
|
||||
}
|
||||
*/
|
||||
stream.printout(buffer, length);
|
||||
if(stream.flags() & ios_base::unitbuf){
|
||||
stream.flush();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef __UCLIBCXX_HAS_WCHAR__
|
||||
template <class traits> class _UCXXEXPORT __ostream_printout<traits, wchar_t, signed long int>{
|
||||
public:
|
||||
static void printout(basic_ostream<wchar_t, traits >& stream, const signed long int n)
|
||||
{
|
||||
wchar_t buffer[20];
|
||||
if( stream.flags() & ios_base::dec){
|
||||
stream.printout(buffer, swprintf(buffer, 20, L"%ld", n));
|
||||
}else if( stream.flags() & ios_base::oct){
|
||||
if( stream.flags() & ios_base::showbase){
|
||||
stream.printout(buffer, swprintf(buffer, 20, L"%#lo", n));
|
||||
}else{
|
||||
stream.printout(buffer, swprintf(buffer, 20, L"%lo", n) );
|
||||
}
|
||||
}else if (stream.flags() & ios_base::hex){
|
||||
if(stream.flags() & ios_base::showbase){
|
||||
if(stream.flags() & ios_base::uppercase){
|
||||
stream.printout(buffer, swprintf(buffer, 20, L"%#lX", n) );
|
||||
}else{
|
||||
stream.printout(buffer, swprintf(buffer, 20, L"%#lx", n) );
|
||||
}
|
||||
}else{
|
||||
if(stream.flags() & ios_base::uppercase){
|
||||
stream.printout(buffer, swprintf(buffer, 20, L"%lX", n) );
|
||||
}else{
|
||||
stream.printout(buffer, swprintf(buffer, 20, L"%lx", n) );
|
||||
}
|
||||
}
|
||||
}
|
||||
if(stream.flags() & ios_base::unitbuf){
|
||||
stream.flush();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <class traits> class _UCXXEXPORT __ostream_printout<traits, wchar_t, unsigned long int>{
|
||||
public:
|
||||
static void printout(basic_ostream<wchar_t, traits >& stream, const unsigned long int n)
|
||||
{
|
||||
wchar_t buffer[20];
|
||||
if( stream.flags() & ios_base::dec){
|
||||
stream.printout(buffer, swprintf(buffer, 20, L"%lu", n));
|
||||
}else if( stream.flags() & ios_base::oct){
|
||||
if( stream.flags() & ios_base::showbase){
|
||||
stream.printout(buffer, swprintf(buffer, 20, L"%#lo", n));
|
||||
}else{
|
||||
stream.printout(buffer, swprintf(buffer, 20, L"%lo", n) );
|
||||
}
|
||||
}else if (stream.flags() & ios_base::hex){
|
||||
if(stream.flags() & ios_base::showbase){
|
||||
if(stream.flags() & ios_base::uppercase){
|
||||
stream.printout(buffer, swprintf(buffer, 20, L"%#lX", n) );
|
||||
}else{
|
||||
stream.printout(buffer, swprintf(buffer, 20, L"%#lx", n) );
|
||||
}
|
||||
}else{
|
||||
if(stream.flags() & ios_base::uppercase){
|
||||
stream.printout(buffer, swprintf(buffer, 20, L"%lX", n) );
|
||||
}else{
|
||||
stream.printout(buffer, swprintf(buffer, 20, L"%lx", n) );
|
||||
}
|
||||
}
|
||||
}
|
||||
if(stream.flags() & ios_base::unitbuf){
|
||||
stream.flush();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
|
||||
|
||||
template <class traits> class _UCXXEXPORT __ostream_printout<traits, wchar_t, signed long long int>{
|
||||
public:
|
||||
static void printout(basic_ostream<wchar_t, traits >& stream, const signed long long int n)
|
||||
{
|
||||
wchar_t buffer[28];
|
||||
if( stream.flags() & ios_base::dec){
|
||||
stream.printout(buffer, swprintf(buffer, 27, L"%lld", n));
|
||||
}else if( stream.flags() & ios_base::oct){
|
||||
if( stream.flags() & ios_base::showbase){
|
||||
stream.printout(buffer, swprintf(buffer, 27, L"%#llo", n));
|
||||
}else{
|
||||
stream.printout(buffer, swprintf(buffer, 27, L"%llo", n) );
|
||||
}
|
||||
}else if (stream.flags() & ios_base::hex){
|
||||
if(stream.flags() & ios_base::showbase){
|
||||
if(stream.flags() & ios_base::uppercase){
|
||||
stream.printout(buffer, swprintf(buffer, 27, L"%#llX", n) );
|
||||
}else{
|
||||
stream.printout(buffer, swprintf(buffer, 27, L"%#llx", n) );
|
||||
}
|
||||
}else{
|
||||
if(stream.flags() & ios_base::uppercase){
|
||||
stream.printout(buffer, swprintf(buffer, 27, L"%llX", n) );
|
||||
}else{
|
||||
stream.printout(buffer, swprintf(buffer, 27, L"%llx", n) );
|
||||
}
|
||||
}
|
||||
}
|
||||
if(stream.flags() & ios_base::unitbuf){
|
||||
stream.flush();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <class traits> class _UCXXEXPORT __ostream_printout<traits, wchar_t, unsigned long long int>{
|
||||
public:
|
||||
static void printout(basic_ostream<wchar_t, traits >& stream, const unsigned long long int n)
|
||||
{
|
||||
wchar_t buffer[28];
|
||||
if( stream.flags() & ios_base::dec){
|
||||
stream.printout(buffer, swprintf(buffer, 27, L"%llu", n));
|
||||
}else if( stream.flags() & ios_base::oct){
|
||||
if( stream.flags() & ios_base::showbase){
|
||||
stream.printout(buffer, swprintf(buffer, 27, L"%#llo", n));
|
||||
}else{
|
||||
stream.printout(buffer, swprintf(buffer, 27, L"%llo", n) );
|
||||
}
|
||||
}else if (stream.flags() & ios_base::hex){
|
||||
if(stream.flags() & ios_base::showbase){
|
||||
if(stream.flags() & ios_base::uppercase){
|
||||
stream.printout(buffer, swprintf(buffer, 27, L"%#llX", n) );
|
||||
}else{
|
||||
stream.printout(buffer, swprintf(buffer, 27, L"%#llx", n) );
|
||||
}
|
||||
}else{
|
||||
if(stream.flags() & ios_base::uppercase){
|
||||
stream.printout(buffer, swprintf(buffer, 27, L"%llX", n) );
|
||||
}else{
|
||||
stream.printout(buffer, swprintf(buffer, 27, L"%llx", n) );
|
||||
}
|
||||
}
|
||||
}
|
||||
if(stream.flags() & ios_base::unitbuf){
|
||||
stream.flush();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif // !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
|
||||
|
||||
template <class traits> class _UCXXEXPORT __ostream_printout<traits, wchar_t, double>{
|
||||
public:
|
||||
static void printout(basic_ostream<wchar_t, traits >& stream, const double f)
|
||||
{
|
||||
wchar_t buffer[32];
|
||||
wchar_t format_string[32];
|
||||
if(stream.flags() & ios_base::scientific){
|
||||
if(stream.flags() & ios_base::uppercase){
|
||||
swprintf(format_string, 32, L"%%%u.%uE", static_cast<int>(stream.width()), static_cast<unsigned int>(stream.precision()));
|
||||
}else{
|
||||
swprintf(format_string, 32, L"%%%u.%ue", static_cast<int>(stream.width()), static_cast<unsigned int>(stream.precision()));
|
||||
}
|
||||
} else if(stream.flags() & ios_base::fixed){
|
||||
swprintf(format_string, 32, L"%%%u.%uf", static_cast<int>(stream.width()), static_cast<unsigned int>(stream.precision()));
|
||||
} else {
|
||||
swprintf(format_string, 32, L"%%%u.%ug", static_cast<int>(stream.width()), static_cast<unsigned int>(stream.precision()));
|
||||
}
|
||||
stream.printout(buffer, swprintf(buffer, 32, format_string, f) );
|
||||
if(stream.flags() & ios_base::unitbuf){
|
||||
stream.flush();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <class traits> class _UCXXEXPORT __ostream_printout<traits, wchar_t, long double>{
|
||||
public:
|
||||
static void printout(basic_ostream<wchar_t, traits >& stream, const long double f)
|
||||
{
|
||||
wchar_t buffer[32];
|
||||
wchar_t format_string[32];
|
||||
if(stream.flags() & ios_base::scientific){
|
||||
if(stream.flags() & ios_base::uppercase){
|
||||
swprintf(format_string, 32, L"%%%u.%uLE", static_cast<unsigned int>(stream.width()), static_cast<unsigned int>(stream.precision()));
|
||||
}else{
|
||||
swprintf(format_string, 32, L"%%%u.%uLe", static_cast<unsigned int>(stream.width()), static_cast<unsigned int>(stream.precision()));
|
||||
}
|
||||
} else if(stream.flags() & ios_base::fixed){
|
||||
swprintf(format_string, 32, L"%%%u.%uLf", static_cast<unsigned int>(stream.width()), static_cast<unsigned int>(stream.precision()));
|
||||
} else {
|
||||
swprintf(format_string, 32, L"%%%u.%uLg", static_cast<unsigned int>(stream.width()), static_cast<unsigned int>(stream.precision()));
|
||||
}
|
||||
stream.printout(buffer, swprintf(buffer, 32, format_string, f) );
|
||||
if(stream.flags() & ios_base::unitbuf){
|
||||
stream.flush();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif //__UCLIBCXX_HAS_WCHAR__
|
||||
|
||||
}
|
||||
|
||||
#pragma GCC visibility pop
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
67
libraries/ArduinoSTL/src/ostream_helpers.cpp
Normal file
67
libraries/ArduinoSTL/src/ostream_helpers.cpp
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* This code is taken from the Arduino Print class.
|
||||
*
|
||||
* printf() doesn't handle floating point types on AVR.
|
||||
* This code helps me hack that in. It's not here permanently.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ostream_helpers"
|
||||
#include <stdio.h>
|
||||
|
||||
namespace std {
|
||||
|
||||
int arduinoPrintFloat(double number, uint8_t digits, char *buffer, size_t buffer_size)
|
||||
{
|
||||
size_t n = 0;
|
||||
|
||||
if (buffer_size < 4)
|
||||
return 0;
|
||||
|
||||
if (isnan(number)) return snprintf(buffer, buffer_size, "nan");
|
||||
if (isinf(number)) return snprintf(buffer, buffer_size, "inf");
|
||||
if (number > 4294967040.0) return snprintf(buffer, buffer_size, "ovf"); // constant determined empirically
|
||||
if (number <-4294967040.0) return snprintf(buffer, buffer_size, "ovf"); // constant determined empirically
|
||||
|
||||
// Handle negative numbers
|
||||
if (number < 0.0) {
|
||||
n += snprintf(&buffer[n], buffer_size-n, "-");
|
||||
number = -number;
|
||||
}
|
||||
|
||||
// Round correctly so that print(1.999, 2) prints as "2.00"
|
||||
double rounding = 0.5;
|
||||
for (uint8_t i=0; i<digits; ++i)
|
||||
rounding /= 10.0;
|
||||
|
||||
number += rounding;
|
||||
|
||||
// Extract the integer part of the number and print it
|
||||
unsigned long int_part = (unsigned long)number;
|
||||
double remainder = number - (double)int_part;
|
||||
n += snprintf(&buffer[n], buffer_size-n, "%lu", int_part);
|
||||
if (n >= buffer_size)
|
||||
return n;
|
||||
|
||||
// Print the decimal point, but only if there are digits beyond
|
||||
if (digits > 0) {
|
||||
n += snprintf(&buffer[n], buffer_size-n, ".");
|
||||
if (n >= buffer_size)
|
||||
return n;
|
||||
}
|
||||
|
||||
// Extract digits from the remainder one at a time
|
||||
while (digits-- > 0)
|
||||
{
|
||||
remainder *= 10.0;
|
||||
unsigned int toPrint = (unsigned int)(remainder);
|
||||
n += snprintf(&buffer[n], buffer_size-n, "%u", toPrint);
|
||||
if (n >= buffer_size)
|
||||
return n;
|
||||
remainder -= toPrint;
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
}
|
||||
126
libraries/ArduinoSTL/src/queue
Normal file
126
libraries/ArduinoSTL/src/queue
Normal file
@@ -0,0 +1,126 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
This file is part of the uClibc++ Library.
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "basic_definitions"
|
||||
#include "deque"
|
||||
#include "vector"
|
||||
#include "functional"
|
||||
|
||||
#ifndef __HEADER_STD_QUEUE
|
||||
#define __HEADER_STD_QUEUE 1
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
|
||||
namespace std{
|
||||
|
||||
template <class T, class Container = deque<T> > class _UCXXEXPORT queue{
|
||||
protected:
|
||||
Container c;
|
||||
public:
|
||||
typedef typename Container::value_type value_type;
|
||||
typedef typename Container::size_type size_type;
|
||||
typedef Container container_type;
|
||||
|
||||
explicit queue(const Container& a = Container()) : c(a) { }
|
||||
|
||||
bool empty() const { return c.empty(); }
|
||||
size_type size() const { return c.size(); }
|
||||
value_type& front() { return c.front(); }
|
||||
const value_type& front() const { return c.front(); }
|
||||
value_type& back() { return c.back(); }
|
||||
const value_type& back() const { return c.back(); }
|
||||
void push(const value_type& x) { c.push_back(x); }
|
||||
void pop() { c.pop_front(); }
|
||||
};
|
||||
|
||||
|
||||
template <class T, class Container> _UCXXEXPORT bool
|
||||
operator==(const queue<T, Container>& x, const queue<T, Container>& y)
|
||||
{
|
||||
return (x.c == y.c);
|
||||
}
|
||||
template <class T, class Container> _UCXXEXPORT bool
|
||||
operator< (const queue<T, Container>& x, const queue<T, Container>& y)
|
||||
{
|
||||
return (x.c < y.c);
|
||||
}
|
||||
template <class T, class Container> _UCXXEXPORT bool
|
||||
operator!=(const queue<T, Container>& x, const queue<T, Container>& y)
|
||||
{
|
||||
return (x.c != y.c);
|
||||
}
|
||||
template <class T, class Container> _UCXXEXPORT bool
|
||||
operator> (const queue<T, Container>& x, const queue<T, Container>& y)
|
||||
{
|
||||
return (x.c > y.c);
|
||||
}
|
||||
template <class T, class Container> _UCXXEXPORT bool
|
||||
operator>=(const queue<T, Container>& x, const queue<T, Container>& y)
|
||||
{
|
||||
return (x.c >= y.c);
|
||||
}
|
||||
template <class T, class Container> _UCXXEXPORT bool
|
||||
operator<=(const queue<T, Container>& x, const queue<T, Container>& y)
|
||||
{
|
||||
return (x.c <= y.c);
|
||||
}
|
||||
|
||||
|
||||
template <class T,
|
||||
class Container = vector<T>,
|
||||
class Compare = less<typename Container::value_type>
|
||||
> class _UCXXEXPORT priority_queue {
|
||||
protected:
|
||||
Container c;
|
||||
Compare comp;
|
||||
public:
|
||||
typedef typename Container::value_type value_type;
|
||||
typedef typename Container::size_type size_type;
|
||||
typedef Container container_type;
|
||||
|
||||
explicit priority_queue(const Compare& x = Compare(), const Container& a = Container())
|
||||
: c(a), comp(x) { make_heap(c.begin(), c.end(), comp) ; }
|
||||
template <class InputIterator> priority_queue(InputIterator first,
|
||||
InputIterator last,
|
||||
const Compare& x = Compare(),
|
||||
const Container& y= Container())
|
||||
: c(y), comp(c)
|
||||
{
|
||||
c.insert(c.end(), first, last);
|
||||
make_heap(c.begin(), c.end(), comp);
|
||||
}
|
||||
|
||||
bool empty() const { return c.empty(); }
|
||||
size_type size() const { return c.size(); }
|
||||
const value_type& top() const { return c.front(); }
|
||||
void push(const value_type& x){
|
||||
c.push_back(x);
|
||||
push_heap(c.begin(), c.end(), comp);
|
||||
}
|
||||
void pop(){
|
||||
pop_heap(c.begin(), c.end(), comp);
|
||||
c.pop_back();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#pragma GCC visibility pop
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
27
libraries/ArduinoSTL/src/queue.cpp
Normal file
27
libraries/ArduinoSTL/src/queue.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "queue"
|
||||
|
||||
|
||||
namespace std{
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
349
libraries/ArduinoSTL/src/serstream
Normal file
349
libraries/ArduinoSTL/src/serstream
Normal file
@@ -0,0 +1,349 @@
|
||||
/*
|
||||
* serstream
|
||||
* Implementation of input/output streams for the Arduino serial classes
|
||||
*
|
||||
* Created on: 2 Jan 2011
|
||||
* Author: Andy Brown
|
||||
* Modfied: Mike Matera
|
||||
*
|
||||
* http://andybrown.me.uk/ws/terms-and-conditions
|
||||
*
|
||||
* Captured from the URL above on June 30th, 2018
|
||||
*
|
||||
* License
|
||||
*
|
||||
* Copyright (c) 2011-2016 Andrew Brown. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* The name of Andrew Brown may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL ANDREW BROWN BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __810370EC_AD69_4ef7_91F5_B1AA16F14712
|
||||
#define __810370EC_AD69_4ef7_91F5_B1AA16F14712
|
||||
|
||||
#include "basic_definitions"
|
||||
|
||||
#include "iosfwd"
|
||||
#include "ios"
|
||||
#include "istream"
|
||||
#include "ostream"
|
||||
#include "iostream"
|
||||
#include <Stream.h>
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
/*
|
||||
* basic_serialbuf implements an unbuffered basic_streambuf as a backing buffer
|
||||
* for the IO classes
|
||||
*/
|
||||
|
||||
template <class charT, class traits, class Tserial>
|
||||
class basic_serialbuf : public basic_streambuf<charT,traits>
|
||||
{
|
||||
public:
|
||||
|
||||
/*
|
||||
* Types used here
|
||||
*/
|
||||
|
||||
typedef charT char_type;
|
||||
typedef typename traits::int_type int_type;
|
||||
|
||||
/*
|
||||
* constructor - wraps an existing Tserial class instance
|
||||
*/
|
||||
|
||||
explicit basic_serialbuf(Tserial& serial_,ios_base::openmode which_ = ios_base::in | ios_base::out)
|
||||
: _serial(serial_)
|
||||
{
|
||||
basic_streambuf<charT,traits>::openedFor = which_;
|
||||
}
|
||||
|
||||
/*
|
||||
* Required to maintain the chain
|
||||
*/
|
||||
|
||||
virtual ~basic_serialbuf() { }
|
||||
|
||||
/*
|
||||
* Get a reference to the wrapped object
|
||||
*/
|
||||
|
||||
Tserial& serial() { return _serial; }
|
||||
|
||||
protected:
|
||||
|
||||
/*
|
||||
* Get how many bytes available
|
||||
*/
|
||||
|
||||
virtual int showmanyc(){
|
||||
return _serial.available();
|
||||
}
|
||||
|
||||
/*
|
||||
* Read up to n chars
|
||||
*/
|
||||
|
||||
virtual streamsize xsgetn(char_type* c, streamsize n) {
|
||||
|
||||
streamsize i = 0;
|
||||
char_type data;
|
||||
|
||||
while((data=_serial.read())!=-1 && i < n ) {
|
||||
c[i] = data;
|
||||
++i;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write up to n chars
|
||||
*/
|
||||
|
||||
virtual streamsize xsputn(const char_type* s, streamsize n){
|
||||
|
||||
//_serial.print("[PUT ");
|
||||
//_serial.print(n);
|
||||
//_serial.print("] ");
|
||||
for(streamsize i=0;i<n;i++)
|
||||
{
|
||||
char_type c = s[i];
|
||||
if ( c == '\n' )
|
||||
_serial.print('\r');
|
||||
_serial.print(c);
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
/*
|
||||
* write a single char
|
||||
*/
|
||||
|
||||
virtual int_type overflow (int_type c = traits::eof()) {
|
||||
if(!traits::eq_int_type(c,traits::eof()))
|
||||
{
|
||||
//_serial.print("[OF]");
|
||||
if ( (char_type)c == '\n' )
|
||||
_serial.print('\r');
|
||||
_serial.print((char_type)c);
|
||||
|
||||
}
|
||||
return traits::not_eof(c);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* peek at a char where possible
|
||||
*/
|
||||
|
||||
virtual int_type underflow(){
|
||||
// There is no EOF condition on a serial stream.
|
||||
// underflow() and uflow() should block, reproducing the
|
||||
// OS behavior when there are no charaters to read.
|
||||
while (! _serial.available()) { /* wait */ }
|
||||
return _serial.peek();
|
||||
}
|
||||
|
||||
/*
|
||||
* Read a char where possible
|
||||
*/
|
||||
|
||||
virtual int_type uflow(){
|
||||
// See underflow() above
|
||||
while (! _serial.available()) { /* wait */ }
|
||||
return _serial.read();
|
||||
}
|
||||
|
||||
/*
|
||||
* Our wrapped arduino class
|
||||
*/
|
||||
|
||||
Tserial& _serial;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Input stream
|
||||
*/
|
||||
|
||||
template <class charT, class traits, class Tserial> class basic_iserialstream
|
||||
: public basic_istream<charT,traits>
|
||||
{
|
||||
public:
|
||||
|
||||
/*
|
||||
* Types used here
|
||||
*/
|
||||
|
||||
typedef charT char_type;
|
||||
|
||||
/*
|
||||
* Constructor - default the serial object to #1
|
||||
* Mega users can explicity initialise with one of
|
||||
* the others
|
||||
*/
|
||||
|
||||
explicit basic_iserialstream(Tserial& serial_)
|
||||
: basic_ios<charT, traits>(&sb), basic_istream<charT,traits>(&sb), sb(serial_,ios_base::in)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Required to maintain the chain
|
||||
*/
|
||||
|
||||
virtual ~basic_iserialstream() { }
|
||||
|
||||
/*
|
||||
* Initialise the baud rate
|
||||
*/
|
||||
|
||||
void begin(long speed_) {
|
||||
sb.serial().begin(speed_);
|
||||
sb.serial().println(__FUNCTION__);
|
||||
}
|
||||
|
||||
/*
|
||||
* The wrapped object
|
||||
*/
|
||||
|
||||
private:
|
||||
basic_serialbuf<charT,traits,Tserial> sb;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Output stream
|
||||
*/
|
||||
|
||||
template <class charT, class traits, class Tserial> class basic_oserialstream
|
||||
: public basic_ostream<charT,traits>
|
||||
{
|
||||
public:
|
||||
|
||||
/*
|
||||
* Types used here
|
||||
*/
|
||||
|
||||
typedef charT char_type;
|
||||
|
||||
/*
|
||||
* Constructor - default the serial object to #1
|
||||
* Mega users can explicity initialise with one of
|
||||
* the others
|
||||
*/
|
||||
|
||||
explicit basic_oserialstream(Tserial& serial_)
|
||||
: basic_ios<charT, traits>(&sb), basic_ostream<charT,traits>(&sb), sb(serial_,ios_base::out)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Required to maintain the chain
|
||||
*/
|
||||
|
||||
virtual ~basic_oserialstream() { }
|
||||
|
||||
/*
|
||||
* Initialise the baud rate
|
||||
*/
|
||||
|
||||
void begin(long speed_) {
|
||||
sb.serial().begin(speed_);
|
||||
}
|
||||
|
||||
/*
|
||||
* The wrapped object
|
||||
*/
|
||||
|
||||
private:
|
||||
basic_serialbuf<charT,traits,Tserial> sb;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Input/output stream
|
||||
*/
|
||||
|
||||
template <class charT, class traits, class Tserial> class basic_ioserialstream
|
||||
: public basic_iostream<charT,traits>
|
||||
{
|
||||
public:
|
||||
|
||||
/*
|
||||
* Types used here
|
||||
*/
|
||||
|
||||
typedef charT char_type;
|
||||
|
||||
/*
|
||||
* Constructor - default the serial object to #1
|
||||
* Mega users can explicity initialise with one of
|
||||
* the others
|
||||
*/
|
||||
|
||||
explicit basic_ioserialstream(Tserial& serial_)
|
||||
: basic_ios<charT, traits>(&sb), basic_iostream<charT,traits>(&sb), sb(serial_,ios_base::in | ios_base::out)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Required to maintain the chain
|
||||
*/
|
||||
|
||||
virtual ~basic_ioserialstream(){ }
|
||||
|
||||
/*
|
||||
* Initialise the baud rate
|
||||
*/
|
||||
|
||||
void begin(long speed_) {
|
||||
sb.serial().begin(speed_);
|
||||
}
|
||||
|
||||
/*
|
||||
* The wrapped object
|
||||
*/
|
||||
|
||||
private:
|
||||
basic_serialbuf<charT, traits, Tserial> sb;
|
||||
};
|
||||
|
||||
|
||||
using ::Stream;
|
||||
|
||||
template <class charT, class traits = char_traits<charT>, class Tserial=Stream> class basic_serialbuf;
|
||||
template <class charT, class traits = char_traits<charT>, class Tserial=Stream> class basic_iserialstream;
|
||||
template <class charT, class traits = char_traits<charT>, class Tserial=Stream> class basic_oserialstream;
|
||||
|
||||
typedef basic_iserialstream<char> ihserialstream;
|
||||
typedef basic_oserialstream<char> ohserialstream;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
406
libraries/ArduinoSTL/src/set
Normal file
406
libraries/ArduinoSTL/src/set
Normal file
@@ -0,0 +1,406 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "memory"
|
||||
#include "utility"
|
||||
#include "iterator"
|
||||
#include "deque"
|
||||
#include "functional"
|
||||
#include "associative_base"
|
||||
|
||||
#ifndef __STD_HEADER_SET
|
||||
#define __STD_HEADER_SET
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
|
||||
namespace std{
|
||||
|
||||
|
||||
template<class Key, class Compare = less<Key>, class Allocator = allocator<Key> > class set;
|
||||
template<class Key, class Compare = less<Key>, class Allocator = allocator<Key> > class multiset;
|
||||
|
||||
|
||||
/* This is the implementation for the set container. As noted above, it deviates
|
||||
* from ISO spec by deriving from a base class in order to reduce code redundancy.
|
||||
* More code could be reduced by convirting to virtual functions (thus allowing
|
||||
* much of the erase and insert code to be duplicated), but that would deviate from
|
||||
* the specifications too much to be worth the risk.
|
||||
*/
|
||||
|
||||
|
||||
//Implementation of set
|
||||
|
||||
|
||||
template<class Key, class Compare, class Allocator> class _UCXXEXPORT set
|
||||
: public __single_associative<Key, Key, Compare, Allocator>
|
||||
{
|
||||
//Default value of allocator does not meet C++ standard specs, but it works for this library
|
||||
//Deal with it
|
||||
public:
|
||||
|
||||
typedef __single_associative<Key, Key, Compare, Allocator> base;
|
||||
typedef typename base::key_type key_type;
|
||||
typedef typename base::value_type value_type;
|
||||
typedef typename base::key_compare key_compare;
|
||||
typedef typename base::allocator_type allocator_type;
|
||||
typedef typename base::reference reference;
|
||||
typedef typename base::const_reference const_reference;
|
||||
typedef typename base::iterator iterator;
|
||||
typedef typename base::const_iterator const_iterator;
|
||||
typedef typename base::size_type size_type;
|
||||
typedef typename base::difference_type difference_type;
|
||||
typedef typename base::pointer pointer;
|
||||
typedef typename base::const_pointer const_pointer;
|
||||
typedef typename base::reverse_iterator reverse_iterator;
|
||||
typedef typename base::const_reverse_iterator const_reverse_iterator;
|
||||
|
||||
// using base::value_compare;
|
||||
|
||||
static const key_type v_t_k(const value_type v){
|
||||
return v;
|
||||
}
|
||||
|
||||
explicit set(const Compare& comp = Compare(), const Allocator& al = Allocator())
|
||||
: base(comp, al, v_t_k) { }
|
||||
|
||||
template <class InputIterator> set(InputIterator first, InputIterator last,
|
||||
const Compare& comp = Compare(), const Allocator& al = Allocator())
|
||||
: base(first, last, comp, al, v_t_k) { }
|
||||
|
||||
set(const set<Key, Compare,Allocator>& x) : base(x) { }
|
||||
~set() { }
|
||||
|
||||
using base::operator=;
|
||||
using base::operator==;
|
||||
using base::operator!=;
|
||||
|
||||
using base::insert;
|
||||
using base::erase;
|
||||
|
||||
using base::begin;
|
||||
using base::end;
|
||||
using base::rbegin;
|
||||
using base::rend;
|
||||
|
||||
using base::empty;
|
||||
using base::size;
|
||||
using base::max_size;
|
||||
|
||||
|
||||
using base::find;
|
||||
using base::count;
|
||||
using base::lower_bound;
|
||||
using base::upper_bound;
|
||||
using base::equal_range;
|
||||
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
|
||||
//Implementation of multiset
|
||||
|
||||
|
||||
template<class Key, class Compare, class Allocator> class _UCXXEXPORT multiset
|
||||
: public __multi_associative<Key, Key, Compare, Allocator>
|
||||
{
|
||||
//Default value of allocator does not meet C++ standard specs, but it works for this library
|
||||
//Deal with it
|
||||
public:
|
||||
|
||||
typedef __multi_associative<Key, Key, Compare, Allocator> base;
|
||||
typedef typename base::key_type key_type;
|
||||
typedef typename base::value_type value_type;
|
||||
typedef typename base::key_compare key_compare;
|
||||
typedef typename base::allocator_type allocator_type;
|
||||
typedef typename base::reference reference;
|
||||
typedef typename base::const_reference const_reference;
|
||||
typedef typename base::iterator iterator;
|
||||
typedef typename base::const_iterator const_iterator;
|
||||
typedef typename base::size_type size_type;
|
||||
typedef typename base::difference_type difference_type;
|
||||
typedef typename base::pointer pointer;
|
||||
typedef typename base::const_pointer const_pointer;
|
||||
typedef typename base::reverse_iterator reverse_iterator;
|
||||
typedef typename base::const_reverse_iterator const_reverse_iterator;
|
||||
|
||||
static const key_type v_t_k(const value_type v){
|
||||
return v;
|
||||
}
|
||||
|
||||
explicit multiset(const Compare& comp = Compare(), const Allocator& al = Allocator())
|
||||
: base(comp, al, v_t_k) { }
|
||||
|
||||
template <class InputIterator> multiset(InputIterator first, InputIterator last,
|
||||
const Compare& comp = Compare(), const Allocator& al = Allocator())
|
||||
: base(first, last, comp, al, v_t_k) { }
|
||||
|
||||
|
||||
multiset(const multiset<Key, Compare, Allocator>& x) : base(x) { }
|
||||
~multiset() { }
|
||||
|
||||
using base::operator=;
|
||||
using base::operator==;
|
||||
using base::operator!=;
|
||||
|
||||
using base::insert;
|
||||
using base::erase;
|
||||
|
||||
using base::begin;
|
||||
using base::end;
|
||||
using base::rbegin;
|
||||
using base::rend;
|
||||
|
||||
using base::empty;
|
||||
using base::size;
|
||||
using base::max_size;
|
||||
|
||||
using base::find;
|
||||
using base::count;
|
||||
using base::lower_bound;
|
||||
using base::upper_bound;
|
||||
using base::equal_range;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
|
||||
/* Non-member functions. These are at the end because they are not associated with any
|
||||
particular class. These will be implemented as I figure out exactly what all of
|
||||
them are supposed to do, and I have time.
|
||||
*/
|
||||
|
||||
template <class Key, class Compare, class Allocator> _UCXXEXPORT bool operator<
|
||||
(const set<Key,Compare,Allocator>& x, const set<Key,Compare,Allocator>& y)
|
||||
{
|
||||
typename set<Key,Compare,Allocator>::const_iterator first1 = x.begin();
|
||||
typename set<Key,Compare,Allocator>::const_iterator first2 = y.begin();
|
||||
typename set<Key,Compare,Allocator>::const_iterator last1 = x.end();
|
||||
typename set<Key,Compare,Allocator>::const_iterator last2 = y.end();
|
||||
|
||||
while(first1 != last1 && first2 != last2){
|
||||
if( *first1 < *first2 ){
|
||||
return true;
|
||||
}
|
||||
if( *first2 < *first1 ){
|
||||
return false;
|
||||
}
|
||||
++first1;
|
||||
++first2;
|
||||
}
|
||||
return first1==last1 && first2 != last2;
|
||||
}
|
||||
|
||||
template <class Key, class Compare, class Allocator> _UCXXEXPORT bool operator>
|
||||
(const set<Key,Compare,Allocator>& x, const set<Key,Compare,Allocator>& y)
|
||||
{
|
||||
typename set<Key,Compare,Allocator>::const_iterator first1 = x.begin();
|
||||
typename set<Key,Compare,Allocator>::const_iterator first2 = y.begin();
|
||||
typename set<Key,Compare,Allocator>::const_iterator last1 = x.end();
|
||||
typename set<Key,Compare,Allocator>::const_iterator last2 = y.end();
|
||||
|
||||
while(first1 != last1 && first2 != last2){
|
||||
if( *first1 > *first2 ){
|
||||
return true;
|
||||
}
|
||||
if( *first2 > *first1 ){
|
||||
return false;
|
||||
}
|
||||
++first1;
|
||||
++first2;
|
||||
}
|
||||
return first1!=last1 && first2 == last2;
|
||||
}
|
||||
|
||||
template <class Key, class Compare, class Allocator> _UCXXEXPORT bool operator>=
|
||||
(const set<Key,Compare,Allocator>& x, const set<Key,Compare,Allocator>& y)
|
||||
{
|
||||
typename set<Key,Compare,Allocator>::const_iterator first1 = x.begin();
|
||||
typename set<Key,Compare,Allocator>::const_iterator first2 = y.begin();
|
||||
typename set<Key,Compare,Allocator>::const_iterator last1 = x.end();
|
||||
typename set<Key,Compare,Allocator>::const_iterator last2 = y.end();
|
||||
|
||||
while(first1 != last1 && first2 != last2){
|
||||
if( *first1 > *first2 ){
|
||||
return true;
|
||||
}
|
||||
if( *first2 > *first1 ){
|
||||
return false;
|
||||
}
|
||||
++first1;
|
||||
++first2;
|
||||
}
|
||||
return first1!=last1;
|
||||
}
|
||||
|
||||
template <class Key, class Compare, class Allocator> _UCXXEXPORT bool operator<=
|
||||
(const set<Key,Compare,Allocator>& x, const set<Key,Compare,Allocator>& y)
|
||||
{
|
||||
typename set<Key,Compare,Allocator>::const_iterator first1 = x.begin();
|
||||
typename set<Key,Compare,Allocator>::const_iterator first2 = y.begin();
|
||||
typename set<Key,Compare,Allocator>::const_iterator last1 = x.end();
|
||||
typename set<Key,Compare,Allocator>::const_iterator last2 = y.end();
|
||||
|
||||
while(first1 != last1 && first2 != last2){
|
||||
if( *first1 < *first2 ){
|
||||
return true;
|
||||
}
|
||||
if( *first2 < *first1 ){
|
||||
return false;
|
||||
}
|
||||
++first1;
|
||||
++first2;
|
||||
}
|
||||
return first2!=last2;
|
||||
}
|
||||
template <class Key, class Compare, class Allocator> _UCXXEXPORT void swap
|
||||
(set<Key,Compare,Allocator>& x, set<Key,Compare,Allocator>& y)
|
||||
{
|
||||
x.swap(y);
|
||||
}
|
||||
|
||||
|
||||
template <class Key, class Compare, class Allocator> _UCXXEXPORT bool operator==
|
||||
(const multiset<Key,Compare,Allocator>& x, const multiset<Key,Compare,Allocator>& y)
|
||||
{
|
||||
if(x.data == y.data){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class Key, class Compare, class Allocator> _UCXXEXPORT bool operator<
|
||||
(const multiset<Key,Compare,Allocator>& x, const multiset<Key,Compare,Allocator>& y)
|
||||
{
|
||||
typename multiset<Key,Compare,Allocator>::const_iterator first1 = x.begin();
|
||||
typename multiset<Key,Compare,Allocator>::const_iterator first2 = y.begin();
|
||||
typename multiset<Key,Compare,Allocator>::const_iterator last1 = x.end();
|
||||
typename multiset<Key,Compare,Allocator>::const_iterator last2 = y.end();
|
||||
|
||||
while(first1 != last1 && first2 != last2){
|
||||
if( *first1 < *first2 ){
|
||||
return true;
|
||||
}
|
||||
if( *first2 < *first1 ){
|
||||
return false;
|
||||
}
|
||||
++first1;
|
||||
++first2;
|
||||
}
|
||||
return first1==last1 && first2 != last2;
|
||||
}
|
||||
|
||||
template <class Key, class Compare, class Allocator> _UCXXEXPORT bool operator!=
|
||||
(const multiset<Key,Compare,Allocator>& x, const multiset<Key,Compare,Allocator>& y)
|
||||
{
|
||||
typename multiset<Key,Compare,Allocator>::const_iterator first1 = x.begin();
|
||||
typename multiset<Key,Compare,Allocator>::const_iterator first2 = y.begin();
|
||||
typename multiset<Key,Compare,Allocator>::const_iterator last1 = x.end();
|
||||
typename multiset<Key,Compare,Allocator>::const_iterator last2 = y.end();
|
||||
|
||||
while(first1 != last1 && first2 != last2){
|
||||
if( *first1 != *first2 ){
|
||||
return true;
|
||||
}
|
||||
++first1;
|
||||
++first2;
|
||||
}
|
||||
return first1!=last1 || first2 != last2;
|
||||
}
|
||||
|
||||
template <class Key, class Compare, class Allocator> _UCXXEXPORT bool operator>
|
||||
(const multiset<Key,Compare,Allocator>& x, const multiset<Key,Compare,Allocator>& y)
|
||||
{
|
||||
typename multiset<Key,Compare,Allocator>::const_iterator first1 = x.begin();
|
||||
typename multiset<Key,Compare,Allocator>::const_iterator first2 = y.begin();
|
||||
typename multiset<Key,Compare,Allocator>::const_iterator last1 = x.end();
|
||||
typename multiset<Key,Compare,Allocator>::const_iterator last2 = y.end();
|
||||
|
||||
while(first1 != last1 && first2 != last2){
|
||||
if( *first1 > *first2 ){
|
||||
return true;
|
||||
}
|
||||
if( *first2 > *first1 ){
|
||||
return false;
|
||||
}
|
||||
++first1;
|
||||
++first2;
|
||||
}
|
||||
return first1!=last1 && first2 == last2;
|
||||
}
|
||||
|
||||
template <class Key, class Compare, class Allocator> _UCXXEXPORT bool operator>=
|
||||
(const multiset<Key,Compare,Allocator>& x, const multiset<Key,Compare,Allocator>& y)
|
||||
{
|
||||
typename multiset<Key,Compare,Allocator>::const_iterator first1 = x.begin();
|
||||
typename multiset<Key,Compare,Allocator>::const_iterator first2 = y.begin();
|
||||
typename multiset<Key,Compare,Allocator>::const_iterator last1 = x.end();
|
||||
typename multiset<Key,Compare,Allocator>::const_iterator last2 = y.end();
|
||||
|
||||
while(first1 != last1 && first2 != last2){
|
||||
if( *first1 > *first2 ){
|
||||
return true;
|
||||
}
|
||||
if( *first2 > *first1 ){
|
||||
return false;
|
||||
}
|
||||
++first1;
|
||||
++first2;
|
||||
}
|
||||
return first1!=last1;
|
||||
}
|
||||
|
||||
template <class Key, class Compare, class Allocator> _UCXXEXPORT bool operator<=
|
||||
(const multiset<Key,Compare,Allocator>& x, const multiset<Key,Compare,Allocator>& y)
|
||||
{
|
||||
typename multiset<Key,Compare,Allocator>::const_iterator first1 = x.begin();
|
||||
typename multiset<Key,Compare,Allocator>::const_iterator first2 = y.begin();
|
||||
typename multiset<Key,Compare,Allocator>::const_iterator last1 = x.end();
|
||||
typename multiset<Key,Compare,Allocator>::const_iterator last2 = y.end();
|
||||
|
||||
while(first1 != last1 && first2 != last2){
|
||||
if( *first1 < *first2 ){
|
||||
return true;
|
||||
}
|
||||
if( *first2 < *first1 ){
|
||||
return false;
|
||||
}
|
||||
++first1;
|
||||
++first2;
|
||||
}
|
||||
return first2!=last2;
|
||||
}
|
||||
|
||||
template <class Key, class Compare, class Allocator> _UCXXEXPORT void swap
|
||||
(multiset<Key,Compare,Allocator>& x, multiset<Key,Compare,Allocator>& y)
|
||||
{
|
||||
x.swap(y);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#pragma GCC visibility pop
|
||||
|
||||
#endif
|
||||
|
||||
33
libraries/ArduinoSTL/src/set.cpp
Normal file
33
libraries/ArduinoSTL/src/set.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "set"
|
||||
|
||||
namespace std{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
384
libraries/ArduinoSTL/src/sstream
Normal file
384
libraries/ArduinoSTL/src/sstream
Normal file
@@ -0,0 +1,384 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "basic_definitions"
|
||||
|
||||
#ifndef HEADER_STD_SSTREAM
|
||||
#define HEADER_STD_SSTREAM 1
|
||||
|
||||
#include "iosfwd"
|
||||
#include "ios"
|
||||
#include "istream"
|
||||
#include "ostream"
|
||||
#include "iostream"
|
||||
#include "string"
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
|
||||
namespace std{
|
||||
|
||||
template <class charT, class traits, class Allocator>
|
||||
class _UCXXEXPORT basic_stringbuf : public basic_streambuf<charT,traits>
|
||||
{
|
||||
public:
|
||||
typedef charT char_type;
|
||||
typedef typename traits::int_type int_type;
|
||||
typedef typename traits::pos_type pos_type;
|
||||
typedef typename traits::off_type off_type;
|
||||
typedef typename Allocator::size_type size_type;
|
||||
|
||||
explicit _UCXXEXPORT basic_stringbuf(ios_base::openmode which = ios_base::in | ios_base::out)
|
||||
: data(), ielement(0), oelement(0)
|
||||
{
|
||||
basic_streambuf<charT,traits>::openedFor = which;
|
||||
}
|
||||
|
||||
explicit _UCXXEXPORT basic_stringbuf(const basic_string<charT,traits,Allocator>& str,
|
||||
ios_base::openmode which = ios_base::in | ios_base::out)
|
||||
: data(str), ielement(0), oelement(0)
|
||||
{
|
||||
if(which & ios_base::ate){
|
||||
oelement = data.length();
|
||||
}
|
||||
basic_streambuf<charT,traits>::openedFor = which;
|
||||
}
|
||||
|
||||
virtual _UCXXEXPORT ~basic_stringbuf() { }
|
||||
|
||||
_UCXXEXPORT basic_string<charT,traits,Allocator> str() const{
|
||||
return data;
|
||||
}
|
||||
|
||||
_UCXXEXPORT void str(const basic_string<charT,traits,Allocator>& s){
|
||||
data = s;
|
||||
ielement = 0;
|
||||
if(basic_streambuf<charT,traits>::openedFor & ios_base::ate){
|
||||
oelement = data.length();
|
||||
}else{
|
||||
oelement = 0;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual _UCXXEXPORT int sync(){
|
||||
return 0;
|
||||
}
|
||||
virtual _UCXXEXPORT int_type underflow(){
|
||||
if(ielement >= data.length()){
|
||||
return traits::eof();
|
||||
}
|
||||
return traits::to_int_type(data[ielement]);
|
||||
}
|
||||
|
||||
virtual _UCXXEXPORT int_type uflow(){
|
||||
int_type retval = underflow();
|
||||
if(retval != traits::eof()){
|
||||
++ielement;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
virtual _UCXXEXPORT int_type pbackfail(int_type c = traits::eof()){
|
||||
//Error possibilities
|
||||
if(ielement == 0){
|
||||
return traits::eof();
|
||||
}
|
||||
if(ielement > data.length()){
|
||||
ielement = data.length();
|
||||
return traits::eof();
|
||||
}
|
||||
//eof passed in
|
||||
if(traits::eq_int_type(c,traits::eof())==true){
|
||||
--ielement;
|
||||
return traits::not_eof(c);
|
||||
}
|
||||
if(traits::eq(traits::to_char_type(c),data[ielement-1]) == true){
|
||||
--ielement;
|
||||
return c;
|
||||
}
|
||||
if(basic_streambuf<charT,traits>::openedFor & ios_base::out){
|
||||
--ielement;
|
||||
data[ielement] = c;
|
||||
return c;
|
||||
}
|
||||
return traits::eof();
|
||||
}
|
||||
|
||||
virtual _UCXXEXPORT int showmanyc(){
|
||||
return data.length() - ielement;
|
||||
}
|
||||
virtual _UCXXEXPORT streamsize xsgetn(char_type* c, streamsize n){
|
||||
streamsize i = 0;
|
||||
while(ielement < data.length() && i < n ){
|
||||
c[i] = data[ielement];
|
||||
++i;
|
||||
++ielement;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
virtual _UCXXEXPORT int_type overflow (int_type c = traits::eof()){
|
||||
//Nothing to do
|
||||
if(traits::eq_int_type(c,traits::eof())){
|
||||
return traits::not_eof(c);
|
||||
}
|
||||
|
||||
//Actually add character, if possible
|
||||
if(basic_streambuf<charT,traits>::openedFor & ios_base::out){
|
||||
if(oelement >= data.length()){
|
||||
data.push_back(c);
|
||||
}else{
|
||||
data[oelement] = c;
|
||||
}
|
||||
++oelement;
|
||||
return c;
|
||||
}
|
||||
//Not possible
|
||||
return traits::eof();
|
||||
}
|
||||
|
||||
virtual _UCXXEXPORT basic_streambuf<charT,traits>* setbuf(charT*, streamsize){
|
||||
//This function does nothing
|
||||
return this;
|
||||
}
|
||||
|
||||
virtual _UCXXEXPORT streamsize xsputn(const char_type* s, streamsize n){
|
||||
data.replace(oelement, n, s, n);
|
||||
oelement += n;
|
||||
return n;
|
||||
}
|
||||
|
||||
virtual _UCXXEXPORT pos_type seekoff(off_type off, ios_base::seekdir way,
|
||||
ios_base::openmode which = ios_base::in | ios_base::out)
|
||||
{
|
||||
//Test for invalid option
|
||||
if( (which & ios_base::in) && (which & ios_base::out) && (way == ios_base::cur)){
|
||||
return -1;
|
||||
}
|
||||
|
||||
//Calculate new location
|
||||
size_type newpos = 0;
|
||||
|
||||
if(way == ios_base::beg){
|
||||
newpos = off;
|
||||
}else if(way == ios_base::cur){
|
||||
if(which & ios_base::out){
|
||||
newpos = data.length() + off;
|
||||
}
|
||||
if(which & ios_base::in){
|
||||
newpos = ielement + off;
|
||||
}
|
||||
|
||||
}else{
|
||||
newpos = data.length() + off;
|
||||
}
|
||||
|
||||
//Test for error conditions
|
||||
if(newpos > data.length()){
|
||||
return -1;
|
||||
}
|
||||
|
||||
//Shuffle pointers
|
||||
|
||||
if(which & ios_base::in){
|
||||
ielement = newpos;
|
||||
}
|
||||
if(which & ios_base::out){
|
||||
data.resize(newpos);
|
||||
if(ielement > data.length()){
|
||||
ielement = data.length();
|
||||
}
|
||||
}
|
||||
|
||||
return newpos;
|
||||
}
|
||||
|
||||
virtual _UCXXEXPORT pos_type seekpos(pos_type sp,
|
||||
ios_base::openmode which = ios_base::in | ios_base::out)
|
||||
{
|
||||
return seekoff(sp, ios_base::beg, which);
|
||||
}
|
||||
|
||||
basic_string<charT,traits,Allocator> data;
|
||||
size_type ielement;
|
||||
size_type oelement;
|
||||
};
|
||||
|
||||
|
||||
template <class charT, class traits, class Allocator> class _UCXXEXPORT basic_istringstream
|
||||
: public basic_istream<charT,traits>
|
||||
{
|
||||
public:
|
||||
typedef charT char_type;
|
||||
typedef typename traits::int_type int_type;
|
||||
typedef typename traits::pos_type pos_type;
|
||||
typedef typename traits::off_type off_type;
|
||||
|
||||
|
||||
explicit _UCXXEXPORT basic_istringstream(ios_base::openmode m = ios_base::in)
|
||||
: basic_ios<charT, traits>(&sb), basic_istream<charT,traits>(&sb), sb(m)
|
||||
{
|
||||
}
|
||||
explicit _UCXXEXPORT basic_istringstream( const basic_string<charT,traits,Allocator>& str,
|
||||
ios_base::openmode which = ios_base::in)
|
||||
: basic_ios<charT, traits>(&sb), basic_istream<charT,traits>(&sb), sb(str, which)
|
||||
{
|
||||
}
|
||||
virtual _UCXXEXPORT ~basic_istringstream() { }
|
||||
_UCXXEXPORT basic_stringbuf<charT,traits,Allocator>* rdbuf() const{
|
||||
return &sb;
|
||||
}
|
||||
_UCXXEXPORT basic_string<charT,traits,Allocator> str() const{
|
||||
return sb.str();
|
||||
}
|
||||
_UCXXEXPORT void str(const basic_string<charT,traits,Allocator>& s){
|
||||
sb.str(s);
|
||||
basic_istream<charT,traits>::clear();
|
||||
}
|
||||
private:
|
||||
basic_stringbuf<charT,traits,Allocator> sb;
|
||||
};
|
||||
|
||||
|
||||
template <class charT, class traits, class Allocator> class _UCXXEXPORT basic_ostringstream
|
||||
: public basic_ostream<charT,traits>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef charT char_type;
|
||||
typedef typename traits::int_type int_type;
|
||||
typedef typename traits::pos_type pos_type;
|
||||
typedef typename traits::off_type off_type;
|
||||
|
||||
explicit _UCXXEXPORT basic_ostringstream(ios_base::openmode m = ios_base::out)
|
||||
: basic_ios<charT, traits>(&sb), basic_ostream<charT,traits>(&sb), sb(m)
|
||||
{
|
||||
}
|
||||
explicit _UCXXEXPORT basic_ostringstream(const basic_string<charT,traits,Allocator>& str,
|
||||
ios_base::openmode which = ios_base::out)
|
||||
: basic_ios<charT, traits>(&sb), basic_ostream<charT,traits>(&sb), sb(str, which)
|
||||
{
|
||||
}
|
||||
virtual _UCXXEXPORT ~basic_ostringstream() { }
|
||||
|
||||
_UCXXEXPORT basic_stringbuf<charT,traits,Allocator>* rdbuf() const{
|
||||
return &sb;
|
||||
}
|
||||
_UCXXEXPORT basic_string<charT,traits,Allocator> str() const{
|
||||
return sb.str();
|
||||
}
|
||||
_UCXXEXPORT void str(const basic_string<charT,traits,Allocator>& s){
|
||||
sb.str(s);
|
||||
basic_ostream<charT,traits>::clear();
|
||||
}
|
||||
private:
|
||||
basic_stringbuf<charT,traits,Allocator> sb;
|
||||
};
|
||||
|
||||
|
||||
template <class charT, class traits, class Allocator> class _UCXXEXPORT basic_stringstream
|
||||
: public basic_iostream<charT,traits>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef charT char_type;
|
||||
typedef typename traits::int_type int_type;
|
||||
typedef typename traits::pos_type pos_type;
|
||||
typedef typename traits::off_type off_type;
|
||||
|
||||
explicit _UCXXEXPORT basic_stringstream(ios_base::openmode which = ios_base::out|ios_base::in)
|
||||
: basic_ios<charT, traits>(&sb), basic_iostream<charT,traits>(&sb), sb(which)
|
||||
{
|
||||
}
|
||||
|
||||
explicit _UCXXEXPORT basic_stringstream(const basic_string<charT,traits,Allocator>& str,
|
||||
ios_base::openmode which = ios_base::out|ios_base::in)
|
||||
: basic_ios<charT, traits>(&sb), basic_iostream<charT,traits>(&sb), sb(str, which)
|
||||
{
|
||||
}
|
||||
virtual _UCXXEXPORT ~basic_stringstream(){ }
|
||||
|
||||
_UCXXEXPORT basic_stringbuf<charT,traits,Allocator>* rdbuf(){
|
||||
return &sb;
|
||||
}
|
||||
_UCXXEXPORT basic_string<charT,traits,Allocator> str() const{
|
||||
return sb.str();
|
||||
}
|
||||
_UCXXEXPORT void str(const basic_string<charT,traits,Allocator>& s){
|
||||
sb.str(s);
|
||||
basic_iostream<charT,traits>::clear();
|
||||
}
|
||||
private:
|
||||
basic_stringbuf<charT, traits> sb;
|
||||
};
|
||||
|
||||
#ifdef __UCLIBCXX_EXPAND_SSTREAM_CHAR__
|
||||
#ifndef __UCLIBCXX_COMPILE_SSTREAM__
|
||||
|
||||
#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
|
||||
|
||||
template <> _UCXXEXPORT basic_stringbuf<char, char_traits<char>, allocator<char> >::
|
||||
basic_stringbuf(ios_base::openmode which);
|
||||
template <> _UCXXEXPORT basic_stringbuf<char, char_traits<char>, allocator<char> >::~basic_stringbuf();
|
||||
|
||||
#endif // __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
|
||||
|
||||
template <> _UCXXEXPORT basic_string<char, char_traits<char>, allocator<char> >
|
||||
basic_stringbuf<char, char_traits<char>, allocator<char> >::str() const;
|
||||
|
||||
template <> _UCXXEXPORT basic_stringbuf<char, char_traits<char>, allocator<char> >::int_type
|
||||
basic_stringbuf<char, char_traits<char>, allocator<char> >::
|
||||
pbackfail(basic_stringbuf<char, char_traits<char>, allocator<char> >::int_type c);
|
||||
|
||||
template <> _UCXXEXPORT basic_stringbuf<char, char_traits<char>, allocator<char> >::pos_type
|
||||
basic_stringbuf<char, char_traits<char>, allocator<char> >::
|
||||
seekoff (basic_stringbuf<char, char_traits<char>, allocator<char> >::off_type off,
|
||||
ios_base::seekdir way,
|
||||
ios_base::openmode which
|
||||
);
|
||||
|
||||
template <> _UCXXEXPORT basic_stringbuf<char, char_traits<char>, allocator<char> >::int_type
|
||||
basic_stringbuf<char, char_traits<char>, allocator<char> >::
|
||||
overflow (basic_stringbuf<char, char_traits<char>, allocator<char> >::int_type c);
|
||||
|
||||
template <> _UCXXEXPORT basic_stringbuf<char, char_traits<char>, allocator<char> >::int_type
|
||||
basic_stringbuf<char, char_traits<char>, allocator<char> >::underflow ();
|
||||
|
||||
template <> _UCXXEXPORT streamsize basic_stringbuf<char, char_traits<char>, allocator<char> >::
|
||||
xsputn(const char* s, streamsize n);
|
||||
|
||||
#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
|
||||
|
||||
template <> _UCXXEXPORT basic_stringstream<char, char_traits<char>, allocator<char> >::
|
||||
basic_stringstream(ios_base::openmode which);
|
||||
template <> _UCXXEXPORT basic_stringstream<char, char_traits<char>, allocator<char> >::~basic_stringstream();
|
||||
template <> _UCXXEXPORT basic_istringstream<char, char_traits<char>, allocator<char> >::~basic_istringstream();
|
||||
template <> _UCXXEXPORT basic_ostringstream<char, char_traits<char>, allocator<char> >::~basic_ostringstream();
|
||||
|
||||
#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#pragma GCC visibility pop
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
59
libraries/ArduinoSTL/src/sstream.cpp
Normal file
59
libraries/ArduinoSTL/src/sstream.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
|
||||
This file is part of the uClibc++ Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#define __UCLIBCXX_COMPILE_SSTREAM__ 1
|
||||
|
||||
#include "sstream"
|
||||
|
||||
namespace std{
|
||||
|
||||
#ifdef __UCLIBCXX_EXPAND_SSTREAM_CHAR__
|
||||
|
||||
typedef char_traits<char> tr_ch;
|
||||
typedef basic_stringbuf<char, tr_ch, allocator<char> > char_stringbuf;
|
||||
|
||||
#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
|
||||
|
||||
template _UCXXEXPORT char_stringbuf::basic_stringbuf(ios_base::openmode which);
|
||||
template _UCXXEXPORT char_stringbuf::~basic_stringbuf();
|
||||
|
||||
#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
|
||||
|
||||
template _UCXXEXPORT basic_string<char, char_traits<char>, allocator<char> > char_stringbuf::str() const;
|
||||
template _UCXXEXPORT char_stringbuf::int_type char_stringbuf::pbackfail(char_stringbuf::int_type c);
|
||||
template _UCXXEXPORT char_stringbuf::int_type char_stringbuf::overflow(char_stringbuf::int_type c);
|
||||
template _UCXXEXPORT char_stringbuf::pos_type
|
||||
char_stringbuf::seekoff(char_stringbuf::off_type, ios_base::seekdir, ios_base::openmode);
|
||||
template _UCXXEXPORT char_stringbuf::int_type char_stringbuf::underflow ();
|
||||
template _UCXXEXPORT streamsize char_stringbuf::xsputn(const char* s, streamsize n);
|
||||
|
||||
#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
|
||||
|
||||
template _UCXXEXPORT basic_stringstream<char, tr_ch, allocator<char> >::basic_stringstream(ios_base::openmode which);
|
||||
template _UCXXEXPORT basic_istringstream<char, tr_ch, allocator<char> >::~basic_istringstream();
|
||||
template _UCXXEXPORT basic_ostringstream<char, tr_ch, allocator<char> >::~basic_ostringstream();
|
||||
template _UCXXEXPORT basic_stringstream<char, tr_ch, allocator<char> >::~basic_stringstream();
|
||||
|
||||
#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
84
libraries/ArduinoSTL/src/stack
Normal file
84
libraries/ArduinoSTL/src/stack
Normal file
@@ -0,0 +1,84 @@
|
||||
/* Copyright (C) 2004 Garrett A. Kajmowicz
|
||||
This file is part of the uClibc++ Library.
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "basic_definitions"
|
||||
#include "deque"
|
||||
|
||||
#ifndef __HEADER_STD_STACK
|
||||
#define __HEADER_STD_STACK 1
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
|
||||
namespace std{
|
||||
|
||||
template <class T, class Container = deque<T> > class _UCXXEXPORT stack{
|
||||
protected:
|
||||
Container c;
|
||||
|
||||
public:
|
||||
typedef typename Container::value_type value_type;
|
||||
typedef typename Container::size_type size_type;
|
||||
typedef Container container_type;
|
||||
|
||||
explicit stack(const Container& a = Container()) : c(a) { }
|
||||
bool empty() const { return c.empty(); }
|
||||
size_type size() const { return c.size(); }
|
||||
value_type& top() { return c.back(); }
|
||||
const value_type& top() const { return c.back(); }
|
||||
void push(const value_type& x) { c.push_back(x); }
|
||||
void pop() { c.pop_back(); }
|
||||
|
||||
bool operator==(const stack<T, Container> &x) const{
|
||||
return x.c == c;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
template <class T, class Container> _UCXXEXPORT bool
|
||||
operator< (const stack<T, Container>& x, const stack<T, Container>& y)
|
||||
{
|
||||
return (x.c < y.c);
|
||||
}
|
||||
template <class T, class Container> _UCXXEXPORT bool
|
||||
operator!=(const stack<T, Container>& x, const stack<T, Container>& y)
|
||||
{
|
||||
return (x.c != y.c);
|
||||
}
|
||||
template <class T, class Container> _UCXXEXPORT bool
|
||||
operator> (const stack<T, Container>& x, const stack<T, Container>& y)
|
||||
{
|
||||
return (x.c > y.c);
|
||||
}
|
||||
template <class T, class Container> _UCXXEXPORT bool
|
||||
operator>=(const stack<T, Container>& x, const stack<T, Container>& y)
|
||||
{
|
||||
return (x.c >= y.c);
|
||||
}
|
||||
template <class T, class Container> _UCXXEXPORT bool
|
||||
operator<=(const stack<T, Container>& x, const stack<T, Container>& y)
|
||||
{
|
||||
return (x.c <= y.c);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#pragma GCC visibility pop
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user