Compare commits
1 Commits
doc_ai
...
winconsole
| Author | SHA1 | Date | |
|---|---|---|---|
| 62c5523127 |
@@ -134,8 +134,8 @@ JavaScriptQuotes: Leave
|
||||
JavaScriptWrapImports: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
LambdaBodyIndentation: Signature
|
||||
MacroBlockBegin: "PRIVATE_DEFINITION_START|STATIC_INITIALIZER_BEGIN|DECLARE_UNIT_CLASS_BEGIN"
|
||||
MacroBlockEnd: "PRIVATE_DEFINITION_END|PRIVATE_DEFINITION_END_NO_INITIALIZE|STATIC_INITIALIZER_END|DECLARE_UNIT_CLASS_END"
|
||||
MacroBlockBegin: "PRIVATE_DEFINITION_START|STATIC_INITIALIZER_BEGIN"
|
||||
MacroBlockEnd: "PRIVATE_DEFINITION_END|PRIVATE_DEFINITION_END_NO_INITIALIZE|STATIC_INITIALIZER_END"
|
||||
MaxEmptyLinesToKeep: 2
|
||||
NamespaceIndentation: None
|
||||
ObjCBinPackProtocolList: Auto
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
Creative Commons Legal Code
|
||||
|
||||
CC0 1.0 Universal
|
||||
|
||||
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
||||
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
|
||||
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
||||
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
||||
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
|
||||
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
|
||||
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
|
||||
HEREUNDER.
|
||||
|
||||
Statement of Purpose
|
||||
|
||||
The laws of most jurisdictions throughout the world automatically confer
|
||||
exclusive Copyright and Related Rights (defined below) upon the creator
|
||||
and subsequent owner(s) (each and all, an "owner") of an original work of
|
||||
authorship and/or a database (each, a "Work").
|
||||
|
||||
Certain owners wish to permanently relinquish those rights to a Work for
|
||||
the purpose of contributing to a commons of creative, cultural and
|
||||
scientific works ("Commons") that the public can reliably and without fear
|
||||
of later claims of infringement build upon, modify, incorporate in other
|
||||
works, reuse and redistribute as freely as possible in any form whatsoever
|
||||
and for any purposes, including without limitation commercial purposes.
|
||||
These owners may contribute to the Commons to promote the ideal of a free
|
||||
culture and the further production of creative, cultural and scientific
|
||||
works, or to gain reputation or greater distribution for their Work in
|
||||
part through the use and efforts of others.
|
||||
|
||||
For these and/or other purposes and motivations, and without any
|
||||
expectation of additional consideration or compensation, the person
|
||||
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
|
||||
is an owner of Copyright and Related Rights in the Work, voluntarily
|
||||
elects to apply CC0 to the Work and publicly distribute the Work under its
|
||||
terms, with knowledge of his or her Copyright and Related Rights in the
|
||||
Work and the meaning and intended legal effect of CC0 on those rights.
|
||||
|
||||
1. Copyright and Related Rights. A Work made available under CC0 may be
|
||||
protected by copyright and related or neighboring rights ("Copyright and
|
||||
Related Rights"). Copyright and Related Rights include, but are not
|
||||
limited to, the following:
|
||||
|
||||
i. the right to reproduce, adapt, distribute, perform, display,
|
||||
communicate, and translate a Work;
|
||||
ii. moral rights retained by the original author(s) and/or performer(s);
|
||||
iii. publicity and privacy rights pertaining to a person's image or
|
||||
likeness depicted in a Work;
|
||||
iv. rights protecting against unfair competition in regards to a Work,
|
||||
subject to the limitations in paragraph 4(a), below;
|
||||
v. rights protecting the extraction, dissemination, use and reuse of data
|
||||
in a Work;
|
||||
vi. database rights (such as those arising under Directive 96/9/EC of the
|
||||
European Parliament and of the Council of 11 March 1996 on the legal
|
||||
protection of databases, and under any national implementation
|
||||
thereof, including any amended or successor version of such
|
||||
directive); and
|
||||
vii. other similar, equivalent or corresponding rights throughout the
|
||||
world based on applicable law or treaty, and any national
|
||||
implementations thereof.
|
||||
|
||||
2. Waiver. To the greatest extent permitted by, but not in contravention
|
||||
of, applicable law, Affirmer hereby overtly, fully, permanently,
|
||||
irrevocably and unconditionally waives, abandons, and surrenders all of
|
||||
Affirmer's Copyright and Related Rights and associated claims and causes
|
||||
of action, whether now known or unknown (including existing as well as
|
||||
future claims and causes of action), in the Work (i) in all territories
|
||||
worldwide, (ii) for the maximum duration provided by applicable law or
|
||||
treaty (including future time extensions), (iii) in any current or future
|
||||
medium and for any number of copies, and (iv) for any purpose whatsoever,
|
||||
including without limitation commercial, advertising or promotional
|
||||
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
|
||||
member of the public at large and to the detriment of Affirmer's heirs and
|
||||
successors, fully intending that such Waiver shall not be subject to
|
||||
revocation, rescission, cancellation, termination, or any other legal or
|
||||
equitable action to disrupt the quiet enjoyment of the Work by the public
|
||||
as contemplated by Affirmer's express Statement of Purpose.
|
||||
|
||||
3. Public License Fallback. Should any part of the Waiver for any reason
|
||||
be judged legally invalid or ineffective under applicable law, then the
|
||||
Waiver shall be preserved to the maximum extent permitted taking into
|
||||
account Affirmer's express Statement of Purpose. In addition, to the
|
||||
extent the Waiver is so judged Affirmer hereby grants to each affected
|
||||
person a royalty-free, non transferable, non sublicensable, non exclusive,
|
||||
irrevocable and unconditional license to exercise Affirmer's Copyright and
|
||||
Related Rights in the Work (i) in all territories worldwide, (ii) for the
|
||||
maximum duration provided by applicable law or treaty (including future
|
||||
time extensions), (iii) in any current or future medium and for any number
|
||||
of copies, and (iv) for any purpose whatsoever, including without
|
||||
limitation commercial, advertising or promotional purposes (the
|
||||
"License"). The License shall be deemed effective as of the date CC0 was
|
||||
applied by Affirmer to the Work. Should any part of the License for any
|
||||
reason be judged legally invalid or ineffective under applicable law, such
|
||||
partial invalidity or ineffectiveness shall not invalidate the remainder
|
||||
of the License, and in such case Affirmer hereby affirms that he or she
|
||||
will not (i) exercise any of his or her remaining Copyright and Related
|
||||
Rights in the Work or (ii) assert any associated claims and causes of
|
||||
action with respect to the Work, in either case contrary to Affirmer's
|
||||
express Statement of Purpose.
|
||||
|
||||
4. Limitations and Disclaimers.
|
||||
|
||||
a. No trademark or patent rights held by Affirmer are waived, abandoned,
|
||||
surrendered, licensed or otherwise affected by this document.
|
||||
b. Affirmer offers the Work as-is and makes no representations or
|
||||
warranties of any kind concerning the Work, express, implied,
|
||||
statutory or otherwise, including without limitation warranties of
|
||||
title, merchantability, fitness for a particular purpose, non
|
||||
infringement, or the absence of latent or other defects, accuracy, or
|
||||
the present or absence of errors, whether or not discoverable, all to
|
||||
the greatest extent permissible under applicable law.
|
||||
c. Affirmer disclaims responsibility for clearing rights of other persons
|
||||
that may apply to the Work or any use thereof, including without
|
||||
limitation any person's Copyright and Related Rights in the Work.
|
||||
Further, Affirmer disclaims responsibility for obtaining any necessary
|
||||
consents, permissions or other rights required for any use of the
|
||||
Work.
|
||||
d. Affirmer understands and acknowledges that Creative Commons is not a
|
||||
party to this document and has no duty or obligation with respect to
|
||||
this CC0 or use of the Work.
|
||||
@@ -1,219 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
|
||||
---- LLVM Exceptions to the Apache 2.0 License ----
|
||||
|
||||
As an exception, if, as a result of your compiling your source code, portions
|
||||
of this Software are embedded into an Object form of such source code, you
|
||||
may redistribute such embedded portions in such Object form without complying
|
||||
with the conditions of Sections 4(a), 4(b) and 4(d) of the License.
|
||||
|
||||
In addition, if you combine or link compiled forms of this Software with
|
||||
software that is licensed under the GPLv2 ("Combined Software") and if a
|
||||
court of competent jurisdiction determines that the patent provision (Section
|
||||
3), the indemnity provision (Section 9) or other Section of the License
|
||||
conflicts with the conditions of the GPLv2, you may retroactively and
|
||||
prospectively choose to deem waived or otherwise exclude such Section(s) of
|
||||
the License, but only in their entirety and only with respect to the Combined
|
||||
Software.
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
CC0 1.0 Universal
|
||||
|
||||
Statement of Purpose
|
||||
|
||||
The laws of most jurisdictions throughout the world automatically confer
|
||||
exclusive Copyright and Related Rights (defined below) upon the creator and
|
||||
subsequent owner(s) (each and all, an "owner") of an original work of
|
||||
authorship and/or a database (each, a "Work").
|
||||
|
||||
Certain owners wish to permanently relinquish those rights to a Work for the
|
||||
purpose of contributing to a commons of creative, cultural and scientific
|
||||
works ("Commons") that the public can reliably and without fear of later
|
||||
claims of infringement build upon, modify, incorporate in other works, reuse
|
||||
and redistribute as freely as possible in any form whatsoever and for any
|
||||
purposes, including without limitation commercial purposes. These owners may
|
||||
contribute to the Commons to promote the ideal of a free culture and the
|
||||
further production of creative, cultural and scientific works, or to gain
|
||||
reputation or greater distribution for their Work in part through the use and
|
||||
efforts of others.
|
||||
|
||||
For these and/or other purposes and motivations, and without any expectation
|
||||
of additional consideration or compensation, the person associating CC0 with a
|
||||
Work (the "Affirmer"), to the extent that he or she is an owner of Copyright
|
||||
and Related Rights in the Work, voluntarily elects to apply CC0 to the Work
|
||||
and publicly distribute the Work under its terms, with knowledge of his or her
|
||||
Copyright and Related Rights in the Work and the meaning and intended legal
|
||||
effect of CC0 on those rights.
|
||||
|
||||
1. Copyright and Related Rights. A Work made available under CC0 may be
|
||||
protected by copyright and related or neighboring rights ("Copyright and
|
||||
Related Rights"). Copyright and Related Rights include, but are not limited
|
||||
to, the following:
|
||||
|
||||
i. the right to reproduce, adapt, distribute, perform, display, communicate,
|
||||
and translate a Work;
|
||||
|
||||
ii. moral rights retained by the original author(s) and/or performer(s);
|
||||
|
||||
iii. publicity and privacy rights pertaining to a person's image or likeness
|
||||
depicted in a Work;
|
||||
|
||||
iv. rights protecting against unfair competition in regards to a Work,
|
||||
subject to the limitations in paragraph 4(a), below;
|
||||
|
||||
v. rights protecting the extraction, dissemination, use and reuse of data in
|
||||
a Work;
|
||||
|
||||
vi. database rights (such as those arising under Directive 96/9/EC of the
|
||||
European Parliament and of the Council of 11 March 1996 on the legal
|
||||
protection of databases, and under any national implementation thereof,
|
||||
including any amended or successor version of such directive); and
|
||||
|
||||
vii. other similar, equivalent or corresponding rights throughout the world
|
||||
based on applicable law or treaty, and any national implementations thereof.
|
||||
|
||||
2. Waiver. To the greatest extent permitted by, but not in contravention of,
|
||||
applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and
|
||||
unconditionally waives, abandons, and surrenders all of Affirmer's Copyright
|
||||
and Related Rights and associated claims and causes of action, whether now
|
||||
known or unknown (including existing as well as future claims and causes of
|
||||
action), in the Work (i) in all territories worldwide, (ii) for the maximum
|
||||
duration provided by applicable law or treaty (including future time
|
||||
extensions), (iii) in any current or future medium and for any number of
|
||||
copies, and (iv) for any purpose whatsoever, including without limitation
|
||||
commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes
|
||||
the Waiver for the benefit of each member of the public at large and to the
|
||||
detriment of Affirmer's heirs and successors, fully intending that such Waiver
|
||||
shall not be subject to revocation, rescission, cancellation, termination, or
|
||||
any other legal or equitable action to disrupt the quiet enjoyment of the Work
|
||||
by the public as contemplated by Affirmer's express Statement of Purpose.
|
||||
|
||||
3. Public License Fallback. Should any part of the Waiver for any reason be
|
||||
judged legally invalid or ineffective under applicable law, then the Waiver
|
||||
shall be preserved to the maximum extent permitted taking into account
|
||||
Affirmer's express Statement of Purpose. In addition, to the extent the Waiver
|
||||
is so judged Affirmer hereby grants to each affected person a royalty-free,
|
||||
non transferable, non sublicensable, non exclusive, irrevocable and
|
||||
unconditional license to exercise Affirmer's Copyright and Related Rights in
|
||||
the Work (i) in all territories worldwide, (ii) for the maximum duration
|
||||
provided by applicable law or treaty (including future time extensions), (iii)
|
||||
in any current or future medium and for any number of copies, and (iv) for any
|
||||
purpose whatsoever, including without limitation commercial, advertising or
|
||||
promotional purposes (the "License"). The License shall be deemed effective as
|
||||
of the date CC0 was applied by Affirmer to the Work. Should any part of the
|
||||
License for any reason be judged legally invalid or ineffective under
|
||||
applicable law, such partial invalidity or ineffectiveness shall not
|
||||
invalidate the remainder of the License, and in such case Affirmer hereby
|
||||
affirms that he or she will not (i) exercise any of his or her remaining
|
||||
Copyright and Related Rights in the Work or (ii) assert any associated claims
|
||||
and causes of action with respect to the Work, in either case contrary to
|
||||
Affirmer's express Statement of Purpose.
|
||||
|
||||
4. Limitations and Disclaimers.
|
||||
|
||||
a. No trademark or patent rights held by Affirmer are waived, abandoned,
|
||||
surrendered, licensed or otherwise affected by this document.
|
||||
|
||||
b. Affirmer offers the Work as-is and makes no representations or warranties
|
||||
of any kind concerning the Work, express, implied, statutory or otherwise,
|
||||
including without limitation warranties of title, merchantability, fitness
|
||||
for a particular purpose, non infringement, or the absence of latent or
|
||||
other defects, accuracy, or the present or absence of errors, whether or not
|
||||
discoverable, all to the greatest extent permissible under applicable law.
|
||||
|
||||
c. Affirmer disclaims responsibility for clearing rights of other persons
|
||||
that may apply to the Work or any use thereof, including without limitation
|
||||
any person's Copyright and Related Rights in the Work. Further, Affirmer
|
||||
disclaims responsibility for obtaining any necessary consents, permissions
|
||||
or other rights required for any use of the Work.
|
||||
|
||||
d. Affirmer understands and acknowledges that Creative Commons is not a
|
||||
party to this document and has no duty or obligation with respect to this
|
||||
CC0 or use of the Work.
|
||||
|
||||
For more information, please see
|
||||
<http://creativecommons.org/publicdomain/zero/1.0/>
|
||||
@@ -1,7 +0,0 @@
|
||||
Copyright 2012-2024 JP Aumasson
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -1,166 +0,0 @@
|
||||
|
||||
/*
|
||||
SipHash reference C implementation
|
||||
|
||||
Copyright (c) 2016 Jean-Philippe Aumasson <jeanphilippe.aumasson@gmail.com>
|
||||
|
||||
To the extent possible under law, the author(s) have dedicated all copyright
|
||||
and related and neighboring rights to this software to the public domain
|
||||
worldwide. This software is distributed without any warranty.
|
||||
|
||||
You should have received a copy of the CC0 Public Domain Dedication along
|
||||
with
|
||||
this software. If not, see
|
||||
<http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
*/
|
||||
#include "halfsiphash.h"
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/* default: SipHash-2-4 */
|
||||
#ifndef cROUNDS
|
||||
#define cROUNDS 2
|
||||
#endif
|
||||
#ifndef dROUNDS
|
||||
#define dROUNDS 4
|
||||
#endif
|
||||
|
||||
#define ROTL(x, b) (uint32_t)(((x) << (b)) | ((x) >> (32 - (b))))
|
||||
|
||||
#define U32TO8_LE(p, v) \
|
||||
(p)[0] = (uint8_t)((v)); \
|
||||
(p)[1] = (uint8_t)((v) >> 8); \
|
||||
(p)[2] = (uint8_t)((v) >> 16); \
|
||||
(p)[3] = (uint8_t)((v) >> 24);
|
||||
|
||||
#define U8TO32_LE(p) \
|
||||
(((uint32_t)((p)[0])) | ((uint32_t)((p)[1]) << 8) | \
|
||||
((uint32_t)((p)[2]) << 16) | ((uint32_t)((p)[3]) << 24))
|
||||
|
||||
#define SIPROUND \
|
||||
do { \
|
||||
v0 += v1; \
|
||||
v1 = ROTL(v1, 5); \
|
||||
v1 ^= v0; \
|
||||
v0 = ROTL(v0, 16); \
|
||||
v2 += v3; \
|
||||
v3 = ROTL(v3, 8); \
|
||||
v3 ^= v2; \
|
||||
v0 += v3; \
|
||||
v3 = ROTL(v3, 7); \
|
||||
v3 ^= v0; \
|
||||
v2 += v1; \
|
||||
v1 = ROTL(v1, 13); \
|
||||
v1 ^= v2; \
|
||||
v2 = ROTL(v2, 16); \
|
||||
} while (0)
|
||||
|
||||
|
||||
#ifdef DEBUG_SIPHASH
|
||||
#include <stdio.h>
|
||||
|
||||
#define TRACE \
|
||||
do { \
|
||||
printf("(%3zu) v0 %08" PRIx32 "\n", inlen, v0); \
|
||||
printf("(%3zu) v1 %08" PRIx32 "\n", inlen, v1); \
|
||||
printf("(%3zu) v2 %08" PRIx32 "\n", inlen, v2); \
|
||||
printf("(%3zu) v3 %08" PRIx32 "\n", inlen, v3); \
|
||||
} while (0)
|
||||
#else
|
||||
#define TRACE
|
||||
#endif
|
||||
|
||||
/*
|
||||
Computes a SipHash value
|
||||
*in: pointer to input data (read-only)
|
||||
inlen: input data length in bytes (any size_t value)
|
||||
*k: pointer to the key data (read-only), must be 8 bytes
|
||||
*out: pointer to output data (write-only), outlen bytes must be allocated
|
||||
outlen: length of the output in bytes, must be 4 or 8
|
||||
*/
|
||||
int halfsiphash(const void *in, const size_t inlen, const void *k, uint8_t *out,
|
||||
const size_t outlen) {
|
||||
|
||||
const unsigned char *ni = (const unsigned char *)in;
|
||||
const unsigned char *kk = (const unsigned char *)k;
|
||||
|
||||
assert((outlen == 4) || (outlen == 8));
|
||||
uint32_t v0 = 0;
|
||||
uint32_t v1 = 0;
|
||||
uint32_t v2 = UINT32_C(0x6c796765);
|
||||
uint32_t v3 = UINT32_C(0x74656462);
|
||||
uint32_t k0 = U8TO32_LE(kk);
|
||||
uint32_t k1 = U8TO32_LE(kk + 4);
|
||||
uint32_t m;
|
||||
int i;
|
||||
const unsigned char *end = ni + inlen - (inlen % sizeof(uint32_t));
|
||||
const int left = inlen & 3;
|
||||
uint32_t b = ((uint32_t)inlen) << 24;
|
||||
v3 ^= k1;
|
||||
v2 ^= k0;
|
||||
v1 ^= k1;
|
||||
v0 ^= k0;
|
||||
|
||||
if (outlen == 8)
|
||||
v1 ^= 0xee;
|
||||
|
||||
for (; ni != end; ni += 4) {
|
||||
m = U8TO32_LE(ni);
|
||||
v3 ^= m;
|
||||
|
||||
TRACE;
|
||||
for (i = 0; i < cROUNDS; ++i)
|
||||
SIPROUND;
|
||||
|
||||
v0 ^= m;
|
||||
}
|
||||
|
||||
switch (left) {
|
||||
case 3:
|
||||
b |= ((uint32_t)ni[2]) << 16;
|
||||
/* FALLTHRU */
|
||||
case 2:
|
||||
b |= ((uint32_t)ni[1]) << 8;
|
||||
/* FALLTHRU */
|
||||
case 1:
|
||||
b |= ((uint32_t)ni[0]);
|
||||
break;
|
||||
case 0:
|
||||
break;
|
||||
}
|
||||
|
||||
v3 ^= b;
|
||||
|
||||
TRACE;
|
||||
for (i = 0; i < cROUNDS; ++i)
|
||||
SIPROUND;
|
||||
|
||||
v0 ^= b;
|
||||
|
||||
if (outlen == 8)
|
||||
v2 ^= 0xee;
|
||||
else
|
||||
v2 ^= 0xff;
|
||||
|
||||
TRACE;
|
||||
for (i = 0; i < dROUNDS; ++i)
|
||||
SIPROUND;
|
||||
|
||||
b = v1 ^ v3;
|
||||
U32TO8_LE(out, b);
|
||||
|
||||
if (outlen == 4)
|
||||
return 0;
|
||||
|
||||
v1 ^= 0xdd;
|
||||
|
||||
TRACE;
|
||||
for (i = 0; i < dROUNDS; ++i)
|
||||
SIPROUND;
|
||||
|
||||
b = v1 ^ v3;
|
||||
U32TO8_LE(out + 4, b);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
SipHash reference C implementation
|
||||
|
||||
Copyright (c) 2012-2021 Jean-Philippe Aumasson
|
||||
<jeanphilippe.aumasson@gmail.com>
|
||||
Copyright (c) 2012-2014 Daniel J. Bernstein <djb@cr.yp.to>
|
||||
|
||||
To the extent possible under law, the author(s) have dedicated all copyright
|
||||
and related and neighboring rights to this software to the public domain
|
||||
worldwide. This software is distributed without any warranty.
|
||||
|
||||
You should have received a copy of the CC0 Public Domain Dedication along
|
||||
with
|
||||
this software. If not, see
|
||||
<http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
*/
|
||||
|
||||
#ifndef HALFSIPHASH_H
|
||||
#define HALFSIPHASH_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int halfsiphash(const void * in, const size_t inlen, const void * k, uint8_t * out, const size_t outlen);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,185 +0,0 @@
|
||||
/*
|
||||
SipHash reference C implementation
|
||||
|
||||
Copyright (c) 2012-2022 Jean-Philippe Aumasson
|
||||
<jeanphilippe.aumasson@gmail.com>
|
||||
Copyright (c) 2012-2014 Daniel J. Bernstein <djb@cr.yp.to>
|
||||
|
||||
To the extent possible under law, the author(s) have dedicated all copyright
|
||||
and related and neighboring rights to this software to the public domain
|
||||
worldwide. This software is distributed without any warranty.
|
||||
|
||||
You should have received a copy of the CC0 Public Domain Dedication along
|
||||
with
|
||||
this software. If not, see
|
||||
<http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
*/
|
||||
|
||||
#include "siphash.h"
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/* default: SipHash-2-4 */
|
||||
#ifndef cROUNDS
|
||||
#define cROUNDS 2
|
||||
#endif
|
||||
#ifndef dROUNDS
|
||||
#define dROUNDS 4
|
||||
#endif
|
||||
|
||||
#define ROTL(x, b) (uint64_t)(((x) << (b)) | ((x) >> (64 - (b))))
|
||||
|
||||
#define U32TO8_LE(p, v) \
|
||||
(p)[0] = (uint8_t)((v)); \
|
||||
(p)[1] = (uint8_t)((v) >> 8); \
|
||||
(p)[2] = (uint8_t)((v) >> 16); \
|
||||
(p)[3] = (uint8_t)((v) >> 24);
|
||||
|
||||
#define U64TO8_LE(p, v) \
|
||||
U32TO8_LE((p), (uint32_t)((v))); \
|
||||
U32TO8_LE((p) + 4, (uint32_t)((v) >> 32));
|
||||
|
||||
#define U8TO64_LE(p) \
|
||||
(((uint64_t)((p)[0])) | ((uint64_t)((p)[1]) << 8) | \
|
||||
((uint64_t)((p)[2]) << 16) | ((uint64_t)((p)[3]) << 24) | \
|
||||
((uint64_t)((p)[4]) << 32) | ((uint64_t)((p)[5]) << 40) | \
|
||||
((uint64_t)((p)[6]) << 48) | ((uint64_t)((p)[7]) << 56))
|
||||
|
||||
#define SIPROUND \
|
||||
do { \
|
||||
v0 += v1; \
|
||||
v1 = ROTL(v1, 13); \
|
||||
v1 ^= v0; \
|
||||
v0 = ROTL(v0, 32); \
|
||||
v2 += v3; \
|
||||
v3 = ROTL(v3, 16); \
|
||||
v3 ^= v2; \
|
||||
v0 += v3; \
|
||||
v3 = ROTL(v3, 21); \
|
||||
v3 ^= v0; \
|
||||
v2 += v1; \
|
||||
v1 = ROTL(v1, 17); \
|
||||
v1 ^= v2; \
|
||||
v2 = ROTL(v2, 32); \
|
||||
} while (0)
|
||||
|
||||
#ifdef DEBUG_SIPHASH
|
||||
#include <stdio.h>
|
||||
|
||||
#define TRACE \
|
||||
do { \
|
||||
printf("(%3zu) v0 %016" PRIx64 "\n", inlen, v0); \
|
||||
printf("(%3zu) v1 %016" PRIx64 "\n", inlen, v1); \
|
||||
printf("(%3zu) v2 %016" PRIx64 "\n", inlen, v2); \
|
||||
printf("(%3zu) v3 %016" PRIx64 "\n", inlen, v3); \
|
||||
} while (0)
|
||||
#else
|
||||
#define TRACE
|
||||
#endif
|
||||
|
||||
/*
|
||||
Computes a SipHash value
|
||||
*in: pointer to input data (read-only)
|
||||
inlen: input data length in bytes (any size_t value)
|
||||
*k: pointer to the key data (read-only), must be 16 bytes
|
||||
*out: pointer to output data (write-only), outlen bytes must be allocated
|
||||
outlen: length of the output in bytes, must be 8 or 16
|
||||
*/
|
||||
int siphash(const void *in, const size_t inlen, const void *k, uint8_t *out,
|
||||
const size_t outlen) {
|
||||
|
||||
const unsigned char *ni = (const unsigned char *)in;
|
||||
const unsigned char *kk = (const unsigned char *)k;
|
||||
|
||||
assert((outlen == 8) || (outlen == 16));
|
||||
uint64_t v0 = UINT64_C(0x736f6d6570736575);
|
||||
uint64_t v1 = UINT64_C(0x646f72616e646f6d);
|
||||
uint64_t v2 = UINT64_C(0x6c7967656e657261);
|
||||
uint64_t v3 = UINT64_C(0x7465646279746573);
|
||||
uint64_t k0 = U8TO64_LE(kk);
|
||||
uint64_t k1 = U8TO64_LE(kk + 8);
|
||||
uint64_t m;
|
||||
int i;
|
||||
const unsigned char *end = ni + inlen - (inlen % sizeof(uint64_t));
|
||||
const int left = inlen & 7;
|
||||
uint64_t b = ((uint64_t)inlen) << 56;
|
||||
v3 ^= k1;
|
||||
v2 ^= k0;
|
||||
v1 ^= k1;
|
||||
v0 ^= k0;
|
||||
|
||||
if (outlen == 16)
|
||||
v1 ^= 0xee;
|
||||
|
||||
for (; ni != end; ni += 8) {
|
||||
m = U8TO64_LE(ni);
|
||||
v3 ^= m;
|
||||
|
||||
TRACE;
|
||||
for (i = 0; i < cROUNDS; ++i)
|
||||
SIPROUND;
|
||||
|
||||
v0 ^= m;
|
||||
}
|
||||
|
||||
switch (left) {
|
||||
case 7:
|
||||
b |= ((uint64_t)ni[6]) << 48;
|
||||
/* FALLTHRU */
|
||||
case 6:
|
||||
b |= ((uint64_t)ni[5]) << 40;
|
||||
/* FALLTHRU */
|
||||
case 5:
|
||||
b |= ((uint64_t)ni[4]) << 32;
|
||||
/* FALLTHRU */
|
||||
case 4:
|
||||
b |= ((uint64_t)ni[3]) << 24;
|
||||
/* FALLTHRU */
|
||||
case 3:
|
||||
b |= ((uint64_t)ni[2]) << 16;
|
||||
/* FALLTHRU */
|
||||
case 2:
|
||||
b |= ((uint64_t)ni[1]) << 8;
|
||||
/* FALLTHRU */
|
||||
case 1:
|
||||
b |= ((uint64_t)ni[0]);
|
||||
break;
|
||||
case 0:
|
||||
break;
|
||||
}
|
||||
|
||||
v3 ^= b;
|
||||
|
||||
TRACE;
|
||||
for (i = 0; i < cROUNDS; ++i)
|
||||
SIPROUND;
|
||||
|
||||
v0 ^= b;
|
||||
|
||||
if (outlen == 16)
|
||||
v2 ^= 0xee;
|
||||
else
|
||||
v2 ^= 0xff;
|
||||
|
||||
TRACE;
|
||||
for (i = 0; i < dROUNDS; ++i)
|
||||
SIPROUND;
|
||||
|
||||
b = v0 ^ v1 ^ v2 ^ v3;
|
||||
U64TO8_LE(out, b);
|
||||
|
||||
if (outlen == 8)
|
||||
return 0;
|
||||
|
||||
v1 ^= 0xdd;
|
||||
|
||||
TRACE;
|
||||
for (i = 0; i < dROUNDS; ++i)
|
||||
SIPROUND;
|
||||
|
||||
b = v0 ^ v1 ^ v2 ^ v3;
|
||||
U64TO8_LE(out + 8, b);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
SipHash reference C implementation
|
||||
|
||||
Copyright (c) 2012-2021 Jean-Philippe Aumasson
|
||||
<jeanphilippe.aumasson@gmail.com>
|
||||
Copyright (c) 2012-2014 Daniel J. Bernstein <djb@cr.yp.to>
|
||||
|
||||
To the extent possible under law, the author(s) have dedicated all copyright
|
||||
and related and neighboring rights to this software to the public domain
|
||||
worldwide. This software is distributed without any warranty.
|
||||
|
||||
You should have received a copy of the CC0 Public Domain Dedication along
|
||||
with
|
||||
this software. If not, see
|
||||
<http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
*/
|
||||
|
||||
#ifndef SIPHASH_H
|
||||
#define SIPHASH_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int siphash(const void * in, const size_t inlen, const void * k, uint8_t * out, const size_t outlen);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,2826 +0,0 @@
|
||||
#include <stdint.h>
|
||||
|
||||
const uint8_t vectors_sip64[64][8] = {
|
||||
{
|
||||
0x31,
|
||||
0x0e,
|
||||
0x0e,
|
||||
0xdd,
|
||||
0x47,
|
||||
0xdb,
|
||||
0x6f,
|
||||
0x72,
|
||||
},
|
||||
{
|
||||
0xfd,
|
||||
0x67,
|
||||
0xdc,
|
||||
0x93,
|
||||
0xc5,
|
||||
0x39,
|
||||
0xf8,
|
||||
0x74,
|
||||
},
|
||||
{
|
||||
0x5a,
|
||||
0x4f,
|
||||
0xa9,
|
||||
0xd9,
|
||||
0x09,
|
||||
0x80,
|
||||
0x6c,
|
||||
0x0d,
|
||||
},
|
||||
{
|
||||
0x2d,
|
||||
0x7e,
|
||||
0xfb,
|
||||
0xd7,
|
||||
0x96,
|
||||
0x66,
|
||||
0x67,
|
||||
0x85,
|
||||
},
|
||||
{
|
||||
0xb7,
|
||||
0x87,
|
||||
0x71,
|
||||
0x27,
|
||||
0xe0,
|
||||
0x94,
|
||||
0x27,
|
||||
0xcf,
|
||||
},
|
||||
{
|
||||
0x8d,
|
||||
0xa6,
|
||||
0x99,
|
||||
0xcd,
|
||||
0x64,
|
||||
0x55,
|
||||
0x76,
|
||||
0x18,
|
||||
},
|
||||
{
|
||||
0xce,
|
||||
0xe3,
|
||||
0xfe,
|
||||
0x58,
|
||||
0x6e,
|
||||
0x46,
|
||||
0xc9,
|
||||
0xcb,
|
||||
},
|
||||
{
|
||||
0x37,
|
||||
0xd1,
|
||||
0x01,
|
||||
0x8b,
|
||||
0xf5,
|
||||
0x00,
|
||||
0x02,
|
||||
0xab,
|
||||
},
|
||||
{
|
||||
0x62,
|
||||
0x24,
|
||||
0x93,
|
||||
0x9a,
|
||||
0x79,
|
||||
0xf5,
|
||||
0xf5,
|
||||
0x93,
|
||||
},
|
||||
{
|
||||
0xb0,
|
||||
0xe4,
|
||||
0xa9,
|
||||
0x0b,
|
||||
0xdf,
|
||||
0x82,
|
||||
0x00,
|
||||
0x9e,
|
||||
},
|
||||
{
|
||||
0xf3,
|
||||
0xb9,
|
||||
0xdd,
|
||||
0x94,
|
||||
0xc5,
|
||||
0xbb,
|
||||
0x5d,
|
||||
0x7a,
|
||||
},
|
||||
{
|
||||
0xa7,
|
||||
0xad,
|
||||
0x6b,
|
||||
0x22,
|
||||
0x46,
|
||||
0x2f,
|
||||
0xb3,
|
||||
0xf4,
|
||||
},
|
||||
{
|
||||
0xfb,
|
||||
0xe5,
|
||||
0x0e,
|
||||
0x86,
|
||||
0xbc,
|
||||
0x8f,
|
||||
0x1e,
|
||||
0x75,
|
||||
},
|
||||
{
|
||||
0x90,
|
||||
0x3d,
|
||||
0x84,
|
||||
0xc0,
|
||||
0x27,
|
||||
0x56,
|
||||
0xea,
|
||||
0x14,
|
||||
},
|
||||
{
|
||||
0xee,
|
||||
0xf2,
|
||||
0x7a,
|
||||
0x8e,
|
||||
0x90,
|
||||
0xca,
|
||||
0x23,
|
||||
0xf7,
|
||||
},
|
||||
{
|
||||
0xe5,
|
||||
0x45,
|
||||
0xbe,
|
||||
0x49,
|
||||
0x61,
|
||||
0xca,
|
||||
0x29,
|
||||
0xa1,
|
||||
},
|
||||
{
|
||||
0xdb,
|
||||
0x9b,
|
||||
0xc2,
|
||||
0x57,
|
||||
0x7f,
|
||||
0xcc,
|
||||
0x2a,
|
||||
0x3f,
|
||||
},
|
||||
{
|
||||
0x94,
|
||||
0x47,
|
||||
0xbe,
|
||||
0x2c,
|
||||
0xf5,
|
||||
0xe9,
|
||||
0x9a,
|
||||
0x69,
|
||||
},
|
||||
{
|
||||
0x9c,
|
||||
0xd3,
|
||||
0x8d,
|
||||
0x96,
|
||||
0xf0,
|
||||
0xb3,
|
||||
0xc1,
|
||||
0x4b,
|
||||
},
|
||||
{
|
||||
0xbd,
|
||||
0x61,
|
||||
0x79,
|
||||
0xa7,
|
||||
0x1d,
|
||||
0xc9,
|
||||
0x6d,
|
||||
0xbb,
|
||||
},
|
||||
{
|
||||
0x98,
|
||||
0xee,
|
||||
0xa2,
|
||||
0x1a,
|
||||
0xf2,
|
||||
0x5c,
|
||||
0xd6,
|
||||
0xbe,
|
||||
},
|
||||
{
|
||||
0xc7,
|
||||
0x67,
|
||||
0x3b,
|
||||
0x2e,
|
||||
0xb0,
|
||||
0xcb,
|
||||
0xf2,
|
||||
0xd0,
|
||||
},
|
||||
{
|
||||
0x88,
|
||||
0x3e,
|
||||
0xa3,
|
||||
0xe3,
|
||||
0x95,
|
||||
0x67,
|
||||
0x53,
|
||||
0x93,
|
||||
},
|
||||
{
|
||||
0xc8,
|
||||
0xce,
|
||||
0x5c,
|
||||
0xcd,
|
||||
0x8c,
|
||||
0x03,
|
||||
0x0c,
|
||||
0xa8,
|
||||
},
|
||||
{
|
||||
0x94,
|
||||
0xaf,
|
||||
0x49,
|
||||
0xf6,
|
||||
0xc6,
|
||||
0x50,
|
||||
0xad,
|
||||
0xb8,
|
||||
},
|
||||
{
|
||||
0xea,
|
||||
0xb8,
|
||||
0x85,
|
||||
0x8a,
|
||||
0xde,
|
||||
0x92,
|
||||
0xe1,
|
||||
0xbc,
|
||||
},
|
||||
{
|
||||
0xf3,
|
||||
0x15,
|
||||
0xbb,
|
||||
0x5b,
|
||||
0xb8,
|
||||
0x35,
|
||||
0xd8,
|
||||
0x17,
|
||||
},
|
||||
{
|
||||
0xad,
|
||||
0xcf,
|
||||
0x6b,
|
||||
0x07,
|
||||
0x63,
|
||||
0x61,
|
||||
0x2e,
|
||||
0x2f,
|
||||
},
|
||||
{
|
||||
0xa5,
|
||||
0xc9,
|
||||
0x1d,
|
||||
0xa7,
|
||||
0xac,
|
||||
0xaa,
|
||||
0x4d,
|
||||
0xde,
|
||||
},
|
||||
{
|
||||
0x71,
|
||||
0x65,
|
||||
0x95,
|
||||
0x87,
|
||||
0x66,
|
||||
0x50,
|
||||
0xa2,
|
||||
0xa6,
|
||||
},
|
||||
{
|
||||
0x28,
|
||||
0xef,
|
||||
0x49,
|
||||
0x5c,
|
||||
0x53,
|
||||
0xa3,
|
||||
0x87,
|
||||
0xad,
|
||||
},
|
||||
{
|
||||
0x42,
|
||||
0xc3,
|
||||
0x41,
|
||||
0xd8,
|
||||
0xfa,
|
||||
0x92,
|
||||
0xd8,
|
||||
0x32,
|
||||
},
|
||||
{
|
||||
0xce,
|
||||
0x7c,
|
||||
0xf2,
|
||||
0x72,
|
||||
0x2f,
|
||||
0x51,
|
||||
0x27,
|
||||
0x71,
|
||||
},
|
||||
{
|
||||
0xe3,
|
||||
0x78,
|
||||
0x59,
|
||||
0xf9,
|
||||
0x46,
|
||||
0x23,
|
||||
0xf3,
|
||||
0xa7,
|
||||
},
|
||||
{
|
||||
0x38,
|
||||
0x12,
|
||||
0x05,
|
||||
0xbb,
|
||||
0x1a,
|
||||
0xb0,
|
||||
0xe0,
|
||||
0x12,
|
||||
},
|
||||
{
|
||||
0xae,
|
||||
0x97,
|
||||
0xa1,
|
||||
0x0f,
|
||||
0xd4,
|
||||
0x34,
|
||||
0xe0,
|
||||
0x15,
|
||||
},
|
||||
{
|
||||
0xb4,
|
||||
0xa3,
|
||||
0x15,
|
||||
0x08,
|
||||
0xbe,
|
||||
0xff,
|
||||
0x4d,
|
||||
0x31,
|
||||
},
|
||||
{
|
||||
0x81,
|
||||
0x39,
|
||||
0x62,
|
||||
0x29,
|
||||
0xf0,
|
||||
0x90,
|
||||
0x79,
|
||||
0x02,
|
||||
},
|
||||
{
|
||||
0x4d,
|
||||
0x0c,
|
||||
0xf4,
|
||||
0x9e,
|
||||
0xe5,
|
||||
0xd4,
|
||||
0xdc,
|
||||
0xca,
|
||||
},
|
||||
{
|
||||
0x5c,
|
||||
0x73,
|
||||
0x33,
|
||||
0x6a,
|
||||
0x76,
|
||||
0xd8,
|
||||
0xbf,
|
||||
0x9a,
|
||||
},
|
||||
{
|
||||
0xd0,
|
||||
0xa7,
|
||||
0x04,
|
||||
0x53,
|
||||
0x6b,
|
||||
0xa9,
|
||||
0x3e,
|
||||
0x0e,
|
||||
},
|
||||
{
|
||||
0x92,
|
||||
0x59,
|
||||
0x58,
|
||||
0xfc,
|
||||
0xd6,
|
||||
0x42,
|
||||
0x0c,
|
||||
0xad,
|
||||
},
|
||||
{
|
||||
0xa9,
|
||||
0x15,
|
||||
0xc2,
|
||||
0x9b,
|
||||
0xc8,
|
||||
0x06,
|
||||
0x73,
|
||||
0x18,
|
||||
},
|
||||
{
|
||||
0x95,
|
||||
0x2b,
|
||||
0x79,
|
||||
0xf3,
|
||||
0xbc,
|
||||
0x0a,
|
||||
0xa6,
|
||||
0xd4,
|
||||
},
|
||||
{
|
||||
0xf2,
|
||||
0x1d,
|
||||
0xf2,
|
||||
0xe4,
|
||||
0x1d,
|
||||
0x45,
|
||||
0x35,
|
||||
0xf9,
|
||||
},
|
||||
{
|
||||
0x87,
|
||||
0x57,
|
||||
0x75,
|
||||
0x19,
|
||||
0x04,
|
||||
0x8f,
|
||||
0x53,
|
||||
0xa9,
|
||||
},
|
||||
{
|
||||
0x10,
|
||||
0xa5,
|
||||
0x6c,
|
||||
0xf5,
|
||||
0xdf,
|
||||
0xcd,
|
||||
0x9a,
|
||||
0xdb,
|
||||
},
|
||||
{
|
||||
0xeb,
|
||||
0x75,
|
||||
0x09,
|
||||
0x5c,
|
||||
0xcd,
|
||||
0x98,
|
||||
0x6c,
|
||||
0xd0,
|
||||
},
|
||||
{
|
||||
0x51,
|
||||
0xa9,
|
||||
0xcb,
|
||||
0x9e,
|
||||
0xcb,
|
||||
0xa3,
|
||||
0x12,
|
||||
0xe6,
|
||||
},
|
||||
{
|
||||
0x96,
|
||||
0xaf,
|
||||
0xad,
|
||||
0xfc,
|
||||
0x2c,
|
||||
0xe6,
|
||||
0x66,
|
||||
0xc7,
|
||||
},
|
||||
{
|
||||
0x72,
|
||||
0xfe,
|
||||
0x52,
|
||||
0x97,
|
||||
0x5a,
|
||||
0x43,
|
||||
0x64,
|
||||
0xee,
|
||||
},
|
||||
{
|
||||
0x5a,
|
||||
0x16,
|
||||
0x45,
|
||||
0xb2,
|
||||
0x76,
|
||||
0xd5,
|
||||
0x92,
|
||||
0xa1,
|
||||
},
|
||||
{
|
||||
0xb2,
|
||||
0x74,
|
||||
0xcb,
|
||||
0x8e,
|
||||
0xbf,
|
||||
0x87,
|
||||
0x87,
|
||||
0x0a,
|
||||
},
|
||||
{
|
||||
0x6f,
|
||||
0x9b,
|
||||
0xb4,
|
||||
0x20,
|
||||
0x3d,
|
||||
0xe7,
|
||||
0xb3,
|
||||
0x81,
|
||||
},
|
||||
{
|
||||
0xea,
|
||||
0xec,
|
||||
0xb2,
|
||||
0xa3,
|
||||
0x0b,
|
||||
0x22,
|
||||
0xa8,
|
||||
0x7f,
|
||||
},
|
||||
{
|
||||
0x99,
|
||||
0x24,
|
||||
0xa4,
|
||||
0x3c,
|
||||
0xc1,
|
||||
0x31,
|
||||
0x57,
|
||||
0x24,
|
||||
},
|
||||
{
|
||||
0xbd,
|
||||
0x83,
|
||||
0x8d,
|
||||
0x3a,
|
||||
0xaf,
|
||||
0xbf,
|
||||
0x8d,
|
||||
0xb7,
|
||||
},
|
||||
{
|
||||
0x0b,
|
||||
0x1a,
|
||||
0x2a,
|
||||
0x32,
|
||||
0x65,
|
||||
0xd5,
|
||||
0x1a,
|
||||
0xea,
|
||||
},
|
||||
{
|
||||
0x13,
|
||||
0x50,
|
||||
0x79,
|
||||
0xa3,
|
||||
0x23,
|
||||
0x1c,
|
||||
0xe6,
|
||||
0x60,
|
||||
},
|
||||
{
|
||||
0x93,
|
||||
0x2b,
|
||||
0x28,
|
||||
0x46,
|
||||
0xe4,
|
||||
0xd7,
|
||||
0x06,
|
||||
0x66,
|
||||
},
|
||||
{
|
||||
0xe1,
|
||||
0x91,
|
||||
0x5f,
|
||||
0x5c,
|
||||
0xb1,
|
||||
0xec,
|
||||
0xa4,
|
||||
0x6c,
|
||||
},
|
||||
{
|
||||
0xf3,
|
||||
0x25,
|
||||
0x96,
|
||||
0x5c,
|
||||
0xa1,
|
||||
0x6d,
|
||||
0x62,
|
||||
0x9f,
|
||||
},
|
||||
{
|
||||
0x57,
|
||||
0x5f,
|
||||
0xf2,
|
||||
0x8e,
|
||||
0x60,
|
||||
0x38,
|
||||
0x1b,
|
||||
0xe5,
|
||||
},
|
||||
{
|
||||
0x72,
|
||||
0x45,
|
||||
0x06,
|
||||
0xeb,
|
||||
0x4c,
|
||||
0x32,
|
||||
0x8a,
|
||||
0x95,
|
||||
},
|
||||
};
|
||||
const uint8_t vectors_sip128[64][16] = {
|
||||
{
|
||||
0xa3,
|
||||
0x81,
|
||||
0x7f,
|
||||
0x04,
|
||||
0xba,
|
||||
0x25,
|
||||
0xa8,
|
||||
0xe6,
|
||||
0x6d,
|
||||
0xf6,
|
||||
0x72,
|
||||
0x14,
|
||||
0xc7,
|
||||
0x55,
|
||||
0x02,
|
||||
0x93,
|
||||
},
|
||||
{
|
||||
0xda,
|
||||
0x87,
|
||||
0xc1,
|
||||
0xd8,
|
||||
0x6b,
|
||||
0x99,
|
||||
0xaf,
|
||||
0x44,
|
||||
0x34,
|
||||
0x76,
|
||||
0x59,
|
||||
0x11,
|
||||
0x9b,
|
||||
0x22,
|
||||
0xfc,
|
||||
0x45,
|
||||
},
|
||||
{
|
||||
0x81,
|
||||
0x77,
|
||||
0x22,
|
||||
0x8d,
|
||||
0xa4,
|
||||
0xa4,
|
||||
0x5d,
|
||||
0xc7,
|
||||
0xfc,
|
||||
0xa3,
|
||||
0x8b,
|
||||
0xde,
|
||||
0xf6,
|
||||
0x0a,
|
||||
0xff,
|
||||
0xe4,
|
||||
},
|
||||
{
|
||||
0x9c,
|
||||
0x70,
|
||||
0xb6,
|
||||
0x0c,
|
||||
0x52,
|
||||
0x67,
|
||||
0xa9,
|
||||
0x4e,
|
||||
0x5f,
|
||||
0x33,
|
||||
0xb6,
|
||||
0xb0,
|
||||
0x29,
|
||||
0x85,
|
||||
0xed,
|
||||
0x51,
|
||||
},
|
||||
{
|
||||
0xf8,
|
||||
0x81,
|
||||
0x64,
|
||||
0xc1,
|
||||
0x2d,
|
||||
0x9c,
|
||||
0x8f,
|
||||
0xaf,
|
||||
0x7d,
|
||||
0x0f,
|
||||
0x6e,
|
||||
0x7c,
|
||||
0x7b,
|
||||
0xcd,
|
||||
0x55,
|
||||
0x79,
|
||||
},
|
||||
{
|
||||
0x13,
|
||||
0x68,
|
||||
0x87,
|
||||
0x59,
|
||||
0x80,
|
||||
0x77,
|
||||
0x6f,
|
||||
0x88,
|
||||
0x54,
|
||||
0x52,
|
||||
0x7a,
|
||||
0x07,
|
||||
0x69,
|
||||
0x0e,
|
||||
0x96,
|
||||
0x27,
|
||||
},
|
||||
{
|
||||
0x14,
|
||||
0xee,
|
||||
0xca,
|
||||
0x33,
|
||||
0x8b,
|
||||
0x20,
|
||||
0x86,
|
||||
0x13,
|
||||
0x48,
|
||||
0x5e,
|
||||
0xa0,
|
||||
0x30,
|
||||
0x8f,
|
||||
0xd7,
|
||||
0xa1,
|
||||
0x5e,
|
||||
},
|
||||
{
|
||||
0xa1,
|
||||
0xf1,
|
||||
0xeb,
|
||||
0xbe,
|
||||
0xd8,
|
||||
0xdb,
|
||||
0xc1,
|
||||
0x53,
|
||||
0xc0,
|
||||
0xb8,
|
||||
0x4a,
|
||||
0xa6,
|
||||
0x1f,
|
||||
0xf0,
|
||||
0x82,
|
||||
0x39,
|
||||
},
|
||||
{
|
||||
0x3b,
|
||||
0x62,
|
||||
0xa9,
|
||||
0xba,
|
||||
0x62,
|
||||
0x58,
|
||||
0xf5,
|
||||
0x61,
|
||||
0x0f,
|
||||
0x83,
|
||||
0xe2,
|
||||
0x64,
|
||||
0xf3,
|
||||
0x14,
|
||||
0x97,
|
||||
0xb4,
|
||||
},
|
||||
{
|
||||
0x26,
|
||||
0x44,
|
||||
0x99,
|
||||
0x06,
|
||||
0x0a,
|
||||
0xd9,
|
||||
0xba,
|
||||
0xab,
|
||||
0xc4,
|
||||
0x7f,
|
||||
0x8b,
|
||||
0x02,
|
||||
0xbb,
|
||||
0x6d,
|
||||
0x71,
|
||||
0xed,
|
||||
},
|
||||
{
|
||||
0x00,
|
||||
0x11,
|
||||
0x0d,
|
||||
0xc3,
|
||||
0x78,
|
||||
0x14,
|
||||
0x69,
|
||||
0x56,
|
||||
0xc9,
|
||||
0x54,
|
||||
0x47,
|
||||
0xd3,
|
||||
0xf3,
|
||||
0xd0,
|
||||
0xfb,
|
||||
0xba,
|
||||
},
|
||||
{
|
||||
0x01,
|
||||
0x51,
|
||||
0xc5,
|
||||
0x68,
|
||||
0x38,
|
||||
0x6b,
|
||||
0x66,
|
||||
0x77,
|
||||
0xa2,
|
||||
0xb4,
|
||||
0xdc,
|
||||
0x6f,
|
||||
0x81,
|
||||
0xe5,
|
||||
0xdc,
|
||||
0x18,
|
||||
},
|
||||
{
|
||||
0xd6,
|
||||
0x26,
|
||||
0xb2,
|
||||
0x66,
|
||||
0x90,
|
||||
0x5e,
|
||||
0xf3,
|
||||
0x58,
|
||||
0x82,
|
||||
0x63,
|
||||
0x4d,
|
||||
0xf6,
|
||||
0x85,
|
||||
0x32,
|
||||
0xc1,
|
||||
0x25,
|
||||
},
|
||||
{
|
||||
0x98,
|
||||
0x69,
|
||||
0xe2,
|
||||
0x47,
|
||||
0xe9,
|
||||
0xc0,
|
||||
0x8b,
|
||||
0x10,
|
||||
0xd0,
|
||||
0x29,
|
||||
0x93,
|
||||
0x4f,
|
||||
0xc4,
|
||||
0xb9,
|
||||
0x52,
|
||||
0xf7,
|
||||
},
|
||||
{
|
||||
0x31,
|
||||
0xfc,
|
||||
0xef,
|
||||
0xac,
|
||||
0x66,
|
||||
0xd7,
|
||||
0xde,
|
||||
0x9c,
|
||||
0x7e,
|
||||
0xc7,
|
||||
0x48,
|
||||
0x5f,
|
||||
0xe4,
|
||||
0x49,
|
||||
0x49,
|
||||
0x02,
|
||||
},
|
||||
{
|
||||
0x54,
|
||||
0x93,
|
||||
0xe9,
|
||||
0x99,
|
||||
0x33,
|
||||
0xb0,
|
||||
0xa8,
|
||||
0x11,
|
||||
0x7e,
|
||||
0x08,
|
||||
0xec,
|
||||
0x0f,
|
||||
0x97,
|
||||
0xcf,
|
||||
0xc3,
|
||||
0xd9,
|
||||
},
|
||||
{
|
||||
0x6e,
|
||||
0xe2,
|
||||
0xa4,
|
||||
0xca,
|
||||
0x67,
|
||||
0xb0,
|
||||
0x54,
|
||||
0xbb,
|
||||
0xfd,
|
||||
0x33,
|
||||
0x15,
|
||||
0xbf,
|
||||
0x85,
|
||||
0x23,
|
||||
0x05,
|
||||
0x77,
|
||||
},
|
||||
{
|
||||
0x47,
|
||||
0x3d,
|
||||
0x06,
|
||||
0xe8,
|
||||
0x73,
|
||||
0x8d,
|
||||
0xb8,
|
||||
0x98,
|
||||
0x54,
|
||||
0xc0,
|
||||
0x66,
|
||||
0xc4,
|
||||
0x7a,
|
||||
0xe4,
|
||||
0x77,
|
||||
0x40,
|
||||
},
|
||||
{
|
||||
0xa4,
|
||||
0x26,
|
||||
0xe5,
|
||||
0xe4,
|
||||
0x23,
|
||||
0xbf,
|
||||
0x48,
|
||||
0x85,
|
||||
0x29,
|
||||
0x4d,
|
||||
0xa4,
|
||||
0x81,
|
||||
0xfe,
|
||||
0xae,
|
||||
0xf7,
|
||||
0x23,
|
||||
},
|
||||
{
|
||||
0x78,
|
||||
0x01,
|
||||
0x77,
|
||||
0x31,
|
||||
0xcf,
|
||||
0x65,
|
||||
0xfa,
|
||||
0xb0,
|
||||
0x74,
|
||||
0xd5,
|
||||
0x20,
|
||||
0x89,
|
||||
0x52,
|
||||
0x51,
|
||||
0x2e,
|
||||
0xb1,
|
||||
},
|
||||
{
|
||||
0x9e,
|
||||
0x25,
|
||||
0xfc,
|
||||
0x83,
|
||||
0x3f,
|
||||
0x22,
|
||||
0x90,
|
||||
0x73,
|
||||
0x3e,
|
||||
0x93,
|
||||
0x44,
|
||||
0xa5,
|
||||
0xe8,
|
||||
0x38,
|
||||
0x39,
|
||||
0xeb,
|
||||
},
|
||||
{
|
||||
0x56,
|
||||
0x8e,
|
||||
0x49,
|
||||
0x5a,
|
||||
0xbe,
|
||||
0x52,
|
||||
0x5a,
|
||||
0x21,
|
||||
0x8a,
|
||||
0x22,
|
||||
0x14,
|
||||
0xcd,
|
||||
0x3e,
|
||||
0x07,
|
||||
0x1d,
|
||||
0x12,
|
||||
},
|
||||
{
|
||||
0x4a,
|
||||
0x29,
|
||||
0xb5,
|
||||
0x45,
|
||||
0x52,
|
||||
0xd1,
|
||||
0x6b,
|
||||
0x9a,
|
||||
0x46,
|
||||
0x9c,
|
||||
0x10,
|
||||
0x52,
|
||||
0x8e,
|
||||
0xff,
|
||||
0x0a,
|
||||
0xae,
|
||||
},
|
||||
{
|
||||
0xc9,
|
||||
0xd1,
|
||||
0x84,
|
||||
0xdd,
|
||||
0xd5,
|
||||
0xa9,
|
||||
0xf5,
|
||||
0xe0,
|
||||
0xcf,
|
||||
0x8c,
|
||||
0xe2,
|
||||
0x9a,
|
||||
0x9a,
|
||||
0xbf,
|
||||
0x69,
|
||||
0x1c,
|
||||
},
|
||||
{
|
||||
0x2d,
|
||||
0xb4,
|
||||
0x79,
|
||||
0xae,
|
||||
0x78,
|
||||
0xbd,
|
||||
0x50,
|
||||
0xd8,
|
||||
0x88,
|
||||
0x2a,
|
||||
0x8a,
|
||||
0x17,
|
||||
0x8a,
|
||||
0x61,
|
||||
0x32,
|
||||
0xad,
|
||||
},
|
||||
{
|
||||
0x8e,
|
||||
0xce,
|
||||
0x5f,
|
||||
0x04,
|
||||
0x2d,
|
||||
0x5e,
|
||||
0x44,
|
||||
0x7b,
|
||||
0x50,
|
||||
0x51,
|
||||
0xb9,
|
||||
0xea,
|
||||
0xcb,
|
||||
0x8d,
|
||||
0x8f,
|
||||
0x6f,
|
||||
},
|
||||
{
|
||||
0x9c,
|
||||
0x0b,
|
||||
0x53,
|
||||
0xb4,
|
||||
0xb3,
|
||||
0xc3,
|
||||
0x07,
|
||||
0xe8,
|
||||
0x7e,
|
||||
0xae,
|
||||
0xe0,
|
||||
0x86,
|
||||
0x78,
|
||||
0x14,
|
||||
0x1f,
|
||||
0x66,
|
||||
},
|
||||
{
|
||||
0xab,
|
||||
0xf2,
|
||||
0x48,
|
||||
0xaf,
|
||||
0x69,
|
||||
0xa6,
|
||||
0xea,
|
||||
0xe4,
|
||||
0xbf,
|
||||
0xd3,
|
||||
0xeb,
|
||||
0x2f,
|
||||
0x12,
|
||||
0x9e,
|
||||
0xeb,
|
||||
0x94,
|
||||
},
|
||||
{
|
||||
0x06,
|
||||
0x64,
|
||||
0xda,
|
||||
0x16,
|
||||
0x68,
|
||||
0x57,
|
||||
0x4b,
|
||||
0x88,
|
||||
0xb9,
|
||||
0x35,
|
||||
0xf3,
|
||||
0x02,
|
||||
0x73,
|
||||
0x58,
|
||||
0xae,
|
||||
0xf4,
|
||||
},
|
||||
{
|
||||
0xaa,
|
||||
0x4b,
|
||||
0x9d,
|
||||
0xc4,
|
||||
0xbf,
|
||||
0x33,
|
||||
0x7d,
|
||||
0xe9,
|
||||
0x0c,
|
||||
0xd4,
|
||||
0xfd,
|
||||
0x3c,
|
||||
0x46,
|
||||
0x7c,
|
||||
0x6a,
|
||||
0xb7,
|
||||
},
|
||||
{
|
||||
0xea,
|
||||
0x5c,
|
||||
0x7f,
|
||||
0x47,
|
||||
0x1f,
|
||||
0xaf,
|
||||
0x6b,
|
||||
0xde,
|
||||
0x2b,
|
||||
0x1a,
|
||||
0xd7,
|
||||
0xd4,
|
||||
0x68,
|
||||
0x6d,
|
||||
0x22,
|
||||
0x87,
|
||||
},
|
||||
{
|
||||
0x29,
|
||||
0x39,
|
||||
0xb0,
|
||||
0x18,
|
||||
0x32,
|
||||
0x23,
|
||||
0xfa,
|
||||
0xfc,
|
||||
0x17,
|
||||
0x23,
|
||||
0xde,
|
||||
0x4f,
|
||||
0x52,
|
||||
0xc4,
|
||||
0x3d,
|
||||
0x35,
|
||||
},
|
||||
{
|
||||
0x7c,
|
||||
0x39,
|
||||
0x56,
|
||||
0xca,
|
||||
0x5e,
|
||||
0xea,
|
||||
0xfc,
|
||||
0x3e,
|
||||
0x36,
|
||||
0x3e,
|
||||
0x9d,
|
||||
0x55,
|
||||
0x65,
|
||||
0x46,
|
||||
0xeb,
|
||||
0x68,
|
||||
},
|
||||
{
|
||||
0x77,
|
||||
0xc6,
|
||||
0x07,
|
||||
0x71,
|
||||
0x46,
|
||||
0xf0,
|
||||
0x1c,
|
||||
0x32,
|
||||
0xb6,
|
||||
0xb6,
|
||||
0x9d,
|
||||
0x5f,
|
||||
0x4e,
|
||||
0xa9,
|
||||
0xff,
|
||||
0xcf,
|
||||
},
|
||||
{
|
||||
0x37,
|
||||
0xa6,
|
||||
0x98,
|
||||
0x6c,
|
||||
0xb8,
|
||||
0x84,
|
||||
0x7e,
|
||||
0xdf,
|
||||
0x09,
|
||||
0x25,
|
||||
0xf0,
|
||||
0xf1,
|
||||
0x30,
|
||||
0x9b,
|
||||
0x54,
|
||||
0xde,
|
||||
},
|
||||
{
|
||||
0xa7,
|
||||
0x05,
|
||||
0xf0,
|
||||
0xe6,
|
||||
0x9d,
|
||||
0xa9,
|
||||
0xa8,
|
||||
0xf9,
|
||||
0x07,
|
||||
0x24,
|
||||
0x1a,
|
||||
0x2e,
|
||||
0x92,
|
||||
0x3c,
|
||||
0x8c,
|
||||
0xc8,
|
||||
},
|
||||
{
|
||||
0x3d,
|
||||
0xc4,
|
||||
0x7d,
|
||||
0x1f,
|
||||
0x29,
|
||||
0xc4,
|
||||
0x48,
|
||||
0x46,
|
||||
0x1e,
|
||||
0x9e,
|
||||
0x76,
|
||||
0xed,
|
||||
0x90,
|
||||
0x4f,
|
||||
0x67,
|
||||
0x11,
|
||||
},
|
||||
{
|
||||
0x0d,
|
||||
0x62,
|
||||
0xbf,
|
||||
0x01,
|
||||
0xe6,
|
||||
0xfc,
|
||||
0x0e,
|
||||
0x1a,
|
||||
0x0d,
|
||||
0x3c,
|
||||
0x47,
|
||||
0x51,
|
||||
0xc5,
|
||||
0xd3,
|
||||
0x69,
|
||||
0x2b,
|
||||
},
|
||||
{
|
||||
0x8c,
|
||||
0x03,
|
||||
0x46,
|
||||
0x8b,
|
||||
0xca,
|
||||
0x7c,
|
||||
0x66,
|
||||
0x9e,
|
||||
0xe4,
|
||||
0xfd,
|
||||
0x5e,
|
||||
0x08,
|
||||
0x4b,
|
||||
0xbe,
|
||||
0xe7,
|
||||
0xb5,
|
||||
},
|
||||
{
|
||||
0x52,
|
||||
0x8a,
|
||||
0x5b,
|
||||
0xb9,
|
||||
0x3b,
|
||||
0xaf,
|
||||
0x2c,
|
||||
0x9c,
|
||||
0x44,
|
||||
0x73,
|
||||
0xcc,
|
||||
0xe5,
|
||||
0xd0,
|
||||
0xd2,
|
||||
0x2b,
|
||||
0xd9,
|
||||
},
|
||||
{
|
||||
0xdf,
|
||||
0x6a,
|
||||
0x30,
|
||||
0x1e,
|
||||
0x95,
|
||||
0xc9,
|
||||
0x5d,
|
||||
0xad,
|
||||
0x97,
|
||||
0xae,
|
||||
0x0c,
|
||||
0xc8,
|
||||
0xc6,
|
||||
0x91,
|
||||
0x3b,
|
||||
0xd8,
|
||||
},
|
||||
{
|
||||
0x80,
|
||||
0x11,
|
||||
0x89,
|
||||
0x90,
|
||||
0x2c,
|
||||
0x85,
|
||||
0x7f,
|
||||
0x39,
|
||||
0xe7,
|
||||
0x35,
|
||||
0x91,
|
||||
0x28,
|
||||
0x5e,
|
||||
0x70,
|
||||
0xb6,
|
||||
0xdb,
|
||||
},
|
||||
{
|
||||
0xe6,
|
||||
0x17,
|
||||
0x34,
|
||||
0x6a,
|
||||
0xc9,
|
||||
0xc2,
|
||||
0x31,
|
||||
0xbb,
|
||||
0x36,
|
||||
0x50,
|
||||
0xae,
|
||||
0x34,
|
||||
0xcc,
|
||||
0xca,
|
||||
0x0c,
|
||||
0x5b,
|
||||
},
|
||||
{
|
||||
0x27,
|
||||
0xd9,
|
||||
0x34,
|
||||
0x37,
|
||||
0xef,
|
||||
0xb7,
|
||||
0x21,
|
||||
0xaa,
|
||||
0x40,
|
||||
0x18,
|
||||
0x21,
|
||||
0xdc,
|
||||
0xec,
|
||||
0x5a,
|
||||
0xdf,
|
||||
0x89,
|
||||
},
|
||||
{
|
||||
0x89,
|
||||
0x23,
|
||||
0x7d,
|
||||
0x9d,
|
||||
0xed,
|
||||
0x9c,
|
||||
0x5e,
|
||||
0x78,
|
||||
0xd8,
|
||||
0xb1,
|
||||
0xc9,
|
||||
0xb1,
|
||||
0x66,
|
||||
0xcc,
|
||||
0x73,
|
||||
0x42,
|
||||
},
|
||||
{
|
||||
0x4a,
|
||||
0x6d,
|
||||
0x80,
|
||||
0x91,
|
||||
0xbf,
|
||||
0x5e,
|
||||
0x7d,
|
||||
0x65,
|
||||
0x11,
|
||||
0x89,
|
||||
0xfa,
|
||||
0x94,
|
||||
0xa2,
|
||||
0x50,
|
||||
0xb1,
|
||||
0x4c,
|
||||
},
|
||||
{
|
||||
0x0e,
|
||||
0x33,
|
||||
0xf9,
|
||||
0x60,
|
||||
0x55,
|
||||
0xe7,
|
||||
0xae,
|
||||
0x89,
|
||||
0x3f,
|
||||
0xfc,
|
||||
0x0e,
|
||||
0x3d,
|
||||
0xcf,
|
||||
0x49,
|
||||
0x29,
|
||||
0x02,
|
||||
},
|
||||
{
|
||||
0xe6,
|
||||
0x1c,
|
||||
0x43,
|
||||
0x2b,
|
||||
0x72,
|
||||
0x0b,
|
||||
0x19,
|
||||
0xd1,
|
||||
0x8e,
|
||||
0xc8,
|
||||
0xd8,
|
||||
0x4b,
|
||||
0xdc,
|
||||
0x63,
|
||||
0x15,
|
||||
0x1b,
|
||||
},
|
||||
{
|
||||
0xf7,
|
||||
0xe5,
|
||||
0xae,
|
||||
0xf5,
|
||||
0x49,
|
||||
0xf7,
|
||||
0x82,
|
||||
0xcf,
|
||||
0x37,
|
||||
0x90,
|
||||
0x55,
|
||||
0xa6,
|
||||
0x08,
|
||||
0x26,
|
||||
0x9b,
|
||||
0x16,
|
||||
},
|
||||
{
|
||||
0x43,
|
||||
0x8d,
|
||||
0x03,
|
||||
0x0f,
|
||||
0xd0,
|
||||
0xb7,
|
||||
0xa5,
|
||||
0x4f,
|
||||
0xa8,
|
||||
0x37,
|
||||
0xf2,
|
||||
0xad,
|
||||
0x20,
|
||||
0x1a,
|
||||
0x64,
|
||||
0x03,
|
||||
},
|
||||
{
|
||||
0xa5,
|
||||
0x90,
|
||||
0xd3,
|
||||
0xee,
|
||||
0x4f,
|
||||
0xbf,
|
||||
0x04,
|
||||
0xe3,
|
||||
0x24,
|
||||
0x7e,
|
||||
0x0d,
|
||||
0x27,
|
||||
0xf2,
|
||||
0x86,
|
||||
0x42,
|
||||
0x3f,
|
||||
},
|
||||
{
|
||||
0x5f,
|
||||
0xe2,
|
||||
0xc1,
|
||||
0xa1,
|
||||
0x72,
|
||||
0xfe,
|
||||
0x93,
|
||||
0xc4,
|
||||
0xb1,
|
||||
0x5c,
|
||||
0xd3,
|
||||
0x7c,
|
||||
0xae,
|
||||
0xf9,
|
||||
0xf5,
|
||||
0x38,
|
||||
},
|
||||
{
|
||||
0x2c,
|
||||
0x97,
|
||||
0x32,
|
||||
0x5c,
|
||||
0xbd,
|
||||
0x06,
|
||||
0xb3,
|
||||
0x6e,
|
||||
0xb2,
|
||||
0x13,
|
||||
0x3d,
|
||||
0xd0,
|
||||
0x8b,
|
||||
0x3a,
|
||||
0x01,
|
||||
0x7c,
|
||||
},
|
||||
{
|
||||
0x92,
|
||||
0xc8,
|
||||
0x14,
|
||||
0x22,
|
||||
0x7a,
|
||||
0x6b,
|
||||
0xca,
|
||||
0x94,
|
||||
0x9f,
|
||||
0xf0,
|
||||
0x65,
|
||||
0x9f,
|
||||
0x00,
|
||||
0x2a,
|
||||
0xd3,
|
||||
0x9e,
|
||||
},
|
||||
{
|
||||
0xdc,
|
||||
0xe8,
|
||||
0x50,
|
||||
0x11,
|
||||
0x0b,
|
||||
0xd8,
|
||||
0x32,
|
||||
0x8c,
|
||||
0xfb,
|
||||
0xd5,
|
||||
0x08,
|
||||
0x41,
|
||||
0xd6,
|
||||
0x91,
|
||||
0x1d,
|
||||
0x87,
|
||||
},
|
||||
{
|
||||
0x67,
|
||||
0xf1,
|
||||
0x49,
|
||||
0x84,
|
||||
0xc7,
|
||||
0xda,
|
||||
0x79,
|
||||
0x12,
|
||||
0x48,
|
||||
0xe3,
|
||||
0x2b,
|
||||
0xb5,
|
||||
0x92,
|
||||
0x25,
|
||||
0x83,
|
||||
0xda,
|
||||
},
|
||||
{
|
||||
0x19,
|
||||
0x38,
|
||||
0xf2,
|
||||
0xcf,
|
||||
0x72,
|
||||
0xd5,
|
||||
0x4e,
|
||||
0xe9,
|
||||
0x7e,
|
||||
0x94,
|
||||
0x16,
|
||||
0x6f,
|
||||
0xa9,
|
||||
0x1d,
|
||||
0x2a,
|
||||
0x36,
|
||||
},
|
||||
{
|
||||
0x74,
|
||||
0x48,
|
||||
0x1e,
|
||||
0x96,
|
||||
0x46,
|
||||
0xed,
|
||||
0x49,
|
||||
0xfe,
|
||||
0x0f,
|
||||
0x62,
|
||||
0x24,
|
||||
0x30,
|
||||
0x16,
|
||||
0x04,
|
||||
0x69,
|
||||
0x8e,
|
||||
},
|
||||
{
|
||||
0x57,
|
||||
0xfc,
|
||||
0xa5,
|
||||
0xde,
|
||||
0x98,
|
||||
0xa9,
|
||||
0xd6,
|
||||
0xd8,
|
||||
0x00,
|
||||
0x64,
|
||||
0x38,
|
||||
0xd0,
|
||||
0x58,
|
||||
0x3d,
|
||||
0x8a,
|
||||
0x1d,
|
||||
},
|
||||
{
|
||||
0x9f,
|
||||
0xec,
|
||||
0xde,
|
||||
0x1c,
|
||||
0xef,
|
||||
0xdc,
|
||||
0x1c,
|
||||
0xbe,
|
||||
0xd4,
|
||||
0x76,
|
||||
0x36,
|
||||
0x74,
|
||||
0xd9,
|
||||
0x57,
|
||||
0x53,
|
||||
0x59,
|
||||
},
|
||||
{
|
||||
0xe3,
|
||||
0x04,
|
||||
0x0c,
|
||||
0x00,
|
||||
0xeb,
|
||||
0x28,
|
||||
0xf1,
|
||||
0x53,
|
||||
0x66,
|
||||
0xca,
|
||||
0x73,
|
||||
0xcb,
|
||||
0xd8,
|
||||
0x72,
|
||||
0xe7,
|
||||
0x40,
|
||||
},
|
||||
{
|
||||
0x76,
|
||||
0x97,
|
||||
0x00,
|
||||
0x9a,
|
||||
0x6a,
|
||||
0x83,
|
||||
0x1d,
|
||||
0xfe,
|
||||
0xcc,
|
||||
0xa9,
|
||||
0x1c,
|
||||
0x59,
|
||||
0x93,
|
||||
0x67,
|
||||
0x0f,
|
||||
0x7a,
|
||||
},
|
||||
{
|
||||
0x58,
|
||||
0x53,
|
||||
0x54,
|
||||
0x23,
|
||||
0x21,
|
||||
0xf5,
|
||||
0x67,
|
||||
0xa0,
|
||||
0x05,
|
||||
0xd5,
|
||||
0x47,
|
||||
0xa4,
|
||||
0xf0,
|
||||
0x47,
|
||||
0x59,
|
||||
0xbd,
|
||||
},
|
||||
{
|
||||
0x51,
|
||||
0x50,
|
||||
0xd1,
|
||||
0x77,
|
||||
0x2f,
|
||||
0x50,
|
||||
0x83,
|
||||
0x4a,
|
||||
0x50,
|
||||
0x3e,
|
||||
0x06,
|
||||
0x9a,
|
||||
0x97,
|
||||
0x3f,
|
||||
0xbd,
|
||||
0x7c,
|
||||
},
|
||||
};
|
||||
const uint8_t vectors_hsip32[64][4] = {
|
||||
{
|
||||
0xa9,
|
||||
0x35,
|
||||
0x9f,
|
||||
0x5b,
|
||||
},
|
||||
{
|
||||
0x27,
|
||||
0x47,
|
||||
0x5a,
|
||||
0xb8,
|
||||
},
|
||||
{
|
||||
0xfa,
|
||||
0x62,
|
||||
0xa6,
|
||||
0x03,
|
||||
},
|
||||
{
|
||||
0x8a,
|
||||
0xfe,
|
||||
0xe7,
|
||||
0x04,
|
||||
},
|
||||
{
|
||||
0x2a,
|
||||
0x6e,
|
||||
0x46,
|
||||
0x89,
|
||||
},
|
||||
{
|
||||
0xc5,
|
||||
0xfa,
|
||||
0xb6,
|
||||
0x69,
|
||||
},
|
||||
{
|
||||
0x58,
|
||||
0x63,
|
||||
0xfc,
|
||||
0x23,
|
||||
},
|
||||
{
|
||||
0x8b,
|
||||
0xcf,
|
||||
0x63,
|
||||
0xc5,
|
||||
},
|
||||
{
|
||||
0xd0,
|
||||
0xb8,
|
||||
0x84,
|
||||
0x8f,
|
||||
},
|
||||
{
|
||||
0xf8,
|
||||
0x06,
|
||||
0xe7,
|
||||
0x79,
|
||||
},
|
||||
{
|
||||
0x94,
|
||||
0xb0,
|
||||
0x79,
|
||||
0x34,
|
||||
},
|
||||
{
|
||||
0x08,
|
||||
0x08,
|
||||
0x30,
|
||||
0x50,
|
||||
},
|
||||
{
|
||||
0x57,
|
||||
0xf0,
|
||||
0x87,
|
||||
0x2f,
|
||||
},
|
||||
{
|
||||
0x77,
|
||||
0xe6,
|
||||
0x63,
|
||||
0xff,
|
||||
},
|
||||
{
|
||||
0xd6,
|
||||
0xff,
|
||||
0xf8,
|
||||
0x7c,
|
||||
},
|
||||
{
|
||||
0x74,
|
||||
0xfe,
|
||||
0x2b,
|
||||
0x97,
|
||||
},
|
||||
{
|
||||
0xd9,
|
||||
0xb5,
|
||||
0xac,
|
||||
0x84,
|
||||
},
|
||||
{
|
||||
0xc4,
|
||||
0x74,
|
||||
0x64,
|
||||
0x5b,
|
||||
},
|
||||
{
|
||||
0x46,
|
||||
0x5b,
|
||||
0x8d,
|
||||
0x9b,
|
||||
},
|
||||
{
|
||||
0x7b,
|
||||
0xef,
|
||||
0xe3,
|
||||
0x87,
|
||||
},
|
||||
{
|
||||
0xe3,
|
||||
0x4d,
|
||||
0x10,
|
||||
0x45,
|
||||
},
|
||||
{
|
||||
0x61,
|
||||
0x3f,
|
||||
0x62,
|
||||
0xb3,
|
||||
},
|
||||
{
|
||||
0x70,
|
||||
0xf3,
|
||||
0x67,
|
||||
0xfe,
|
||||
},
|
||||
{
|
||||
0xe6,
|
||||
0xad,
|
||||
0xb8,
|
||||
0xbd,
|
||||
},
|
||||
{
|
||||
0x27,
|
||||
0x40,
|
||||
0x0c,
|
||||
0x63,
|
||||
},
|
||||
{
|
||||
0x26,
|
||||
0x78,
|
||||
0x78,
|
||||
0x75,
|
||||
},
|
||||
{
|
||||
0x4f,
|
||||
0x56,
|
||||
0x7b,
|
||||
0x5f,
|
||||
},
|
||||
{
|
||||
0x3a,
|
||||
0xb0,
|
||||
0xe6,
|
||||
0x69,
|
||||
},
|
||||
{
|
||||
0xb0,
|
||||
0x64,
|
||||
0x40,
|
||||
0x00,
|
||||
},
|
||||
{
|
||||
0xff,
|
||||
0x67,
|
||||
0x0f,
|
||||
0xb4,
|
||||
},
|
||||
{
|
||||
0x50,
|
||||
0x9e,
|
||||
0x33,
|
||||
0x8b,
|
||||
},
|
||||
{
|
||||
0x5d,
|
||||
0x58,
|
||||
0x9f,
|
||||
0x1a,
|
||||
},
|
||||
{
|
||||
0xfe,
|
||||
0xe7,
|
||||
0x21,
|
||||
0x12,
|
||||
},
|
||||
{
|
||||
0x33,
|
||||
0x75,
|
||||
0x32,
|
||||
0x59,
|
||||
},
|
||||
{
|
||||
0x6a,
|
||||
0x43,
|
||||
0x4f,
|
||||
0x8c,
|
||||
},
|
||||
{
|
||||
0xfe,
|
||||
0x28,
|
||||
0xb7,
|
||||
0x29,
|
||||
},
|
||||
{
|
||||
0xe7,
|
||||
0x5c,
|
||||
0xc6,
|
||||
0xec,
|
||||
},
|
||||
{
|
||||
0x69,
|
||||
0x7e,
|
||||
0x8d,
|
||||
0x54,
|
||||
},
|
||||
{
|
||||
0x63,
|
||||
0x68,
|
||||
0x8b,
|
||||
0x0f,
|
||||
},
|
||||
{
|
||||
0x65,
|
||||
0x0b,
|
||||
0x62,
|
||||
0xb4,
|
||||
},
|
||||
{
|
||||
0xb6,
|
||||
0xbc,
|
||||
0x18,
|
||||
0x40,
|
||||
},
|
||||
{
|
||||
0x5d,
|
||||
0x07,
|
||||
0x45,
|
||||
0x05,
|
||||
},
|
||||
{
|
||||
0x24,
|
||||
0x42,
|
||||
0xfd,
|
||||
0x2e,
|
||||
},
|
||||
{
|
||||
0x7b,
|
||||
0xb7,
|
||||
0x86,
|
||||
0x3a,
|
||||
},
|
||||
{
|
||||
0x77,
|
||||
0x05,
|
||||
0xd5,
|
||||
0x48,
|
||||
},
|
||||
{
|
||||
0xd7,
|
||||
0x52,
|
||||
0x08,
|
||||
0xb1,
|
||||
},
|
||||
{
|
||||
0xb6,
|
||||
0xd4,
|
||||
0x99,
|
||||
0xc8,
|
||||
},
|
||||
{
|
||||
0x08,
|
||||
0x92,
|
||||
0x20,
|
||||
0x2e,
|
||||
},
|
||||
{
|
||||
0x69,
|
||||
0xe1,
|
||||
0x2c,
|
||||
0xe3,
|
||||
},
|
||||
{
|
||||
0x8d,
|
||||
0xb5,
|
||||
0x80,
|
||||
0xe5,
|
||||
},
|
||||
{
|
||||
0x36,
|
||||
0x97,
|
||||
0x64,
|
||||
0xc6,
|
||||
},
|
||||
{
|
||||
0x01,
|
||||
0x6e,
|
||||
0x02,
|
||||
0x04,
|
||||
},
|
||||
{
|
||||
0x3b,
|
||||
0x85,
|
||||
0xf3,
|
||||
0xd4,
|
||||
},
|
||||
{
|
||||
0xfe,
|
||||
0xdb,
|
||||
0x66,
|
||||
0xbe,
|
||||
},
|
||||
{
|
||||
0x1e,
|
||||
0x69,
|
||||
0x2a,
|
||||
0x3a,
|
||||
},
|
||||
{
|
||||
0xc6,
|
||||
0x89,
|
||||
0x84,
|
||||
0xc0,
|
||||
},
|
||||
{
|
||||
0xa5,
|
||||
0xc5,
|
||||
0xb9,
|
||||
0x40,
|
||||
},
|
||||
{
|
||||
0x9b,
|
||||
0xe9,
|
||||
0xe8,
|
||||
0x8c,
|
||||
},
|
||||
{
|
||||
0x7d,
|
||||
0xbc,
|
||||
0x81,
|
||||
0x40,
|
||||
},
|
||||
{
|
||||
0x7c,
|
||||
0x07,
|
||||
0x8e,
|
||||
0xc5,
|
||||
},
|
||||
{
|
||||
0xd4,
|
||||
0xe7,
|
||||
0x6c,
|
||||
0x73,
|
||||
},
|
||||
{
|
||||
0x42,
|
||||
0x8f,
|
||||
0xcb,
|
||||
0xb9,
|
||||
},
|
||||
{
|
||||
0xbd,
|
||||
0x83,
|
||||
0x99,
|
||||
0x7a,
|
||||
},
|
||||
{
|
||||
0x59,
|
||||
0xea,
|
||||
0x4a,
|
||||
0x74,
|
||||
},
|
||||
};
|
||||
const uint8_t vectors_hsip64[64][8] = {
|
||||
{
|
||||
0x21,
|
||||
0x8d,
|
||||
0x1f,
|
||||
0x59,
|
||||
0xb9,
|
||||
0xb8,
|
||||
0x3c,
|
||||
0xc8,
|
||||
},
|
||||
{
|
||||
0xbe,
|
||||
0x55,
|
||||
0x24,
|
||||
0x12,
|
||||
0xf8,
|
||||
0x38,
|
||||
0x73,
|
||||
0x15,
|
||||
},
|
||||
{
|
||||
0x06,
|
||||
0x4f,
|
||||
0x39,
|
||||
0xef,
|
||||
0x7c,
|
||||
0x50,
|
||||
0xeb,
|
||||
0x57,
|
||||
},
|
||||
{
|
||||
0xce,
|
||||
0x0f,
|
||||
0x1a,
|
||||
0x45,
|
||||
0xf7,
|
||||
0x06,
|
||||
0x06,
|
||||
0x79,
|
||||
},
|
||||
{
|
||||
0xd5,
|
||||
0xe7,
|
||||
0x8a,
|
||||
0x17,
|
||||
0x5b,
|
||||
0xe5,
|
||||
0x2e,
|
||||
0xa1,
|
||||
},
|
||||
{
|
||||
0xcb,
|
||||
0x9d,
|
||||
0x7c,
|
||||
0x3f,
|
||||
0x2f,
|
||||
0x3d,
|
||||
0xb5,
|
||||
0x80,
|
||||
},
|
||||
{
|
||||
0xce,
|
||||
0x3e,
|
||||
0x91,
|
||||
0x35,
|
||||
0x8a,
|
||||
0xa2,
|
||||
0xbc,
|
||||
0x25,
|
||||
},
|
||||
{
|
||||
0xff,
|
||||
0x20,
|
||||
0x27,
|
||||
0x28,
|
||||
0xb0,
|
||||
0x7b,
|
||||
0xc6,
|
||||
0x84,
|
||||
},
|
||||
{
|
||||
0xed,
|
||||
0xfe,
|
||||
0xe8,
|
||||
0x20,
|
||||
0xbc,
|
||||
0xe4,
|
||||
0x85,
|
||||
0x8c,
|
||||
},
|
||||
{
|
||||
0x5b,
|
||||
0x51,
|
||||
0xcc,
|
||||
0xcc,
|
||||
0x13,
|
||||
0x88,
|
||||
0x83,
|
||||
0x07,
|
||||
},
|
||||
{
|
||||
0x95,
|
||||
0xb0,
|
||||
0x46,
|
||||
0x9f,
|
||||
0x06,
|
||||
0xa6,
|
||||
0xf2,
|
||||
0xee,
|
||||
},
|
||||
{
|
||||
0xae,
|
||||
0x26,
|
||||
0x33,
|
||||
0x39,
|
||||
0x94,
|
||||
0xdd,
|
||||
0xcd,
|
||||
0x48,
|
||||
},
|
||||
{
|
||||
0x7b,
|
||||
0xc7,
|
||||
0x1f,
|
||||
0x9f,
|
||||
0xae,
|
||||
0xf5,
|
||||
0xc7,
|
||||
0x99,
|
||||
},
|
||||
{
|
||||
0x5a,
|
||||
0x23,
|
||||
0x52,
|
||||
0xd7,
|
||||
0x5a,
|
||||
0x0c,
|
||||
0x37,
|
||||
0x44,
|
||||
},
|
||||
{
|
||||
0x3b,
|
||||
0xb1,
|
||||
0xa8,
|
||||
0x70,
|
||||
0xea,
|
||||
0xe8,
|
||||
0xe6,
|
||||
0x58,
|
||||
},
|
||||
{
|
||||
0x21,
|
||||
0x7d,
|
||||
0x0b,
|
||||
0xcb,
|
||||
0x4e,
|
||||
0x81,
|
||||
0xc9,
|
||||
0x02,
|
||||
},
|
||||
{
|
||||
0x73,
|
||||
0x36,
|
||||
0xaa,
|
||||
0xd2,
|
||||
0x5f,
|
||||
0x7b,
|
||||
0xf3,
|
||||
0xb5,
|
||||
},
|
||||
{
|
||||
0x37,
|
||||
0xad,
|
||||
0xc0,
|
||||
0x64,
|
||||
0x1c,
|
||||
0x4c,
|
||||
0x4f,
|
||||
0x6a,
|
||||
},
|
||||
{
|
||||
0xc9,
|
||||
0xb2,
|
||||
0xdb,
|
||||
0x2b,
|
||||
0x9a,
|
||||
0x3e,
|
||||
0x42,
|
||||
0xf9,
|
||||
},
|
||||
{
|
||||
0xf9,
|
||||
0x10,
|
||||
0xe4,
|
||||
0x80,
|
||||
0x20,
|
||||
0xab,
|
||||
0x36,
|
||||
0x3c,
|
||||
},
|
||||
{
|
||||
0x1b,
|
||||
0xf5,
|
||||
0x2b,
|
||||
0x0a,
|
||||
0x6f,
|
||||
0xee,
|
||||
0xa7,
|
||||
0xdb,
|
||||
},
|
||||
{
|
||||
0x00,
|
||||
0x74,
|
||||
0x1d,
|
||||
0xc2,
|
||||
0x69,
|
||||
0xe8,
|
||||
0xb3,
|
||||
0xef,
|
||||
},
|
||||
{
|
||||
0xe2,
|
||||
0x01,
|
||||
0x03,
|
||||
0xfa,
|
||||
0x1b,
|
||||
0xa7,
|
||||
0x76,
|
||||
0xef,
|
||||
},
|
||||
{
|
||||
0x4c,
|
||||
0x22,
|
||||
0x10,
|
||||
0xe5,
|
||||
0x4b,
|
||||
0x68,
|
||||
0x1d,
|
||||
0x73,
|
||||
},
|
||||
{
|
||||
0x70,
|
||||
0x74,
|
||||
0x10,
|
||||
0x45,
|
||||
0xae,
|
||||
0x3f,
|
||||
0xa6,
|
||||
0xf1,
|
||||
},
|
||||
{
|
||||
0x0c,
|
||||
0x86,
|
||||
0x40,
|
||||
0x37,
|
||||
0x39,
|
||||
0x71,
|
||||
0x40,
|
||||
0x38,
|
||||
},
|
||||
{
|
||||
0x0d,
|
||||
0x89,
|
||||
0x9e,
|
||||
0xd8,
|
||||
0x11,
|
||||
0x29,
|
||||
0x23,
|
||||
0xf0,
|
||||
},
|
||||
{
|
||||
0x22,
|
||||
0x6b,
|
||||
0xf5,
|
||||
0xfa,
|
||||
0xb8,
|
||||
0x1e,
|
||||
0xe1,
|
||||
0xb8,
|
||||
},
|
||||
{
|
||||
0x2d,
|
||||
0x92,
|
||||
0x5f,
|
||||
0xfb,
|
||||
0x1e,
|
||||
0x00,
|
||||
0x16,
|
||||
0xb5,
|
||||
},
|
||||
{
|
||||
0x36,
|
||||
0x19,
|
||||
0x58,
|
||||
0xd5,
|
||||
0x2c,
|
||||
0xee,
|
||||
0x10,
|
||||
0xf1,
|
||||
},
|
||||
{
|
||||
0x29,
|
||||
0x1a,
|
||||
0xaf,
|
||||
0x86,
|
||||
0x48,
|
||||
0x98,
|
||||
0x17,
|
||||
0x9d,
|
||||
},
|
||||
{
|
||||
0x86,
|
||||
0x3c,
|
||||
0x7f,
|
||||
0x15,
|
||||
0x5c,
|
||||
0x34,
|
||||
0x11,
|
||||
0x7c,
|
||||
},
|
||||
{
|
||||
0x28,
|
||||
0x70,
|
||||
0x9d,
|
||||
0x46,
|
||||
0xd8,
|
||||
0x11,
|
||||
0x62,
|
||||
0x6c,
|
||||
},
|
||||
{
|
||||
0x24,
|
||||
0x84,
|
||||
0x77,
|
||||
0x68,
|
||||
0x1d,
|
||||
0x28,
|
||||
0xf8,
|
||||
0x9c,
|
||||
},
|
||||
{
|
||||
0x83,
|
||||
0x24,
|
||||
0xe4,
|
||||
0xd7,
|
||||
0x52,
|
||||
0x8f,
|
||||
0x98,
|
||||
0x30,
|
||||
},
|
||||
{
|
||||
0xf9,
|
||||
0xef,
|
||||
0xd4,
|
||||
0xe1,
|
||||
0x3a,
|
||||
0xea,
|
||||
0x6b,
|
||||
0xd8,
|
||||
},
|
||||
{
|
||||
0x86,
|
||||
0xd6,
|
||||
0x7a,
|
||||
0x40,
|
||||
0xec,
|
||||
0x42,
|
||||
0x76,
|
||||
0xdc,
|
||||
},
|
||||
{
|
||||
0x3f,
|
||||
0x62,
|
||||
0x92,
|
||||
0xec,
|
||||
0xcc,
|
||||
0xa9,
|
||||
0x7e,
|
||||
0x35,
|
||||
},
|
||||
{
|
||||
0xcb,
|
||||
0xd9,
|
||||
0x2e,
|
||||
0xe7,
|
||||
0x24,
|
||||
0xd4,
|
||||
0x21,
|
||||
0x09,
|
||||
},
|
||||
{
|
||||
0x36,
|
||||
0x8d,
|
||||
0xf6,
|
||||
0x80,
|
||||
0x8d,
|
||||
0x40,
|
||||
0x3d,
|
||||
0x79,
|
||||
},
|
||||
{
|
||||
0x5b,
|
||||
0x38,
|
||||
0xc8,
|
||||
0x1c,
|
||||
0x67,
|
||||
0xc8,
|
||||
0xae,
|
||||
0x4c,
|
||||
},
|
||||
{
|
||||
0x95,
|
||||
0xab,
|
||||
0x71,
|
||||
0x89,
|
||||
0xd4,
|
||||
0x39,
|
||||
0xac,
|
||||
0xb3,
|
||||
},
|
||||
{
|
||||
0xa9,
|
||||
0x1a,
|
||||
0x52,
|
||||
0xc0,
|
||||
0x25,
|
||||
0x32,
|
||||
0x70,
|
||||
0x24,
|
||||
},
|
||||
{
|
||||
0x5b,
|
||||
0x00,
|
||||
0x87,
|
||||
0xc6,
|
||||
0x95,
|
||||
0x28,
|
||||
0xac,
|
||||
0xea,
|
||||
},
|
||||
{
|
||||
0x1e,
|
||||
0x30,
|
||||
0xf3,
|
||||
0xad,
|
||||
0x27,
|
||||
0xdc,
|
||||
0xb1,
|
||||
0x5a,
|
||||
},
|
||||
{
|
||||
0x69,
|
||||
0x7f,
|
||||
0x5c,
|
||||
0x9a,
|
||||
0x90,
|
||||
0x32,
|
||||
0x4e,
|
||||
0xd4,
|
||||
},
|
||||
{
|
||||
0x49,
|
||||
0x5c,
|
||||
0x0f,
|
||||
0x99,
|
||||
0x55,
|
||||
0x57,
|
||||
0xdc,
|
||||
0x38,
|
||||
},
|
||||
{
|
||||
0x94,
|
||||
0x27,
|
||||
0x20,
|
||||
0x2a,
|
||||
0x3c,
|
||||
0x29,
|
||||
0xf9,
|
||||
0x4d,
|
||||
},
|
||||
{
|
||||
0xa9,
|
||||
0xea,
|
||||
0xa8,
|
||||
0xc0,
|
||||
0x4b,
|
||||
0xa9,
|
||||
0x3e,
|
||||
0x3e,
|
||||
},
|
||||
{
|
||||
0xee,
|
||||
0xa4,
|
||||
0xc1,
|
||||
0x73,
|
||||
0x7d,
|
||||
0x01,
|
||||
0x12,
|
||||
0x18,
|
||||
},
|
||||
{
|
||||
0x91,
|
||||
0x2d,
|
||||
0x56,
|
||||
0x8f,
|
||||
0xd8,
|
||||
0xf6,
|
||||
0x5a,
|
||||
0x49,
|
||||
},
|
||||
{
|
||||
0x56,
|
||||
0x91,
|
||||
0x95,
|
||||
0x96,
|
||||
0xb0,
|
||||
0xff,
|
||||
0x5c,
|
||||
0x97,
|
||||
},
|
||||
{
|
||||
0x02,
|
||||
0x44,
|
||||
0x5a,
|
||||
0x79,
|
||||
0x98,
|
||||
0xf5,
|
||||
0x50,
|
||||
0xe1,
|
||||
},
|
||||
{
|
||||
0x86,
|
||||
0xec,
|
||||
0x46,
|
||||
0x6c,
|
||||
0xe7,
|
||||
0x1d,
|
||||
0x1f,
|
||||
0xb2,
|
||||
},
|
||||
{
|
||||
0x35,
|
||||
0x95,
|
||||
0x69,
|
||||
0xe7,
|
||||
0xd2,
|
||||
0x89,
|
||||
0xe3,
|
||||
0xbc,
|
||||
},
|
||||
{
|
||||
0x87,
|
||||
0x1b,
|
||||
0x05,
|
||||
0xca,
|
||||
0x62,
|
||||
0xbb,
|
||||
0x7c,
|
||||
0x96,
|
||||
},
|
||||
{
|
||||
0xa1,
|
||||
0xa4,
|
||||
0x92,
|
||||
0xf9,
|
||||
0x42,
|
||||
0xf1,
|
||||
0x5f,
|
||||
0x1d,
|
||||
},
|
||||
{
|
||||
0x12,
|
||||
0xec,
|
||||
0x26,
|
||||
0x7f,
|
||||
0xf6,
|
||||
0x09,
|
||||
0x5b,
|
||||
0x6e,
|
||||
},
|
||||
{
|
||||
0x5d,
|
||||
0x1b,
|
||||
0x5e,
|
||||
0xa1,
|
||||
0xb2,
|
||||
0x31,
|
||||
0xd8,
|
||||
0x9d,
|
||||
},
|
||||
{
|
||||
0xd8,
|
||||
0xcf,
|
||||
0xb4,
|
||||
0x45,
|
||||
0x3f,
|
||||
0x92,
|
||||
0xee,
|
||||
0x54,
|
||||
},
|
||||
{
|
||||
0xd6,
|
||||
0x76,
|
||||
0x28,
|
||||
0x90,
|
||||
0xbf,
|
||||
0x26,
|
||||
0xe4,
|
||||
0x60,
|
||||
},
|
||||
{
|
||||
0x31,
|
||||
0x35,
|
||||
0x63,
|
||||
0xa4,
|
||||
0xb7,
|
||||
0xed,
|
||||
0x5c,
|
||||
0xf3,
|
||||
},
|
||||
{
|
||||
0xf9,
|
||||
0x0b,
|
||||
0x3a,
|
||||
0xb5,
|
||||
0x72,
|
||||
0xd4,
|
||||
0x66,
|
||||
0x93,
|
||||
},
|
||||
{
|
||||
0x2e,
|
||||
0xa6,
|
||||
0x3c,
|
||||
0x71,
|
||||
0xbf,
|
||||
0x32,
|
||||
0x60,
|
||||
0x87,
|
||||
},
|
||||
};
|
||||
@@ -1,103 +0,0 @@
|
||||
PCRE2 License
|
||||
=============
|
||||
|
||||
| SPDX-License-Identifier: | BSD-3-Clause WITH PCRE2-exception |
|
||||
|---------|-------|
|
||||
|
||||
PCRE2 is a library of functions to support regular expressions whose syntax
|
||||
and semantics are as close as possible to those of the Perl 5 language.
|
||||
|
||||
Releases 10.00 and above of PCRE2 are distributed under the terms of the "BSD"
|
||||
licence, as specified below, with one exemption for certain binary
|
||||
redistributions. The documentation for PCRE2, supplied in the "doc" directory,
|
||||
is distributed under the same terms as the software itself. The data in the
|
||||
testdata directory is not copyrighted and is in the public domain.
|
||||
|
||||
The basic library functions are written in C and are freestanding. Also
|
||||
included in the distribution is a just-in-time compiler that can be used to
|
||||
optimize pattern matching. This is an optional feature that can be omitted when
|
||||
the library is built.
|
||||
|
||||
|
||||
COPYRIGHT
|
||||
---------
|
||||
|
||||
### The basic library functions
|
||||
|
||||
Written by: Philip Hazel
|
||||
Email local part: Philip.Hazel
|
||||
Email domain: gmail.com
|
||||
|
||||
Retired from University of Cambridge Computing Service,
|
||||
Cambridge, England.
|
||||
|
||||
Copyright (c) 1997-2007 University of Cambridge
|
||||
Copyright (c) 2007-2024 Philip Hazel
|
||||
All rights reserved.
|
||||
|
||||
### PCRE2 Just-In-Time compilation support
|
||||
|
||||
Written by: Zoltan Herczeg
|
||||
Email local part: hzmester
|
||||
Email domain: freemail.hu
|
||||
|
||||
Copyright (c) 2010-2024 Zoltan Herczeg
|
||||
All rights reserved.
|
||||
|
||||
### Stack-less Just-In-Time compiler
|
||||
|
||||
Written by: Zoltan Herczeg
|
||||
Email local part: hzmester
|
||||
Email domain: freemail.hu
|
||||
|
||||
Copyright (c) 2009-2024 Zoltan Herczeg
|
||||
All rights reserved.
|
||||
|
||||
### All other contributions
|
||||
|
||||
Many other contributors have participated in the authorship of PCRE2. As PCRE2
|
||||
has never required a Contributor Licensing Agreement, or other copyright
|
||||
assignment agreement, all contributions have copyright retained by each
|
||||
original contributor or their employer.
|
||||
|
||||
|
||||
THE "BSD" LICENCE
|
||||
-----------------
|
||||
|
||||
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 notices,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notices, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of the University of Cambridge nor the names of any
|
||||
contributors may 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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
||||
|
||||
|
||||
EXEMPTION FOR BINARY LIBRARY-LIKE PACKAGES
|
||||
------------------------------------------
|
||||
|
||||
The second condition in the BSD licence (covering binary redistributions) does
|
||||
not apply all the way down a chain of software. If binary package A includes
|
||||
PCRE2, it must respect the condition, but if package B is software that
|
||||
includes package A, the condition is not imposed on package B unless it uses
|
||||
PCRE2 independently.
|
||||
|
||||
End
|
||||
@@ -5,8 +5,8 @@ if (POLICY CMP0177)
|
||||
endif()
|
||||
project(PIP)
|
||||
set(PIP_MAJOR 5)
|
||||
set(PIP_MINOR 5)
|
||||
set(PIP_REVISION 5)
|
||||
set(PIP_MINOR 3)
|
||||
set(PIP_REVISION 0)
|
||||
set(PIP_SUFFIX )
|
||||
set(PIP_COMPANY SHS)
|
||||
set(PIP_DOMAIN org.SHS)
|
||||
@@ -116,10 +116,8 @@ macro(pip_module NAME LIBS LABEL INCLUDES SOURCES MSG)
|
||||
list(REMOVE_ITEM HS ${PHS})
|
||||
endif()
|
||||
if (NOT "x${SOURCES}" STREQUAL "x")
|
||||
foreach (_s ${SOURCES})
|
||||
file(GLOB_RECURSE ASRC "${_s}/*.cpp" "${_s}/*.c")
|
||||
list(APPEND CPPS ${ASRC})
|
||||
endforeach()
|
||||
file(GLOB_RECURSE ASRC "${SOURCES}/*.cpp" "${SOURCES}/*.c")
|
||||
list(APPEND CPPS ${ASRC})
|
||||
endif()
|
||||
list(APPEND HDRS ${HS})
|
||||
list(APPEND PHDRS ${PHS})
|
||||
@@ -382,7 +380,7 @@ endif()
|
||||
add_subdirectory("3rd/pcre2" EXCLUDE_FROM_ALL)
|
||||
list(APPEND LIBS_MAIN pcre2-16-static)
|
||||
|
||||
pip_module(main "${LIBS_MAIN}" "PIP main library" "" "${PIP_3PL_DIR}/BLAKE2;${PIP_3PL_DIR}/SipHash" "")
|
||||
pip_module(main "${LIBS_MAIN}" "PIP main library" "" "${PIP_3PL_DIR}/BLAKE2" "")
|
||||
|
||||
generate_export_header(pip)
|
||||
list(APPEND HDRS "${CMAKE_CURRENT_BINARY_DIR}/pip_export.h")
|
||||
@@ -594,7 +592,7 @@ if (NOT CROSSTOOLS)
|
||||
if (NOT DEFINED ANDROID_PLATFORM)
|
||||
if(microhttpd_FOUND AND curl_FOUND)
|
||||
add_executable(pip_test "main.cpp")
|
||||
target_link_libraries(pip_test pip pip_io_utils pip_client_server pip_http_server pip_http_client)
|
||||
target_link_libraries(pip_test pip pip_io_utils pip_client_server pip_http_server pip_http_client pip_console)
|
||||
if(sodium_FOUND)
|
||||
add_executable(pip_cloud_test "main_picloud_test.cpp")
|
||||
target_link_libraries(pip_cloud_test pip_cloud)
|
||||
|
||||
BIN
lang/pip_ru.btf
BIN
lang/pip_ru.btf
Binary file not shown.
512
lang/pip_ru.ts
512
lang/pip_ru.ts
@@ -20,7 +20,7 @@
|
||||
<context>
|
||||
<name>PIFile</name>
|
||||
<message>
|
||||
<location filename="../libs/main/io_devices/pifile.cpp" line="296"/>
|
||||
<location filename="../libs/main/io_devices/pifile.cpp" line="300"/>
|
||||
<source>Downsize is not supported yet :-(</source>
|
||||
<translation>Уменьшение размера не поддерживается</translation>
|
||||
</message>
|
||||
@@ -66,239 +66,6 @@
|
||||
<translation type="vanished">Предупреждение: PICrypt неактивен, для активации установите библиотеку sodium и пересоберите PIP</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PIUnits</name>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="88"/>
|
||||
<source>E</source>
|
||||
<translation>Э</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="85"/>
|
||||
<source>G</source>
|
||||
<translation>Г</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="84"/>
|
||||
<source>M</source>
|
||||
<translation>М</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="87"/>
|
||||
<source>P</source>
|
||||
<translation>П</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="92"/>
|
||||
<source>Q</source>
|
||||
<translation>Кв</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="91"/>
|
||||
<source>R</source>
|
||||
<translation>Рн</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="86"/>
|
||||
<source>T</source>
|
||||
<translation>Т</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="90"/>
|
||||
<source>Y</source>
|
||||
<translation>И</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="89"/>
|
||||
<source>Z</source>
|
||||
<translation>З</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="101"/>
|
||||
<source>a</source>
|
||||
<translation>а</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="95"/>
|
||||
<source>c</source>
|
||||
<translation>с</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="94"/>
|
||||
<source>d</source>
|
||||
<translation>д</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="100"/>
|
||||
<source>f</source>
|
||||
<translation>ф</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="82"/>
|
||||
<source>h</source>
|
||||
<translation>г</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="83"/>
|
||||
<source>k</source>
|
||||
<translation>к</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="96"/>
|
||||
<source>m</source>
|
||||
<translation>м</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="98"/>
|
||||
<source>n</source>
|
||||
<translation>н</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="99"/>
|
||||
<source>p</source>
|
||||
<translation>п</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="104"/>
|
||||
<source>r</source>
|
||||
<translation>рн</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="97"/>
|
||||
<source>u</source>
|
||||
<translation>мк</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="103"/>
|
||||
<source>y</source>
|
||||
<translation>и</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="102"/>
|
||||
<source>z</source>
|
||||
<translation>з</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="81"/>
|
||||
<source>da</source>
|
||||
<translation>да</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="88"/>
|
||||
<source>exa</source>
|
||||
<translation>экса</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="101"/>
|
||||
<source>atto</source>
|
||||
<translation>атто</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="81"/>
|
||||
<source>deca</source>
|
||||
<translation>дека</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="94"/>
|
||||
<source>deci</source>
|
||||
<translation>деци</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="85"/>
|
||||
<source>giga</source>
|
||||
<translation>гига</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="83"/>
|
||||
<source>kilo</source>
|
||||
<translation>кило</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="84"/>
|
||||
<source>mega</source>
|
||||
<translation>мега</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="98"/>
|
||||
<source>nano</source>
|
||||
<translation>нано</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="87"/>
|
||||
<source>peta</source>
|
||||
<translation>пета</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="99"/>
|
||||
<source>pico</source>
|
||||
<translation>пико</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="86"/>
|
||||
<source>tera</source>
|
||||
<translation>тера</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="95"/>
|
||||
<source>centi</source>
|
||||
<translation>санти</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="100"/>
|
||||
<source>femto</source>
|
||||
<translation>фемто</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="82"/>
|
||||
<source>hecto</source>
|
||||
<translation>гекто</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="97"/>
|
||||
<source>micro</source>
|
||||
<translation>микро</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="96"/>
|
||||
<source>milli</source>
|
||||
<translation>милли</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="91"/>
|
||||
<source>ronna</source>
|
||||
<translation>ронна</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="104"/>
|
||||
<source>ronto</source>
|
||||
<translation>ронто</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="103"/>
|
||||
<source>yocto</source>
|
||||
<translation>иокто</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="90"/>
|
||||
<source>yotta</source>
|
||||
<translation>иотта</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="102"/>
|
||||
<source>zepto</source>
|
||||
<translation>зепто</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="89"/>
|
||||
<source>zetta</source>
|
||||
<translation>зетта</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_prefix.cpp" line="92"/>
|
||||
<source>quetta</source>
|
||||
<translation>кветта</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PIBinLog</name>
|
||||
<message>
|
||||
@@ -486,47 +253,47 @@
|
||||
<context>
|
||||
<name>PIString</name>
|
||||
<message>
|
||||
<location filename="../libs/main/text/pistring.cpp" line="1807"/>
|
||||
<location filename="../libs/main/text/pistring.cpp" line="1787"/>
|
||||
<source>B</source>
|
||||
<translation>Б</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/text/pistring.cpp" line="1827"/>
|
||||
<location filename="../libs/main/text/pistring.cpp" line="1807"/>
|
||||
<source>EiB</source>
|
||||
<translation>ЭиБ</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/text/pistring.cpp" line="1824"/>
|
||||
<location filename="../libs/main/text/pistring.cpp" line="1804"/>
|
||||
<source>GiB</source>
|
||||
<translation>ГиБ</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/text/pistring.cpp" line="1822"/>
|
||||
<location filename="../libs/main/text/pistring.cpp" line="1802"/>
|
||||
<source>KiB</source>
|
||||
<translation>КиБ</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/text/pistring.cpp" line="1823"/>
|
||||
<location filename="../libs/main/text/pistring.cpp" line="1803"/>
|
||||
<source>MiB</source>
|
||||
<translation>МиБ</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/text/pistring.cpp" line="1826"/>
|
||||
<location filename="../libs/main/text/pistring.cpp" line="1806"/>
|
||||
<source>PiB</source>
|
||||
<translation>ПиБ</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/text/pistring.cpp" line="1825"/>
|
||||
<location filename="../libs/main/text/pistring.cpp" line="1805"/>
|
||||
<source>TiB</source>
|
||||
<translation>ТиБ</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/text/pistring.cpp" line="1829"/>
|
||||
<location filename="../libs/main/text/pistring.cpp" line="1809"/>
|
||||
<source>YiB</source>
|
||||
<translation>ЙиБ</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/text/pistring.cpp" line="1828"/>
|
||||
<location filename="../libs/main/text/pistring.cpp" line="1808"/>
|
||||
<source>ZiB</source>
|
||||
<translation>ЗиБ</translation>
|
||||
</message>
|
||||
@@ -552,7 +319,7 @@
|
||||
<context>
|
||||
<name>PIProcess</name>
|
||||
<message>
|
||||
<location filename="../libs/main/system/piprocess.cpp" line="316"/>
|
||||
<location filename="../libs/main/system/piprocess.cpp" line="200"/>
|
||||
<source>"CreateProcess" error: %1</source>
|
||||
<translation>Ошибка "CreateProcess": %1</translation>
|
||||
</message>
|
||||
@@ -560,12 +327,12 @@
|
||||
<context>
|
||||
<name>PIVariant</name>
|
||||
<message>
|
||||
<location filename="../libs/main/types/pivariant.cpp" line="418"/>
|
||||
<location filename="../libs/main/types/pivariant.cpp" line="415"/>
|
||||
<source>Can`t initialize PIVariant from unregistered type "%1"!</source>
|
||||
<translation>Невозможно инициализировать PIVariant из незарегистрированного типа "%1"!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/types/pivariant.cpp" line="396"/>
|
||||
<location filename="../libs/main/types/pivariant.cpp" line="393"/>
|
||||
<source>Can`t initialize PIVariant from unregistered typeID "%1"!</source>
|
||||
<translation>Невозможно инициализировать PIVariant из незарегистрированного ID типа "%1"!</translation>
|
||||
</message>
|
||||
@@ -591,7 +358,7 @@
|
||||
<context>
|
||||
<name>PIEthernet</name>
|
||||
<message>
|
||||
<location filename="../libs/main/io_devices/piethernet.cpp" line="1275"/>
|
||||
<location filename="../libs/main/io_devices/piethernet.cpp" line="1272"/>
|
||||
<source>Can`t get interfaces: %1</source>
|
||||
<translation>Невозможно получить интерфейсы: %1</translation>
|
||||
</message>
|
||||
@@ -622,67 +389,6 @@
|
||||
<translation>Ошибка: Режим ReadWrite не поддерживается, используйте WriteOnly или ReadOnly</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PIUnitsMass</name>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_mass.cpp" line="35"/>
|
||||
<source>g</source>
|
||||
<translation>г</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_mass.cpp" line="37"/>
|
||||
<source>℥</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_mass.cpp" line="36"/>
|
||||
<source>lb</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_mass.cpp" line="25"/>
|
||||
<source>gram</source>
|
||||
<translation>грамм</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_mass.cpp" line="27"/>
|
||||
<source>ounce</source>
|
||||
<translation>унция</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_mass.cpp" line="26"/>
|
||||
<source>pound</source>
|
||||
<translation>фунт</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PIUnitsTime</name>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_time.cpp" line="34"/>
|
||||
<source>s</source>
|
||||
<translation>с</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_time.cpp" line="35"/>
|
||||
<source>Hz</source>
|
||||
<translation>Гц</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_time.cpp" line="26"/>
|
||||
<source>hertz</source>
|
||||
<translation>герц</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_time.cpp" line="25"/>
|
||||
<source>second</source>
|
||||
<translation>секунд</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_time.cpp" line="25"/>
|
||||
<source>secons</source>
|
||||
<translation type="vanished">секунд</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PIConnection</name>
|
||||
<message>
|
||||
@@ -749,29 +455,6 @@
|
||||
<translation>toSystemTime() Предупреждение: неверная частота: %1</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PIUnitsAngle</name>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_angle.cpp" line="36"/>
|
||||
<source>°</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_angle.cpp" line="37"/>
|
||||
<source>rad</source>
|
||||
<translation>рад</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_angle.cpp" line="27"/>
|
||||
<source>degree</source>
|
||||
<translation>градусы</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_angle.cpp" line="28"/>
|
||||
<source>radian</source>
|
||||
<translation>радиан</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PIEthUtilBase</name>
|
||||
<message>
|
||||
@@ -845,171 +528,4 @@
|
||||
<translation>Невозможно открыть процесс с ID = %1, %2!</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PIUnitsDistance</name>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_distance.cpp" line="40"/>
|
||||
<source>"</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_distance.cpp" line="44"/>
|
||||
<source>Å</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_distance.cpp" line="39"/>
|
||||
<source>m</source>
|
||||
<translation>м</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_distance.cpp" line="45"/>
|
||||
<source>au</source>
|
||||
<translation>а. е.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_distance.cpp" line="42"/>
|
||||
<source>ft</source>
|
||||
<translation>фут</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_distance.cpp" line="43"/>
|
||||
<source>yd</source>
|
||||
<translation>ярд</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_distance.cpp" line="27"/>
|
||||
<source>mil</source>
|
||||
<translation>мил</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_distance.cpp" line="28"/>
|
||||
<source>foot</source>
|
||||
<translation>фут</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_distance.cpp" line="26"/>
|
||||
<source>inch</source>
|
||||
<translation>дюйм</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_distance.cpp" line="41"/>
|
||||
<source>thou</source>
|
||||
<translation>мил</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_distance.cpp" line="29"/>
|
||||
<source>yard</source>
|
||||
<translation>ярд</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_distance.cpp" line="25"/>
|
||||
<source>meter</source>
|
||||
<translation>метр</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_distance.cpp" line="30"/>
|
||||
<source>angstrom</source>
|
||||
<translation>ангстрем</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_distance.cpp" line="31"/>
|
||||
<source>astronomical unit</source>
|
||||
<translation>астрономическая единица</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PIUnitsPressure</name>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_pressure.cpp" line="36"/>
|
||||
<source>Pa</source>
|
||||
<translation>Па</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_pressure.cpp" line="37"/>
|
||||
<source>atm</source>
|
||||
<translation>атм</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_pressure.cpp" line="38"/>
|
||||
<source>bar</source>
|
||||
<translation>бар</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_pressure.cpp" line="39"/>
|
||||
<source>mmHg</source>
|
||||
<translation>мм рт. ст.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_pressure.cpp" line="28"/>
|
||||
<source>mm Hg</source>
|
||||
<translation>мм рт. ст.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_pressure.cpp" line="25"/>
|
||||
<source>pascal</source>
|
||||
<translation>паскаль</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_pressure.cpp" line="26"/>
|
||||
<source>atmosphere</source>
|
||||
<translation>атмосфер</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PIUnitsInformation</name>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_information.cpp" line="35"/>
|
||||
<source>B</source>
|
||||
<translation>Б</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_information.cpp" line="34"/>
|
||||
<source>b</source>
|
||||
<translation>б</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_information.cpp" line="25"/>
|
||||
<source>bit</source>
|
||||
<translation>бит</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_information.cpp" line="26"/>
|
||||
<source>byte</source>
|
||||
<translation>байт</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PIUnitsTemperature</name>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_temperature.cpp" line="35"/>
|
||||
<source>K</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_temperature.cpp" line="36"/>
|
||||
<source>°C</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_temperature.cpp" line="37"/>
|
||||
<source>°F</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_temperature.cpp" line="25"/>
|
||||
<source>Kelvin</source>
|
||||
<translation>Кельвин</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_temperature.cpp" line="26"/>
|
||||
<source>Celsius</source>
|
||||
<translation>Цельсий</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../libs/main/units/piunits_class_temperature.cpp" line="27"/>
|
||||
<source>Fahrenheit</source>
|
||||
<translation>Фаренгейт</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
||||
@@ -59,7 +59,7 @@ bool PIHTTPClient::init() {
|
||||
if (is_cancel) return false;
|
||||
CurlThreadPool::instance();
|
||||
if (!PRIVATE->init()) return false;
|
||||
auto ait = request.queryArguments().makeIterator();
|
||||
auto ait = request.arguments().makeIterator();
|
||||
while (ait.next()) {
|
||||
if (!url.contains('?'))
|
||||
url.append('?');
|
||||
|
||||
@@ -363,5 +363,5 @@ void MicrohttpdServer::addFixedHeaders(MessageMutable & msg) {
|
||||
msg.addHeader(Header::ContentType, "application/json; charset=utf-8");
|
||||
}
|
||||
}
|
||||
// msg.addHeader(Header::AccessControlAllowOrigin, "*");
|
||||
msg.addHeader(Header::AccessControlAllowOrigin, "*");
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
//! \file piclientserver_client.h
|
||||
//! \ingroup ClientServer
|
||||
//! \brief
|
||||
//! \~english Client and ServerClient classes
|
||||
//! \~russian Классы Client и ServerClient
|
||||
//! \details
|
||||
//! \~english Provides client implementation for connecting to servers and server-side client representation.
|
||||
//! \~russian Обеспечивает реализацию клиента для подключения к серверам и представление клиента на стороне сервера.
|
||||
/*! \file piclientserver_client.h
|
||||
* \ingroup ClientServer
|
||||
* \~\brief
|
||||
* \~english
|
||||
* \~russian
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
//! \file piclientserver_client_base.h
|
||||
//! \ingroup ClientServer
|
||||
//! \brief
|
||||
//! \~english Base class for client-server communication
|
||||
//! \~russian Базовый класс для клиент-серверного взаимодействия
|
||||
//! \details
|
||||
//! \~english Provides base functionality for client-server communication with diagnostics support.
|
||||
//! \~russian Обеспечивает базовую функциональность для клиент-серверного взаимодействия с поддержкой диагностики.
|
||||
/*! \file piclientserver_client_base.h
|
||||
* \ingroup ClientServer
|
||||
* \~\brief
|
||||
* \~english
|
||||
* \~russian
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
@@ -39,112 +37,77 @@ class Server;
|
||||
|
||||
class ClientInterface {};
|
||||
|
||||
//! \brief
|
||||
//! \~english Base class for client and server-side client
|
||||
//! \~russian Базовый класс для клиента и клиента на стороне сервера
|
||||
//! ~english Base class for client-server communication with diagnostics support
|
||||
//! ~russian Базовый класс для клиент-серверного взаимодействия с поддержкой диагностики
|
||||
// template<bool EnableDiagnostics = false>
|
||||
class PIP_CLIENT_SERVER_EXPORT ClientBase {
|
||||
friend class Server;
|
||||
NO_COPY_CLASS(ClientBase);
|
||||
|
||||
public:
|
||||
//! \brief
|
||||
//! \~english Constructs ClientBase
|
||||
//! \~russian Создает ClientBase
|
||||
ClientBase();
|
||||
|
||||
//! \brief
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
virtual ~ClientBase();
|
||||
|
||||
//! \brief
|
||||
//! \~english Gets underlying TCP connection
|
||||
//! \~russian Возвращает TCP-соединение
|
||||
//! ~english Gets underlying TCP connection
|
||||
//! ~russian Возвращает TCP-соединение
|
||||
const PIEthernet * getTCP() const { return tcp; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Closes the connection
|
||||
//! \~russian Закрывает соединение
|
||||
//! ~english Closes the connection
|
||||
//! ~russian Закрывает соединение
|
||||
void close();
|
||||
|
||||
//! \brief
|
||||
//! \~english Gracefully stops and waits for completion
|
||||
//! \~russian Плавно останавливает и ожидает завершения
|
||||
//! ~english Gracefully stops and waits for completion
|
||||
//! ~russian Плавно останавливает и ожидает завершения
|
||||
void stopAndWait();
|
||||
|
||||
|
||||
//! \brief
|
||||
//! \~english Writes byte array to the connection
|
||||
//! \~russian Записывает массив байтов в соединение
|
||||
//! ~english Writes byte array to the connection
|
||||
//! ~russian Записывает массив байтов в соединение
|
||||
int write(const void * d, const size_t s);
|
||||
|
||||
//! \brief
|
||||
//! \~english Writes byte array to the connection
|
||||
//! \~russian Записывает массив байтов в соединение
|
||||
//! ~english Writes byte array to the connection
|
||||
//! ~russian Записывает массив байтов в соединение
|
||||
int write(const PIByteArray & ba) { return write(ba.data(), ba.size()); }
|
||||
|
||||
|
||||
//! \brief
|
||||
//! \~english Enables diagnostics collection
|
||||
//! \~russian Включает сбор диагностики
|
||||
//! ~english Enables diagnostics collection
|
||||
//! ~russian Включает сбор диагностики
|
||||
void enableDiagnostics();
|
||||
|
||||
//! \brief
|
||||
//! \~english Gets current diagnostics state
|
||||
//! \~russian Возвращает текущее состояние диагностики
|
||||
//! ~english Gets current diagnostics state
|
||||
//! ~russian Возвращает текущее состояние диагностики
|
||||
PIDiagnostics::State diagnostics() const;
|
||||
|
||||
|
||||
//! \brief
|
||||
//! \~english Gets current received packet bytes already received (all bytes count passed in \a receivePacketStart())
|
||||
//! \~russian Возвращает сколько байт принимаемого пакета получено (общее количество передается в \a receivePacketStart())
|
||||
//! ~english Gets current received packet bytes already received (all bytes count passed in \a receivePacketStart())
|
||||
//! ~russian Возвращает сколько байт принимаемого пакета получено (общее количество передается в \a receivePacketStart())
|
||||
int receivePacketProgress() const;
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns stream configuration
|
||||
//! \~russian Возвращает конфигурацию стрима
|
||||
const PIStreamPackerConfig & configuration() const { return stream.configuration(); }
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns stream configuration
|
||||
//! \~russian Возвращает конфигурацию стрима
|
||||
PIStreamPackerConfig & configuration() { return stream.configuration(); }
|
||||
|
||||
//! \brief
|
||||
//! \~english Sets stream configuration
|
||||
//! \~russian Устанавливает конфигурацию стрима
|
||||
void setConfiguration(const PIStreamPackerConfig & config) { stream.setConfiguration(config); }
|
||||
|
||||
protected:
|
||||
//! \brief
|
||||
//! \~english Called when data is received
|
||||
//! \~russian Вызывается при получении данных
|
||||
//! ~english Called when data is received
|
||||
//! ~russian Вызывается при получении данных
|
||||
virtual void readed(PIByteArray data) {}
|
||||
|
||||
//! \brief
|
||||
//! \~english Called when connection is established
|
||||
//! \~russian Вызывается при установке соединения
|
||||
//! ~english Called when connection is established
|
||||
//! ~russian Вызывается при установке соединения
|
||||
virtual void connected() {}
|
||||
|
||||
//! \brief
|
||||
//! \~english Called when connection is closed
|
||||
//! \~russian Вызывается при закрытии соединения
|
||||
//! ~english Called when connection is closed
|
||||
//! ~russian Вызывается при закрытии соединения
|
||||
virtual void disconnected() {}
|
||||
|
||||
//! \brief
|
||||
//! \~english Called when packet receiving starts
|
||||
//! \~russian Вызывается при начале получения пакета
|
||||
//! ~english Called when packet receiving starts
|
||||
//! ~russian Вызывается при начале получения пакета
|
||||
virtual void receivePacketStart(int size) {}
|
||||
|
||||
//! \brief
|
||||
//! \~english Called when packet receiving ends
|
||||
//! \~russian Вызывается при завершении получения пакета
|
||||
//! ~english Called when packet receiving ends
|
||||
//! ~russian Вызывается при завершении получения пакета
|
||||
virtual void receivePacketEnd() {}
|
||||
|
||||
//! \brief
|
||||
//! \~english Initializes the client
|
||||
//! \~russian Инициализирует клиента
|
||||
void init();
|
||||
|
||||
bool own_tcp = false;
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
//! \file piclientserver_server.h
|
||||
//! \ingroup ClientServer
|
||||
//! \brief
|
||||
//! \~english TCP Server
|
||||
//! \~russian TCP Сервер
|
||||
//! \details
|
||||
//! \~english TCP server implementation for client-server communication.
|
||||
//! \~russian Реализация TCP сервера для клиент-серверного взаимодействия.
|
||||
/*! \file piclientserver_server.h
|
||||
* \ingroup ClientServer
|
||||
* \~\brief
|
||||
* \~english
|
||||
* \~russian
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Module includes
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
//! \file picloudbase.h
|
||||
//! \ingroup Cloud
|
||||
//! \brief
|
||||
//! \~english Base class for PICloudClient and PICloudServer
|
||||
//! \~russian Базовый класс для PICloudClient и PICloudServer
|
||||
//! \details
|
||||
//! \~english Provides common functionality for cloud client and server implementations.
|
||||
//! \~russian Обеспечивает общую функциональность для реализаций облачного клиента и сервера.
|
||||
/*! \file picloudbase.h
|
||||
* \ingroup Cloud
|
||||
* \~\brief
|
||||
* \~english Base class for PICloudClient and PICloudServer
|
||||
* \~russian Базовый класс для PICloudClient и PICloudServer
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
PICloud Base - Base class for PICloudClient and PICloud Server
|
||||
@@ -33,20 +31,10 @@
|
||||
#include "pistreampacker.h"
|
||||
|
||||
|
||||
//! \brief
|
||||
//! \~english Base class for cloud client and server
|
||||
//! \~russian Базовый класс для облачного клиента и сервера
|
||||
|
||||
class PIP_CLOUD_EXPORT PICloudBase {
|
||||
public:
|
||||
//! \brief
|
||||
//! \~english Constructs PICloudBase
|
||||
//! \~russian Создает PICloudBase
|
||||
PICloudBase();
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns server name
|
||||
//! \~russian Возвращает имя сервера
|
||||
PIString serverName() const;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
//! \file picloudclient.h
|
||||
//! \ingroup Cloud
|
||||
//! \brief
|
||||
//! \~english PICloud Client
|
||||
//! \~russian Клиент PICloud
|
||||
//! \details
|
||||
//! \~english Client implementation for connecting to PICloud servers over TCP.
|
||||
//! \~russian Реализация клиента для подключения к серверам PICloud по TCP.
|
||||
/*! \file picloudclient.h
|
||||
* \ingroup Cloud
|
||||
* \~\brief
|
||||
* \~english PICloud Client
|
||||
* \~russian Клиент PICloud
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
PICloud Client
|
||||
@@ -32,9 +30,7 @@
|
||||
#include "piconditionvar.h"
|
||||
|
||||
|
||||
//! \brief PICloud client implementation
|
||||
//! \~english PICloud client for connecting to servers
|
||||
//! \~russian Клиент PICloud для подключения к серверам
|
||||
//! \brief PICloudClient
|
||||
|
||||
class PIP_CLOUD_EXPORT PICloudClient
|
||||
: public PIIODevice
|
||||
@@ -42,75 +38,23 @@ class PIP_CLOUD_EXPORT PICloudClient
|
||||
PIIODEVICE(PICloudClient, "");
|
||||
|
||||
public:
|
||||
//! \brief
|
||||
//! \~english Constructs PICloudClient
|
||||
//! \~russian Создает PICloudClient
|
||||
explicit PICloudClient(const PIString & path = PIString(), PIIODevice::DeviceMode mode = PIIODevice::ReadWrite);
|
||||
|
||||
//! \brief
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
virtual ~PICloudClient();
|
||||
|
||||
//! \brief
|
||||
//! \~english Sets server name
|
||||
//! \~russian Устанавливает имя сервера
|
||||
void setServerName(const PIString & server_name);
|
||||
|
||||
//! \brief
|
||||
//! \~english Sets keep connection mode
|
||||
//! \~russian Устанавливает режим поддержания соединения
|
||||
void setKeepConnection(bool on);
|
||||
|
||||
//! \brief
|
||||
//! \~english Checks if connected to server
|
||||
//! \~russian Проверяет подключение к серверу
|
||||
bool isConnected() const { return is_connected; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns number of bytes available
|
||||
//! \~russian Возвращает количество доступных байт
|
||||
ssize_t bytesAvailable() const override { return buff.size(); }
|
||||
|
||||
//! \brief
|
||||
//! \~english Interrupts connection
|
||||
//! \~russian Прерывает соединение
|
||||
void interrupt() override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Raised when connected to server
|
||||
//! \~russian Вызывается при подключении к серверу
|
||||
EVENT(connected);
|
||||
|
||||
//! \brief
|
||||
//! \~english Raised when disconnected from server
|
||||
//! \~russian Вызывается при отключении от сервера
|
||||
EVENT(disconnected);
|
||||
|
||||
protected:
|
||||
//! \brief
|
||||
//! \~english Opens device
|
||||
//! \~russian Открывает устройство
|
||||
bool openDevice() override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Closes device
|
||||
//! \~russian Закрывает устройство
|
||||
bool closeDevice() override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Reads data from device
|
||||
//! \~russian Читает данные из устройства
|
||||
ssize_t readDevice(void * read_to, ssize_t max_size) override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Writes data to device
|
||||
//! \~russian Записывает данные в устройство
|
||||
ssize_t writeDevice(const void * data, ssize_t size) override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns device info flags
|
||||
//! \~russian Возвращает флаги информации об устройстве
|
||||
DeviceInfoFlags deviceInfoFlags() const override { return PIIODevice::Reliable; }
|
||||
|
||||
private:
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
//! \file picloudserver.h
|
||||
//! \ingroup Cloud
|
||||
//! \brief
|
||||
//! \~english PICloud Server
|
||||
//! \~russian Сервер PICloud
|
||||
//! \details
|
||||
//! \~english Server implementation for accepting PICloud client connections over TCP.
|
||||
//! \~russian Реализация сервера для приема подключений клиентов PICloud по TCP.
|
||||
/*! \file picloudserver.h
|
||||
* \ingroup Cloud
|
||||
* \~\brief
|
||||
* \~english PICloud Server
|
||||
* \~russian Сервер PICloud
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
PICloud Server
|
||||
@@ -38,70 +36,25 @@ class PIP_CLOUD_EXPORT PICloudServer
|
||||
PIIODEVICE(PICloudServer, "");
|
||||
|
||||
public:
|
||||
//! \brief
|
||||
//! \~english Constructs PICloudServer
|
||||
//! \~russian Создает PICloudServer
|
||||
//! PICloudServer
|
||||
explicit PICloudServer(const PIString & path = PIString(), PIIODevice::DeviceMode mode = PIIODevice::ReadWrite);
|
||||
|
||||
//! \brief
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
virtual ~PICloudServer();
|
||||
|
||||
//! \brief Connected client representation
|
||||
//! \~english Represents a client connected to the server
|
||||
//! \~russian Представляет клиента, подключенного к серверу
|
||||
class Client: public PIIODevice {
|
||||
PIIODEVICE(PICloudServer::Client, "");
|
||||
friend class PICloudServer;
|
||||
|
||||
public:
|
||||
//! \brief
|
||||
//! \~english Constructs Client
|
||||
//! \~russian Создает Client
|
||||
//! \param srv Parent server / Родительский сервер
|
||||
//! \param id Client ID / ID клиента
|
||||
Client(PICloudServer * srv = nullptr, uint id = 0);
|
||||
|
||||
//! \brief
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
virtual ~Client();
|
||||
|
||||
protected:
|
||||
//! \brief
|
||||
//! \~english Opens device
|
||||
//! \~russian Открывает устройство
|
||||
bool openDevice() override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Closes device
|
||||
//! \~russian Закрывает устройство
|
||||
bool closeDevice() override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Reads data from device
|
||||
//! \~russian Читает данные из устройства
|
||||
ssize_t readDevice(void * read_to, ssize_t max_size) override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Writes data to device
|
||||
//! \~russian Записывает данные в устройство
|
||||
ssize_t writeDevice(const void * data, ssize_t size) override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns device info flags
|
||||
//! \~russian Возвращает флаги информации об устройстве
|
||||
DeviceInfoFlags deviceInfoFlags() const override { return PIIODevice::Reliable; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns number of bytes available
|
||||
//! \~russian Возвращает количество доступных байт
|
||||
ssize_t bytesAvailable() const override { return buff.size(); }
|
||||
|
||||
//! \brief
|
||||
//! \~english Interrupts connection
|
||||
//! \~russian Прерывает соединение
|
||||
void interrupt() override;
|
||||
|
||||
private:
|
||||
@@ -114,45 +67,17 @@ public:
|
||||
std::atomic_bool is_connected;
|
||||
};
|
||||
|
||||
//! \brief
|
||||
//! \~english Sets server name
|
||||
//! \~russian Устанавливает имя сервера
|
||||
void setServerName(const PIString & server_name);
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns list of connected clients
|
||||
//! \~russian Возвращает список подключенных клиентов
|
||||
PIVector<PICloudServer::Client *> clients() const;
|
||||
|
||||
//! \brief
|
||||
//! \~english Raised when new client connects
|
||||
//! \~russian Вызывается при подключении нового клиента
|
||||
EVENT1(newConnection, PICloudServer::Client *, client);
|
||||
|
||||
protected:
|
||||
//! \brief
|
||||
//! \~english Opens device
|
||||
//! \~russian Открывает устройство
|
||||
bool openDevice() override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Closes device
|
||||
//! \~russian Закрывает устройство
|
||||
bool closeDevice() override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Reads data from device
|
||||
//! \~russian Читает данные из устройства
|
||||
ssize_t readDevice(void * read_to, ssize_t max_size) override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Writes data to device
|
||||
//! \~russian Записывает данные в устройство
|
||||
ssize_t writeDevice(const void * data, ssize_t max_size) override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Interrupts connection
|
||||
//! \~russian Прерывает соединение
|
||||
void interrupt() override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
//! \file picloudtcp.h
|
||||
//! \ingroup Cloud
|
||||
//! \brief
|
||||
//! \~english PICloud TCP transport
|
||||
//! \~russian TCP слой PICloud
|
||||
//! \details
|
||||
//! \~english Low-level TCP protocol implementation for PICloud communication.
|
||||
//! \~russian Реализация низкоуровневого TCP-протокола для коммуникации PICloud.
|
||||
/*! \file picloudtcp.h
|
||||
* \ingroup Cloud
|
||||
* \~\brief
|
||||
* \~english PICloud TCP transport
|
||||
* \~russian TCP слой PICloud
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
PICloud TCP transport
|
||||
@@ -38,118 +36,45 @@ class PIStreamPacker;
|
||||
|
||||
namespace PICloud {
|
||||
|
||||
//! \brief TCP transport protocol
|
||||
//! \~english TCP transport protocol for cloud communication
|
||||
//! \~russian TCP транспортный протокол для облачной коммуникации
|
||||
|
||||
class PIP_CLOUD_EXPORT TCP {
|
||||
public:
|
||||
//! \brief Protocol version
|
||||
enum Version {
|
||||
Version_1 = 1, //!< Version 1 / Версия 1
|
||||
Version_2 = 2, //!< Version 2 / Версия 2
|
||||
Version_1 = 1,
|
||||
Version_2 = 2,
|
||||
};
|
||||
|
||||
//! \brief Connection role
|
||||
enum Role {
|
||||
InvalidRole = 0, //!< Invalid role / Неверная роль
|
||||
Server = 1, //!< Server role / Роль сервера
|
||||
Client = 2, //!< Client role / Роль клиента
|
||||
InvalidRole = 0,
|
||||
Server = 1,
|
||||
Client = 2,
|
||||
};
|
||||
|
||||
//! \brief Message type
|
||||
enum Type {
|
||||
InvalidType = 0, //!< Invalid type / Неверный тип
|
||||
Connect = 1, //!< Connect message / Сообщение о подключении
|
||||
Disconnect = 2, //!< Disconnect message / Сообщение об отключении
|
||||
Data = 3, //!< Data message / Сообщение с данными
|
||||
Ping = 4, //!< Ping message / Сообщение ping
|
||||
InvalidType = 0,
|
||||
Connect = 1,
|
||||
Disconnect = 2,
|
||||
Data = 3,
|
||||
Ping = 4,
|
||||
};
|
||||
|
||||
//! \brief
|
||||
//! \~english Constructs TCP transport
|
||||
//! \~russian Создает TCP транспорт
|
||||
//! \param s Stream packer instance / Экземпляр стримового упаковщика
|
||||
TCP(PIStreamPacker * s);
|
||||
|
||||
//! \brief
|
||||
//! \~english Sets connection role
|
||||
//! \~russian Устанавливает роль соединения
|
||||
void setRole(Role r);
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns connection role
|
||||
//! \~russian Возвращает роль соединения
|
||||
Role role() const { return (Role)header.role; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Sets server name
|
||||
//! \~russian Устанавливает имя сервера
|
||||
void setServerName(const PIString & server_name_);
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns server name
|
||||
//! \~russian Возвращает имя сервера
|
||||
PIString serverName() const;
|
||||
|
||||
//! \brief
|
||||
//! \~english Sends start message
|
||||
//! \~russian Отправляет сообщение о старте
|
||||
void sendStart();
|
||||
|
||||
//! \brief
|
||||
//! \~english Sends connected message
|
||||
//! \~russian Отправляет сообщение о подключении
|
||||
void sendConnected(uint client_id);
|
||||
|
||||
//! \brief
|
||||
//! \~english Sends disconnected message
|
||||
//! \~russian Отправляет сообщение об отключении
|
||||
void sendDisconnected(uint client_id);
|
||||
|
||||
//! \brief
|
||||
//! \~english Sends data to all clients
|
||||
//! \~russian Отправляет данные всем клиентам
|
||||
int sendData(const PIByteArray & data);
|
||||
|
||||
//! \brief
|
||||
//! \~english Sends data to specific client
|
||||
//! \~russian Отправляет данные конкретному клиенту
|
||||
int sendData(const PIByteArray & data, uint client_id);
|
||||
|
||||
//! \brief
|
||||
//! \~english Sends ping message
|
||||
//! \~russian Отправляет сообщение ping
|
||||
void sendPing();
|
||||
|
||||
//! \brief
|
||||
//! \~english Parses header from buffer
|
||||
//! \~russian Парсит заголовок из буфера
|
||||
PIPair<PICloud::TCP::Type, PICloud::TCP::Role> parseHeader(PIByteArray & ba);
|
||||
|
||||
//! \brief
|
||||
//! \~english Checks if data can be parsed
|
||||
//! \~russian Проверяет возможность парсинга данных
|
||||
bool canParseData(PIByteArray & ba);
|
||||
|
||||
//! \brief
|
||||
//! \~english Parses data for server
|
||||
//! \~russian Парсит данные для сервера
|
||||
PIPair<uint, PIByteArray> parseDataServer(PIByteArray & ba);
|
||||
|
||||
//! \brief
|
||||
//! \~english Parses connect data
|
||||
//! \~russian Парсит данные подключения
|
||||
PIByteArray parseConnect_d(PIByteArray & ba);
|
||||
|
||||
//! \brief
|
||||
//! \~english Parses connect message
|
||||
//! \~russian Парсит сообщение подключения
|
||||
uint parseConnect(PIByteArray & ba);
|
||||
|
||||
//! \brief
|
||||
//! \~english Parses disconnect message
|
||||
//! \~russian Парсит сообщение отключения
|
||||
uint parseDisconnect(PIByteArray & ba);
|
||||
|
||||
private:
|
||||
|
||||
@@ -29,12 +29,12 @@
|
||||
#include "pithread.h"
|
||||
#include "pitime.h"
|
||||
|
||||
#define WAIT_FOR_EXIT \
|
||||
while (!PIKbdListener::exiting) \
|
||||
piMSleep(PIP_MIN_MSLEEP * 5); \
|
||||
if (PIKbdListener::instance()) { \
|
||||
if (!PIKbdListener::instance()->stopAndWait(PISystemTime::fromSeconds(1))) PIKbdListener::instance()->terminate(); \
|
||||
}
|
||||
#define WAIT_FOR_EXIT \
|
||||
while (!PIKbdListener::exiting) \
|
||||
piMSleep(PIP_MIN_MSLEEP * 5); \
|
||||
if (PIKbdListener::instance()) { \
|
||||
if (!PIKbdListener::instance()->stopAndWait(PISystemTime::fromSeconds(1))) PIKbdListener::instance()->terminate(); \
|
||||
}
|
||||
|
||||
|
||||
class PIP_EXPORT PIKbdListener: public PIThread {
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
//! \file piscreen.h
|
||||
//! \ingroup Console
|
||||
//! \brief
|
||||
//! \~english Console tiling manager
|
||||
//! \~russian Консольный тайловый менеджер
|
||||
//! \details
|
||||
//! \~english Main console screen manager providing tile-based UI rendering and keyboard input.
|
||||
//! \~russian Основной менеджер консольного экрана, обеспечивающий отрисовку UI на основе тайлов и ввод с клавиатуры.
|
||||
/*! \file piscreen.h
|
||||
* \ingroup Console
|
||||
* \~\brief
|
||||
* \~english Console tiling manager
|
||||
* \~russian Консольный тайловый менеджер
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Console GUI
|
||||
@@ -40,126 +38,46 @@ class PIP_CONSOLE_EXPORT PIScreen
|
||||
class SystemConsole;
|
||||
|
||||
public:
|
||||
//! \brief
|
||||
//! \~english Constructs PIScreen
|
||||
//! \~russian Создает PIScreen
|
||||
//! \param startNow Start immediately / Запустить немедленно
|
||||
//! \param slot Keyboard handler function / Обработчик клавиатуры
|
||||
//! Constructs %PIScreen with key handler "slot" and if "startNow" start it
|
||||
PIScreen(bool startNow = true, PIKbdListener::KBFunc slot = 0);
|
||||
|
||||
//! \brief
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
~PIScreen();
|
||||
|
||||
//! \brief
|
||||
//! \~english Enables exit capture with key
|
||||
//! \~russian Включает захват выхода по клавише
|
||||
//! Directly call function from \a PIKbdListener
|
||||
void enableExitCapture(int key = 'Q') { listener->enableExitCapture(key); }
|
||||
|
||||
//! \brief
|
||||
//! \~english Disables exit capture
|
||||
//! \~russian Отключает захват выхода
|
||||
//! Directly call function from \a PIKbdListener
|
||||
void disableExitCapture() { listener->disableExitCapture(); }
|
||||
|
||||
//! \brief
|
||||
//! \~english Checks if exit is captured
|
||||
//! \~russian Проверяет, захвачен ли выход
|
||||
//! Directly call function from \a PIKbdListener
|
||||
bool exitCaptured() const { return listener->exitCaptured(); }
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns exit key
|
||||
//! \~russian Возвращает клавишу выхода
|
||||
//! Directly call function from \a PIKbdListener
|
||||
int exitKey() const { return listener->exitKey(); }
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns window width
|
||||
//! \~russian Возвращает ширину окна
|
||||
int windowWidth() const { return console.width; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns window height
|
||||
//! \~russian Возвращает высоту окна
|
||||
int windowHeight() const { return console.height; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Checks if mouse is enabled
|
||||
//! \~russian Проверяет, включена ли мышь
|
||||
bool isMouseEnabled() const { return mouse_; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Sets mouse enabled state
|
||||
//! \~russian Устанавливает состояние мыши
|
||||
void setMouseEnabled(bool on);
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns root tile
|
||||
//! \~russian Возвращает корневой тайл
|
||||
PIScreenTile * rootTile() { return &root; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Finds tile by name
|
||||
//! \~russian Находит тайл по имени
|
||||
PIScreenTile * tileByName(const PIString & name);
|
||||
|
||||
//! \brief
|
||||
//! \~english Sets dialog tile
|
||||
//! \~russian Устанавливает диалоговый тайл
|
||||
void setDialogTile(PIScreenTile * t);
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns current dialog tile
|
||||
//! \~russian Возвращает текущий диалоговый тайл
|
||||
PIScreenTile * dialogTile() const { return tile_dialog; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns screen drawer
|
||||
//! \~russian Возвращает отрисовщик экрана
|
||||
PIScreenDrawer * drawer() { return &drawer_; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Clears the screen
|
||||
//! \~russian Очищает экран
|
||||
void clear() { drawer_.clear(); }
|
||||
|
||||
//! \brief
|
||||
//! \~english Resizes screen
|
||||
//! \~russian Изменяет размер экрана
|
||||
void resize(int w, int h) { console.resize(w, h); }
|
||||
|
||||
//! \brief
|
||||
//! \~english Waits for finish
|
||||
//! \~russian Ожидает завершения
|
||||
EVENT_HANDLER0(void, waitForFinish);
|
||||
|
||||
//! \brief
|
||||
//! \~english Starts screen
|
||||
//! \~russian Запускает экран
|
||||
EVENT_HANDLER0(void, start) { start(false); }
|
||||
|
||||
//! \brief
|
||||
//! \~english Starts screen
|
||||
//! \~russian Запускает экран
|
||||
EVENT_HANDLER1(void, start, bool, wait);
|
||||
|
||||
//! \brief
|
||||
//! \~english Stops screen
|
||||
//! \~russian Останавливает экран
|
||||
EVENT_HANDLER0(void, stop) { stop(false); }
|
||||
|
||||
//! \brief
|
||||
//! \~english Stops screen
|
||||
//! \~russian Останавливает экран
|
||||
EVENT_HANDLER1(void, stop, bool, clear);
|
||||
|
||||
//! \brief
|
||||
//! \~english Raised on key pressed
|
||||
//! \~russian Вызывается при нажатии клавиши
|
||||
EVENT2(keyPressed, PIKbdListener::KeyEvent, key, void *, data);
|
||||
|
||||
//! \brief
|
||||
//! \~english Raised on tile event
|
||||
//! \~russian Вызывается при событии тайла
|
||||
EVENT2(tileEvent, PIScreenTile *, tile, PIScreenTypes::TileEvent, e);
|
||||
|
||||
//! \handlers
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
//! \file piscreenconsole.h
|
||||
//! \ingroup Console
|
||||
//! \brief
|
||||
//! \~english Tile for PIScreen with PIConsole API
|
||||
//! \~russian Тайл для PIScreen с API PIConsole
|
||||
//! \details
|
||||
//! \~english Provides tiles for displaying variable data and console-like content.
|
||||
//! \~russian Обеспечивает тайлы для отображения данных переменных и консольного контента.
|
||||
/*! \file piscreenconsole.h
|
||||
* \ingroup Console
|
||||
* \~\brief
|
||||
* \~english Tile for PIScreen with PIConsole API
|
||||
* \~russian Тайл для PIScreen с API PIConsole
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Tile for PIScreen with PIConsole API
|
||||
@@ -34,30 +32,17 @@
|
||||
/// NOTE: incomplete class
|
||||
/// TODO: write TileVars
|
||||
|
||||
//! \brief
|
||||
//! \~english Tile for displaying variable data
|
||||
//! \~russian Тайл для отображения данных переменных
|
||||
|
||||
class PIP_CONSOLE_EXPORT TileVars: public PIScreenTile {
|
||||
public:
|
||||
//! \brief
|
||||
//! \~english Constructs TileVars
|
||||
//! \~russian Создает TileVars
|
||||
//! \param n Tile name / Имя тайла
|
||||
TileVars(const PIString & n = PIString());
|
||||
|
||||
protected:
|
||||
//! \brief Variable data structure
|
||||
struct PIP_CONSOLE_EXPORT Variable {
|
||||
Variable() {
|
||||
nx = ny = type = offset = bitFrom = bitCount = size = 0;
|
||||
format = PIScreenTypes::CellFormat();
|
||||
ptr = 0;
|
||||
}
|
||||
|
||||
//! \brief
|
||||
//! \~english Checks if variable is empty
|
||||
//! \~russian Проверяет, пустая ли переменная
|
||||
bool isEmpty() const { return (ptr == 0); }
|
||||
PIString name;
|
||||
PIScreenTypes::CellFormat format;
|
||||
@@ -82,34 +67,15 @@ protected:
|
||||
ptr = src.ptr;
|
||||
}*/
|
||||
};
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns variables
|
||||
//! \~russian Возвращает переменные
|
||||
PIVector<Variable> variables;
|
||||
PIScreenTypes::Alignment alignment;
|
||||
|
||||
//! \brief
|
||||
//! \~english Calculates tile size hint
|
||||
//! \~russian Вычисляет рекомендуемый размер тайла
|
||||
void sizeHint(int & w, int & h) const override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Draws tile content
|
||||
//! \~russian Рисует содержимое тайла
|
||||
void drawEvent(PIScreenDrawer * d) override;
|
||||
};
|
||||
|
||||
|
||||
//! \brief
|
||||
//! \~english Console-style tile for PIScreen
|
||||
//! \~russian Консольный тайл для PIScreen
|
||||
|
||||
class PIP_CONSOLE_EXPORT PIScreenConsoleTile: public PIScreenTile {
|
||||
public:
|
||||
//! \brief
|
||||
//! \~english Constructs PIScreenConsoleTile
|
||||
//! \~russian Создает PIScreenConsoleTile
|
||||
PIScreenConsoleTile();
|
||||
};
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
//! \file piscreendrawer.h
|
||||
//! \ingroup Console
|
||||
//! \brief
|
||||
//! \~english Drawer for PIScreen
|
||||
//! \~russian Отрисовщик для PIScreen
|
||||
//! \details
|
||||
//! \~english Provides drawing primitives for console screen rendering.
|
||||
//! \~russian Обеспечивает примитивы отрисовки для рендеринга консольного экрана.
|
||||
/*! \file piscreendrawer.h
|
||||
* \ingroup Console
|
||||
* \~\brief
|
||||
* \~english Drawer for PIScreen
|
||||
* \~russian Отрисовщик для PIScreen
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Drawer for PIScreen
|
||||
@@ -32,51 +30,31 @@
|
||||
#include "piscreentypes.h"
|
||||
#include "pistring.h"
|
||||
|
||||
//! \brief Screen drawer for console rendering
|
||||
//! \~english Console screen drawer for rendering graphics
|
||||
//! \~russian Отрисовщик консольного экрана для рендеринга графики
|
||||
|
||||
class PIP_CONSOLE_EXPORT PIScreenDrawer {
|
||||
friend class PIScreen;
|
||||
PIScreenDrawer(PIVector<PIVector<PIScreenTypes::Cell>> & c);
|
||||
|
||||
public:
|
||||
//! \brief ASCII art characters
|
||||
enum ArtChar {
|
||||
LineVertical = 1, //!< Vertical line / Вертикальная линия
|
||||
LineHorizontal, //!< Horizontal line / Горизонтальная линия
|
||||
Cross, //!< Cross / Крест
|
||||
CornerTopLeft, //!< Top-left corner / Угол сверху-слева
|
||||
CornerTopRight, //!< Top-right corner / Угол сверху-справа
|
||||
CornerBottomLeft, //!< Bottom-left corner / Угол снизу-слева
|
||||
CornerBottomRight, //!< Bottom-right corner / Угол снизу-справа
|
||||
Unchecked, //!< Unchecked box / Неотмеченная клетка
|
||||
Checked //!< Checked box / Отмеченная клетка
|
||||
LineVertical = 1,
|
||||
LineHorizontal,
|
||||
Cross,
|
||||
CornerTopLeft,
|
||||
CornerTopRight,
|
||||
CornerBottomLeft,
|
||||
CornerBottomRight,
|
||||
Unchecked,
|
||||
Checked
|
||||
};
|
||||
|
||||
//! \brief
|
||||
//! \~english Clears the screen
|
||||
//! \~russian Очищает экран
|
||||
void clear();
|
||||
|
||||
//! \brief
|
||||
//! \~english Clears rectangle
|
||||
//! \~russian Очищает прямоугольник
|
||||
void clearRect(int x0, int y0, int x1, int y1) { fillRect(x0, y0, x1, y1, ' '); }
|
||||
|
||||
//! \brief
|
||||
//! \~english Draws pixel
|
||||
//! \~russian Рисует пиксель
|
||||
void drawPixel(int x,
|
||||
int y,
|
||||
const PIChar & c,
|
||||
PIScreenTypes::Color col_char = PIScreenTypes::Default,
|
||||
PIScreenTypes::Color col_back = PIScreenTypes::Default,
|
||||
PIScreenTypes::CharFlags flags_char = 0);
|
||||
|
||||
//! \brief
|
||||
//! \~english Draws line
|
||||
//! \~russian Рисует линию
|
||||
void drawLine(int x0,
|
||||
int y0,
|
||||
int x1,
|
||||
@@ -85,10 +63,6 @@ public:
|
||||
PIScreenTypes::Color col_char = PIScreenTypes::Default,
|
||||
PIScreenTypes::Color col_back = PIScreenTypes::Default,
|
||||
PIScreenTypes::CharFlags flags_char = 0);
|
||||
|
||||
//! \brief
|
||||
//! \~english Draws rectangle
|
||||
//! \~russian Рисует прямоугольник
|
||||
void drawRect(int x0,
|
||||
int y0,
|
||||
int x1,
|
||||
@@ -97,10 +71,6 @@ public:
|
||||
PIScreenTypes::Color col_char = PIScreenTypes::Default,
|
||||
PIScreenTypes::Color col_back = PIScreenTypes::Default,
|
||||
PIScreenTypes::CharFlags flags_char = 0);
|
||||
|
||||
//! \brief
|
||||
//! \~english Draws frame
|
||||
//! \~russian Рисует рамку
|
||||
void drawFrame(int x0,
|
||||
int y0,
|
||||
int x1,
|
||||
@@ -108,20 +78,12 @@ public:
|
||||
PIScreenTypes::Color col_char = PIScreenTypes::Default,
|
||||
PIScreenTypes::Color col_back = PIScreenTypes::Default,
|
||||
PIScreenTypes::CharFlags flags_char = 0);
|
||||
|
||||
//! \brief
|
||||
//! \~english Draws text
|
||||
//! \~russian Рисует текст
|
||||
void drawText(int x,
|
||||
int y,
|
||||
const PIString & s,
|
||||
PIScreenTypes::Color col_char = PIScreenTypes::Default,
|
||||
PIScreenTypes::Color col_back = PIScreenTypes::Transparent,
|
||||
PIScreenTypes::CharFlags flags_char = 0);
|
||||
|
||||
//! \brief
|
||||
//! \~english Fills rectangle
|
||||
//! \~russian Заполняет прямоугольник
|
||||
void fillRect(int x0,
|
||||
int y0,
|
||||
int x1,
|
||||
@@ -130,20 +92,10 @@ public:
|
||||
PIScreenTypes::Color col_char = PIScreenTypes::Default,
|
||||
PIScreenTypes::Color col_back = PIScreenTypes::Default,
|
||||
PIScreenTypes::CharFlags flags_char = 0);
|
||||
|
||||
//! \brief
|
||||
//! \~english Fills rectangle with content
|
||||
//! \~russian Заполняет прямоугольник содержимым
|
||||
void fillRect(int x0, int y0, int x1, int y1, PIVector<PIVector<PIScreenTypes::Cell>> & content);
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns art character by type
|
||||
//! \~russian Возвращает символ искусства по типу
|
||||
PIChar artChar(const ArtChar type) const { return arts_.value(type, PIChar(' ')); }
|
||||
|
||||
//! \brief
|
||||
//! \~english Clears cell matrix
|
||||
//! \~russian Очищает матрицу ячеек
|
||||
static void clear(PIVector<PIVector<PIScreenTypes::Cell>> & cells);
|
||||
|
||||
private:
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
//! \file piscreentile.h
|
||||
//! \ingroup Console
|
||||
//! \brief
|
||||
//! \~english Basic PIScreen tile
|
||||
//! \~russian Базовый тайл для PIScreen
|
||||
//! \details
|
||||
//! \~english Base class for all screen tiles providing layout and event handling.
|
||||
//! \~russian Базовый класс для всех экранных тайлов, обеспечивающий компоновку и обработку событий.
|
||||
/*! \file piscreentile.h
|
||||
* \ingroup Console
|
||||
* \~\brief
|
||||
* \~english Basic PIScreen tile
|
||||
* \~russian Базовый тайл для PIScreen
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Basic PIScreen tile
|
||||
@@ -34,89 +32,27 @@
|
||||
|
||||
class PIScreenDrawer;
|
||||
|
||||
//! \brief
|
||||
//! \~english Base tile class for console screen
|
||||
//! \~russian Базовый класс тайла для консольного экрана
|
||||
|
||||
class PIP_CONSOLE_EXPORT PIScreenTile: public PIObject {
|
||||
friend class PIScreen;
|
||||
PIOBJECT_SUBCLASS(PIScreenTile, PIObject);
|
||||
|
||||
public:
|
||||
//! \brief
|
||||
//! \~english Constructs PIScreenTile
|
||||
//! \~russian Создает PIScreenTile
|
||||
//! \param n Tile name / Имя тайла
|
||||
//! \param d Layout direction / Направление компоновки
|
||||
//! \param p Size policy / Политика размера
|
||||
PIScreenTile(const PIString & n = PIString(),
|
||||
PIScreenTypes::Direction d = PIScreenTypes::Vertical,
|
||||
PIScreenTypes::SizePolicy p = PIScreenTypes::Preferred);
|
||||
|
||||
//! \brief
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
virtual ~PIScreenTile();
|
||||
|
||||
//! \brief
|
||||
//! \~english Adds child tile
|
||||
//! \~russian Добавляет дочерний тайл
|
||||
void addTile(PIScreenTile * t);
|
||||
|
||||
//! \brief
|
||||
//! \~english Takes ownership of tile
|
||||
//! \~russian Забирает владение тайла
|
||||
void takeTile(PIScreenTile * t);
|
||||
|
||||
//! \brief
|
||||
//! \~english Removes child tile
|
||||
//! \~russian Удаляет дочерний тайл
|
||||
void removeTile(PIScreenTile * t);
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns parent tile
|
||||
//! \~russian Возвращает родительский тайл
|
||||
PIScreenTile * parentTile() const { return parent; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns child tiles
|
||||
//! \~russian Возвращает дочерние тайлы
|
||||
//! \param only_visible Only visible tiles / Только видимые тайлы
|
||||
PIVector<PIScreenTile *> children(bool only_visible = false);
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns child under mouse position
|
||||
//! \~russian Возвращает тайл под мышью
|
||||
PIScreenTile * childUnderMouse(int x, int y);
|
||||
|
||||
//! \brief
|
||||
//! \~english Shows tile
|
||||
//! \~russian Показывает тайл
|
||||
void show() { visible = true; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Hides tile
|
||||
//! \~russian Скрывает тайл
|
||||
void hide() { visible = false; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Sets focus to this tile
|
||||
//! \~russian Устанавливает фокус на этот тайл
|
||||
void setFocus();
|
||||
|
||||
//! \brief
|
||||
//! \~english Checks if tile has focus
|
||||
//! \~russian Проверяет, имеет ли тайл фокус
|
||||
bool hasFocus() const { return has_focus; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Sets all margins
|
||||
//! \~russian Устанавливает все отступы
|
||||
void setMargins(int m) { marginLeft = marginRight = marginTop = marginBottom = m; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Sets individual margins
|
||||
//! \~russian Устанавливает отдельные отступы
|
||||
void setMargins(int l, int r, int t, int b) {
|
||||
marginLeft = l;
|
||||
marginRight = r;
|
||||
@@ -124,24 +60,9 @@ public:
|
||||
marginBottom = b;
|
||||
}
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns tile X position
|
||||
//! \~russian Возвращает позицию X тайла
|
||||
int x() const { return x_; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns tile Y position
|
||||
//! \~russian Возвращает позицию Y тайла
|
||||
int y() const { return y_; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns tile width
|
||||
//! \~russian Возвращает ширину тайла
|
||||
int width() const { return width_; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns tile height
|
||||
//! \~russian Возвращает высоту тайла
|
||||
int height() const { return height_; }
|
||||
|
||||
PIScreenTypes::Direction direction;
|
||||
@@ -156,64 +77,29 @@ public:
|
||||
bool visible;
|
||||
|
||||
protected:
|
||||
//! \brief
|
||||
//! \~english Returns desired tile size in "w" and "h"
|
||||
//! \~russian Возвращает желаемый размер тайла в "w" и "h"
|
||||
//! Returns desired tile size in "w" and "h"
|
||||
virtual void sizeHint(int & w, int & h) const;
|
||||
|
||||
//! \brief
|
||||
//! \~english Tile has been resized to "w"x"h"
|
||||
//! \~russian Тайл был изменен на "w"x"h"
|
||||
//! Tile has been resized to "w"x"h"
|
||||
virtual void resizeEvent(int w, int h) {}
|
||||
|
||||
//! \brief
|
||||
//! \~english Draw tile with drawer "d" in world-space coordinates
|
||||
//! \~russian Рисует тайл отрисовщиком "d" в мировых координатах
|
||||
//! Draw tile with drawer "d" in world-space coordinates
|
||||
virtual void drawEvent(PIScreenDrawer * d) {}
|
||||
|
||||
//! \brief
|
||||
//! \~english Return "true" if you process key
|
||||
//! \~russian Возвращает "true" если вы обрабатываете клавишу
|
||||
//! Return "true" if you process key
|
||||
virtual bool keyEvent(PIKbdListener::KeyEvent key) { return false; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Return "true" if you process event
|
||||
//! \~russian Возвращает "true" если вы обрабатываете событие
|
||||
//! Return "true" if you process event
|
||||
virtual bool mouseEvent(PIKbdListener::MouseEvent me) { return false; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Return "true" if you process wheel
|
||||
//! \~russian Возвращает "true" если вы обрабатываете колесо
|
||||
//! Return "true" if you process wheel
|
||||
virtual bool wheelEvent(PIKbdListener::WheelEvent we) { return false; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Raises tile event
|
||||
//! \~russian Вызывает событие тайла
|
||||
void raiseEvent(PIScreenTypes::TileEvent e);
|
||||
|
||||
//! \brief
|
||||
//! \~english Sets screen reference
|
||||
//! \~russian Устанавливает ссылку на экран
|
||||
void setScreen(PIScreenTypes::PIScreenBase * s);
|
||||
|
||||
//! \brief
|
||||
//! \~english Deletes all children
|
||||
//! \~russian Удаляет всех потомков
|
||||
void deleteChildren();
|
||||
|
||||
//! \brief
|
||||
//! \~english Internal draw event
|
||||
//! \~russian Внутреннее событие отрисовки
|
||||
void drawEventInternal(PIScreenDrawer * d);
|
||||
|
||||
//! \brief
|
||||
//! \~english Performs layout
|
||||
//! \~russian Выполняет компоновку
|
||||
void layout();
|
||||
|
||||
//! \brief
|
||||
//! \~english Checks if layout is needed
|
||||
//! \~russian Проверяет, нужна ли компоновка
|
||||
bool needLayout() { return size_policy != PIScreenTypes::Ignore; }
|
||||
|
||||
PIVector<PIScreenTile *> tiles;
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
//! \file piscreentiles.h
|
||||
//! \ingroup Console
|
||||
//! \brief
|
||||
//! \~english Various tiles for PIScreen
|
||||
//! \~russian Различные тайлы для PIScreen
|
||||
//! \details
|
||||
//! \~english Provides ready-to-use tile implementations for common UI elements.
|
||||
//! \~russian Обеспечивает готовые к использованию реализации тайлов для общих элементов UI.
|
||||
/*! \file piscreentiles.h
|
||||
* \ingroup Console
|
||||
* \~\brief
|
||||
* \~english Various tiles for PIScreen
|
||||
* \~russian Различные тайлы для PIScreen
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Various tiles for PIScreen
|
||||
@@ -32,326 +30,125 @@
|
||||
#include "piscreentile.h"
|
||||
|
||||
|
||||
//! \brief
|
||||
//! \~english Tile for displaying simple text content
|
||||
//! \~russian Тайл для отображения простого текстового контента
|
||||
class PIP_CONSOLE_EXPORT TileSimple: public PIScreenTile {
|
||||
PIOBJECT_SUBCLASS(TileSimple, PIScreenTile);
|
||||
|
||||
public:
|
||||
//! \brief Row type
|
||||
typedef PIPair<PIString, PIScreenTypes::CellFormat> Row;
|
||||
|
||||
//! \brief
|
||||
//! \~english Constructs TileSimple
|
||||
//! \~russian Создает TileSimple
|
||||
//! \param n Tile name / Имя тайла
|
||||
TileSimple(const PIString & n = PIString());
|
||||
|
||||
//! \brief
|
||||
//! \~english Constructs TileSimple with row
|
||||
//! \~russian Создает TileSimple со строкой
|
||||
//! \param r Row content / Содержимое строки
|
||||
TileSimple(const Row & r);
|
||||
|
||||
//! \brief
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
virtual ~TileSimple() {}
|
||||
|
||||
//! \brief Tile content rows
|
||||
PIVector<Row> content;
|
||||
|
||||
//! \brief Text alignment
|
||||
PIScreenTypes::Alignment alignment;
|
||||
|
||||
protected:
|
||||
//! \brief
|
||||
//! \~english Calculates tile size hint
|
||||
//! \~russian Вычисляет рекомендуемый размер тайла
|
||||
void sizeHint(int & w, int & h) const override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Draws tile content
|
||||
//! \~russian Рисует содержимое тайла
|
||||
void drawEvent(PIScreenDrawer * d) override;
|
||||
};
|
||||
|
||||
|
||||
class TileList;
|
||||
|
||||
//! \brief
|
||||
//! \~english Scrollbar for list containers
|
||||
//! \~russian Полоса прокрутки для списков
|
||||
class PIP_CONSOLE_EXPORT TileScrollBar: public PIScreenTile {
|
||||
PIOBJECT_SUBCLASS(TileScrollBar, PIScreenTile);
|
||||
friend class TileList;
|
||||
|
||||
public:
|
||||
//! \brief
|
||||
//! \~english Constructs TileScrollBar
|
||||
//! \~russian Создает TileScrollBar
|
||||
//! \param n Tile name / Имя тайла
|
||||
TileScrollBar(const PIString & n = PIString());
|
||||
|
||||
//! \brief
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
virtual ~TileScrollBar() {}
|
||||
|
||||
//! \brief
|
||||
//! \~english Sets minimum value
|
||||
//! \~russian Устанавливает минимальное значение
|
||||
void setMinimum(int v);
|
||||
|
||||
//! \brief
|
||||
//! \~english Sets maximum value
|
||||
//! \~russian Устанавливает максимальное значение
|
||||
void setMaximum(int v);
|
||||
|
||||
//! \brief
|
||||
//! \~english Sets current value
|
||||
//! \~russian Устанавливает текущее значение
|
||||
void setValue(int v);
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns minimum value
|
||||
//! \~russian Возвращает минимальное значение
|
||||
int minimum() const { return minimum_; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns maximum value
|
||||
//! \~russian Возвращает максимальное значение
|
||||
int maximum() const { return maximum_; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns current value
|
||||
//! \~russian Возвращает текущее значение
|
||||
int value() const { return value_; }
|
||||
|
||||
//! \brief Scrollbar thickness
|
||||
int thickness;
|
||||
|
||||
protected:
|
||||
//! \brief Validates scrollbar state
|
||||
//! \~english Validates scrollbar state
|
||||
//! \~russian Проверяет состояние полосы прокрутки
|
||||
void _check();
|
||||
|
||||
//! \brief
|
||||
//! \~english Calculates tile size hint
|
||||
//! \~russian Вычисляет рекомендуемый размер тайла
|
||||
void sizeHint(int & w, int & h) const override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Draws tile content
|
||||
//! \~russian Рисует содержимое тайла
|
||||
void drawEvent(PIScreenDrawer * d) override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Handles mouse events
|
||||
//! \~russian Обрабатывает события мыши
|
||||
bool mouseEvent(PIKbdListener::MouseEvent me) override;
|
||||
int minimum_, maximum_, value_;
|
||||
PIChar line_char;
|
||||
};
|
||||
|
||||
|
||||
//! \brief
|
||||
//! \~english Scrollable list tile
|
||||
//! \~russian Прокручиваемый список
|
||||
class PIP_CONSOLE_EXPORT TileList: public PIScreenTile {
|
||||
PIOBJECT_SUBCLASS(TileList, PIScreenTile);
|
||||
|
||||
public:
|
||||
//! \brief Selection mode
|
||||
enum SelectionMode {
|
||||
NoSelection, //!< No selection / Без выделения
|
||||
SingleSelection, //!< Single item selection / Выделение одного элемента
|
||||
MultiSelection //!< Multiple items selection / Выделение нескольких элементов
|
||||
NoSelection,
|
||||
SingleSelection,
|
||||
MultiSelection
|
||||
};
|
||||
|
||||
//! \brief Event type
|
||||
enum EventType {
|
||||
SelectionChanged, //!< Selection changed / Выделение изменено
|
||||
RowPressed //!< Row pressed / Строка нажата
|
||||
SelectionChanged,
|
||||
RowPressed
|
||||
};
|
||||
|
||||
//! \brief
|
||||
//! \~english Constructs TileList
|
||||
//! \~russian Создает TileList
|
||||
//! \param n Tile name / Имя тайла
|
||||
//! \param sm Selection mode / Режим выделения
|
||||
TileList(const PIString & n = PIString(), SelectionMode sm = NoSelection);
|
||||
|
||||
//! \brief
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
virtual ~TileList() {}
|
||||
|
||||
//! \brief Row type
|
||||
typedef PIPair<PIString, PIScreenTypes::CellFormat> Row;
|
||||
|
||||
//! \brief List content
|
||||
PIDeque<Row> content;
|
||||
|
||||
//! \brief Text alignment
|
||||
PIScreenTypes::Alignment alignment;
|
||||
|
||||
//! \brief Selection mode
|
||||
SelectionMode selection_mode;
|
||||
|
||||
//! \brief Selected indices
|
||||
PISet<int> selected;
|
||||
|
||||
//! \brief Line height
|
||||
int lhei, cur, offset;
|
||||
|
||||
protected:
|
||||
//! \brief
|
||||
//! \~english Calculates tile size hint
|
||||
//! \~russian Вычисляет рекомендуемый размер тайла
|
||||
void sizeHint(int & w, int & h) const override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Called when resized
|
||||
//! \~russian Вызывается при изменении размера
|
||||
void resizeEvent(int w, int h) override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Draws tile content
|
||||
//! \~russian Рисует содержимое тайла
|
||||
void drawEvent(PIScreenDrawer * d) override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Handles key events
|
||||
//! \~russian Обрабатывает события клавиатуры
|
||||
bool keyEvent(PIKbdListener::KeyEvent key) override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Handles mouse events
|
||||
//! \~russian Обрабатывает события мыши
|
||||
bool mouseEvent(PIKbdListener::MouseEvent me) override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Handles wheel events
|
||||
//! \~russian Обрабатывает события колеса
|
||||
bool wheelEvent(PIKbdListener::WheelEvent we) override;
|
||||
TileScrollBar * scroll;
|
||||
bool mouse_sel;
|
||||
};
|
||||
|
||||
|
||||
//! \brief
|
||||
//! \~english Clickable button tile
|
||||
//! \~russian Кликабельная кнопка
|
||||
class PIP_CONSOLE_EXPORT TileButton: public PIScreenTile {
|
||||
PIOBJECT_SUBCLASS(TileButton, PIScreenTile);
|
||||
|
||||
public:
|
||||
//! \brief
|
||||
//! \~english Constructs TileButton
|
||||
//! \~russian Создает TileButton
|
||||
//! \param n Tile name / Имя тайла
|
||||
TileButton(const PIString & n = PIString());
|
||||
|
||||
//! \brief
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
virtual ~TileButton() {}
|
||||
|
||||
//! \brief Event type
|
||||
enum EventType {
|
||||
ButtonClicked //!< Button clicked / Кнопка нажата
|
||||
ButtonClicked
|
||||
};
|
||||
|
||||
//! \brief Button format
|
||||
PIScreenTypes::CellFormat format;
|
||||
|
||||
//! \brief Button text
|
||||
PIString text;
|
||||
|
||||
protected:
|
||||
//! \brief
|
||||
//! \~english Calculates tile size hint
|
||||
//! \~russian Вычисляет рекомендуемый размер тайла
|
||||
void sizeHint(int & w, int & h) const override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Draws tile content
|
||||
//! \~russian Рисует содержимое тайла
|
||||
void drawEvent(PIScreenDrawer * d) override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Handles key events
|
||||
//! \~russian Обрабатывает события клавиатуры
|
||||
bool keyEvent(PIKbdListener::KeyEvent key) override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Handles mouse events
|
||||
//! \~russian Обрабатывает события мыши
|
||||
bool mouseEvent(PIKbdListener::MouseEvent me) override;
|
||||
};
|
||||
|
||||
|
||||
//! \brief
|
||||
//! \~english Group of buttons with selection
|
||||
//! \~russian Группа кнопок с выбором
|
||||
|
||||
class PIP_CONSOLE_EXPORT TileButtons: public PIScreenTile {
|
||||
PIOBJECT_SUBCLASS(TileButtons, PIScreenTile);
|
||||
|
||||
public:
|
||||
//! \brief
|
||||
//! \~english Constructs TileButtons
|
||||
//! \~russian Создает TileButtons
|
||||
//! \param n Tile name / Имя тайла
|
||||
TileButtons(const PIString & n = PIString());
|
||||
|
||||
//! \brief
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
virtual ~TileButtons() {}
|
||||
|
||||
//! \brief Event type
|
||||
enum EventType {
|
||||
ButtonSelected //!< Button selected / Кнопка выбрана
|
||||
ButtonSelected
|
||||
};
|
||||
|
||||
//! \brief Button type
|
||||
typedef PIPair<PIString, PIScreenTypes::CellFormat> Button;
|
||||
|
||||
//! \brief Button alignment
|
||||
PIScreenTypes::Alignment alignment;
|
||||
|
||||
//! \brief Button content
|
||||
PIVector<Button> content;
|
||||
|
||||
//! \brief Current selection
|
||||
int cur;
|
||||
|
||||
protected:
|
||||
//! \brief
|
||||
//! \~english Calculates tile size hint
|
||||
//! \~russian Вычисляет рекомендуемый размер тайла
|
||||
void sizeHint(int & w, int & h) const override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Draws tile content
|
||||
//! \~russian Рисует содержимое тайла
|
||||
void drawEvent(PIScreenDrawer * d) override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Handles key events
|
||||
//! \~russian Обрабатывает события клавиатуры
|
||||
bool keyEvent(PIKbdListener::KeyEvent key) override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Handles mouse events
|
||||
//! \~russian Обрабатывает события мыши
|
||||
bool mouseEvent(PIKbdListener::MouseEvent me) override;
|
||||
|
||||
//! \brief Button rectangle
|
||||
struct Rect {
|
||||
Rect(int _x0 = 0, int _y0 = 0, int _x1 = 0, int _y1 = 0): x0(_x0), y0(_y0), x1(_x1), y1(_y1) {}
|
||||
int x0, y0, x1, y1;
|
||||
@@ -360,192 +157,74 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
//! \brief
|
||||
//! \~english Checkbox with toggle state
|
||||
//! \~russian Флажок с переключаемым состоянием
|
||||
class PIP_CONSOLE_EXPORT TileCheck: public PIScreenTile {
|
||||
PIOBJECT_SUBCLASS(TileCheck, PIScreenTile);
|
||||
|
||||
public:
|
||||
//! \brief
|
||||
//! \~english Constructs TileCheck
|
||||
//! \~russian Создает TileCheck
|
||||
//! \param n Tile name / Имя тайла
|
||||
TileCheck(const PIString & n = PIString());
|
||||
|
||||
//! \brief
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
virtual ~TileCheck() {}
|
||||
|
||||
//! \brief Event type
|
||||
enum EventType {
|
||||
Toggled //!< State toggled / Состояние переключено
|
||||
Toggled
|
||||
};
|
||||
|
||||
//! \brief Checkbox format
|
||||
PIScreenTypes::CellFormat format;
|
||||
|
||||
//! \brief Checkbox text
|
||||
PIString text;
|
||||
|
||||
//! \brief Checkbox state
|
||||
bool toggled;
|
||||
|
||||
protected:
|
||||
//! \brief
|
||||
//! \~english Calculates tile size hint
|
||||
//! \~russian Вычисляет рекомендуемый размер тайла
|
||||
void sizeHint(int & w, int & h) const override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Draws tile content
|
||||
//! \~russian Рисует содержимое тайла
|
||||
void drawEvent(PIScreenDrawer * d) override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Handles key events
|
||||
//! \~russian Обрабатывает события клавиатуры
|
||||
bool keyEvent(PIKbdListener::KeyEvent key) override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Handles mouse events
|
||||
//! \~russian Обрабатывает события мыши
|
||||
bool mouseEvent(PIKbdListener::MouseEvent me) override;
|
||||
};
|
||||
|
||||
|
||||
//! \brief
|
||||
//! \~english Progress bar for displaying progress
|
||||
//! \~russian Индикатор прогресса
|
||||
class PIP_CONSOLE_EXPORT TileProgress: public PIScreenTile {
|
||||
PIOBJECT_SUBCLASS(TileProgress, PIScreenTile);
|
||||
|
||||
public:
|
||||
//! \brief
|
||||
//! \~english Constructs TileProgress
|
||||
//! \~russian Создает TileProgress
|
||||
//! \param n Tile name / Имя тайла
|
||||
TileProgress(const PIString & n = PIString());
|
||||
|
||||
//! \brief
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
virtual ~TileProgress() {}
|
||||
|
||||
//! \brief Progress format
|
||||
PIScreenTypes::CellFormat format;
|
||||
|
||||
//! \brief Prefix text
|
||||
PIString prefix;
|
||||
|
||||
//! \brief Suffix text
|
||||
PIString suffix;
|
||||
|
||||
//! \brief Maximum value
|
||||
double maximum;
|
||||
|
||||
//! \brief Current value
|
||||
double value;
|
||||
|
||||
protected:
|
||||
//! \brief
|
||||
//! \~english Calculates tile size hint
|
||||
//! \~russian Вычисляет рекомендуемый размер тайла
|
||||
void sizeHint(int & w, int & h) const override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Draws tile content
|
||||
//! \~russian Рисует содержимое тайла
|
||||
void drawEvent(PIScreenDrawer * d) override;
|
||||
};
|
||||
|
||||
|
||||
//! \brief
|
||||
//! \~english Tile for displaying console output
|
||||
//! \~russian Тайл для отображения консольного вывода
|
||||
|
||||
class PIP_CONSOLE_EXPORT TilePICout: public TileList {
|
||||
PIOBJECT_SUBCLASS(TilePICout, PIScreenTile);
|
||||
|
||||
public:
|
||||
//! \brief
|
||||
//! \~english Constructs TilePICout
|
||||
//! \~russian Создает TilePICout
|
||||
//! \param n Tile name / Имя тайла
|
||||
TilePICout(const PIString & n = PIString());
|
||||
|
||||
//! \brief
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
virtual ~TilePICout() {}
|
||||
|
||||
//! \brief Output format
|
||||
PIScreenTypes::CellFormat format;
|
||||
|
||||
//! \brief Maximum lines
|
||||
int max_lines;
|
||||
|
||||
protected:
|
||||
//! \brief
|
||||
//! \~english Draws tile content
|
||||
//! \~russian Рисует содержимое тайла
|
||||
void drawEvent(PIScreenDrawer * d) override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Handles key events
|
||||
//! \~russian Обрабатывает события клавиатуры
|
||||
bool keyEvent(PIKbdListener::KeyEvent key) override;
|
||||
};
|
||||
|
||||
|
||||
//! \brief
|
||||
//! \~english Text input tile
|
||||
//! \~russian Тайл текстового ввода
|
||||
|
||||
class PIP_CONSOLE_EXPORT TileInput: public PIScreenTile {
|
||||
PIOBJECT_SUBCLASS(TileInput, PIScreenTile);
|
||||
|
||||
public:
|
||||
//! \brief
|
||||
//! \~english Constructs TileInput
|
||||
//! \~russian Создает TileInput
|
||||
//! \param n Tile name / Имя тайла
|
||||
TileInput(const PIString & n = PIString());
|
||||
|
||||
//! \brief
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
virtual ~TileInput() {}
|
||||
|
||||
//! \brief Input format
|
||||
PIScreenTypes::CellFormat format;
|
||||
|
||||
//! \brief Input text
|
||||
PIString text;
|
||||
|
||||
//! \brief Maximum text length
|
||||
int max_length;
|
||||
|
||||
protected:
|
||||
//! \brief
|
||||
//! \~english Calculates tile size hint
|
||||
//! \~russian Вычисляет рекомендуемый размер тайла
|
||||
void sizeHint(int & w, int & h) const override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Draws tile content
|
||||
//! \~russian Рисует содержимое тайла
|
||||
void drawEvent(PIScreenDrawer * d) override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Handles key events
|
||||
//! \~russian Обрабатывает события клавиатуры
|
||||
bool keyEvent(PIKbdListener::KeyEvent key) override;
|
||||
|
||||
//! \brief
|
||||
//! \~english Resets cursor position
|
||||
//! \~russian Сбрасывает позицию курсора
|
||||
void reserCursor();
|
||||
int cur, offset;
|
||||
bool inv;
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
//! \file piscreentypes.h
|
||||
//! \ingroup Console
|
||||
//! \brief
|
||||
//! \~english Types for PIScreen
|
||||
//! \~russian Типы для PIScreen
|
||||
//! \details
|
||||
//! \~english Provides common types used by screen tiles and drawer.
|
||||
//! \~russian Обеспечивает общие типы, используемые тайлами и отрисовщиком экрана.
|
||||
/*! \file piscreentypes.h
|
||||
* \ingroup Console
|
||||
* \~\brief
|
||||
* \~english Types for PIScreen
|
||||
* \~russian Типы для PIScreen
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Types for PIScreen
|
||||
@@ -36,9 +34,7 @@ class PIScreenTile;
|
||||
|
||||
namespace PIScreenTypes {
|
||||
|
||||
//! \brief Color for chars or background
|
||||
//! \~english Console color values
|
||||
//! \~russian Значения цветов консоли
|
||||
//! Color for chars or background
|
||||
enum Color {
|
||||
Default /** Default */,
|
||||
Black /** Black */,
|
||||
@@ -52,9 +48,7 @@ enum Color {
|
||||
Transparent /** Save previous color */
|
||||
};
|
||||
|
||||
//! \brief Flags for chars
|
||||
//! \~english Character formatting flags
|
||||
//! \~russian Флаги форматирования символов
|
||||
//! Flags for chars
|
||||
enum CharFlag {
|
||||
Bold /** Bold or bright */ = 0x1,
|
||||
Blink /** Blink text */ = 0x2,
|
||||
@@ -62,18 +56,14 @@ enum CharFlag {
|
||||
Inverse = 0x08
|
||||
};
|
||||
|
||||
//! \brief Alignment
|
||||
//! \~english Text alignment modes
|
||||
//! \~russian Режимы выравнивания текста
|
||||
//! Alignment
|
||||
enum Alignment {
|
||||
Left /** Left */,
|
||||
Center /** Center */,
|
||||
Right /** Right */
|
||||
};
|
||||
|
||||
//! \brief Size policy
|
||||
//! \~english Tile sizing policies
|
||||
//! \~russian Политики размеров тайлов
|
||||
//! Size policy
|
||||
enum SizePolicy {
|
||||
Fixed /** Fixed size */,
|
||||
Preferred /** Preferred size */,
|
||||
@@ -81,17 +71,13 @@ enum SizePolicy {
|
||||
Ignore /** Ignore layout logic */
|
||||
};
|
||||
|
||||
//! \brief Direction
|
||||
//! \~english Layout directions
|
||||
//! \~russian Направления компоновки
|
||||
//! Direction
|
||||
enum Direction {
|
||||
Horizontal /** Horizontal */,
|
||||
Vertical /** Vertical */
|
||||
};
|
||||
|
||||
//! \brief Focus flags
|
||||
//! \~english Tile focus behavior flags
|
||||
//! \~russian Флаги поведения фокуса тайла
|
||||
//! Focus flags
|
||||
enum FocusFlag {
|
||||
CanHasFocus /** Tile can has focus */ = 0x1,
|
||||
NextByTab /** Focus passed to next tile by tab key */ = 0x2,
|
||||
@@ -106,19 +92,8 @@ enum FocusFlag {
|
||||
typedef PIFlags<CharFlag> CharFlags;
|
||||
typedef PIFlags<FocusFlag> FocusFlags;
|
||||
|
||||
//! \brief Cell format union
|
||||
//! \~english Packed cell formatting data
|
||||
//! \~russian Упакованные данные форматирования ячейки
|
||||
|
||||
union PIP_CONSOLE_EXPORT CellFormat {
|
||||
//! \brief
|
||||
//! \~english Constructs CellFormat from raw value
|
||||
//! \~russian Создает CellFormat из сырого значения
|
||||
CellFormat(ushort f = 0) { raw_format = f; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Constructs CellFormat from color and flags
|
||||
//! \~russian Создает CellFormat из цвета и флагов
|
||||
CellFormat(Color col_char, Color col_back = Default, CharFlags flags_ = 0) {
|
||||
color_char = col_char;
|
||||
color_back = col_back;
|
||||
@@ -130,49 +105,19 @@ union PIP_CONSOLE_EXPORT CellFormat {
|
||||
ushort color_back: 4;
|
||||
ushort flags : 8;
|
||||
};
|
||||
|
||||
//! \brief
|
||||
//! \~english Equality operator
|
||||
//! \~russian Оператор равенства
|
||||
bool operator==(const CellFormat & c) const { return raw_format == c.raw_format; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Inequality operator
|
||||
//! \~russian Оператор неравенства
|
||||
bool operator!=(const CellFormat & c) const { return raw_format != c.raw_format; }
|
||||
};
|
||||
|
||||
//! \brief Screen cell
|
||||
//! \~english Single character cell with formatting
|
||||
//! \~russian Одна символьная ячейка с форматированием
|
||||
struct PIP_CONSOLE_EXPORT Cell {
|
||||
//! \brief
|
||||
//! \~english Constructs Cell
|
||||
//! \~russian Создает Cell
|
||||
Cell(PIChar c = PIChar(' '), CellFormat f = CellFormat()) {
|
||||
symbol = c;
|
||||
format = f;
|
||||
}
|
||||
|
||||
//! \brief Cell format
|
||||
CellFormat format;
|
||||
|
||||
//! \brief Cell character
|
||||
PIChar symbol;
|
||||
|
||||
//! \brief
|
||||
//! \~english Equality operator
|
||||
//! \~russian Оператор равенства
|
||||
bool operator==(const Cell & c) const { return format == c.format && symbol == c.symbol; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Inequality operator
|
||||
//! \~russian Оператор неравенства
|
||||
bool operator!=(const Cell & c) const { return format != c.format || symbol != c.symbol; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Assignment operator
|
||||
//! \~russian Оператор присваивания
|
||||
Cell & operator=(const Cell & c) {
|
||||
symbol = c.symbol;
|
||||
if (c.format.color_back == Transparent) {
|
||||
@@ -184,52 +129,18 @@ struct PIP_CONSOLE_EXPORT Cell {
|
||||
}
|
||||
};
|
||||
|
||||
//! \brief Tile event data
|
||||
//! \~english Event data passed to tiles
|
||||
//! \~russian Данные события, передаваемые тайлам
|
||||
struct PIP_CONSOLE_EXPORT TileEvent {
|
||||
//! \brief
|
||||
//! \~english Constructs TileEvent
|
||||
//! \~russian Создает TileEvent
|
||||
//! \param t Event type / Тип события
|
||||
//! \param d Event data / Данные события
|
||||
TileEvent(int t = -1, const PIVariant & d = PIVariant()): type(t), data(d) {}
|
||||
|
||||
//! \brief Event type
|
||||
int type;
|
||||
|
||||
//! \brief Event data
|
||||
PIVariant data;
|
||||
};
|
||||
|
||||
//! \brief Base screen interface
|
||||
//! \~english Base interface for screen tiles
|
||||
//! \~russian Базовый интерфейс для экранных тайлов
|
||||
class PIP_CONSOLE_EXPORT PIScreenBase {
|
||||
public:
|
||||
//! \brief
|
||||
//! \~english Constructs PIScreenBase
|
||||
//! \~russian Создает PIScreenBase
|
||||
PIScreenBase() {}
|
||||
|
||||
//! \brief
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
virtual ~PIScreenBase() {}
|
||||
|
||||
//! \brief
|
||||
//! \~english Handles internal tile event
|
||||
//! \~russian Обрабатывает внутреннее событие тайла
|
||||
virtual void tileEventInternal(PIScreenTile *, TileEvent) {}
|
||||
|
||||
//! \brief
|
||||
//! \~english Handles tile removal
|
||||
//! \~russian Обрабатывает удаление тайла
|
||||
virtual void tileRemovedInternal(PIScreenTile *) {}
|
||||
|
||||
//! \brief
|
||||
//! \~english Handles tile focus change
|
||||
//! \~russian Обрабатывает изменение фокуса тайла
|
||||
virtual void tileSetFocusInternal(PIScreenTile *) {}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
//! \file piterminal.h
|
||||
//! \ingroup Console
|
||||
//! \brief
|
||||
//! \~english Virtual terminal
|
||||
//! \~russian Виртуальный терминал
|
||||
//! \details
|
||||
//! \~english Provides terminal emulation for reading console input and output.
|
||||
//! \~russian Обеспечивает эмуляцию терминала для чтения ввода и вывода консоли.
|
||||
/*! \file piterminal.h
|
||||
* \ingroup Console
|
||||
* \~\brief
|
||||
* \~english Virtual terminal
|
||||
* \~russian Виртуальный терминал
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Virtual terminal
|
||||
@@ -37,66 +35,22 @@ class PIP_CONSOLE_EXPORT PITerminal: public PIThread {
|
||||
PIOBJECT_SUBCLASS(PITerminal, PIThread);
|
||||
|
||||
public:
|
||||
//! \brief
|
||||
//! \~english Constructs PITerminal
|
||||
//! \~russian Создает PITerminal
|
||||
//! Constructs %PITerminal
|
||||
PITerminal();
|
||||
|
||||
//! \brief
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
~PITerminal();
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns number of columns
|
||||
//! \~russian Возвращает количество колонок
|
||||
int columns() const { return size_x; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns number of rows
|
||||
//! \~russian Возвращает количество строк
|
||||
int rows() const { return size_y; }
|
||||
|
||||
//! \brief
|
||||
//! \~english Resizes terminal
|
||||
//! \~russian Изменяет размер терминала
|
||||
//! \param cols Number of columns / Количество колонок
|
||||
//! \param rows Number of rows / Количество строк
|
||||
bool resize(int cols, int rows);
|
||||
|
||||
//! \brief
|
||||
//! \~english Writes data to terminal
|
||||
//! \~russian Записывает данные в терминал
|
||||
void write(const PIByteArray & d);
|
||||
|
||||
//! \brief
|
||||
//! \~english Writes special key to terminal
|
||||
//! \~russian Записывает специальную клавишу в терминал
|
||||
void write(PIKbdListener::SpecialKey k, PIKbdListener::KeyModifiers m);
|
||||
|
||||
//! \brief
|
||||
//! \~english Writes key event to terminal
|
||||
//! \~russian Записывает событие клавиши в терминал
|
||||
void write(PIKbdListener::KeyEvent ke);
|
||||
|
||||
//! \brief
|
||||
//! \~english Returns terminal content
|
||||
//! \~russian Возвращает содержимое терминала
|
||||
PIVector<PIVector<PIScreenTypes::Cell>> content();
|
||||
|
||||
//! \brief
|
||||
//! \~english Checks if key is special
|
||||
//! \~russian Проверяет, является ли клавиша специальной
|
||||
static bool isSpecialKey(int k);
|
||||
|
||||
//! \brief
|
||||
//! \~english Initializes terminal
|
||||
//! \~russian Инициализирует терминал
|
||||
bool initialize();
|
||||
|
||||
//! \brief
|
||||
//! \~english Destroys terminal
|
||||
//! \~russian Уничтожает терминал
|
||||
void destroy();
|
||||
|
||||
private:
|
||||
|
||||
@@ -1,17 +1,8 @@
|
||||
//! \addtogroup Containers
|
||||
//! \{
|
||||
//! \file piset.h
|
||||
//! \brief
|
||||
//! \~english Declares \a PISet
|
||||
//! \~russian Объявление \a PISet
|
||||
//! \~\authors
|
||||
//! \~english
|
||||
//! Ivan Pelipenko peri4ko@yandex.ru;
|
||||
//! Andrey Bychkov work.a.b@yandex.ru;
|
||||
//! \~russian
|
||||
//! Иван Пелипенко peri4ko@yandex.ru;
|
||||
//! Андрей Бычков work.a.b@yandex.ru;
|
||||
//! \~\}
|
||||
/*! \file piset.h
|
||||
* \brief Set container
|
||||
*
|
||||
* This file declare PISet
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Set container
|
||||
@@ -36,33 +27,13 @@
|
||||
|
||||
#include "pimap.h"
|
||||
|
||||
//! \addtogroup Containers
|
||||
//! \{
|
||||
//! \class PISet
|
||||
//! \brief
|
||||
//! \~english A set is a collection of unique elements.
|
||||
//! \~russian Множество - это коллекция уникальных элементов.
|
||||
//! \~\}
|
||||
//! \details
|
||||
//! \~english
|
||||
//! This class is used to store a collection of unique elements of any type.
|
||||
//! You can add values to the set using \a operator<< or the \a insert() function.
|
||||
//! You can check if a value already exists in the set using \a operator[] or the \a contains() function.
|
||||
//! These operations have logarithmic complexity.
|
||||
//! To iterate over all elements, use STL-style iterators \a begin() and \a end().
|
||||
//!
|
||||
//! The set is implemented as a wrapper around \a PIMap, where keys are the elements
|
||||
//! and values are dummy byte values (used only for storage).
|
||||
//! \~russian
|
||||
//! Этот класс используется для хранения коллекции уникальных элементов любого типа.
|
||||
//! Вы можете добавлять значения в множество с помощью \a operator<< или функции \a insert().
|
||||
//! Вы можете проверить, существует ли значение в множестве, используя \a operator[] или функцию \a contains().
|
||||
//! Эти операции имеют логарифмическую сложность.
|
||||
//! Для перебора всех элементов используйте итераторы в стиле STL \a begin() и \a end().
|
||||
//!
|
||||
//! Множество реализовано как обёртка над \a PIMap, где ключами являются элементы,
|
||||
//! а значениями являются фиктивные байтовые значения (используются только для хранения).
|
||||
//! \~\sa \a PIMap, \a PIVector
|
||||
/*! \brief Set of any type
|
||||
* \details This class used to store collection of unique elements
|
||||
* of any type. You can only add values to set with \a operator<< or
|
||||
* with function \a insert(). You can discover if value already in
|
||||
* set with \a operator[] or with function \a find(). These function
|
||||
* has logarithmic complexity.
|
||||
*/
|
||||
template<typename T>
|
||||
class PISet: public PIMap<T, uchar> {
|
||||
typedef PIMap<T, uchar> _CSet;
|
||||
@@ -72,31 +43,26 @@ class PISet: public PIMap<T, uchar> {
|
||||
friend PIBinaryStream<P> & operator>>(PIBinaryStream<P> & s, PISet<T1> & v);
|
||||
|
||||
public:
|
||||
//! \~english Constructs an empty set.
|
||||
//! \~russian Создает пустое множество.
|
||||
//! Contructs an empty set
|
||||
PISet() {}
|
||||
|
||||
//! \~english Constructs a set with one element `value`.
|
||||
//! \~russian Создает множество с одним элементом `value`.
|
||||
//! Contructs set with one element "value"
|
||||
explicit PISet(const T & value) { _CSet::insert(value, 0); }
|
||||
|
||||
//! \~english Constructs a set with two elements `v0` and `v1`.
|
||||
//! \~russian Создает множество с двумя элементами `v0` и `v1`.
|
||||
//! Contructs set with elements "v0" and "v1"
|
||||
PISet(const T & v0, const T & v1) {
|
||||
_CSet::insert(v0, 0);
|
||||
_CSet::insert(v1, 0);
|
||||
}
|
||||
|
||||
//! \~english Constructs a set with three elements `v0`, `v1` and `v2`.
|
||||
//! \~russian Создает множество с тремя элементами `v0`, `v1` и `v2`.
|
||||
//! Contructs set with elements "v0", "v1" and "v2"
|
||||
PISet(const T & v0, const T & v1, const T & v2) {
|
||||
_CSet::insert(v0, 0);
|
||||
_CSet::insert(v1, 0);
|
||||
_CSet::insert(v2, 0);
|
||||
}
|
||||
|
||||
//! \~english Constructs a set with four elements `v0`, `v1`, `v2` and `v3`.
|
||||
//! \~russian Создает множество с четырьмя элементами `v0`, `v1`, `v2` и `v3`.
|
||||
//! Contructs set with elements "v0", "v1", "v2" and "v3"
|
||||
PISet(const T & v0, const T & v1, const T & v2, const T & v3) {
|
||||
_CSet::insert(v0, 0);
|
||||
_CSet::insert(v1, 0);
|
||||
@@ -188,8 +154,7 @@ public:
|
||||
inline const_iterator begin() const { return const_iterator(this, 0); }
|
||||
inline const_iterator end() const { return const_iterator(this, _CSet::size()); }
|
||||
|
||||
//! \~english Constructs a set from a vector of elements.
|
||||
//! \~russian Создает множество из вектора элементов.
|
||||
//! Contructs set from vector of elements
|
||||
explicit PISet(const PIVector<T> & values) {
|
||||
if (values.isEmpty()) return;
|
||||
for (int i = 0; i < values.size_s(); ++i) {
|
||||
@@ -197,8 +162,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
//! \~english Constructs a set from a deque of elements.
|
||||
//! \~russian Создает множество из deque элементов.
|
||||
//! Contructs set from deque of elements
|
||||
explicit PISet(const PIDeque<T> & values) {
|
||||
if (values.isEmpty()) return;
|
||||
for (int i = 0; i < values.size_s(); ++i) {
|
||||
@@ -208,8 +172,6 @@ public:
|
||||
|
||||
typedef T key_type;
|
||||
|
||||
//! \~english Inserts element `t` into the set.
|
||||
//! \~russian Вставляет элемент `t` в множество.
|
||||
PISet<T> & operator<<(const T & t) {
|
||||
_CSet::insert(t, 0);
|
||||
return *this;
|
||||
@@ -223,62 +185,52 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Tests if element `t` exists in the set.
|
||||
//! \~russian Проверяет наличие элемента `t` в множестве.
|
||||
//! \~english Tests if element `key` exists in the set.
|
||||
//! \~russian Проверяет наличие элемента `key` в массиве.
|
||||
inline bool contains(const T & t) const { return _CSet::contains(t); }
|
||||
|
||||
//! \~english Tests if element `t` exists in the set.
|
||||
//! \~russian Проверяет наличие элемента `t` в множестве.
|
||||
//! Returns if element "t" exists in this set
|
||||
bool operator[](const T & t) const { return _CSet::contains(t); }
|
||||
|
||||
//! \~english Removes element `t` from the set.
|
||||
//! \~russian Удаляет элемент `t` из множества.
|
||||
//! Returns if element "t" exists in this set
|
||||
PISet<T> & remove(const T & t) {
|
||||
_CSet::remove(t);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Returns the union of this set with set `v`.
|
||||
//! \~russian Возвращает объединение этого множества с множеством `v`.
|
||||
//! Unite set with "v"
|
||||
PISet<T> & unite(const PISet<T> & v) {
|
||||
for (const auto & i: v)
|
||||
_CSet::insert(i, 0);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Returns the difference of this set and set `v`.
|
||||
//! \~russian Возвращает разность этого множества и множества `v`.
|
||||
//! Subtract set with "v"
|
||||
PISet<T> & subtract(const PISet<T> & v) {
|
||||
for (const auto & i: v)
|
||||
_CSet::remove(i);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Returns the intersection of this set with set `v`.
|
||||
//! \~russian Возвращает пересечение этого множества с множеством `v`.
|
||||
//! Intersect set with "v"
|
||||
PISet<T> & intersect(const PISet<T> & v) {
|
||||
_CSet::removeWhere([&v](const T & k, uchar) { return !v.contains(k); });
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Returns the union of this set with set `v`.
|
||||
//! \~russian Возвращает объединение этого множества с множеством `v`.
|
||||
//! Unite set with "v"
|
||||
PISet<T> & operator+=(const PISet<T> & v) { return unite(v); }
|
||||
|
||||
//! \~english Returns the union of this set with set `v`.
|
||||
//! \~russian Возвращает объединение этого множества с множеством `v`.
|
||||
//! Unite set with "v"
|
||||
PISet<T> & operator|=(const PISet<T> & v) { return unite(v); }
|
||||
|
||||
//! \~english Returns the difference of this set and set `v`.
|
||||
//! \~russian Возвращает разность этого множества и множества `v`.
|
||||
//! Subtract set with "v"
|
||||
PISet<T> & operator-=(const PISet<T> & v) { return subtract(v); }
|
||||
|
||||
//! \~english Returns the intersection of this set with set `v`.
|
||||
//! \~russian Возвращает пересечение этого множества с множеством `v`.
|
||||
//! Intersect set with "v"
|
||||
PISet<T> & operator&=(const PISet<T> & v) { return intersect(v); }
|
||||
|
||||
//! \~english Converts the set to a vector.
|
||||
//! \~russian Преобразует множество в вектор.
|
||||
//! Returns content of set as PIVector
|
||||
PIVector<T> toVector() const {
|
||||
PIVector<T> ret;
|
||||
for (const auto & i: *this)
|
||||
@@ -286,8 +238,7 @@ public:
|
||||
return ret;
|
||||
}
|
||||
|
||||
//! \~english Converts the set to a deque.
|
||||
//! \~russian Преобразует множество в deque.
|
||||
//! Returns content of set as PIDeque
|
||||
PIDeque<T> toDeque() const {
|
||||
PIDeque<T> ret;
|
||||
for (const auto & i: *this)
|
||||
@@ -297,8 +248,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
//! \~english Returns the union of two sets.
|
||||
//! \~russian Возвращает объединение двух множеств.
|
||||
//! \relatesalso PISet \brief Returns unite of two sets
|
||||
template<typename T>
|
||||
PISet<T> operator+(const PISet<T> & v0, const PISet<T> & v1) {
|
||||
PISet<T> ret(v0);
|
||||
@@ -306,8 +256,7 @@ PISet<T> operator+(const PISet<T> & v0, const PISet<T> & v1) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
//! \~english Returns the difference of two sets.
|
||||
//! \~russian Возвращает разность двух множеств.
|
||||
//! \relatesalso PISet \brief Returns subtraction of two sets
|
||||
template<typename T>
|
||||
PISet<T> operator-(const PISet<T> & v0, const PISet<T> & v1) {
|
||||
PISet<T> ret(v0);
|
||||
@@ -315,8 +264,7 @@ PISet<T> operator-(const PISet<T> & v0, const PISet<T> & v1) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
//! \~english Returns the union of two sets.
|
||||
//! \~russian Возвращает объединение двух множеств.
|
||||
//! \relatesalso PISet \brief Returns unite of two sets
|
||||
template<typename T>
|
||||
PISet<T> operator|(const PISet<T> & v0, const PISet<T> & v1) {
|
||||
PISet<T> ret(v0);
|
||||
@@ -324,8 +272,7 @@ PISet<T> operator|(const PISet<T> & v0, const PISet<T> & v1) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
//! \~english Returns the intersection of two sets.
|
||||
//! \~russian Возвращает пересечение двух множеств.
|
||||
//! \relatesalso PISet \brief Returns intersetion of two sets
|
||||
template<typename T>
|
||||
PISet<T> operator&(const PISet<T> & v0, const PISet<T> & v1) {
|
||||
PISet<T> ret(v0);
|
||||
@@ -334,9 +281,6 @@ PISet<T> operator&(const PISet<T> & v0, const PISet<T> & v1) {
|
||||
}
|
||||
|
||||
|
||||
//! \relatesalso PICout
|
||||
//! \~english Output operator to \a PICout
|
||||
//! \~russian Оператор вывода в \a PICout
|
||||
template<typename Type>
|
||||
inline PICout operator<<(PICout s, const PISet<Type> & v) {
|
||||
s.space();
|
||||
@@ -353,6 +297,4 @@ inline PICout operator<<(PICout s, const PISet<Type> & v) {
|
||||
return s;
|
||||
}
|
||||
|
||||
//! \}
|
||||
|
||||
#endif // PISET_H
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
//! \addtogroup Containers
|
||||
//! \{
|
||||
//! \file pivector2d.h
|
||||
//! \brief
|
||||
//! \~english Declares \a PIVector2D
|
||||
//! \~russian Объявление \a PIVector2D
|
||||
//! \~\authors
|
||||
//! \~english
|
||||
//! Andrey Bychkov work.a.b@yandex.ru;
|
||||
//! \~russian
|
||||
//! Андрей Бычков work.a.b@yandex.ru;
|
||||
//! \~\}
|
||||
/*! \file pivector2d.h
|
||||
* \brief 2D wrapper around PIVector
|
||||
*
|
||||
* This file declares PIVector
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
2D wrapper around PIVector
|
||||
@@ -32,71 +25,31 @@
|
||||
#ifndef PIVECTOR2D_H
|
||||
#define PIVECTOR2D_H
|
||||
|
||||
#include "pipair.h"
|
||||
#include "pivector.h"
|
||||
|
||||
//! \addtogroup Containers
|
||||
//! \{
|
||||
//! \class PIVector2D
|
||||
//! \brief
|
||||
//! \~english 2D array container.
|
||||
//! \~russian Двумерный контейнер-массив.
|
||||
//! \details
|
||||
//! \~english
|
||||
//! This class is used to store a 2D array of elements of any type as a single continuous block of memory (a plain PIVector).
|
||||
//! Elements can be accessed using the `[][]` operators, where the first index is the row and the second is the column.
|
||||
//! Rows can be manipulated as \a PIVector objects, allowing modification of individual elements or assignment of entire rows.
|
||||
//! You cannot directly add or remove elements to change the dimensions of the array after construction
|
||||
//! (use \a resize(), \a addRow(), \a removeRow(), \a removeColumn() instead), but you can modify the values of existing elements.
|
||||
//! \~russian
|
||||
//! Этот класс используется для хранения двумерного массива элементов любого типа в виде единого непрерывного блока памяти (обычного
|
||||
//! PIVector). Доступ к элементам осуществляется с помощью операторов `[][]`, где первый индекс — это строка, а второй — столбец. Со
|
||||
//! строками можно работать как с объектами \a PIVector, что позволяет изменять отдельные элементы или присваивать целые строки. Нельзя
|
||||
//! напрямую добавлять или удалять элементы, чтобы изменить размеры массива после создания (используйте \a resize(), \a addRow(), \a
|
||||
//! removeRow(), \a removeColumn() для этого), но можно изменять значения существующих элементов.
|
||||
|
||||
/*! \brief 2D array,
|
||||
* \details This class used to store 2D array of any type elements as plain vector.
|
||||
* You can read/write any element via operators [][], first dimension - row, second - column.
|
||||
* The first dimension is Row, and you can operate with Row as PIVector<T>: modify any element, assign to another Row and etc.
|
||||
* You can't add values to array, but you can modify any elements or create another PIVector2D.
|
||||
* PIVector2D has constructors from PIVector<T> and PIVector<PIVector<T> >
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
class PIVector2D {
|
||||
public:
|
||||
//! \~english Constructs an empty 2D array.
|
||||
//! \~russian Создает пустой двумерный массив.
|
||||
inline PIVector2D() { rows_ = cols_ = 0; }
|
||||
|
||||
//! \~english Constructs a 2D array with the given dimensions, filled with copies of `f`.
|
||||
//! \~russian Создает двумерный массив заданного размера, заполненный копиями `f`.
|
||||
//! \param rows Number of rows.
|
||||
//! \param cols Number of columns.
|
||||
//! \param f Value to fill the array with.
|
||||
//! \~english \param rows Количество строк.
|
||||
//! \~russian \param rows Количество строк.
|
||||
//! \~english \param cols Количество столбцов.
|
||||
//! \~russian \param cols Количество столбцов.
|
||||
//! \~english \param f Значение для заполнения массива.
|
||||
//! \~russian \param f Значение для заполнения массива.
|
||||
inline PIVector2D(size_t rows, size_t cols, const T & f = T()) {
|
||||
rows_ = rows;
|
||||
cols_ = cols;
|
||||
mat.resize(rows * cols, f);
|
||||
}
|
||||
|
||||
//! \~english Constructs a 2D array from an existing 1D vector, reshaping it.
|
||||
//! \~russian Создает двумерный массив из существующего одномерного вектора, изменяя его форму.
|
||||
//! \param rows Number of rows.
|
||||
//! \param cols Number of columns.
|
||||
//! \param v The source 1D vector. Its size must be at least `rows * cols`.
|
||||
inline PIVector2D(size_t rows, size_t cols, const PIVector<T> & v): rows_(rows), cols_(cols), mat(v) { mat.resize(rows * cols); }
|
||||
|
||||
//! \~english Move constructs a 2D array from an existing 1D vector, reshaping it.
|
||||
//! \~russian Конструктор перемещения из существующего одномерного вектора, изменяя его форму.
|
||||
//! \param rows Number of rows.
|
||||
//! \param cols Number of columns.
|
||||
//! \param v The source 1D vector (rvalue reference). Its size must be at least `rows * cols`.
|
||||
inline PIVector2D(size_t rows, size_t cols, PIVector<T> && v): rows_(rows), cols_(cols), mat(std::move(v)) { mat.resize(rows * cols); }
|
||||
|
||||
//! \~english Constructs a 2D array from a vector of vectors (jagged array). Assumes all inner vectors have the same size.
|
||||
//! \~russian Создает двумерный массив из вектора векторов (рваного массива). Предполагается, что все внутренние векторы имеют
|
||||
//! одинаковый размер. \param v The source vector of vectors.
|
||||
inline PIVector2D(const PIVector<PIVector<T>> & v) {
|
||||
rows_ = v.size();
|
||||
if (rows_) {
|
||||
@@ -110,43 +63,22 @@ public:
|
||||
if (mat.isEmpty()) rows_ = cols_ = 0;
|
||||
}
|
||||
|
||||
//! \~english Number of rows.
|
||||
//! \~russian Количество строк.
|
||||
inline size_t rows() const { return rows_; }
|
||||
|
||||
//! \~english Number of columns.
|
||||
//! \~russian Количество столбцов.
|
||||
inline size_t cols() const { return cols_; }
|
||||
|
||||
//! \~english Total number of elements (`rows * cols`).
|
||||
//! \~russian Общее количество элементов (`строки * столбцы`).
|
||||
inline size_t size() const { return mat.size(); }
|
||||
|
||||
//! \~english Total number of elements as signed value.
|
||||
//! \~russian Общее количество элементов в виде знакового числа.
|
||||
inline ssize_t size_s() const { return mat.size_s(); }
|
||||
|
||||
//! \~english Total number of elements.
|
||||
//! \~russian Общее количество элементов.
|
||||
inline size_t length() const { return mat.length(); }
|
||||
|
||||
//! \~english Number of elements that the underlying container has currently allocated space for.
|
||||
//! \~russian Количество элементов, для которого сейчас выделена память во внутреннем контейнере.
|
||||
inline size_t capacity() const { return mat.capacity(); }
|
||||
|
||||
//! \~english Checks if the array has no elements.
|
||||
//! \~russian Проверяет, пуст ли массив.
|
||||
inline bool isEmpty() const { return mat.isEmpty(); }
|
||||
|
||||
//! \~english Checks if the array has elements.
|
||||
//! \~russian Проверяет, не пуст ли массив.
|
||||
inline bool isNotEmpty() const { return mat.isNotEmpty(); }
|
||||
|
||||
|
||||
//! \class Row
|
||||
//! \brief
|
||||
//! \~english Proxy class representing a single row in a \a PIVector2D for modification.
|
||||
//! \~russian Прокси-класс, представляющий одну строку в \a PIVector2D для модификации.
|
||||
class Row {
|
||||
friend class PIVector2D<T>;
|
||||
|
||||
@@ -159,179 +91,65 @@ public:
|
||||
size_t st_, sz_;
|
||||
|
||||
public:
|
||||
//! \~english Size of the row (number of columns).
|
||||
//! \~russian Размер строки (количество столбцов).
|
||||
inline size_t size() const { return sz_; }
|
||||
|
||||
//! \~english Accesses the element at the given column index within the row.
|
||||
//! \~russian Доступ к элементу по заданному индексу столбца в строке.
|
||||
inline T & operator[](size_t index) { return (*p_)[st_ + index]; }
|
||||
|
||||
//! \~english Const access to the element at the given column index within the row.
|
||||
//! \~russian Константный доступ к элементу по заданному индексу столбца в строке.
|
||||
inline const T & operator[](size_t index) const { return (*p_)[st_ + index]; }
|
||||
|
||||
//! \~english Returns a pointer to the row data starting at an optional offset.
|
||||
//! \~russian Возвращает указатель на данные строки, начиная с опционального смещения.
|
||||
inline T * data(size_t index = 0) { return p_->data(st_ + index); }
|
||||
|
||||
//! \~english Returns a const pointer to the row data starting at an optional offset.
|
||||
//! \~russian Возвращает константный указатель на данные строки, начиная с опционального смещения.
|
||||
inline const T * data(size_t index = 0) const { return p_->data(st_ + index); }
|
||||
|
||||
//! \~english Assigns the contents of another Row to this row.
|
||||
//! \~russian Присваивает этой строке содержимое другой строки.
|
||||
inline Row & operator=(const Row & other) {
|
||||
if (p_ == other.p_ && st_ == other.st_) return *this;
|
||||
const size_t sz = piMin<size_t>(sz_, other.sz_);
|
||||
p_->_copyRaw(p_->data(st_), other.data(), sz);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Assigns the contents of a \a PIVector to this row.
|
||||
//! \~russian Присваивает этой строке содержимое \a PIVector.
|
||||
inline Row & operator=(const PIVector<T> & other) {
|
||||
const size_t sz = piMin<size_t>(sz_, other.size());
|
||||
p_->_copyRaw(p_->data(st_), other.data(), sz);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Converts the row to a \a PIVector.
|
||||
//! \~russian Преобразует строку в \a PIVector.
|
||||
inline PIVector<T> toVector() const { return PIVector<T>(p_->data(st_), sz_); }
|
||||
|
||||
// --- Поиск в строке ---
|
||||
inline ssize_t indexOf(const T & e, ssize_t start = 0) const {
|
||||
if (start < 0) start = 0;
|
||||
for (size_t i = (size_t)start; i < sz_; ++i) {
|
||||
if ((*p_)[st_ + i] == e) return (ssize_t)i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
inline ssize_t lastIndexOf(const T & e, ssize_t start = -1) const {
|
||||
ssize_t from = (start < 0 || (size_t)start >= sz_) ? (ssize_t)sz_ - 1 : start;
|
||||
for (ssize_t i = from; i >= 0; --i) {
|
||||
if ((*p_)[st_ + i] == e) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
inline ssize_t indexWhere(std::function<bool(const T & e)> test, ssize_t start = 0) const {
|
||||
if (start < 0) start = 0;
|
||||
for (size_t i = (size_t)start; i < sz_; ++i) {
|
||||
if (test((*p_)[st_ + i])) return (ssize_t)i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
inline ssize_t lastIndexWhere(std::function<bool(const T & e)> test, ssize_t start = -1) const {
|
||||
ssize_t from = (start < 0 || (size_t)start >= sz_) ? (ssize_t)sz_ - 1 : start;
|
||||
for (ssize_t i = from; i >= 0; --i) {
|
||||
if (test((*p_)[st_ + i])) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
};
|
||||
|
||||
//! \class Col
|
||||
//! \brief
|
||||
//! \~english Proxy class representing a single column in a \a PIVector2D for modification.
|
||||
//! \~russian Прокси-класс, представляющий один столбец в \a PIVector2D для модификации.
|
||||
class Col {
|
||||
friend class PIVector2D<T>;
|
||||
|
||||
private:
|
||||
inline Col(PIVector2D<T> * p, size_t col): p_(&(p->mat)) {
|
||||
inline Col(PIVector2D<T> * p, size_t row): p_(&(p->mat)) {
|
||||
step_ = p->cols_;
|
||||
col_ = col;
|
||||
row_ = row;
|
||||
sz_ = p->rows_;
|
||||
}
|
||||
PIVector<T> * p_;
|
||||
size_t step_, col_, sz_;
|
||||
size_t step_, row_, sz_;
|
||||
|
||||
public:
|
||||
//! \~english Size of the column (number of rows).
|
||||
//! \~russian Размер столбца (количество строк).
|
||||
inline size_t size() const { return sz_; }
|
||||
|
||||
//! \~english Accesses the element at the given row index within the column.
|
||||
//! \~russian Доступ к элементу по заданному индексу строки в столбце.
|
||||
inline T & operator[](size_t index) { return (*p_)[index * step_ + col_]; }
|
||||
|
||||
//! \~english Const access to the element at the given row index within the column.
|
||||
//! \~russian Константный доступ к элементу по заданному индексу строки в столбце.
|
||||
inline const T & operator[](size_t index) const { return (*p_)[index * step_ + col_]; }
|
||||
|
||||
//! \~english Returns a pointer to the column data starting at an optional row offset.
|
||||
//! \~russian Возвращает указатель на данные столбца, начиная с опционального смещения по строкам.
|
||||
inline T * data(size_t index = 0) { return p_->data(index * step_ + col_); }
|
||||
|
||||
//! \~english Returns a const pointer to the column data starting at an optional row offset.
|
||||
//! \~russian Возвращает константный указатель на данные столбца, начиная с опционального смещения по строкам.
|
||||
inline const T * data(size_t index = 0) const { return p_->data(index * step_ + col_); }
|
||||
|
||||
//! \~english Assigns the contents of another Col to this column.
|
||||
//! \~russian Присваивает этому столбцу содержимое другого столбца.
|
||||
inline T & operator[](size_t index) { return (*p_)[index * step_ + row_]; }
|
||||
inline const T & operator[](size_t index) const { return (*p_)[index * step_ + row_]; }
|
||||
inline T * data(size_t index = 0) { return p_->data(index * step_ + row_); }
|
||||
inline const T * data(size_t index = 0) const { return p_->data(index * step_ + row_); }
|
||||
inline Col & operator=(const Col & other) {
|
||||
if (p_ == other.p_ && col_ == other.col_) return *this;
|
||||
if (p_ == other.p_ && row_ == other.row_) return *this;
|
||||
const size_t sz = piMin<size_t>(sz_, other.sz_);
|
||||
for (size_t i = 0; i < sz; ++i)
|
||||
(*p_)[i * step_ + col_] = other[i];
|
||||
for (int i = 0; i < sz; ++i)
|
||||
(*p_)[i * step_ + row_] = other[i];
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Assigns the contents of a \a PIVector to this column.
|
||||
//! \~russian Присваивает этому столбцу содержимое \a PIVector.
|
||||
inline Col & operator=(const PIVector<T> & other) {
|
||||
inline Row & operator=(const PIVector<T> & other) {
|
||||
const size_t sz = piMin<size_t>(sz_, other.size());
|
||||
for (size_t i = 0; i < sz; ++i)
|
||||
(*p_)[i * step_ + col_] = other[i];
|
||||
for (int i = 0; i < sz; ++i)
|
||||
(*p_)[i * step_ + row_] = other[i];
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Converts the column to a \a PIVector.
|
||||
//! \~russian Преобразует столбец в \a PIVector.
|
||||
inline PIVector<T> toVector() const {
|
||||
PIVector<T> ret;
|
||||
ret.reserve(sz_);
|
||||
for (size_t i = 0; i < sz_; i++)
|
||||
ret << (*p_)[i * step_ + col_];
|
||||
ret << (*p_)[i * step_ + row_];
|
||||
return ret;
|
||||
}
|
||||
|
||||
// --- Поиск в столбце ---
|
||||
inline ssize_t indexOf(const T & e, ssize_t start = 0) const {
|
||||
if (start < 0) start = 0;
|
||||
for (size_t i = (size_t)start; i < sz_; ++i) {
|
||||
if ((*p_)[i * step_ + col_] == e) return (ssize_t)i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
inline ssize_t lastIndexOf(const T & e, ssize_t start = -1) const {
|
||||
ssize_t from = (start < 0 || (size_t)start >= sz_) ? (ssize_t)sz_ - 1 : start;
|
||||
for (ssize_t i = from; i >= 0; --i) {
|
||||
if ((*p_)[i * step_ + col_] == e) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
inline ssize_t indexWhere(std::function<bool(const T & e)> test, ssize_t start = 0) const {
|
||||
if (start < 0) start = 0;
|
||||
for (size_t i = (size_t)start; i < sz_; ++i) {
|
||||
if (test((*p_)[i * step_ + col_])) return (ssize_t)i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
inline ssize_t lastIndexWhere(std::function<bool(const T & e)> test, ssize_t start = -1) const {
|
||||
ssize_t from = (start < 0 || (size_t)start >= sz_) ? (ssize_t)sz_ - 1 : start;
|
||||
for (ssize_t i = from; i >= 0; --i) {
|
||||
if (test((*p_)[i * step_ + col_])) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
};
|
||||
|
||||
//! \class RowConst
|
||||
//! \brief
|
||||
//! \~english Proxy class representing a single read-only row in a \a PIVector2D.
|
||||
//! \~russian Прокси-класс, представляющий одну строку в \a PIVector2D только для чтения.
|
||||
class RowConst {
|
||||
friend class PIVector2D<T>;
|
||||
|
||||
@@ -344,195 +162,64 @@ public:
|
||||
size_t st_, sz_;
|
||||
|
||||
public:
|
||||
//! \~english Size of the row (number of columns).
|
||||
//! \~russian Размер строки (количество столбцов).
|
||||
inline size_t size() const { return sz_; }
|
||||
|
||||
//! \~english Const access to the element at the given column index within the row.
|
||||
//! \~russian Константный доступ к элементу по заданному индексу столбца в строке.
|
||||
inline const T & operator[](size_t index) const { return (*p_)[st_ + index]; }
|
||||
|
||||
//! \~english Returns a const pointer to the row data starting at an optional offset.
|
||||
//! \~russian Возвращает константный указатель на данные строки, начиная с опционального смещения.
|
||||
inline const T * data(size_t index = 0) const { return p_->data(st_ + index); }
|
||||
|
||||
//! \~english Converts the row to a \a PIVector.
|
||||
//! \~russian Преобразует строку в \a PIVector.
|
||||
inline PIVector<T> toVector() const { return PIVector<T>(p_->data(st_), sz_); }
|
||||
|
||||
// --- Поиск в строке (только чтение) ---
|
||||
inline ssize_t indexOf(const T & e, ssize_t start = 0) const {
|
||||
if (start < 0) start = 0;
|
||||
for (size_t i = (size_t)start; i < sz_; ++i) {
|
||||
if ((*p_)[st_ + i] == e) return (ssize_t)i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
inline ssize_t lastIndexOf(const T & e, ssize_t start = -1) const {
|
||||
ssize_t from = (start < 0 || (size_t)start >= sz_) ? (ssize_t)sz_ - 1 : start;
|
||||
for (ssize_t i = from; i >= 0; --i) {
|
||||
if ((*p_)[st_ + i] == e) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
inline ssize_t indexWhere(std::function<bool(const T & e)> test, ssize_t start = 0) const {
|
||||
if (start < 0) start = 0;
|
||||
for (size_t i = (size_t)start; i < sz_; ++i) {
|
||||
if (test((*p_)[st_ + i])) return (ssize_t)i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
inline ssize_t lastIndexWhere(std::function<bool(const T & e)> test, ssize_t start = -1) const {
|
||||
ssize_t from = (start < 0 || (size_t)start >= sz_) ? (ssize_t)sz_ - 1 : start;
|
||||
for (ssize_t i = from; i >= 0; --i) {
|
||||
if (test((*p_)[st_ + i])) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
};
|
||||
|
||||
//! \class ColConst
|
||||
//! \brief
|
||||
//! \~english Proxy class representing a single read-only column in a \a PIVector2D.
|
||||
//! \~russian Прокси-класс, представляющий один столбец в \a PIVector2D только для чтения.
|
||||
class ColConst {
|
||||
friend class PIVector2D<T>;
|
||||
|
||||
private:
|
||||
inline ColConst(const PIVector2D<T> * p, size_t col): p_(&(p->mat)) {
|
||||
inline ColConst(const PIVector2D<T> * p, size_t row): p_(&(p->mat)) {
|
||||
step_ = p->cols_;
|
||||
col_ = col;
|
||||
row_ = row;
|
||||
sz_ = p->rows_;
|
||||
}
|
||||
const PIVector<T> * p_;
|
||||
size_t step_, col_, sz_;
|
||||
size_t step_, row_, sz_;
|
||||
|
||||
public:
|
||||
//! \~english Size of the column (number of rows).
|
||||
//! \~russian Размер столбца (количество строк).
|
||||
inline size_t size() const { return sz_; }
|
||||
|
||||
//! \~english Const access to the element at the given row index within the column.
|
||||
//! \~russian Константный доступ к элементу по заданному индексу строки в столбце.
|
||||
inline const T & operator[](size_t index) const { return (*p_)[index * step_ + col_]; }
|
||||
|
||||
//! \~english Returns a const pointer to the column data starting at an optional row offset.
|
||||
//! \~russian Возвращает константный указатель на данные столбца, начиная с опционального смещения по строкам.
|
||||
inline const T * data(size_t index = 0) const { return p_->data(index * step_ + col_); }
|
||||
|
||||
//! \~english Converts the column to a \a PIVector.
|
||||
//! \~russian Преобразует столбец в \a PIVector.
|
||||
inline size_t size() const { return p_->rows_; }
|
||||
inline const T & operator[](size_t index) const { return (*p_)[index * step_ + row_]; }
|
||||
inline const T * data(size_t index = 0) const { return p_->data(index * step_ + row_); }
|
||||
inline PIVector<T> toVector() const {
|
||||
PIVector<T> ret;
|
||||
ret.reserve(sz_);
|
||||
for (size_t i = 0; i < size(); i++)
|
||||
ret << (*p_)[i * step_ + col_];
|
||||
for (int i = 0; i < size(); i++)
|
||||
ret << (*p_)[i * step_ + row_];
|
||||
return ret;
|
||||
}
|
||||
|
||||
// --- Поиск в столбце (только чтение) ---
|
||||
inline ssize_t indexOf(const T & e, ssize_t start = 0) const {
|
||||
if (start < 0) start = 0;
|
||||
for (size_t i = (size_t)start; i < sz_; ++i) {
|
||||
if ((*p_)[i * step_ + col_] == e) return (ssize_t)i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
inline ssize_t lastIndexOf(const T & e, ssize_t start = -1) const {
|
||||
ssize_t from = (start < 0 || (size_t)start >= sz_) ? (ssize_t)sz_ - 1 : start;
|
||||
for (ssize_t i = from; i >= 0; --i) {
|
||||
if ((*p_)[i * step_ + col_] == e) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
inline ssize_t indexWhere(std::function<bool(const T & e)> test, ssize_t start = 0) const {
|
||||
if (start < 0) start = 0;
|
||||
for (size_t i = (size_t)start; i < sz_; ++i) {
|
||||
if (test((*p_)[i * step_ + col_])) return (ssize_t)i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
inline ssize_t lastIndexWhere(std::function<bool(const T & e)> test, ssize_t start = -1) const {
|
||||
ssize_t from = (start < 0 || (size_t)start >= sz_) ? (ssize_t)sz_ - 1 : start;
|
||||
for (ssize_t i = from; i >= 0; --i) {
|
||||
if (test((*p_)[i * step_ + col_])) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
};
|
||||
|
||||
//! \~english Returns a reference to the element at the given row and column.
|
||||
//! \~russian Возвращает ссылку на элемент по заданной строке и столбцу.
|
||||
inline T & element(size_t row, size_t col) { return mat[row * cols_ + col]; }
|
||||
|
||||
//! \~english Returns a const reference to the element at the given row and column.
|
||||
//! \~russian Возвращает константную ссылку на элемент по заданной строке и столбцу.
|
||||
inline const T & element(size_t row, size_t col) const { return mat[row * cols_ + col]; }
|
||||
|
||||
//! \~english Returns a const reference to the element at the given row and column (bounds-checked only in debug).
|
||||
//! \~russian Возвращает константную ссылку на элемент по заданной строке и столбцу (проверка границ только в отладочном режиме).
|
||||
inline const T & at(size_t row, size_t col) const { return mat[row * cols_ + col]; }
|
||||
|
||||
//! \~english Returns a proxy object for the row at the given index for modification.
|
||||
//! \~russian Возвращает прокси-объект для строки по заданному индексу для модификации.
|
||||
inline Row operator[](size_t index) { return Row(this, index); }
|
||||
|
||||
//! \~english Returns a proxy object for the row at the given index for read-only access.
|
||||
//! \~russian Возвращает прокси-объект для строки по заданному индексу только для чтения.
|
||||
inline RowConst operator[](size_t index) const { return RowConst(this, index); }
|
||||
|
||||
//! \~english Returns a pointer to the underlying flat data starting at an optional offset.
|
||||
//! \~russian Возвращает указатель на внутренние плоские данные, начиная с опционального смещения.
|
||||
inline T * data(size_t index = 0) { return mat.data(index); }
|
||||
|
||||
//! \~english Returns a const pointer to the underlying flat data starting at an optional offset.
|
||||
//! \~russian Возвращает константный указатель на внутренние плоские данные, начиная с опционального смещения.
|
||||
inline const T * data(size_t index = 0) const { return mat.data(index); }
|
||||
|
||||
|
||||
//! \~english Returns a proxy object for the row at the given index for modification.
|
||||
//! \~russian Возвращает прокси-объект для строки по заданному индексу для модификации.
|
||||
inline Row row(size_t index) { return Row(this, index); }
|
||||
|
||||
//! \~english Returns a proxy object for the row at the given index for read-only access.
|
||||
//! \~russian Возвращает прокси-объект для строки по заданному индексу только для чтения.
|
||||
inline RowConst row(size_t index) const { return RowConst(this, index); }
|
||||
|
||||
//! \~english Returns a proxy object for the column at the given index for modification.
|
||||
//! \~russian Возвращает прокси-объект для столбца по заданному индексу для модификации.
|
||||
inline Col col(size_t index) { return Col(this, index); }
|
||||
|
||||
//! \~english Returns a proxy object for the column at the given index for read-only access.
|
||||
//! \~russian Возвращает прокси-объект для столбца по заданному индексу только для чтения.
|
||||
inline ColConst col(size_t index) const { return ColConst(this, index); }
|
||||
|
||||
|
||||
//! \~english Replaces a row with the contents of another Row object.
|
||||
//! \~russian Заменяет строку содержимым другого объекта Row.
|
||||
inline PIVector2D<T> & setRow(size_t row, const Row & other) {
|
||||
const size_t sz = piMin<size_t>(cols_, other.sz_);
|
||||
mat._copyRaw(mat.data(cols_ * row), other.data(), sz);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Replaces a row with the contents of a read-only RowConst object.
|
||||
//! \~russian Заменяет строку содержимым объекта RowConst только для чтения.
|
||||
inline PIVector2D<T> & setRow(size_t row, const RowConst & other) {
|
||||
const size_t sz = piMin<size_t>(cols_, other.sz_);
|
||||
mat._copyRaw(mat.data(cols_ * row), other.data(), sz);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Replaces a row with the contents of a \a PIVector.
|
||||
//! \~russian Заменяет строку содержимым \a PIVector.
|
||||
inline PIVector2D<T> & setRow(size_t row, const PIVector<T> & other) {
|
||||
const size_t sz = piMin<size_t>(cols_, other.size());
|
||||
mat._copyRaw(mat.data(cols_ * row), other.data(), sz);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Appends a new row to the bottom of the array from another Row object.
|
||||
//! \~russian Добавляет новую строку в конец массива из другого объекта Row.
|
||||
inline PIVector2D<T> & addRow(const Row & other) {
|
||||
if (cols_ == 0) cols_ = other.sz_;
|
||||
const size_t sz = piMin<size_t>(cols_, other.sz_);
|
||||
@@ -542,9 +229,6 @@ public:
|
||||
rows_++;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Appends a new row to the bottom of the array from a read-only RowConst object.
|
||||
//! \~russian Добавляет новую строку в конец массива из объекта RowConst только для чтения.
|
||||
inline PIVector2D<T> & addRow(const RowConst & other) {
|
||||
if (cols_ == 0) cols_ = other.sz_;
|
||||
const size_t sz = piMin<size_t>(cols_, other.sz_);
|
||||
@@ -554,9 +238,6 @@ public:
|
||||
rows_++;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Appends a new row to the bottom of the array from a \a PIVector.
|
||||
//! \~russian Добавляет новую строку в конец массива из \a PIVector.
|
||||
inline PIVector2D<T> & addRow(const PIVector<T> & other) {
|
||||
if (cols_ == 0) cols_ = other.size();
|
||||
const size_t sz = piMin<size_t>(cols_, other.size());
|
||||
@@ -567,40 +248,34 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Resizes the 2D array to new dimensions.
|
||||
//! \~russian Изменяет размер двумерного массива.
|
||||
//! \details
|
||||
//! \~english If the new dimensions are larger, new elements are filled with `f`.
|
||||
//! If they are smaller, the array is truncated.
|
||||
//! \~russian Если новые размеры больше, новые элементы заполняются `f`.
|
||||
//! Если они меньше, массив обрезается.
|
||||
inline PIVector2D<T> & resize(size_t rows, size_t cols, const T & f = T()) {
|
||||
if (rows == rows_ && cols == cols_) return *this;
|
||||
PIVector2D<T> tmp(rows, cols, f);
|
||||
size_t copyRows = piMin(rows_, rows);
|
||||
size_t copyCols = piMin(cols_, cols);
|
||||
for (size_t r = 0; r < copyRows; ++r) {
|
||||
for (size_t c = 0; c < copyCols; ++c) {
|
||||
tmp.element(r, c) = element(r, c);
|
||||
mat.resize(rows * cols_, f);
|
||||
rows_ = rows;
|
||||
const int cs = (cols - cols_);
|
||||
if (cs < 0) {
|
||||
for (size_t r = 0; r < rows; ++r) {
|
||||
mat.remove(r * cols + cols, -cs);
|
||||
}
|
||||
}
|
||||
swap(tmp);
|
||||
mat.resize(rows * cols, f);
|
||||
if (!mat.isEmpty()) {
|
||||
if (cs > 0) {
|
||||
for (size_t r = 0; r < rows_; ++r) {
|
||||
for (int i = 0; i < cs; ++i)
|
||||
mat.insert(r * cols + cols_, mat.take_back());
|
||||
}
|
||||
}
|
||||
}
|
||||
cols_ = cols;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Equality operator.
|
||||
//! \~russian Оператор равенства.
|
||||
inline bool operator==(const PIVector2D<T> & t) const {
|
||||
if (cols_ != t.cols_ || rows_ != t.rows_) return false;
|
||||
return mat == t.mat;
|
||||
}
|
||||
|
||||
//! \~english Inequality operator.
|
||||
//! \~russian Оператор неравенства.
|
||||
inline bool operator!=(const PIVector2D<T> & t) const { return !(*this == t); }
|
||||
|
||||
//! \~english Converts the 2D array to a vector of vectors (PIVector<PIVector<T>>).
|
||||
//! \~russian Преобразует двумерный массив в вектор векторов (PIVector<PIVector<T>>).
|
||||
inline PIVector<PIVector<T>> toVectors() const {
|
||||
PIVector<PIVector<T>> ret;
|
||||
ret.reserve(rows_);
|
||||
@@ -609,27 +284,18 @@ public:
|
||||
return ret;
|
||||
}
|
||||
|
||||
//! \~english Returns a const reference to the underlying flat \a PIVector.
|
||||
//! \~russian Возвращает константную ссылку на внутренний плоский \a PIVector.
|
||||
inline const PIVector<T> & asPlainVector() const { return mat; }
|
||||
|
||||
//! \~english Returns a reference to the underlying flat \a PIVector.
|
||||
//! \~russian Возвращает ссылку на внутренний плоский \a PIVector.
|
||||
inline PIVector<T> & asPlainVector() { return mat; }
|
||||
|
||||
//! \~english Returns a copy of the underlying flat \a PIVector.
|
||||
//! \~russian Возвращает копию внутреннего плоского \a PIVector.
|
||||
inline PIVector<T> toPlainVector() const { return mat; }
|
||||
|
||||
//! \~english Swaps this 2D array with another.
|
||||
//! \~russian Меняет местами этот двумерный массив с другим.
|
||||
inline PIVector<T> & plainVector() { return mat; }
|
||||
|
||||
inline const PIVector<T> & plainVector() const { return mat; }
|
||||
|
||||
inline void swap(PIVector2D<T> & other) {
|
||||
mat.swap(other.mat);
|
||||
piSwap<size_t>(rows_, other.rows_);
|
||||
piSwap<size_t>(cols_, other.cols_);
|
||||
}
|
||||
|
||||
//! \internal
|
||||
template<typename T1 = T, typename std::enable_if<std::is_trivially_copyable<T1>::value, int>::type = 0>
|
||||
inline PIVector2D<T> & _resizeRaw(size_t r, size_t c) {
|
||||
rows_ = r;
|
||||
@@ -638,318 +304,22 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Clears the array, removing all elements and setting dimensions to 0.
|
||||
//! \~russian Очищает массив, удаляя все элементы и устанавливая размеры в 0.
|
||||
inline void clear() {
|
||||
rows_ = cols_ = 0;
|
||||
mat.clear();
|
||||
}
|
||||
|
||||
|
||||
//! \~english Checks if the underlying flat vector contains the element `e`.
|
||||
//! \~russian Проверяет, содержит ли внутренний плоский вектор элемент `e`.
|
||||
inline bool contains(const T & e, ssize_t start = 0) const { return mat.contains(e, start); }
|
||||
|
||||
//! \~english Checks if the underlying flat vector contains all elements of `v`.
|
||||
//! \~russian Проверяет, содержит ли внутренний плоский вектор все элементы `v`.
|
||||
inline bool contains(const PIVector<T> & v, ssize_t start = 0) const { return mat.contains(v, start); }
|
||||
|
||||
//! \~english Counts occurrences of `e` in the underlying flat vector.
|
||||
//! \~russian Подсчитывает количество вхождений `e` во внутреннем плоском векторе.
|
||||
inline int entries(const T & e, ssize_t start = 0) const { return mat.entries(e, start); }
|
||||
|
||||
//! \~english Counts elements in the flat vector that pass the `test`.
|
||||
//! \~russian Подсчитывает элементы в плоском векторе, проходящие `test`.
|
||||
inline int entries(std::function<bool(const T & e)> test, ssize_t start = 0) const { return mat.entries(test, start); }
|
||||
|
||||
|
||||
//! \~english Returns the first index (row, col) of `e` in the 2D array.
|
||||
//! \~russian Возвращает первый индекс (строка, столбец) элемента `e` в двумерном массиве.
|
||||
inline PIPair<ssize_t, ssize_t> indexOf(const T & e, ssize_t start = 0) const {
|
||||
ssize_t flat = mat.indexOf(e, start);
|
||||
if (flat < 0 || cols_ == 0) return PIPair<ssize_t, ssize_t>(-1, -1);
|
||||
return PIPair<ssize_t, ssize_t>(flat / cols_, flat % cols_);
|
||||
}
|
||||
|
||||
//! \~english Returns the first index (row, col) in the 2D array that passes the `test`.
|
||||
//! \~russian Возвращает первый индекс (строка, столбец) в двумерном массиве, проходящий `test`.
|
||||
inline PIPair<ssize_t, ssize_t> indexWhere(std::function<bool(const T & e)> test, ssize_t start = 0) const {
|
||||
ssize_t flat = mat.indexWhere(test, start);
|
||||
if (flat < 0 || cols_ == 0) return PIPair<ssize_t, ssize_t>(-1, -1);
|
||||
return PIPair<ssize_t, ssize_t>(flat / cols_, flat % cols_);
|
||||
}
|
||||
|
||||
//! \~english Returns the last index (row, col) of `e` in the 2D array.
|
||||
//! \~russian Возвращает последний индекс (строка, столбец) элемента `e` в двумерном массиве.
|
||||
inline PIPair<ssize_t, ssize_t> lastIndexOf(const T & e, ssize_t start = -1) const {
|
||||
ssize_t flat = mat.lastIndexOf(e, start);
|
||||
if (flat < 0 || cols_ == 0) return PIPair<ssize_t, ssize_t>(-1, -1);
|
||||
return PIPair<ssize_t, ssize_t>(flat / cols_, flat % cols_);
|
||||
}
|
||||
|
||||
//! \~english Returns the last index (row, col) in the 2D array that passes the `test`.
|
||||
//! \~russian Возвращает последний индекс (строка, столбец) в двумерном массиве, проходящий `test`.
|
||||
inline PIPair<ssize_t, ssize_t> lastIndexWhere(std::function<bool(const T & e)> test, ssize_t start = -1) const {
|
||||
ssize_t flat = mat.lastIndexWhere(test, start);
|
||||
if (flat < 0 || cols_ == 0) return PIPair<ssize_t, ssize_t>(-1, -1);
|
||||
return PIPair<ssize_t, ssize_t>(flat / cols_, flat % cols_);
|
||||
}
|
||||
|
||||
|
||||
//! \~english Tests if any element in the flat vector passes the `test`.
|
||||
//! \~russian Проверяет, проходит ли какой-либо элемент в плоском векторе `test`.
|
||||
inline bool any(std::function<bool(const T & e)> test) const { return mat.any(test); }
|
||||
|
||||
//! \~english Tests if all elements in the flat vector pass the `test`.
|
||||
//! \~russian Проверяет, проходят ли все элементы в плоском векторе `test`.
|
||||
inline bool every(std::function<bool(const T & e)> test) const { return mat.every(test); }
|
||||
|
||||
//! \~english Fills the entire 2D array with copies of `e`.
|
||||
//! \~russian Заполняет весь двумерный массив копиями `e`.
|
||||
inline PIVector2D<T> & fill(const T & e = T()) {
|
||||
mat.fill(e);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Fills the entire 2D array using a generator function `f` based on flat index.
|
||||
//! \~russian Заполняет весь двумерный массив, используя функцию-генератор `f` на основе плоского индекса.
|
||||
inline PIVector2D<T> & fill(std::function<T(size_t i)> f) {
|
||||
mat.fill(f);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Same as \a fill().
|
||||
//! \~russian То же, что и \a fill().
|
||||
inline PIVector2D<T> & assign(const T & e = T()) { return fill(e); }
|
||||
|
||||
//! \~english Assigns new size and fills with value.
|
||||
//! \~russian Задаёт новый размер и заполняет значением.
|
||||
inline PIVector2D<T> & assign(size_t rows, size_t cols, const T & f = T()) {
|
||||
mat.assign(rows * cols, f);
|
||||
rows_ = rows;
|
||||
cols_ = cols;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// TODO: исправить - при транспонировании количество строк становится количеством столбцов и наоборот
|
||||
//! \~english Returns a transposed 2D array (rows become columns and vice versa).
|
||||
//! \~russian Возвращает транспонированный двумерный массив (строки становятся столбцами и наоборот).
|
||||
inline PIVector2D<T> transposed() const {
|
||||
if (isEmpty()) return PIVector2D<T>();
|
||||
PIVector2D<T> result(cols_, rows_);
|
||||
for (size_t r = 0; r < rows_; ++r) {
|
||||
for (size_t c = 0; c < cols_; ++c) {
|
||||
result.element(c, r) = element(r, c);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//! \~english Reverses the order of rows in place.
|
||||
//! \~russian Изменяет порядок строк на обратный на месте.
|
||||
inline PIVector2D<T> & reverseRows() {
|
||||
const size_t half = rows_ / 2;
|
||||
for (size_t i = 0; i < half; ++i) {
|
||||
T * row1 = data(i * cols_);
|
||||
T * row2 = data((rows_ - 1 - i) * cols_);
|
||||
for (size_t j = 0; j < cols_; ++j) {
|
||||
piSwap(row1[j], row2[j]);
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Reverses the order of columns in each row in place.
|
||||
//! \~russian Изменяет порядок столбцов в каждой строке на обратный на месте.
|
||||
inline PIVector2D<T> & reverseColumns() {
|
||||
for (size_t r = 0; r < rows_; ++r) {
|
||||
Row currentRow = row(r);
|
||||
const size_t half = cols_ / 2;
|
||||
for (size_t c = 0; c < half; ++c) {
|
||||
piSwap<T>(currentRow[c], currentRow[cols_ - 1 - c]);
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Returns a sub-2D array (a range of rows and columns).
|
||||
//! \~russian Возвращает подмассив (диапазон строк и столбцов).
|
||||
inline PIVector2D<T> getRange(size_t rowStart, size_t rowCount, size_t colStart, size_t colCount) const {
|
||||
if (rowStart >= rows_ || colStart >= cols_ || rowCount == 0 || colCount == 0) return PIVector2D<T>();
|
||||
size_t actualRowCount = piMin(rowCount, rows_ - rowStart);
|
||||
size_t actualColCount = piMin(colCount, cols_ - colStart);
|
||||
|
||||
PIVector2D<T> result(actualRowCount, actualColCount);
|
||||
for (size_t r = 0; r < actualRowCount; ++r) {
|
||||
for (size_t c = 0; c < actualColCount; ++c) {
|
||||
result.element(r, c) = element(rowStart + r, colStart + c);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//! \~english Applies a function to each element and returns a new 2D array of a different type.
|
||||
//! \~russian Применяет функцию к каждому элементу и возвращает новый двумерный массив другого типа.
|
||||
template<typename ST>
|
||||
inline PIVector2D<ST> map(std::function<ST(const T & e)> f) const {
|
||||
return PIVector2D<ST>(rows_, cols_, mat.template map<ST>(f));
|
||||
return PIVector2D<ST>(rows_, cols_, mat.map(f));
|
||||
}
|
||||
|
||||
//! \~english Applies a function (with row and col indices) to each element and returns a new 2D array.
|
||||
//! \~russian Применяет функцию (с индексами строки и столбца) к каждому элементу и возвращает новый двумерный массив.
|
||||
template<typename ST>
|
||||
inline PIVector2D<ST> mapIndexed(std::function<ST(size_t row, size_t col, const T & e)> f) const {
|
||||
PIVector<ST> mappedMat;
|
||||
mappedMat.reserve(size());
|
||||
for (size_t r = 0; r < rows_; ++r) {
|
||||
for (size_t c = 0; c < cols_; ++c) {
|
||||
mappedMat << f(r, c, element(r, c));
|
||||
}
|
||||
}
|
||||
return PIVector2D<ST>(rows_, cols_, std::move(mappedMat));
|
||||
}
|
||||
inline void forEach(std::function<void(const T &)> f) const { mat.forEach(f); }
|
||||
|
||||
// --- Итерация по строкам и столбцам ---
|
||||
//! \~english Applies a function to each row (modifiable).
|
||||
//! \~russian Применяет функцию к каждой строке (с возможностью изменения).
|
||||
inline PIVector2D<T> & forEachRow(std::function<void(Row)> f) {
|
||||
for (size_t r = 0; r < rows_; ++r)
|
||||
f(row(r));
|
||||
inline PIVector2D<T> & forEach(std::function<void(T &)> f) {
|
||||
mat.forEach(f);
|
||||
return *this;
|
||||
}
|
||||
//! \~english Applies a function to each row (read-only).
|
||||
//! \~russian Применяет функцию к каждой строке (только чтение).
|
||||
inline void forEachRow(std::function<void(RowConst)> f) const {
|
||||
for (size_t r = 0; r < rows_; ++r)
|
||||
f(row(r));
|
||||
}
|
||||
//! \~english Applies a function to each column (modifiable).
|
||||
//! \~russian Применяет функцию к каждому столбцу (с возможностью изменения).
|
||||
inline PIVector2D<T> & forEachColumn(std::function<void(Col)> f) {
|
||||
for (size_t c = 0; c < cols_; ++c)
|
||||
f(col(c));
|
||||
return *this;
|
||||
}
|
||||
//! \~english Applies a function to each column (read-only).
|
||||
//! \~russian Применяет функцию к каждому столбцу (только чтение).
|
||||
inline void forEachColumn(std::function<void(ColConst)> f) const {
|
||||
for (size_t c = 0; c < cols_; ++c)
|
||||
f(col(c));
|
||||
}
|
||||
|
||||
//! \~english Accumulates a value across all elements.
|
||||
//! \~russian Аккумулирует значение по всем элементам.
|
||||
template<typename ST>
|
||||
inline ST reduce(std::function<ST(const T & e, const ST & acc)> f, const ST & initial = ST()) const {
|
||||
return mat.template reduce<ST>(f, initial);
|
||||
}
|
||||
|
||||
//! \~english Accumulates a value across all elements with indices.
|
||||
//! \~russian Аккумулирует значение по всем элементам с индексами.
|
||||
template<typename ST>
|
||||
inline ST reduceIndexed(std::function<ST(size_t row, size_t col, const T & e, const ST & acc)> f, const ST & initial = ST()) const {
|
||||
ST ret(initial);
|
||||
for (size_t r = 0; r < rows_; ++r) {
|
||||
for (size_t c = 0; c < cols_; ++c) {
|
||||
ret = f(r, c, element(r, c), ret);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
//! \~english Removes a row from the 2D array.
|
||||
//! \~russian Удаляет строку из двумерного массива.
|
||||
inline PIVector2D<T> & removeRow(size_t row) {
|
||||
if (row >= rows_) return *this;
|
||||
size_t startIdx = row * cols_;
|
||||
mat.remove(startIdx, cols_);
|
||||
rows_--;
|
||||
if (rows_ == 0) cols_ = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Removes a column from the 2D array.
|
||||
//! \~russian Удаляет столбец из двумерного массива.
|
||||
inline PIVector2D<T> & removeColumn(size_t col) {
|
||||
if (col >= cols_ || rows_ == 0) return *this;
|
||||
PIVector2D<T> result(rows_, cols_ - 1);
|
||||
for (size_t r = 0; r < rows_; ++r) {
|
||||
for (size_t c = 0, nc = 0; c < cols_; ++c) {
|
||||
if (c == col) continue;
|
||||
result.element(r, nc++) = element(r, c);
|
||||
}
|
||||
}
|
||||
swap(result);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Removes all rows that satisfy a condition.
|
||||
//! \~russian Удаляет все строки, удовлетворяющие условию.
|
||||
inline PIVector2D<T> & removeRowsWhere(std::function<bool(const RowConst &)> test) {
|
||||
ssize_t r = rows_ - 1;
|
||||
while (r >= 0) {
|
||||
if (test(RowConst(this, r))) {
|
||||
removeRow(r);
|
||||
}
|
||||
--r;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Removes all columns that satisfy a condition.
|
||||
//! \~russian Удаляет все столбцы, удовлетворяющие условию.
|
||||
inline PIVector2D<T> & removeColumnsWhere(std::function<bool(const ColConst &)> test) {
|
||||
ssize_t c = cols_ - 1;
|
||||
while (c >= 0) {
|
||||
if (test(ColConst(this, c))) {
|
||||
removeColumn(c);
|
||||
}
|
||||
--c;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//! \~english Returns a new 2D array containing only the rows that pass the test.
|
||||
//! \~russian Возвращает новый двумерный массив, содержащий только строки, прошедшие проверку.
|
||||
inline PIVector2D<T> filterRows(std::function<bool(const RowConst &)> test) const {
|
||||
PIVector2D<T> result;
|
||||
for (size_t r = 0; r < rows_; ++r) {
|
||||
RowConst currentRow = row(r);
|
||||
if (test(currentRow)) {
|
||||
result.addRow(currentRow);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//! \~english Returns a new 2D array containing only the columns that pass the test.
|
||||
//! \~russian Возвращает новый двумерный массив, содержащий только столбцы, прошедшие проверку.
|
||||
inline PIVector2D<T> filterColumns(std::function<bool(const ColConst &)> test) const {
|
||||
if (isEmpty()) return PIVector2D<T>();
|
||||
PIVector<size_t> goodCols;
|
||||
for (size_t c = 0; c < cols_; ++c) {
|
||||
if (test(col(c))) {
|
||||
goodCols << c;
|
||||
}
|
||||
}
|
||||
PIVector2D<T> result(rows_, goodCols.size());
|
||||
for (size_t r = 0; r < rows_; ++r) {
|
||||
for (size_t gc = 0; gc < goodCols.size(); ++gc) {
|
||||
result.element(r, gc) = element(r, goodCols[gc]);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//! \~english Returns a new 2D array (as a single row) containing only the elements that pass the test.
|
||||
//! \~russian Возвращает новый двумерный массив (в виде одной строки), содержащий только элементы, прошедшие проверку.
|
||||
inline PIVector2D<T> filterElements(std::function<bool(const T &)> test) const {
|
||||
PIVector<T> filtered = mat.filter(test);
|
||||
if (filtered.isEmpty()) return PIVector2D<T>();
|
||||
return PIVector2D<T>(1, filtered.size(), filtered);
|
||||
}
|
||||
|
||||
protected:
|
||||
size_t rows_, cols_;
|
||||
@@ -957,9 +327,6 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
//! \relatesalso PICout
|
||||
//! \~english Output operator for \a PIVector2D to \a PICout.
|
||||
//! \~russian Оператор вывода \a PIVector2D в \a PICout.
|
||||
template<typename T>
|
||||
inline PICout operator<<(PICout s, const PIVector2D<T> & v) {
|
||||
s.saveAndSetControls(0);
|
||||
@@ -979,6 +346,5 @@ inline PICout operator<<(PICout s, const PIVector2D<T> & v) {
|
||||
return s;
|
||||
}
|
||||
|
||||
//! \}
|
||||
|
||||
#endif // PIVECTOR2D_H
|
||||
|
||||
@@ -245,9 +245,6 @@ inline constexpr T piAbs(const T & v) {
|
||||
}
|
||||
|
||||
|
||||
//! \~\brief
|
||||
//! \~english Templated function return minimum of two values
|
||||
//! \~russian Шаблонный метод, возвращающий минимум из двух значений
|
||||
template<typename T>
|
||||
constexpr T piMin(const T & f, const T & s) {
|
||||
return ((f > s) ? s : f);
|
||||
@@ -285,9 +282,6 @@ constexpr T piMin(const T & f, const T & s, const Args &... args) {
|
||||
}
|
||||
|
||||
|
||||
//! \~\brief
|
||||
//! \~english Templated function return maximum of two values
|
||||
//! \~russian Шаблонный метод, возвращающий максимум из двух значений
|
||||
template<typename T>
|
||||
constexpr T piMax(const T & f, const T & s) {
|
||||
return ((f < s) ? s : f);
|
||||
|
||||
@@ -64,16 +64,7 @@ PIP_EXPORT PIString errorString();
|
||||
//! \~russian Сброс последней ошибки
|
||||
PIP_EXPORT void errorClear();
|
||||
|
||||
//! \ingroup Core
|
||||
//! \brief
|
||||
//! \~english Initialize random number generator
|
||||
//! \~russian Инициализация генератора случайных чисел
|
||||
PIP_EXPORT void randomize();
|
||||
|
||||
//! \ingroup Core
|
||||
//! \brief
|
||||
//! \~english Returns random integer value
|
||||
//! \~russian Возвращает случайное целое число
|
||||
PIP_EXPORT int randomi();
|
||||
|
||||
//! \ingroup Core
|
||||
|
||||
@@ -45,15 +45,11 @@ public:
|
||||
s = size_;
|
||||
}
|
||||
|
||||
//! \~english Copy constructor
|
||||
//! \~russian Конструктор копирования
|
||||
PIMemoryBlock(const PIMemoryBlock & o) {
|
||||
d = o.d;
|
||||
s = o.s;
|
||||
}
|
||||
|
||||
//! \~english Assignment operator
|
||||
//! \~russian Оператор присваивания
|
||||
PIMemoryBlock & operator=(const PIMemoryBlock & o) {
|
||||
d = o.d;
|
||||
s = o.s;
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include "pidigest_md5_p.h"
|
||||
#include "pidigest_sha1_p.h"
|
||||
#include "pidigest_sha2_p.h"
|
||||
#include "pidigest_siphash_p.h"
|
||||
|
||||
|
||||
int PIDigest::hashLength(Type type) {
|
||||
@@ -50,10 +49,6 @@ int PIDigest::hashLength(Type type) {
|
||||
case Type::BLAKE2b_256: return 32;
|
||||
case Type::BLAKE2b_384: return 48;
|
||||
case Type::BLAKE2b_512: return 64;
|
||||
case Type::SipHash_2_4_64: return 8;
|
||||
case Type::SipHash_2_4_128: return 16;
|
||||
case Type::HalfSipHash_2_4_32: return 4;
|
||||
case Type::HalfSipHash_2_4_64: return 8;
|
||||
default: break;
|
||||
}
|
||||
return 0;
|
||||
@@ -82,10 +77,6 @@ int PIDigest::blockLength(Type type) {
|
||||
case Type::BLAKE2b_256:
|
||||
case Type::BLAKE2b_384:
|
||||
case Type::BLAKE2b_512: return 128;
|
||||
case Type::SipHash_2_4_64: return 8;
|
||||
case Type::SipHash_2_4_128: return 16;
|
||||
case Type::HalfSipHash_2_4_32: return 4;
|
||||
case Type::HalfSipHash_2_4_64: return 8;
|
||||
default: break;
|
||||
}
|
||||
return 0;
|
||||
@@ -114,10 +105,6 @@ PIConstChars PIDigest::typeName(Type type) {
|
||||
case Type::BLAKE2b_256: return "BLAKE2b_256";
|
||||
case Type::BLAKE2b_384: return "BLAKE2b_384";
|
||||
case Type::BLAKE2b_512: return "BLAKE2b_512";
|
||||
case Type::SipHash_2_4_64: return "SipHash_2_4_64";
|
||||
case Type::SipHash_2_4_128: return "SipHash_2_4_128";
|
||||
case Type::HalfSipHash_2_4_32: return "HalfSipHash_2_4_32";
|
||||
case Type::HalfSipHash_2_4_64: return "HalfSipHash_2_4_64";
|
||||
default: break;
|
||||
}
|
||||
return "Unknown";
|
||||
@@ -136,42 +123,16 @@ PIByteArray PIDigest::calculate(const PIByteArray & msg, Type type) {
|
||||
case Type::SHA2_512: return SHA2::sha5xx(msg, SHA2::initial_512, 64);
|
||||
case Type::SHA2_512_224: return SHA2::sha5xx(msg, SHA2::initial_512_224, 28);
|
||||
case Type::SHA2_512_256: return SHA2::sha5xx(msg, SHA2::initial_512_256, 32);
|
||||
case Type::BLAKE2s_128: return BLAKE2::blake2s(msg, {}, 16);
|
||||
case Type::BLAKE2s_160: return BLAKE2::blake2s(msg, {}, 20);
|
||||
case Type::BLAKE2s_224: return BLAKE2::blake2s(msg, {}, 28);
|
||||
case Type::BLAKE2s_256: return BLAKE2::blake2s(msg, {}, 32);
|
||||
case Type::BLAKE2b_128: return BLAKE2::blake2b(msg, {}, 16);
|
||||
case Type::BLAKE2b_160: return BLAKE2::blake2b(msg, {}, 20);
|
||||
case Type::BLAKE2b_224: return BLAKE2::blake2b(msg, {}, 28);
|
||||
case Type::BLAKE2b_256: return BLAKE2::blake2b(msg, {}, 32);
|
||||
case Type::BLAKE2b_384: return BLAKE2::blake2b(msg, {}, 48);
|
||||
case Type::BLAKE2b_512: return BLAKE2::blake2b(msg, {}, 64);
|
||||
case Type::SipHash_2_4_64: return SipHash::siphash(msg, {}, 8);
|
||||
case Type::SipHash_2_4_128: return SipHash::siphash(msg, {}, 16);
|
||||
case Type::HalfSipHash_2_4_32: return SipHash::halfsiphash(msg, {}, 4);
|
||||
case Type::HalfSipHash_2_4_64: return SipHash::halfsiphash(msg, {}, 8);
|
||||
default: break;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
PIByteArray PIDigest::calculateWithKey(const PIByteArray & msg, const PIByteArray & key, Type type) {
|
||||
switch (type) {
|
||||
case Type::BLAKE2s_128: return BLAKE2::blake2s(msg, key, 16);
|
||||
case Type::BLAKE2s_160: return BLAKE2::blake2s(msg, key, 20);
|
||||
case Type::BLAKE2s_224: return BLAKE2::blake2s(msg, key, 28);
|
||||
case Type::BLAKE2s_256: return BLAKE2::blake2s(msg, key, 32);
|
||||
case Type::BLAKE2b_128: return BLAKE2::blake2b(msg, key, 16);
|
||||
case Type::BLAKE2b_160: return BLAKE2::blake2b(msg, key, 20);
|
||||
case Type::BLAKE2b_224: return BLAKE2::blake2b(msg, key, 28);
|
||||
case Type::BLAKE2b_256: return BLAKE2::blake2b(msg, key, 32);
|
||||
case Type::BLAKE2b_384: return BLAKE2::blake2b(msg, key, 48);
|
||||
case Type::BLAKE2b_512: return BLAKE2::blake2b(msg, key, 64);
|
||||
case Type::SipHash_2_4_64: return SipHash::siphash(msg, key, 8);
|
||||
case Type::SipHash_2_4_128: return SipHash::siphash(msg, key, 16);
|
||||
case Type::HalfSipHash_2_4_32: return SipHash::halfsiphash(msg, key, 4);
|
||||
case Type::HalfSipHash_2_4_64: return SipHash::halfsiphash(msg, key, 8);
|
||||
case Type::BLAKE2s_128: return BLAKE2::blake2s(msg, 16);
|
||||
case Type::BLAKE2s_160: return BLAKE2::blake2s(msg, 20);
|
||||
case Type::BLAKE2s_224: return BLAKE2::blake2s(msg, 28);
|
||||
case Type::BLAKE2s_256: return BLAKE2::blake2s(msg, 32);
|
||||
case Type::BLAKE2b_128: return BLAKE2::blake2b(msg, 16);
|
||||
case Type::BLAKE2b_160: return BLAKE2::blake2b(msg, 20);
|
||||
case Type::BLAKE2b_224: return BLAKE2::blake2b(msg, 28);
|
||||
case Type::BLAKE2b_256: return BLAKE2::blake2b(msg, 32);
|
||||
case Type::BLAKE2b_384: return BLAKE2::blake2b(msg, 48);
|
||||
case Type::BLAKE2b_512: return BLAKE2::blake2b(msg, 64);
|
||||
default: break;
|
||||
}
|
||||
return {};
|
||||
|
||||
@@ -39,18 +39,15 @@ class PIP_EXPORT PIDigest {
|
||||
public:
|
||||
enum class Type {
|
||||
SHA1,
|
||||
|
||||
SHA2_224,
|
||||
SHA2_256,
|
||||
SHA2_384,
|
||||
SHA2_512,
|
||||
SHA2_512_224,
|
||||
SHA2_512_256,
|
||||
|
||||
MD2,
|
||||
MD4,
|
||||
MD5,
|
||||
|
||||
BLAKE2s_128,
|
||||
BLAKE2s_160,
|
||||
BLAKE2s_224,
|
||||
@@ -61,12 +58,6 @@ public:
|
||||
BLAKE2b_256,
|
||||
BLAKE2b_384,
|
||||
BLAKE2b_512,
|
||||
|
||||
SipHash_2_4_64,
|
||||
SipHash_2_4_128,
|
||||
HalfSipHash_2_4_32,
|
||||
HalfSipHash_2_4_64,
|
||||
|
||||
Count,
|
||||
};
|
||||
|
||||
@@ -75,7 +66,6 @@ public:
|
||||
static PIConstChars typeName(Type type);
|
||||
|
||||
static PIByteArray calculate(const PIByteArray & msg, Type type);
|
||||
static PIByteArray calculateWithKey(const PIByteArray & msg, const PIByteArray & key, Type type);
|
||||
static PIByteArray HMAC(const PIByteArray & msg, const PIByteArray & key, PIDigest::Type type);
|
||||
};
|
||||
|
||||
|
||||
@@ -21,18 +21,44 @@
|
||||
|
||||
#include "3rd/BLAKE2/blake2.h"
|
||||
|
||||
#define IMPLEMENT(func, key_len) \
|
||||
PIByteArray BLAKE2::func(const PIByteArray & in, const PIByteArray & key, int out_bytes) { \
|
||||
PIByteArray ret(out_bytes); \
|
||||
::func(ret.data(), ret.size(), in.data(), in.size(), key.isEmpty() ? nullptr : key.data(), piMini(key.size(), key_len)); \
|
||||
return ret; \
|
||||
}
|
||||
|
||||
IMPLEMENT(blake2s, BLAKE2S_KEYBYTES)
|
||||
IMPLEMENT(blake2b, BLAKE2B_KEYBYTES)
|
||||
IMPLEMENT(blake2sp, BLAKE2S_KEYBYTES)
|
||||
IMPLEMENT(blake2bp, BLAKE2B_KEYBYTES)
|
||||
IMPLEMENT(blake2xs, BLAKE2S_KEYBYTES)
|
||||
IMPLEMENT(blake2xb, BLAKE2B_KEYBYTES)
|
||||
PIByteArray BLAKE2::blake2s(const PIByteArray & in, int out_bytes) {
|
||||
PIByteArray ret(out_bytes);
|
||||
::blake2s(ret.data(), ret.size(), in.data(), in.size(), nullptr, 0);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef IMPLEMENT
|
||||
|
||||
PIByteArray BLAKE2::blake2b(const PIByteArray & in, int out_bytes) {
|
||||
PIByteArray ret(out_bytes);
|
||||
::blake2b(ret.data(), ret.size(), in.data(), in.size(), nullptr, 0);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
PIByteArray BLAKE2::blake2sp(const PIByteArray & in, int out_bytes) {
|
||||
PIByteArray ret(out_bytes);
|
||||
::blake2sp(ret.data(), ret.size(), in.data(), in.size(), nullptr, 0);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
PIByteArray BLAKE2::blake2bp(const PIByteArray & in, int out_bytes) {
|
||||
PIByteArray ret(out_bytes);
|
||||
::blake2bp(ret.data(), ret.size(), in.data(), in.size(), nullptr, 0);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
PIByteArray BLAKE2::blake2xs(const PIByteArray & in, int out_bytes) {
|
||||
PIByteArray ret(out_bytes);
|
||||
::blake2xs(ret.data(), ret.size(), in.data(), in.size(), nullptr, 0);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
PIByteArray BLAKE2::blake2xb(const PIByteArray & in, int out_bytes) {
|
||||
PIByteArray ret(out_bytes);
|
||||
::blake2xb(ret.data(), ret.size(), in.data(), in.size(), nullptr, 0);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -24,12 +24,12 @@
|
||||
|
||||
class BLAKE2 {
|
||||
public:
|
||||
static PIByteArray blake2s(const PIByteArray & in, const PIByteArray & key, int out_bytes);
|
||||
static PIByteArray blake2b(const PIByteArray & in, const PIByteArray & key, int out_bytes);
|
||||
static PIByteArray blake2sp(const PIByteArray & in, const PIByteArray & key, int out_bytes);
|
||||
static PIByteArray blake2bp(const PIByteArray & in, const PIByteArray & key, int out_bytes);
|
||||
static PIByteArray blake2xs(const PIByteArray & in, const PIByteArray & key, int out_bytes);
|
||||
static PIByteArray blake2xb(const PIByteArray & in, const PIByteArray & key, int out_bytes);
|
||||
static PIByteArray blake2s(const PIByteArray & in, int out_bytes);
|
||||
static PIByteArray blake2b(const PIByteArray & in, int out_bytes);
|
||||
static PIByteArray blake2sp(const PIByteArray & in, int out_bytes);
|
||||
static PIByteArray blake2bp(const PIByteArray & in, int out_bytes);
|
||||
static PIByteArray blake2xs(const PIByteArray & in, int out_bytes);
|
||||
static PIByteArray blake2xb(const PIByteArray & in, int out_bytes);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -67,10 +67,10 @@ inline T shift_u(T v, int bits) {
|
||||
}
|
||||
|
||||
PIByteArray SHA2::sha2xx(const PIByteArray & in, const uint32_t * initial, int out_bytes) {
|
||||
constexpr int part_size = 64;
|
||||
constexpr int rounds = 64;
|
||||
constexpr int part_size = 64;
|
||||
constexpr int rounds = 64;
|
||||
|
||||
static constexpr uint32_t k[rounds] = {
|
||||
static constexpr uint32_t k[part_size] = {
|
||||
0x428A2F98u, 0x71374491u, 0xB5C0FBCFu, 0xE9B5DBA5u, 0x3956C25Bu, 0x59F111F1u, 0x923F82A4u, 0xAB1C5ED5u, 0xD807AA98u, 0x12835B01u,
|
||||
0x243185BEu, 0x550C7DC3u, 0x72BE5D74u, 0x80DEB1FEu, 0x9BDC06A7u, 0xC19BF174u, 0xE49B69C1u, 0xEFBE4786u, 0x0FC19DC6u, 0x240CA1CCu,
|
||||
0x2DE92C6Fu, 0x4A7484AAu, 0x5CB0A9DCu, 0x76F988DAu, 0x983E5152u, 0xA831C66Du, 0xB00327C8u, 0xBF597FC7u, 0xC6E00BF3u, 0xD5A79147u,
|
||||
@@ -150,10 +150,10 @@ PIByteArray SHA2::sha2xx(const PIByteArray & in, const uint32_t * initial, int o
|
||||
}
|
||||
|
||||
PIByteArray SHA2::sha5xx(const PIByteArray & in, const uint64_t * initial, int out_bytes) {
|
||||
constexpr int part_size = 128;
|
||||
constexpr int rounds = 80;
|
||||
constexpr int part_size = 128;
|
||||
constexpr int rounds = 80;
|
||||
|
||||
static constexpr uint64_t k[rounds] = {
|
||||
static constexpr uint64_t k[80] = {
|
||||
0X428A2F98D728AE22U, 0X7137449123EF65CDU, 0XB5C0FBCFEC4D3B2FU, 0XE9B5DBA58189DBBCU, 0X3956C25BF348B538U, 0X59F111F1B605D019U,
|
||||
0X923F82A4AF194F9BU, 0XAB1C5ED5DA6D8118U, 0XD807AA98A3030242U, 0X12835B0145706FBEU, 0X243185BE4EE4B28CU, 0X550C7DC3D5FFB4E2U,
|
||||
0X72BE5D74F27B896FU, 0X80DEB1FE3B1696B1U, 0X9BDC06A725C71235U, 0XC19BF174CF692694U, 0XE49B69C19EF14AD2U, 0XEFBE4786384F25E3U,
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Digest algorithms
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program 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 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "pidigest_siphash_p.h"
|
||||
|
||||
#include "3rd/SipHash/halfsiphash.h"
|
||||
#include "3rd/SipHash/siphash.h"
|
||||
#include "3rd/SipHash/vectors.h"
|
||||
|
||||
|
||||
PIByteArray SipHash::siphash(const PIByteArray & in, const PIByteArray & key, int out_bytes) {
|
||||
PIByteArray ret(out_bytes);
|
||||
static PIByteArray empty_key(16, 0);
|
||||
if (key.isEmpty())
|
||||
::siphash(in.data(), in.size(), empty_key.data(), ret.data(), ret.size());
|
||||
else {
|
||||
if (key.size() >= 16)
|
||||
::siphash(in.data(), in.size(), key.data(), ret.data(), ret.size());
|
||||
else {
|
||||
auto skey = key.resized(16);
|
||||
::siphash(in.data(), in.size(), skey.data(), ret.data(), ret.size());
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
PIByteArray SipHash::halfsiphash(const PIByteArray & in, const PIByteArray & key, int out_bytes) {
|
||||
PIByteArray ret(out_bytes);
|
||||
static PIByteArray empty_key(8, 0);
|
||||
if (key.isEmpty())
|
||||
::halfsiphash(in.data(), in.size(), empty_key.data(), ret.data(), ret.size());
|
||||
else {
|
||||
if (key.size() >= 8)
|
||||
::halfsiphash(in.data(), in.size(), key.data(), ret.data(), ret.size());
|
||||
else {
|
||||
auto skey = key.resized(8);
|
||||
::halfsiphash(in.data(), in.size(), skey.data(), ret.data(), ret.size());
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Digest algorithms
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program 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 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef pidigest_siphash_h
|
||||
#define pidigest_siphash_h
|
||||
|
||||
#include "pibytearray.h"
|
||||
|
||||
class SipHash {
|
||||
public:
|
||||
static PIByteArray siphash(const PIByteArray & in, const PIByteArray & key, int out_bytes);
|
||||
static PIByteArray halfsiphash(const PIByteArray & in, const PIByteArray & key, int out_bytes);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -29,53 +29,21 @@
|
||||
|
||||
#include "pimathbase.h"
|
||||
|
||||
//! \~english Geographical ellipsoid Earth model
|
||||
//! \~russian Географическая эллипсоидная модель Земли
|
||||
class PIP_EXPORT PIEllipsoidModel {
|
||||
public:
|
||||
//! \~english Default constructor
|
||||
//! \~russian Конструктор по умолчанию
|
||||
PIEllipsoidModel();
|
||||
|
||||
//! \~english Get eccentricity squared
|
||||
//! \~russian Получить квадрат эксцентриситета
|
||||
double eccSquared() const { return eccentricity * eccentricity; }
|
||||
|
||||
//! \~english Get semi-minor axis (b)
|
||||
//! \~russian Получить малую полуось (b)
|
||||
double eccSquared() const { return eccentricity * eccentricity; } // eccentricity squared
|
||||
double b() const { return a * sqrt(1 - eccSquared()); }
|
||||
|
||||
//! \~english WGS84 ellipsoid model
|
||||
//! \~russian Эллипсоид WGS84
|
||||
static PIEllipsoidModel WGS84Ellipsoid();
|
||||
|
||||
//! \~english PZ90 ellipsoid model
|
||||
//! \~russian Эллипсоид ПЗ-90
|
||||
static PIEllipsoidModel PZ90Ellipsoid();
|
||||
|
||||
//! \~english GPS ellipsoid (same as WGS84)
|
||||
//! \~russian Эллипсоид GPS (то же что WGS84)
|
||||
static PIEllipsoidModel GPSEllipsoid();
|
||||
|
||||
//! \~english Krasovskiy ellipsoid model
|
||||
//! \~russian Эллипсоид Красовского
|
||||
static PIEllipsoidModel KrasovskiyEllipsoid();
|
||||
|
||||
//! \~english Major semi-axis (meters)
|
||||
//! \~russian Большая полуось (метры)
|
||||
double a;
|
||||
|
||||
//! \~english Flattening (f = (a-b)/a)
|
||||
//! \~russian Сплюснутость (f = (a-b)/a)
|
||||
double flattening;
|
||||
|
||||
//! \~english First eccentricity
|
||||
//! \~russian Первый эксцентриситет
|
||||
double eccentricity;
|
||||
|
||||
//! \~english Angular velocity (rad/sec)
|
||||
//! \~russian Угловая скорость (рад/сек)
|
||||
double angVelocity;
|
||||
double a; /// Major axis of Earth in meters
|
||||
double flattening; /// Flattening (ellipsoid parameter)
|
||||
double eccentricity; /// Eccentricity (ellipsoid parameter)
|
||||
double angVelocity; /// Angular velocity of Earth in radians/sec
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -29,338 +29,147 @@
|
||||
#include "piellipsoidmodel.h"
|
||||
#include "pimathvector.h"
|
||||
|
||||
//! \~english Geographical position class
|
||||
//! \~russian Класс географической позиции
|
||||
class PIP_EXPORT PIGeoPosition: public PIMathVectorT3d {
|
||||
public:
|
||||
//! \~english Coordinate system types
|
||||
//! \~russian Типы систем координат
|
||||
enum CoordinateSystem {
|
||||
Unknown = 0, //!< Unknown coordinate system
|
||||
Geodetic, //!< Geodetic latitude, longitude, and height above ellipsoid
|
||||
Geocentric, //!< Geocentric (regular spherical coordinates)
|
||||
Cartesian, //!< Cartesian (Earth-centered, Earth-fixed)
|
||||
Spherical //!< Spherical coordinates (theta,phi,radius)
|
||||
Unknown = 0, /// Unknown coordinate system
|
||||
Geodetic, /// Geodetic latitude, longitude, and height above ellipsoid
|
||||
Geocentric, /// Geocentric (regular spherical coordinates)
|
||||
Cartesian, /// Cartesian (Earth-centered, Earth-fixed)
|
||||
Spherical /// Spherical coordinates (theta,phi,radius)
|
||||
};
|
||||
|
||||
//! \~english One centimeter tolerance
|
||||
//! \~russian Допуск один сантиметр
|
||||
static const double one_cm_tolerance;
|
||||
|
||||
//! \~english One millimeter tolerance
|
||||
//! \~russian Допуск один миллиметр
|
||||
static const double one_mm_tolerance;
|
||||
|
||||
//! \~english One micron tolerance
|
||||
//! \~russian Допуск один микрон
|
||||
static const double one_um_tolerance;
|
||||
|
||||
//! \~english Default position tolerance (default 1mm)
|
||||
//! \~russian Допуск позиции по умолчанию (по умолчанию 1мм)
|
||||
static double position_tolerance;
|
||||
|
||||
//! \~english Set position tolerance
|
||||
//! \~russian Установить допуск позиции
|
||||
//! \param tol New tolerance value
|
||||
//! \return Previous tolerance value
|
||||
static const double one_cm_tolerance; /// One centimeter tolerance.
|
||||
static const double one_mm_tolerance; /// One millimeter tolerance.
|
||||
static const double one_um_tolerance; /// One micron tolerance.
|
||||
static double position_tolerance; /// Default tolerance (default 1mm)
|
||||
static double setPositionTolerance(const double tol) {
|
||||
position_tolerance = tol;
|
||||
return position_tolerance;
|
||||
}
|
||||
|
||||
//! \~english Get position tolerance
|
||||
//! \~russian Получить допуск позиции
|
||||
static double getPositionTolerance() { return position_tolerance; }
|
||||
|
||||
//! \~english Default constructor
|
||||
//! \~russian Конструктор по умолчанию
|
||||
PIGeoPosition();
|
||||
|
||||
//! \~english Constructor with coordinates
|
||||
//! \~russian Конструктор с координатами
|
||||
//! \param a First coordinate
|
||||
//! \param b Second coordinate
|
||||
//! \param c Third coordinate
|
||||
//! \param s Coordinate system
|
||||
//! \param ell Ellipsoid model
|
||||
PIGeoPosition(double a, double b, double c, CoordinateSystem s = Cartesian, PIEllipsoidModel ell = PIEllipsoidModel::WGS84Ellipsoid());
|
||||
|
||||
//! \~english Constructor from vector
|
||||
//! \~russian Конструктор из вектора
|
||||
//! \param v Vector with coordinates
|
||||
//! \param s Coordinate system
|
||||
//! \param ell Ellipsoid model
|
||||
PIGeoPosition(PIMathVectorT3d v, CoordinateSystem s = Cartesian, PIEllipsoidModel ell = PIEllipsoidModel::WGS84Ellipsoid());
|
||||
|
||||
|
||||
//! \~english Transform to specified coordinate system
|
||||
//! \~russian Преобразовать в указанную систему координат
|
||||
//! \param sys Target coordinate system
|
||||
//! \return Reference to this position
|
||||
PIGeoPosition & transformTo(CoordinateSystem sys);
|
||||
|
||||
//! \~english Convert to geodetic coordinates
|
||||
//! \~russian Преобразовать в геодезические координаты
|
||||
PIGeoPosition & asGeodetic() {
|
||||
transformTo(Geodetic);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Convert to geodetic coordinates using specified ellipsoid
|
||||
//! \~russian Преобразовать в геодезические координаты с указанным эллипсоидом
|
||||
//! \param ell Ellipsoid model to use
|
||||
//! \return Reference to this position
|
||||
} /// Convert to geodetic coordinate
|
||||
PIGeoPosition & asGeodetic(const PIEllipsoidModel & ell) {
|
||||
setEllipsoidModel(ell);
|
||||
transformTo(Geodetic);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Convert to ECEF (cartesian) coordinates
|
||||
//! \~russian Преобразовать в координаты ECEF (декартовы)
|
||||
} /// Convert to another ell, then to geodetic coordinates
|
||||
PIGeoPosition & asECEF() {
|
||||
transformTo(Cartesian);
|
||||
return *this;
|
||||
}
|
||||
} /// Convert to cartesian coordinates
|
||||
|
||||
//! \~english Get X coordinate (or first coordinate in Cartesian)
|
||||
//! \~russian Получить координату X (или первую координату в Декартовой)
|
||||
double x() const;
|
||||
|
||||
//! \~english Get Y coordinate (or second coordinate in Cartesian)
|
||||
//! \~russian Получить координату Y (или вторую координату в Декартовой)
|
||||
double y() const;
|
||||
|
||||
//! \~english Get Z coordinate (or third coordinate in Cartesian)
|
||||
//! \~russian Получить координату Z (или третью координату в Декартовой)
|
||||
double z() const;
|
||||
|
||||
//! \~english Get geodetic latitude in degrees
|
||||
//! \~russian Получить геодезическую широту в градусах
|
||||
double latitudeGeodetic() const;
|
||||
|
||||
//! \~english Get geocentric latitude in degrees
|
||||
//! \~russian Получить геоцентрическую широту в градусах
|
||||
double latitudeGeocentric() const;
|
||||
|
||||
//! \~english Get longitude in degrees
|
||||
//! \~russian Получить долготу в градусах
|
||||
double longitude() const;
|
||||
|
||||
//! \~english Get theta (angle from Z axis) in degrees
|
||||
//! \~russian Получить тета (угол от оси Z) в градусах
|
||||
double theta() const;
|
||||
|
||||
//! \~english Get phi (angle in XY plane from X axis) in degrees
|
||||
//! \~russian Получить фи (угол в плоскости XY от оси X) в градусах
|
||||
double phi() const;
|
||||
|
||||
//! \~english Get radius (distance from Earth center)
|
||||
//! \~russian Получить радиус (расстояние от центра Земли)
|
||||
double radius() const;
|
||||
|
||||
//! \~english Get height above ellipsoid
|
||||
//! \~russian Получить высоту над эллипсоидом
|
||||
double height() const;
|
||||
|
||||
//! \~english Set ellipsoid model for this position
|
||||
//! \~russian Установить модель эллипсоида для этой позиции
|
||||
//! \param ell Ellipsoid model
|
||||
/// Set the ellipsoid values for this PIGeoPosition given a ellipsoid.
|
||||
void setEllipsoidModel(const PIEllipsoidModel & ell) { el = ell; }
|
||||
|
||||
//! \~english Set position from geodetic coordinates
|
||||
//! \~russian Установить позицию из геодезических координат
|
||||
//! \param lat Latitude in degrees
|
||||
//! \param lon Longitude in degrees
|
||||
//! \param ht Height above ellipsoid
|
||||
//! \param ell Ellipsoid model (default WGS84)
|
||||
//! \return Reference to this position
|
||||
/// Set the \a PIGeoPosition given geodetic coordinates in degrees. \a CoordinateSystem is set to \a Geodetic.
|
||||
PIGeoPosition & setGeodetic(double lat, double lon, double ht, PIEllipsoidModel ell = PIEllipsoidModel::WGS84Ellipsoid());
|
||||
|
||||
//! \~english Set position from geocentric coordinates
|
||||
//! \~russian Установить позицию из геоцентрических координат
|
||||
//! \param lat Latitude in degrees
|
||||
//! \param lon Longitude in degrees
|
||||
//! \param rad Radius
|
||||
//! \return Reference to this position
|
||||
/// Set the \a PIGeoPosition given geocentric coordinates in degrees. \a CoordinateSystem is set to \a Geocentric
|
||||
PIGeoPosition & setGeocentric(double lat, double lon, double rad);
|
||||
|
||||
//! \~english Set position from spherical coordinates
|
||||
//! \~russian Установить позицию из сферических координат
|
||||
//! \param theta Angle from Z axis in degrees
|
||||
//! \param phi Angle in XY plane from X axis in degrees
|
||||
//! \param rad Radius
|
||||
//! \return Reference to this position
|
||||
/// Set the \a PIGeoPosition given spherical coordinates in degrees. \a CoordinateSystem is set to \a Spherical
|
||||
PIGeoPosition & setSpherical(double theta, double phi, double rad);
|
||||
|
||||
//! \~english Set position from ECEF coordinates
|
||||
//! \~russian Установить позицию из координат ECEF
|
||||
//! \param x X coordinate in meters
|
||||
//! \param y Y coordinate in meters
|
||||
//! \param z Z coordinate in meters
|
||||
//! \return Reference to this position
|
||||
/// Set the \a PIGeoPosition given ECEF coordinates in meeters. \a CoordinateSystem is set to \a Cartesian.
|
||||
PIGeoPosition & setECEF(double x, double y, double z);
|
||||
|
||||
//! \~english Convert spherical to Cartesian coordinates
|
||||
//! \~russian Преобразовать сферические в декартовы координаты
|
||||
//! \param tpr Input spherical (theta, phi, radius)
|
||||
//! \param xyz Output Cartesian (x, y, z)
|
||||
/// Fundamental conversion from spherical to cartesian coordinates.
|
||||
static void convertSphericalToCartesian(const PIMathVectorT3d & tpr, PIMathVectorT3d & xyz);
|
||||
|
||||
//! \~english Convert Cartesian to spherical coordinates
|
||||
//! \~russian Преобразовать декартовы в сферические координаты
|
||||
//! \param xyz Input Cartesian (x, y, z)
|
||||
//! \param tpr Output spherical (theta, phi, radius)
|
||||
/// Fundamental routine to convert cartesian to spherical coordinates.
|
||||
static void convertCartesianToSpherical(const PIMathVectorT3d & xyz, PIMathVectorT3d & tpr);
|
||||
|
||||
//! \~english Convert Cartesian (ECEF) to geodetic coordinates
|
||||
//! \~russian Преобразовать декартовы (ECEF) в геодезические координаты
|
||||
//! \param xyz Input Cartesian (x, y, z)
|
||||
//! \param llh Output geodetic (latitude, longitude, height)
|
||||
//! \param ell Ellipsoid model (default WGS84)
|
||||
/// Fundamental routine to convert ECEF (cartesian) to geodetic coordinates,
|
||||
static void convertCartesianToGeodetic(const PIMathVectorT3d & xyz,
|
||||
PIMathVectorT3d & llh,
|
||||
PIEllipsoidModel ell = PIEllipsoidModel::WGS84Ellipsoid());
|
||||
|
||||
//! \~english Convert geodetic to Cartesian (ECEF) coordinates
|
||||
//! \~russian Преобразовать геодезические в декартовы (ECEF) координаты
|
||||
//! \param llh Input geodetic (latitude, longitude, height)
|
||||
//! \param xyz Output Cartesian (x, y, z)
|
||||
//! \param ell Ellipsoid model (default WGS84)
|
||||
/// Fundamental routine to convert geodetic to ECEF (cartesian) coordinates,
|
||||
static void convertGeodeticToCartesian(const PIMathVectorT3d & llh,
|
||||
PIMathVectorT3d & xyz,
|
||||
PIEllipsoidModel ell = PIEllipsoidModel::WGS84Ellipsoid());
|
||||
|
||||
//! \~english Convert Cartesian (ECEF) to geocentric coordinates
|
||||
//! \~russian Преобразовать декартовы (ECEF) в геоцентрические координаты
|
||||
//! \param xyz Input Cartesian (x, y, z)
|
||||
//! \param llr Output geocentric (latitude, longitude, radius)
|
||||
/// Fundamental routine to convert cartesian (ECEF) to geocentric
|
||||
static void convertCartesianToGeocentric(const PIMathVectorT3d & xyz, PIMathVectorT3d & llr);
|
||||
|
||||
//! \~english Convert geocentric to Cartesian (ECEF)
|
||||
//! \~russian Преобразовать геоцентрические в декартовы (ECEF)
|
||||
//! \param llr Input geocentric (latitude, longitude, radius)
|
||||
//! \param xyz Output Cartesian (x, y, z)
|
||||
/// Fundamental routine to convert geocentric to cartesian (ECEF)
|
||||
static void convertGeocentricToCartesian(const PIMathVectorT3d & llr, PIMathVectorT3d & xyz);
|
||||
|
||||
//! \~english Convert geocentric to geodetic
|
||||
//! \~russian Преобразовать геоцентрические в геодезические
|
||||
//! \param llr Input geocentric (latitude, longitude, radius)
|
||||
//! \param llh Output geodetic (latitude, longitude, height)
|
||||
//! \param ell Ellipsoid model (default WGS84)
|
||||
/// Fundamental routine to convert geocentric to geodetic
|
||||
static void convertGeocentricToGeodetic(const PIMathVectorT3d & llr,
|
||||
PIMathVectorT3d & llh,
|
||||
PIEllipsoidModel ell = PIEllipsoidModel::WGS84Ellipsoid());
|
||||
|
||||
//! \~english Convert geodetic to geocentric
|
||||
//! \~russian Преобразовать геодезические в геоцентрические
|
||||
//! \param llh Input geodetic (latitude, longitude, height)
|
||||
//! \param llr Output geocentric (latitude, longitude, radius)
|
||||
//! \param ell Ellipsoid model (default WGS84)
|
||||
/// Fundamental routine to convert geodetic to geocentric
|
||||
static void convertGeodeticToGeocentric(const PIMathVectorT3d & llh,
|
||||
PIMathVectorT3d & llr,
|
||||
PIEllipsoidModel ell = PIEllipsoidModel::WGS84Ellipsoid());
|
||||
|
||||
//! \~english Compute radius of ellipsoid at given latitude
|
||||
//! \~russian Вычислить радиус эллипсоида на заданной широте
|
||||
//! \param geolat Geodetic latitude in degrees
|
||||
//! \param ell Ellipsoid model (default WGS84)
|
||||
//! \return Radius in meters
|
||||
/// Compute the radius of the ellipsoidal Earth, given the geodetic latitude.
|
||||
static double radiusEarth(double geolat, PIEllipsoidModel ell = PIEllipsoidModel::WGS84Ellipsoid());
|
||||
|
||||
//! \~english Compute radius of ellipsoid at current position
|
||||
//! \~russian Вычислить радиус эллипсоида в текущей позиции
|
||||
double radiusEarth() const {
|
||||
PIGeoPosition p(*this);
|
||||
p.transformTo(PIGeoPosition::Geodetic);
|
||||
return PIGeoPosition::radiusEarth((*this)[0], p.el);
|
||||
}
|
||||
|
||||
//! \~english Compute range between two positions
|
||||
//! \~russian Вычислить расстояние между двумя позициями
|
||||
//! \param a First position
|
||||
//! \param b Second position
|
||||
//! \return Range in meters
|
||||
/// Compute the range in meters between two PIGeoPositions.
|
||||
static double range(const PIGeoPosition & a, const PIGeoPosition & b);
|
||||
|
||||
//! \~english Compute range from this position to another
|
||||
//! \~russian Вычислить расстояние от этой позиции до другой
|
||||
//! \param p Target position
|
||||
//! \return Range in meters
|
||||
double range(const PIGeoPosition & p) const { return range((*this), p); }
|
||||
|
||||
//! \~english Compute elevation angle to target position
|
||||
//! \~russian Вычислить угол возвышения до целевой позиции
|
||||
//! \param p Target position
|
||||
//! \return Elevation angle in degrees
|
||||
/// Computes the elevation of the input (p) position as seen from this PIGeoPosition.
|
||||
double elevation(const PIGeoPosition & p) const;
|
||||
|
||||
//! \~english Compute geodetic elevation angle to target position
|
||||
//! \~russian Вычислить геодезический угол возвышения до целевой позиции
|
||||
//! \param p Target position
|
||||
//! \return Elevation angle in degrees
|
||||
/// Computes the elevation of the input (p) position as seen from this PIGeoPosition, using a Geodetic (ellipsoidal) system.
|
||||
double elevationGeodetic(const PIGeoPosition & p) const;
|
||||
|
||||
//! \~english Compute azimuth angle to target position
|
||||
//! \~russian Вычислить азимут до целевой позиции
|
||||
//! \param p Target position
|
||||
//! \return Azimuth angle in degrees
|
||||
/// Computes the azimuth of the input (p) position as seen from this PIGeoPosition.
|
||||
double azimuth(const PIGeoPosition & p) const;
|
||||
|
||||
//! \~english Compute geodetic azimuth angle to target position
|
||||
//! \~russian Вычислить геодезический азимут до целевой позиции
|
||||
//! \param p Target position
|
||||
//! \return Azimuth angle in degrees
|
||||
/// Computes the azimuth of the input (p) position as seen from this PIGeoPosition, using a Geodetic (ellipsoidal) system.
|
||||
double azimuthGeodetic(const PIGeoPosition & p) const;
|
||||
|
||||
//! \~english Get radius of curvature of the meridian
|
||||
//! \~russian Получить радиус кривизны меридиана
|
||||
//! \return Radius in meters
|
||||
/// Computes the radius of curvature of the meridian (Rm) corresponding to this PIGeoPosition.
|
||||
double getCurvMeridian() const;
|
||||
|
||||
//! \~english Get radius of curvature in the prime vertical
|
||||
//! \~russian Получить радиус кривизны в вертикале
|
||||
//! \return Radius in meters
|
||||
/// Computes the radius of curvature in the prime vertical (Rn) corresponding to this PIGeoPosition.
|
||||
double getCurvPrimeVertical() const;
|
||||
|
||||
//! \~english Get as PIMathVectorT3d
|
||||
//! \~russian Получить как PIMathVectorT3d
|
||||
//! \return Reference to underlying vector
|
||||
/// Returns as PIMathVectorT3d
|
||||
const PIMathVectorT3d & vector() const { return *this; }
|
||||
|
||||
//! \~english Assignment from vector
|
||||
//! \~russian Присваивание из вектора
|
||||
PIGeoPosition & operator=(const PIMathVectorT3d & v);
|
||||
|
||||
//! \~english Subtraction
|
||||
//! \~russian Вычитание
|
||||
PIGeoPosition & operator-=(const PIGeoPosition & right);
|
||||
|
||||
//! \~english Addition
|
||||
//! \~russian Сложение
|
||||
PIGeoPosition & operator+=(const PIGeoPosition & right);
|
||||
|
||||
//! \~english Subtraction
|
||||
//! \~russian Вычитание
|
||||
friend PIGeoPosition operator-(const PIGeoPosition & left, const PIGeoPosition & right);
|
||||
|
||||
//! \~english Addition
|
||||
//! \~russian Сложение
|
||||
friend PIGeoPosition operator+(const PIGeoPosition & left, const PIGeoPosition & right);
|
||||
|
||||
//! \~english Scalar multiplication
|
||||
//! \~russian Умножение на скаляр
|
||||
friend PIGeoPosition operator*(const double & scale, const PIGeoPosition & right);
|
||||
friend PIGeoPosition operator*(const PIGeoPosition & left, const double & scale);
|
||||
friend PIGeoPosition operator*(const int & scale, const PIGeoPosition & right);
|
||||
friend PIGeoPosition operator*(const PIGeoPosition & left, const int & scale);
|
||||
|
||||
//! \~english Equality comparison
|
||||
//! \~russian Сравнение на равенство
|
||||
bool operator==(const PIGeoPosition & right) const;
|
||||
|
||||
//! \~english Inequality comparison
|
||||
//! \~russian Сравнение на неравенство
|
||||
bool operator!=(const PIGeoPosition & right) const { return !(operator==(right)); }
|
||||
|
||||
|
||||
|
||||
@@ -13,51 +13,51 @@ public:
|
||||
};
|
||||
|
||||
|
||||
//! \~english Main HTTP client class for performing requests with event callbacks.
|
||||
//! \~russian Основной класс HTTP-клиента для выполнения запросов с callback-ми событий.
|
||||
//! ~english Main HTTP client class for performing requests with event callbacks.
|
||||
//! ~russian Основной класс HTTP-клиента для выполнения запросов с callback-ми событий.
|
||||
class PIP_HTTP_CLIENT_EXPORT PIHTTPClient: private PIHTTPClientBase {
|
||||
friend class PIHTTPClientBase;
|
||||
friend class CurlThreadPool;
|
||||
|
||||
public:
|
||||
//! \~english Creates a new HTTP request instance with the specified URL, method and message.
|
||||
//! \~russian Создает новый экземпляр HTTP-запроса с указанным URL, методом и сообщением.
|
||||
//! ~english Creates a new HTTP request instance with the specified URL, method and message.
|
||||
//! ~russian Создает новый экземпляр HTTP-запроса с указанным URL, методом и сообщением.
|
||||
static PIHTTPClient * create(const PIString & url, PIHTTP::Method method = PIHTTP::Method::Get, const PIHTTP::MessageConst & req = {});
|
||||
|
||||
//! \~english Sets a callback for successful request completion (no parameters).
|
||||
//! \~russian Устанавливает callback для успешного завершения запроса (без параметров).
|
||||
//! ~english Sets a callback for successful request completion (no parameters).
|
||||
//! ~russian Устанавливает callback для успешного завершения запроса (без параметров).
|
||||
PIHTTPClient * onFinish(std::function<void()> f);
|
||||
|
||||
//! \~english Sets a callback for successful request completion (with response).
|
||||
//! \~russian Устанавливает callback для успешного завершения запроса (с ответом).
|
||||
//! ~english Sets a callback for successful request completion (with response).
|
||||
//! ~russian Устанавливает callback для успешного завершения запроса (с ответом).
|
||||
PIHTTPClient * onFinish(std::function<void(const PIHTTP::MessageConst &)> f);
|
||||
|
||||
//! \~english Sets a callback for request errors (no parameters).
|
||||
//! \~russian Устанавливает callback для ошибок запроса (без параметров).
|
||||
//! ~english Sets a callback for request errors (no parameters).
|
||||
//! ~russian Устанавливает callback для ошибок запроса (без параметров).
|
||||
PIHTTPClient * onError(std::function<void()> f);
|
||||
|
||||
//! \~english Sets a callback for request errors (with error response).
|
||||
//! \~russian Устанавливает callback для ошибок запроса (с ответом об ошибке).
|
||||
//! ~english Sets a callback for request errors (with error response).
|
||||
//! ~russian Устанавливает callback для ошибок запроса (с ответом об ошибке).
|
||||
PIHTTPClient * onError(std::function<void(const PIHTTP::MessageConst &)> f);
|
||||
|
||||
//! \~english Sets a callback for request abortion (no parameters).
|
||||
//! \~russian Устанавливает callback для прерывания запроса (без параметров).
|
||||
//! ~english Sets a callback for request abortion (no parameters).
|
||||
//! ~russian Устанавливает callback для прерывания запроса (без параметров).
|
||||
PIHTTPClient * onAbort(std::function<void()> f);
|
||||
|
||||
//! \~english Sets a callback for request abortion (with abort response).
|
||||
//! \~russian Устанавливает callback для прерывания запроса (с ответом о прерывании).
|
||||
//! ~english Sets a callback for request abortion (with abort response).
|
||||
//! ~russian Устанавливает callback для прерывания запроса (с ответом о прерывании).
|
||||
PIHTTPClient * onAbort(std::function<void(const PIHTTP::MessageConst &)> f);
|
||||
|
||||
//! \~english Starts the HTTP request execution.
|
||||
//! \~russian Начинает выполнение HTTP-запроса.
|
||||
//! ~english Starts the HTTP request execution.
|
||||
//! ~russian Начинает выполнение HTTP-запроса.
|
||||
void start();
|
||||
|
||||
//! \~english Aborts the current HTTP request.
|
||||
//! \~russian Прерывает текущий HTTP-запрос.
|
||||
//! ~english Aborts the current HTTP request.
|
||||
//! ~russian Прерывает текущий HTTP-запрос.
|
||||
void abort();
|
||||
|
||||
//! \~english Returns the last error message.
|
||||
//! \~russian Возвращает последнее сообщение об ошибке.
|
||||
//! ~english Returns the last error message.
|
||||
//! ~russian Возвращает последнее сообщение об ошибке.
|
||||
PIString lastError() const { return last_error; }
|
||||
|
||||
private:
|
||||
|
||||
@@ -9,68 +9,68 @@
|
||||
namespace PIHTTP {
|
||||
|
||||
|
||||
//! \~english Immutable HTTP message container with accessors for message components
|
||||
//! \~russian Контейнер для неизменяемого HTTP-сообщения с методами доступа к компонентам
|
||||
//! ~english Immutable HTTP message container with accessors for message components
|
||||
//! ~russian Контейнер для неизменяемого HTTP-сообщения с методами доступа к компонентам
|
||||
class PIP_EXPORT MessageConst {
|
||||
public:
|
||||
//! \~english Gets the HTTP method used in the message
|
||||
//! \~russian Возвращает HTTP-метод, использованный в сообщении
|
||||
//! ~english Gets the HTTP method used in the message
|
||||
//! ~russian Возвращает HTTP-метод, использованный в сообщении
|
||||
PIHTTP::Method method() const { return m_method; }
|
||||
|
||||
//! \~english Gets the HTTP status code
|
||||
//! \~russian Возвращает HTTP-статус код
|
||||
//! ~english Gets the HTTP status code
|
||||
//! ~russian Возвращает HTTP-статус код
|
||||
PIHTTP::Code code() const { return m_code; }
|
||||
|
||||
//! \~english Checks if status code is informational (1xx)
|
||||
//! \~russian Проверяет, является ли статус код информационным (1xx)
|
||||
//! ~english Checks if status code is informational (1xx)
|
||||
//! ~russian Проверяет, является ли статус код информационным (1xx)
|
||||
bool isCodeInformational() const;
|
||||
|
||||
//! \~english Checks if status code indicates success (2xx)
|
||||
//! \~russian Проверяет, указывает ли статус код на успех (2xx)
|
||||
//! ~english Checks if status code indicates success (2xx)
|
||||
//! ~russian Проверяет, указывает ли статус код на успех (2xx)
|
||||
bool isCodeSuccess() const;
|
||||
|
||||
//! \~english Checks if status code indicates redirection (3xx)
|
||||
//! \~russian Проверяет, указывает ли статус код на перенаправление (3xx)
|
||||
//! ~english Checks if status code indicates redirection (3xx)
|
||||
//! ~russian Проверяет, указывает ли статус код на перенаправление (3xx)
|
||||
bool isCodeRedirection() const;
|
||||
|
||||
//! \~english Checks if status code indicates client error (4xx)
|
||||
//! \~russian Проверяет, указывает ли статус код на ошибку клиента (4xx)
|
||||
//! ~english Checks if status code indicates client error (4xx)
|
||||
//! ~russian Проверяет, указывает ли статус код на ошибку клиента (4xx)
|
||||
bool isCodeClientError() const;
|
||||
|
||||
//! \~english Checks if status code indicates server error (5xx)
|
||||
//! \~russian Проверяет, указывает ли статус код на ошибку сервера (5xx)
|
||||
//! ~english Checks if status code indicates server error (5xx)
|
||||
//! ~russian Проверяет, указывает ли статус код на ошибку сервера (5xx)
|
||||
bool isCodeServerError() const;
|
||||
|
||||
//! \~english Checks if status code indicates any error (4xx or 5xx)
|
||||
//! \~russian Проверяет, указывает ли статус код на любую ошибку (4xx или 5xx)
|
||||
//! ~english Checks if status code indicates any error (4xx or 5xx)
|
||||
//! ~russian Проверяет, указывает ли статус код на любую ошибку (4xx или 5xx)
|
||||
bool isCodeError() const { return isCodeClientError() || isCodeServerError(); }
|
||||
|
||||
//! \~english Gets the request/response path
|
||||
//! \~russian Возвращает путь запроса/ответа
|
||||
//! ~english Gets the request/response path
|
||||
//! ~russian Возвращает путь запроса/ответа
|
||||
const PIString & path() const { return m_path; }
|
||||
|
||||
//! \~english Gets path components as list
|
||||
//! \~russian Возвращает компоненты пути в виде списка
|
||||
//! ~english Gets path components as list
|
||||
//! ~russian Возвращает компоненты пути в виде списка
|
||||
PIStringList pathList() const { return m_path.split('/').removeAll({}); }
|
||||
|
||||
//! \~english Gets the message body
|
||||
//! \~russian Возвращает тело сообщения
|
||||
//! ~english Gets the message body
|
||||
//! ~russian Возвращает тело сообщения
|
||||
const PIByteArray & body() const { return m_body; }
|
||||
|
||||
//! \~english Gets all message headers
|
||||
//! \~russian Возвращает все заголовки сообщения
|
||||
//! ~english Gets all message headers
|
||||
//! ~russian Возвращает все заголовки сообщения
|
||||
const PIMap<PIString, PIString> & headers() const { return m_headers; }
|
||||
|
||||
//! \~english Gets URL query arguments
|
||||
//! \~russian Возвращает URL query аргументы
|
||||
//! ~english Gets URL query arguments
|
||||
//! ~russian Возвращает URL query аргументы
|
||||
const PIMap<PIString, PIString> & queryArguments() const { return m_query_arguments; }
|
||||
|
||||
//! \~english Gets URL path arguments
|
||||
//! \~russian Возвращает URL path аргументы
|
||||
//! ~english Gets URL path arguments
|
||||
//! ~russian Возвращает URL path аргументы
|
||||
const PIMap<PIString, PIString> & pathArguments() const { return m_path_arguments; }
|
||||
|
||||
//! \~english Gets all message arguments (query + path)
|
||||
//! \~russian Возвращает все аргументы сообщения (query + path)
|
||||
//! ~english Gets all message arguments (query + path)
|
||||
//! ~russian Возвращает все аргументы сообщения (query + path)
|
||||
const PIMap<PIString, PIString> & arguments() const { return m_arguments; }
|
||||
|
||||
protected:
|
||||
@@ -83,24 +83,24 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
//! \~english Mutable HTTP message container with modifiers for message components
|
||||
//! \~russian Контейнер для изменяемого HTTP-сообщения с методами модификации
|
||||
//! ~english Mutable HTTP message container with modifiers for message components
|
||||
//! ~russian Контейнер для изменяемого HTTP-сообщения с методами модификации
|
||||
class PIP_EXPORT MessageMutable: public MessageConst {
|
||||
public:
|
||||
//! \~english Sets the HTTP method
|
||||
//! \~russian Устанавливает HTTP-метод
|
||||
//! ~english Sets the HTTP method
|
||||
//! ~russian Устанавливает HTTP-метод
|
||||
MessageMutable & setMethod(PIHTTP::Method m);
|
||||
|
||||
//! \~english Sets the HTTP status code
|
||||
//! \~russian Устанавливает HTTP-статус код
|
||||
//! ~english Sets the HTTP status code
|
||||
//! ~russian Устанавливает HTTP-статус код
|
||||
MessageMutable & setCode(PIHTTP::Code c);
|
||||
|
||||
//! \~english Sets the request/response path
|
||||
//! \~russian Устанавливает путь запроса/ответа
|
||||
//! ~english Sets the request/response path
|
||||
//! ~russian Устанавливает путь запроса/ответа
|
||||
MessageMutable & setPath(PIString p);
|
||||
|
||||
//! \~english Sets the message body
|
||||
//! \~russian Устанавливает тело сообщения
|
||||
//! ~english Sets the message body
|
||||
//! ~russian Устанавливает тело сообщения
|
||||
MessageMutable & setBody(PIByteArray b);
|
||||
|
||||
const PIMap<PIString, PIString> & headers() const { return m_headers; }
|
||||
@@ -111,50 +111,50 @@ public:
|
||||
|
||||
PIMap<PIString, PIString> & headers() { return m_headers; }
|
||||
|
||||
//! \~english Adds a header to the message
|
||||
//! \~russian Добавляет заголовок к сообщению
|
||||
//! ~english Adds a header to the message
|
||||
//! ~russian Добавляет заголовок к сообщению
|
||||
MessageMutable & addHeader(const PIString & header, const PIString & value);
|
||||
|
||||
//! \~english Removes a header from the message
|
||||
//! \~russian Удаляет заголовок из сообщения
|
||||
//! ~english Removes a header from the message
|
||||
//! ~russian Удаляет заголовок из сообщения
|
||||
MessageMutable & removeHeader(const PIString & header);
|
||||
|
||||
//! \~english Gets reference to URL query arguments
|
||||
//! \~russian Возвращает ссылку на URL query аргументы
|
||||
//! ~english Gets reference to URL query arguments
|
||||
//! ~russian Возвращает ссылку на URL query аргументы
|
||||
PIMap<PIString, PIString> & queryArguments() { return m_query_arguments; }
|
||||
|
||||
//! \~english Adds an URL query argument to the message
|
||||
//! \~russian Добавляет URL query аргумент к сообщению
|
||||
//! ~english Adds an URL query argument to the message
|
||||
//! ~russian Добавляет URL query аргумент к сообщению
|
||||
MessageMutable & addQueryArgument(const PIString & arg, const PIString & value);
|
||||
|
||||
//! \~english Removes an URL query argument from the message
|
||||
//! \~russian Удаляет URL query аргумент из сообщения
|
||||
//! ~english Removes an URL query argument from the message
|
||||
//! ~russian Удаляет URL query аргумент из сообщения
|
||||
MessageMutable & removeQueryArgument(const PIString & arg);
|
||||
|
||||
//! \~english Gets reference to URL path arguments
|
||||
//! \~russian Возвращает ссылку на URL path аргументы
|
||||
//! ~english Gets reference to URL path arguments
|
||||
//! ~russian Возвращает ссылку на URL path аргументы
|
||||
PIMap<PIString, PIString> & pathArguments() { return m_path_arguments; }
|
||||
|
||||
//! \~english Adds an URL path argument to the message
|
||||
//! \~russian Добавляет URL path аргумент к сообщению
|
||||
//! ~english Adds an URL path argument to the message
|
||||
//! ~russian Добавляет URL path аргумент к сообщению
|
||||
MessageMutable & addPathArgument(const PIString & arg, const PIString & value);
|
||||
|
||||
//! \~english Removes an URL path argument from the message
|
||||
//! \~russian Удаляет URL query path из сообщения
|
||||
//! ~english Removes an URL path argument from the message
|
||||
//! ~russian Удаляет URL query path из сообщения
|
||||
MessageMutable & removePathArgument(const PIString & arg);
|
||||
|
||||
//! \~english Creates message from HTTP status code
|
||||
//! \~russian Создает сообщение из HTTP-статус кода
|
||||
//! ~english Creates message from HTTP status code
|
||||
//! ~russian Создает сообщение из HTTP-статус кода
|
||||
static MessageMutable fromCode(PIHTTP::Code c);
|
||||
|
||||
//! \~english Creates message from HTTP method
|
||||
//! \~russian Создает сообщение из HTTP-метода
|
||||
//! ~english Creates message from HTTP method
|
||||
//! ~russian Создает сообщение из HTTP-метода
|
||||
static MessageMutable fromMethod(PIHTTP::Method m);
|
||||
};
|
||||
|
||||
|
||||
//! \~english Gets string representation of HTTP method
|
||||
//! \~russian Возвращает строковое представление HTTP-метода
|
||||
//! ~english Gets string representation of HTTP method
|
||||
//! ~russian Возвращает строковое представление HTTP-метода
|
||||
PIP_EXPORT const char * methodName(Method m);
|
||||
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
struct MicrohttpdServerConnection;
|
||||
|
||||
//! \~english Base HTTP server class implementing core functionality
|
||||
//! \~russian Базовый класс HTTP сервера, реализующий основную функциональность
|
||||
//! ~english Base HTTP server class implementing core functionality
|
||||
//! ~runnan Базовый класс HTTP сервера, реализующий основную функциональность
|
||||
class PIP_HTTP_SERVER_EXPORT MicrohttpdServer: public PIObject {
|
||||
PIOBJECT(MicrohttpdServer)
|
||||
friend struct MicrohttpdServerConnection;
|
||||
@@ -17,75 +17,75 @@ public:
|
||||
MicrohttpdServer();
|
||||
virtual ~MicrohttpdServer();
|
||||
|
||||
//! \~english Server configuration options
|
||||
//! \~russian Опции конфигурации сервера
|
||||
//! ~english Server configuration options
|
||||
//! ~russian Опции конфигурации сервера
|
||||
enum class Option {
|
||||
ConnectionLimit, //!< \~english Maximum concurrent connections
|
||||
//!< \~russian Максимальное количество соединений
|
||||
ConnectionTimeout, //!< \~english Connection timeout in seconds
|
||||
//!< \~russian Таймаут соединения в секундах
|
||||
HTTPSEnabled, //!< \~english Enable HTTPS support
|
||||
//!< \~russian Включить поддержку HTTPS
|
||||
HTTPSMemKey, //!< \~english SSL key in memory (PIByteArray)
|
||||
//!< \~russian SSL ключ в памяти (PIByteArray)
|
||||
HTTPSMemCert, //!< \~english SSL certificate in memory (PIByteArray)
|
||||
//!< \~russian SSL сертификат в памяти (PIByteArray)
|
||||
HTTPSKeyPassword //!< \~english SSL key password (PIByteArray)
|
||||
//!< \~russian Пароль SSL ключа (PIByteArray)
|
||||
ConnectionLimit, //!< ~english Maximum concurrent connections
|
||||
//!< ~russian Максимальное количество соединений
|
||||
ConnectionTimeout, //!< ~english Connection timeout in seconds
|
||||
//!< ~russian Таймаут соединения в секундах
|
||||
HTTPSEnabled, //!< ~english Enable HTTPS support
|
||||
//!< ~russian Включить поддержку HTTPS
|
||||
HTTPSMemKey, //!< ~english SSL key in memory (PIByteArray)
|
||||
//!< ~russian SSL ключ в памяти (PIByteArray)
|
||||
HTTPSMemCert, //!< ~english SSL certificate in memory (PIByteArray)
|
||||
//!< ~russian SSL сертификат в памяти (PIByteArray)
|
||||
HTTPSKeyPassword //!< ~english SSL key password (PIByteArray)
|
||||
//!< ~russian Пароль SSL ключа (PIByteArray)
|
||||
};
|
||||
|
||||
//! \~english Sets server option
|
||||
//! \~russian Устанавливает опцию сервера
|
||||
//! ~english Sets server option
|
||||
//! ~russian Устанавливает опцию сервера
|
||||
void setOption(Option o, PIVariant v);
|
||||
|
||||
//! \~english Sets server favicon
|
||||
//! \~russian Устанавливает фавикон сервера
|
||||
//! ~english Sets server favicon
|
||||
//! ~russian Устанавливает фавикон сервера
|
||||
void setFavicon(const PIByteArray & im);
|
||||
|
||||
|
||||
//! \~english Starts server on specified address
|
||||
//! \~russian Запускает сервер на указанном адресе
|
||||
//! ~english Starts server on specified address
|
||||
//! ~russian Запускает сервер на указанном адресе
|
||||
bool listen(PINetworkAddress addr);
|
||||
|
||||
//! \~english Starts server on all interfaces
|
||||
//! \~russian Запускает сервер на всех интерфейсах
|
||||
//! ~english Starts server on all interfaces
|
||||
//! ~russian Запускает сервер на всех интерфейсах
|
||||
bool listenAll(ushort port) { return listen({0, port}); }
|
||||
|
||||
//! \~english Checks if server is running
|
||||
//! \~russian Проверяет, работает ли сервер
|
||||
//! ~english Checks if server is running
|
||||
//! ~russian Проверяет, работает ли сервер
|
||||
bool isListen() const;
|
||||
|
||||
//! \~english Stops the server
|
||||
//! \~russian Останавливает сервер
|
||||
//! ~english Stops the server
|
||||
//! ~russian Останавливает сервер
|
||||
void stop();
|
||||
|
||||
|
||||
//! \~english Enables basic authentication
|
||||
//! \~russian Включает базовую аутентификацию
|
||||
//! ~english Enables basic authentication
|
||||
//! ~russian Включает базовую аутентификацию
|
||||
void enableBasicAuth() { setBasicAuthEnabled(true); }
|
||||
|
||||
//! \~english Disables basic authentication
|
||||
//! \~russian Выключает базовую аутентификацию
|
||||
//! ~english Disables basic authentication
|
||||
//! ~russian Выключает базовую аутентификацию
|
||||
void disableBasicAuth() { setBasicAuthEnabled(false); }
|
||||
|
||||
//! \~english Set basic authentication enabled to "yes"
|
||||
//! \~russian Устанавливает базовую аутентификацию в "yes"
|
||||
//! ~english Set basic authentication enabled to "yes"
|
||||
//! ~russian Устанавливает базовую аутентификацию в "yes"
|
||||
void setBasicAuthEnabled(bool yes) { use_basic_auth = yes; }
|
||||
|
||||
//! \~english Return if basic authentication enabled
|
||||
//! \~russian Возвращает включена ли базовая аутентификация
|
||||
//! ~english Return if basic authentication enabled
|
||||
//! ~russian Возвращает включена ли базовая аутентификация
|
||||
bool isBasicAuthEnabled() const { return use_basic_auth; }
|
||||
|
||||
//! \~english Sets basic authentication realm
|
||||
//! \~russian Устанавливает область аутентификации
|
||||
//! ~english Sets basic authentication realm
|
||||
//! ~russian Устанавливает область аутентификации
|
||||
void setBasicAuthRealm(const PIString & r) { realm = r; }
|
||||
|
||||
//! \~english Sets request processing callback
|
||||
//! \~russian Устанавливает callback для обработки запросов
|
||||
//! ~english Sets request processing callback
|
||||
//! ~russian Устанавливает callback для обработки запросов
|
||||
void setRequestCallback(std::function<PIHTTP::MessageMutable(const PIHTTP::MessageConst &)> c) { callback = c; }
|
||||
|
||||
//! \~english Sets basic authentication callback
|
||||
//! \~russian Устанавливает callback для базовой аутентификации
|
||||
//! ~english Sets basic authentication callback
|
||||
//! ~russian Устанавливает callback для базовой аутентификации
|
||||
void setBasicAuthCallback(std::function<bool(const PIString &, const PIString &)> c) { callback_auth = c; }
|
||||
|
||||
private:
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
#include "microhttpd_server.h"
|
||||
|
||||
//! \~english HTTP server
|
||||
//! \~russian HTTP сервер
|
||||
//! ~english HTTP server
|
||||
//! ~russian HTTP сервер
|
||||
class PIP_HTTP_SERVER_EXPORT PIHTTPServer: public MicrohttpdServer {
|
||||
PIOBJECT_SUBCLASS(PIHTTPServer, MicrohttpdServer)
|
||||
|
||||
@@ -15,12 +15,12 @@ public:
|
||||
using RequestFunction = std::function<PIHTTP::MessageMutable(const PIHTTP::MessageConst &)>;
|
||||
|
||||
|
||||
//! \~english Registers handler for specific path and HTTP method
|
||||
//! \~russian Регистрирует обработчик для указанного пути и HTTP метода
|
||||
//! ~english Registers handler for specific path and HTTP method
|
||||
//! ~russian Регистрирует обработчик для указанного пути и HTTP метода
|
||||
bool registerPath(const PIString & path, PIHTTP::Method method, RequestFunction functor);
|
||||
|
||||
//! \~english Registers handler for specific path and HTTP method
|
||||
//! \~russian Регистрирует обработчик для указанного пути и HTTP метода
|
||||
//! ~english Registers handler for specific path and HTTP method
|
||||
//! ~russian Регистрирует обработчик для указанного пути и HTTP метода
|
||||
template<typename T>
|
||||
bool
|
||||
registerPath(const PIString & path, PIHTTP::Method method, T * o, PIHTTP::MessageMutable (T::*function)(const PIHTTP::MessageConst &)) {
|
||||
@@ -28,36 +28,36 @@ public:
|
||||
}
|
||||
|
||||
|
||||
//! \~english Registers handler for unregistered pathes
|
||||
//! \~russian Регистрирует обработчик для незарегистрированных путей
|
||||
//! ~english Registers handler for unregistered pathes
|
||||
//! ~russian Регистрирует обработчик для незарегистрированных путей
|
||||
void registerUnhandled(RequestFunction functor);
|
||||
|
||||
//! \~english Registers handler for unregistered pathes
|
||||
//! \~russian Регистрирует обработчик для незарегистрированных путей
|
||||
//! ~english Registers handler for unregistered pathes
|
||||
//! ~russian Регистрирует обработчик для незарегистрированных путей
|
||||
template<typename T>
|
||||
void registerUnhandled(T * o, PIHTTP::MessageMutable (T::*function)(const PIHTTP::MessageConst &)) {
|
||||
registerUnhandled([o, function](const PIHTTP::MessageConst & m) { return (o->*function)(m); });
|
||||
}
|
||||
|
||||
//! \~english Unregisters handler for specific path and method
|
||||
//! \~russian Удаляет обработчик для указанного пути и метода
|
||||
//! ~english Unregisters handler for specific path and method
|
||||
//! ~russian Удаляет обработчик для указанного пути и метода
|
||||
void unregisterPath(const PIString & path, PIHTTP::Method method);
|
||||
|
||||
//! \~english Unregisters all handlers for specific path
|
||||
//! \~russian Удаляет все обработчики для указанного пути
|
||||
//! ~english Unregisters all handlers for specific path
|
||||
//! ~russian Удаляет все обработчики для указанного пути
|
||||
void unregisterPath(const PIString & path);
|
||||
|
||||
|
||||
//! \~english Adds header to all server responses
|
||||
//! \~russian Добавляет заголовок ко всем ответам сервера
|
||||
//! ~english Adds header to all server responses
|
||||
//! ~russian Добавляет заголовок ко всем ответам сервера
|
||||
void addReplyHeader(const PIString & name, const PIString & value) { reply_headers[name] = value; }
|
||||
|
||||
//! \~english Removes header from server responses
|
||||
//! \~russian Удаляет заголовок из ответов сервера
|
||||
//! ~english Removes header from server responses
|
||||
//! ~russian Удаляет заголовок из ответов сервера
|
||||
void removeReplyHeader(const PIString & name) { reply_headers.remove(name); }
|
||||
|
||||
//! \~english Clears all custom response headers
|
||||
//! \~russian Очищает все пользовательские заголовки ответов
|
||||
//! ~english Clears all custom response headers
|
||||
//! ~russian Очищает все пользовательские заголовки ответов
|
||||
void clearReplyHeaders() { reply_headers.clear(); }
|
||||
|
||||
private:
|
||||
|
||||
@@ -29,36 +29,16 @@
|
||||
#include "piiodevice.h"
|
||||
|
||||
|
||||
//! \ingroup IO
|
||||
//! \~\brief
|
||||
//! \~english CAN device.
|
||||
//! \~russian Устройство CAN.
|
||||
class PIP_EXPORT PICAN: public PIIODevice {
|
||||
PIIODEVICE(PICAN, "can");
|
||||
|
||||
public:
|
||||
//! \~english Constructs %PICAN with empty path and ReadWrite mode
|
||||
//! \~russian Создаёт %PICAN с пустым путём и режимом ReadWrite
|
||||
explicit PICAN(const PIString & path = PIString(), PIIODevice::DeviceMode mode = PIIODevice::ReadWrite);
|
||||
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
virtual ~PICAN();
|
||||
|
||||
//! \~english Set CAN ID for filtering received messages
|
||||
//! \~russian Устанавливает CAN ID для фильтрации принимаемых сообщений
|
||||
void setCANID(int id);
|
||||
|
||||
//! \~english Returns current CAN ID
|
||||
//! \~russian Возвращает текущий CAN ID
|
||||
int CANID() const;
|
||||
|
||||
//! \~english Returns CAN ID of last readed message
|
||||
//! \~russian Возвращает CAN ID последнего прочитанного сообщения
|
||||
int readedCANID() const;
|
||||
|
||||
//! \~english Interrupt blocking operation
|
||||
//! \~russian Прерывает блокирующую операцию
|
||||
void interrupt() override;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -390,7 +390,7 @@ void PIIODevice::read_func() {
|
||||
ssize_t readed_ = read(buffer_tr.data(), buffer_tr.size_s());
|
||||
if (read_thread.isStopping()) return;
|
||||
if (readed_ <= 0) {
|
||||
piMSleep(threaded_read_timeout_ms);
|
||||
piMSleep(10);
|
||||
// cout << readed_ << ", " << errno << ", " << errorString() << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -271,10 +271,6 @@ public:
|
||||
bool waitThreadedReadFinished(PISystemTime timeout = {});
|
||||
|
||||
|
||||
uint threadedReadTimeout() const { return threaded_read_timeout_ms; }
|
||||
void setThreadedReadTimeout(uint ms) { threaded_read_timeout_ms = ms; }
|
||||
|
||||
|
||||
//! \~english Returns if threaded write is started
|
||||
//! \~russian Возвращает запущен ли поток записи
|
||||
bool isThreadedWrite() const;
|
||||
@@ -595,7 +591,7 @@ private:
|
||||
PIQueue<PIPair<PIByteArray, ullong>> write_queue;
|
||||
PISystemTime reopen_timeout;
|
||||
ullong tri = 0;
|
||||
uint threaded_read_buffer_size, threaded_read_timeout_ms = 10;
|
||||
uint threaded_read_buffer_size;
|
||||
bool reopen_enabled = true, destroying = false;
|
||||
|
||||
static PIMutex nfp_mutex;
|
||||
|
||||
@@ -29,10 +29,6 @@
|
||||
#include "pidiagnostics.h"
|
||||
#include "piethernet.h"
|
||||
|
||||
//! \ingroup IO
|
||||
//! \~\brief
|
||||
//! \~english Peering net node.
|
||||
//! \~russian Элемент пиринговой сети.
|
||||
class PIP_EXPORT PIPeer: public PIIODevice {
|
||||
PIIODEVICE(PIPeer, "peer");
|
||||
|
||||
@@ -40,16 +36,9 @@ private:
|
||||
class PeerData;
|
||||
|
||||
public:
|
||||
//! \~english Constructs %PIPeer with name "name"
|
||||
//! \~russian Создаёт %PIPeer с именем "name"
|
||||
explicit PIPeer(const PIString & name = PIString());
|
||||
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
virtual ~PIPeer();
|
||||
|
||||
//! \~english Peer information structure
|
||||
//! \~russian Структура информации о пире
|
||||
class PIP_EXPORT PeerInfo {
|
||||
friend class PIPeer;
|
||||
BINARY_STREAM_FRIEND(PIPeer::PeerInfo);
|
||||
@@ -98,89 +87,38 @@ public:
|
||||
|
||||
BINARY_STREAM_FRIEND(PIPeer::PeerInfo);
|
||||
|
||||
//! \~english Send data to peer with name "to"
|
||||
//! \~russian Отправляет данные пиру с именем "to"
|
||||
bool send(const PIString & to, const PIByteArray & data) { return send(to, data.data(), data.size_s()); }
|
||||
|
||||
//! \~english Send string to peer with name "to"
|
||||
//! \~russian Отправляет строку пиру с именем "to"
|
||||
bool send(const PIString & to, const PIString & data) { return send(to, data.data(), data.size_s()); }
|
||||
bool send(const PIString & to, const void * data, int size);
|
||||
|
||||
//! \~english Send data to peer "to"
|
||||
//! \~russian Отправляет данные пиру "to"
|
||||
bool send(const PeerInfo & to, const PIByteArray & data) { return send(to.name, data.data(), data.size_s()); }
|
||||
bool send(const PeerInfo & to, const PIString & data) { return send(to.name, data.data(), data.size_s()); }
|
||||
bool send(const PeerInfo & to, const void * data, int size) { return send(to.name, data, size); }
|
||||
bool send(const PeerInfo * to, const PIByteArray & data);
|
||||
bool send(const PeerInfo * to, const PIString & data);
|
||||
bool send(const PeerInfo * to, const void * data, int size);
|
||||
|
||||
//! \~english Send data to all peers
|
||||
//! \~russian Отправляет данные всем пирам
|
||||
void sendToAll(const PIByteArray & data);
|
||||
void sendToAll(const PIString & data);
|
||||
void sendToAll(const void * data, int size);
|
||||
|
||||
//! \~english Returns if receiving multicast packets is enabled
|
||||
//! \~russian Возвращает включён ли приём мультикаст пакетов
|
||||
bool isMulticastReceive() const { return !eths_mcast.isEmpty(); }
|
||||
|
||||
//! \~english Returns if receiving broadcast packets is enabled
|
||||
//! \~russian Возвращает включён ли приём широковещательных пакетов
|
||||
bool isBroadcastReceive() const { return !eths_bcast.isEmpty(); }
|
||||
|
||||
//! \~english Returns diagnostic service
|
||||
//! \~russian Возвращает диагностический сервис
|
||||
PIDiagnostics & diagnosticService() { return diag_s; }
|
||||
|
||||
//! \~english Returns diagnostic data
|
||||
//! \~russian Возвращает диагностические данные
|
||||
PIDiagnostics & diagnosticData() { return diag_d; }
|
||||
|
||||
//! \~english Returns all known peers
|
||||
//! \~russian Возвращает всех известных пиров
|
||||
const PIVector<PIPeer::PeerInfo> & allPeers() const { return peers; }
|
||||
|
||||
//! \~english Returns if peer with name "name" exists
|
||||
//! \~russian Возвращает существует ли пир с именем "name"
|
||||
bool isPeerExists(const PIString & name) const { return getPeerByName(name) != 0; }
|
||||
|
||||
//! \~english Returns peer info by name, or nullptr if not found
|
||||
//! \~russian Возвращает информацию о пире по имени, или nullptr если не найден
|
||||
const PeerInfo * getPeerByName(const PIString & name) const { return peers_map.value(name, 0); }
|
||||
|
||||
//! \~english Returns self info
|
||||
//! \~russian Возвращает информацию о себе
|
||||
const PeerInfo & selfInfo() const { return self_info; }
|
||||
const PIMap<PIString, PIVector<PeerInfo *>> & _peerMap() const { return addresses_map; }
|
||||
|
||||
//! \~english Reinitialize peer network
|
||||
//! \~russian Переинициализирует пиринговую сеть
|
||||
void reinit();
|
||||
|
||||
//! \~english Lock peers list
|
||||
//! \~russian Блокирует список пиров
|
||||
void lock() { peers_mutex.lock(); }
|
||||
|
||||
//! \~english Unlock peers list
|
||||
//! \~russian Разблокирует список пиров
|
||||
void unlock() { peers_mutex.unlock(); }
|
||||
|
||||
//! \~english Change peer name to "new_name"
|
||||
//! \~russian Изменяет имя пира на "new_name"
|
||||
void changeName(const PIString & new_name);
|
||||
|
||||
//! \~english Returns trusted peer name
|
||||
//! \~russian Возвращает имя доверенного пира
|
||||
const PIString & trustPeerName() const { return trust_peer; }
|
||||
|
||||
//! \~english Set trusted peer name
|
||||
//! \~russian Устанавливает имя доверенного пира
|
||||
void setTrustPeerName(const PIString & peer_name) { trust_peer = peer_name; }
|
||||
|
||||
//! \~english Set TCP server IP address
|
||||
//! \~russian Устанавливает IP адрес TCP сервера
|
||||
void setTcpServerIP(const PIString & ip);
|
||||
|
||||
ssize_t bytesAvailable() const override;
|
||||
|
||||
@@ -29,59 +29,35 @@
|
||||
#include "piiodevice.h"
|
||||
|
||||
|
||||
//! \ingroup IO
|
||||
//! \~\brief
|
||||
//! \~english SPI device.
|
||||
//! \~russian Устройство SPI.
|
||||
class PIP_EXPORT PISPI: public PIIODevice {
|
||||
PIIODEVICE(PISPI, "spi");
|
||||
|
||||
public:
|
||||
//! \~english Constructs %PISPI with path "path", speed "speed_hz" and mode "mode"
|
||||
//! \~russian Создаёт %PISPI с путём "path", скоростью "speed_hz" и режимом "mode"
|
||||
explicit PISPI(const PIString & path = PIString(), uint speed_hz = 1000000, PIIODevice::DeviceMode mode = PIIODevice::ReadWrite);
|
||||
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
virtual ~PISPI();
|
||||
|
||||
//! \~english Parameters of PISPI
|
||||
//! \~russian Параметры PISPI
|
||||
//! \brief Parameters of PISPI
|
||||
enum Parameters {
|
||||
ClockInverse /*! \~english SPI clk polarity control \~russian Управление полярностью SPI clk */ = 0x1,
|
||||
ClockPhaseShift /*! \~english SPI clk phase control \~russian Управление фазой SPI clk */ = 0x2,
|
||||
ClockInverse /*! SPI clk polarity control*/ = 0x1,
|
||||
ClockPhaseShift /*! SPI clk phase control */ = 0x2,
|
||||
};
|
||||
|
||||
//! \~english Set SPI speed in Hz
|
||||
//! \~russian Устанавливает скорость SPI в Гц
|
||||
void setSpeed(uint speed_hz);
|
||||
|
||||
//! \~english Returns current SPI speed in Hz
|
||||
//! \~russian Возвращает текущую скорость SPI в Гц
|
||||
uint speed() const { return spi_speed; }
|
||||
|
||||
//! \~english Set number of bits per word, default is 8
|
||||
//! \~russian Устанавливает количество бит на слово, по умолчанию 8
|
||||
void setBits(uchar bits = 8);
|
||||
|
||||
//! \~english Returns number of bits per word
|
||||
//! \~russian Возвращает количество бит на слово
|
||||
uchar bits() const { return spi_bits; }
|
||||
|
||||
//! \~english Set parameters to "parameters_"
|
||||
//! \~russian Устанавливает параметры в "parameters_"
|
||||
//! Set parameters to "parameters_"
|
||||
void setParameters(PIFlags<PISPI::Parameters> parameters_) { spi_mode = (int)parameters_; }
|
||||
|
||||
//! \~english Set parameter "parameter" to "on" state
|
||||
//! \~russian Устанавливает параметр "parameter" в состояние "on"
|
||||
//! Set parameter "parameter" to "on" state
|
||||
void setParameter(PISPI::Parameters parameter, bool on = true);
|
||||
|
||||
//! \~english Returns if parameter "parameter" is set
|
||||
//! \~russian Возвращает установлен ли параметр "parameter"
|
||||
//! Returns if parameter "parameter" is set
|
||||
bool isParameterSet(PISPI::Parameters parameter) const;
|
||||
|
||||
//! \~english Returns parameters
|
||||
//! \~russian Возвращает параметры
|
||||
//! Returns parameters
|
||||
PIFlags<PISPI::Parameters> parameters() const { return spi_mode; }
|
||||
|
||||
ssize_t bytesAvailable() const override;
|
||||
|
||||
@@ -62,24 +62,13 @@
|
||||
|
||||
struct usb_dev_handle;
|
||||
|
||||
//! \ingroup IO
|
||||
//! \~\brief
|
||||
//! \~english USB device.
|
||||
//! \~russian Устройство USB.
|
||||
class PIP_USB_EXPORT PIUSB: public PIIODevice {
|
||||
PIIODEVICE(PIUSB, "usb");
|
||||
|
||||
public:
|
||||
//! \~english Constructs %PIUSB with vendor ID "vid" and product ID "pid"
|
||||
//! \~russian Создаёт %PIUSB с идентификатором поставщика "vid" и идентификатором продукта "pid"
|
||||
explicit PIUSB(ushort vid = 0, ushort pid = 0);
|
||||
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
virtual ~PIUSB();
|
||||
|
||||
//! \~english USB endpoint structure
|
||||
//! \~russian Структура USB endpoint
|
||||
struct PIP_USB_EXPORT Endpoint {
|
||||
Endpoint(uchar a = 0, uchar at = 0, ushort mps = 0) {
|
||||
address = a;
|
||||
@@ -122,8 +111,6 @@ public:
|
||||
UsageType usage_type = DataEndpoint;
|
||||
};
|
||||
|
||||
//! \~english USB interface structure
|
||||
//! \~russian Структура USB интерфейса
|
||||
struct PIP_USB_EXPORT Interface {
|
||||
uchar index = 0;
|
||||
uchar value_to_select = 0;
|
||||
@@ -133,8 +120,6 @@ public:
|
||||
PIVector<PIUSB::Endpoint> endpoints;
|
||||
};
|
||||
|
||||
//! \~english USB configuration structure
|
||||
//! \~russian Структура USB конфигурации
|
||||
struct PIP_USB_EXPORT Configuration {
|
||||
uchar index = 0;
|
||||
uchar value_to_select = 0;
|
||||
@@ -145,8 +130,6 @@ public:
|
||||
PIVector<PIUSB::Interface> interfaces;
|
||||
};
|
||||
|
||||
//! \~english USB device descriptor structure
|
||||
//! \~russian Структура дескриптора USB устройства
|
||||
struct PIP_USB_EXPORT Descriptor {
|
||||
ushort usb_spec_number = 0;
|
||||
uchar device_class = 0;
|
||||
@@ -162,100 +145,36 @@ public:
|
||||
PIVector<PIUSB::Configuration> configurations;
|
||||
};
|
||||
|
||||
//! \~english Returns current device descriptor
|
||||
//! \~russian Возвращает текущий дескриптор устройства
|
||||
const PIUSB::Descriptor & currentDescriptor() const { return desc_; }
|
||||
|
||||
//! \~english Returns current configuration
|
||||
//! \~russian Возвращает текущую конфигурацию
|
||||
const PIUSB::Configuration & currentConfiguration() const { return conf_; }
|
||||
|
||||
//! \~english Returns current interface
|
||||
//! \~russian Возвращает текущий интерфейс
|
||||
const PIUSB::Interface & currentInterface() const { return iface_; }
|
||||
|
||||
//! \~english Returns vendor ID
|
||||
//! \~russian Возвращает ID поставщика
|
||||
ushort vendorID() const { return vid_; }
|
||||
|
||||
//! \~english Returns product ID
|
||||
//! \~russian Возвращает ID продукта
|
||||
ushort productID() const { return pid_; }
|
||||
|
||||
//! \~english Returns device number
|
||||
//! \~russian Возвращает номер устройства
|
||||
int deviceNumber() const { return property("deviceNumber").toInt(); }
|
||||
|
||||
//! \~english Returns read timeout in milliseconds
|
||||
//! \~russian Возвращает таймаут чтения в миллисекундах
|
||||
int timeoutRead() const { return property("timeoutRead").toInt(); }
|
||||
|
||||
//! \~english Returns write timeout in milliseconds
|
||||
//! \~russian Возвращает таймаут записи в миллисекундах
|
||||
int timeoutWrite() const { return property("timeoutWrite").toInt(); }
|
||||
|
||||
//! \~english Returns read endpoint
|
||||
//! \~russian Возвращает endpoint для чтения
|
||||
const PIUSB::Endpoint & endpointRead() const { return ep_read; }
|
||||
|
||||
//! \~english Returns write endpoint
|
||||
//! \~russian Возвращает endpoint для записи
|
||||
const PIUSB::Endpoint & endpointWrite() const { return ep_write; }
|
||||
|
||||
//! \~english Returns all endpoints
|
||||
//! \~russian Возвращает все endpoints
|
||||
const PIVector<PIUSB::Endpoint> & endpoints() const { return eps; }
|
||||
|
||||
//! \~english Returns read endpoints
|
||||
//! \~russian Возвращает endpoints для чтения
|
||||
PIVector<PIUSB::Endpoint> endpointsRead();
|
||||
|
||||
//! \~english Returns write endpoints
|
||||
//! \~russian Возвращает endpoints для записи
|
||||
PIVector<PIUSB::Endpoint> endpointsWrite();
|
||||
|
||||
//! \~english Returns endpoint by address
|
||||
//! \~russian Возвращает endpoint по адресу
|
||||
PIUSB::Endpoint getEndpointByAddress(uchar address);
|
||||
|
||||
//! \~english Set vendor ID to "vid"
|
||||
//! \~russian Устанавливает ID поставщика в "vid"
|
||||
void setVendorID(ushort vid);
|
||||
|
||||
//! \~english Set product ID to "pid"
|
||||
//! \~russian Устанавливает ID продукта в "pid"
|
||||
void setProductID(ushort pid);
|
||||
|
||||
//! \~english Set configuration by value
|
||||
//! \~russian Устанавливает конфигурацию по значению
|
||||
bool setConfiguration(uchar value);
|
||||
|
||||
//! \~english Set interface by value
|
||||
//! \~russian Устанавливает интерфейс по значению
|
||||
bool setInterface(uchar value);
|
||||
|
||||
//! \~english Set read endpoint
|
||||
//! \~russian Устанавливает endpoint для чтения
|
||||
void setEndpointRead(const PIUSB::Endpoint & ep) { ep_read = ep; }
|
||||
|
||||
//! \~english Set write endpoint
|
||||
//! \~russian Устанавливает endpoint для записи
|
||||
void setEndpointWrite(const PIUSB::Endpoint & ep) { ep_write = ep; }
|
||||
|
||||
//! \~english Set device number
|
||||
//! \~russian Устанавливает номер устройства
|
||||
void setDeviceNumber(int dn) { setProperty("deviceNumber", dn); }
|
||||
|
||||
//! \~english Set read timeout in milliseconds
|
||||
//! \~russian Устанавливает таймаут чтения в миллисекундах
|
||||
void setTimeoutRead(int t) { setProperty("timeoutRead", t); }
|
||||
|
||||
//! \~english Set write timeout in milliseconds
|
||||
//! \~russian Устанавливает таймаут записи в миллисекундах
|
||||
void setTimeoutWrite(int t) { setProperty("timeoutWrite", t); }
|
||||
|
||||
//! \~english Control write to device
|
||||
//! \~russian Управляющая запись в устройство
|
||||
int controlWrite(const void * data, int max_size);
|
||||
|
||||
virtual void flush() override;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
//! \file picrc.h
|
||||
//! \ingroup Math
|
||||
//! \~\brief
|
||||
//! \~english CRC checksum calculation
|
||||
//! \~russian Вычисление CRC контрольной суммы
|
||||
|
||||
/*!
|
||||
/*! \file picrc.h
|
||||
* \ingroup Math
|
||||
* \~\brief
|
||||
* \~english CRC checksum calculation
|
||||
* \~russian Вычисление CRC контрольной суммы
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
CRC checksum calculator
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
@@ -28,113 +28,67 @@
|
||||
|
||||
#include "pistring.h"
|
||||
|
||||
//! \addtogroup Math
|
||||
//! \{
|
||||
//! \class uint_cl
|
||||
//! \brief
|
||||
//! \~english Fixed-size unsigned integer class for CRC calculations
|
||||
//! \~russian Класс целого числа фиксированного размера для вычисления CRC
|
||||
//! \details
|
||||
//! \~english Provides arbitrary length unsigned integer support for CRC computation
|
||||
//! \~russian Обеспечивает поддержку целых чисел произвольной длины для вычисления CRC
|
||||
//! \}
|
||||
|
||||
template<int L>
|
||||
class PIP_EXPORT uint_cl {
|
||||
public:
|
||||
//! \~english Default constructor, initializes to zero
|
||||
//! \~russian Конструктор по умолчанию, инициализирует нулём
|
||||
uint_cl() {
|
||||
for (int i = 0; i < L / 8; ++i)
|
||||
data_[i] = 0;
|
||||
}
|
||||
|
||||
//! \~english Copy constructor
|
||||
//! \~russian Конструктор копирования
|
||||
uint_cl(const uint_cl<L> & v) {
|
||||
for (int i = 0; i < L / 8; ++i)
|
||||
data_[i] = v.data_[i];
|
||||
}
|
||||
|
||||
//! \~english Construct from unsigned char
|
||||
//! \~russian Конструктор из unsigned char
|
||||
uint_cl(uchar v) {
|
||||
for (int i = 0; i < L / 8; ++i)
|
||||
data_[i] = (i == 0 ? v : 0);
|
||||
}
|
||||
|
||||
//! \~english Construct from char
|
||||
//! \~russian Конструктор из char
|
||||
uint_cl(char v) {
|
||||
for (int i = 0; i < L / 8; ++i)
|
||||
data_[i] = (i == 0 ? v : 0);
|
||||
}
|
||||
|
||||
//! \~english Construct from unsigned short
|
||||
//! \~russian Конструктор из unsigned short
|
||||
uint_cl(ushort v) {
|
||||
int l = piMin<uint>(L / 8, sizeof(v));
|
||||
memcpy(data_, &v, l);
|
||||
for (int i = l; i < L / 8; ++i)
|
||||
data_[i] = 0;
|
||||
}
|
||||
|
||||
//! \~english Construct from short
|
||||
//! \~russian Конструктор из short
|
||||
uint_cl(short v) {
|
||||
int l = piMin<uint>(L / 8, sizeof(v));
|
||||
memcpy(data_, &v, l);
|
||||
for (int i = l; i < L / 8; ++i)
|
||||
data_[i] = 0;
|
||||
}
|
||||
|
||||
//! \~english Construct from unsigned int
|
||||
//! \~russian Конструктор из unsigned int
|
||||
uint_cl(uint v) {
|
||||
int l = piMin<uint>(L / 8, sizeof(v));
|
||||
memcpy(data_, &v, l);
|
||||
for (int i = l; i < L / 8; ++i)
|
||||
data_[i] = 0;
|
||||
}
|
||||
|
||||
//! \~english Construct from int
|
||||
//! \~russian Конструктор из int
|
||||
uint_cl(int v) {
|
||||
int l = piMin<uint>(L / 8, sizeof(v));
|
||||
memcpy(data_, &v, l);
|
||||
for (int i = l; i < L / 8; ++i)
|
||||
data_[i] = 0;
|
||||
}
|
||||
|
||||
//! \~english Construct from unsigned long
|
||||
//! \~russian Конструктор из unsigned long
|
||||
uint_cl(ulong v) {
|
||||
int l = piMin<uint>(L / 8, sizeof(v));
|
||||
memcpy(data_, &v, l);
|
||||
for (int i = l; i < L / 8; ++i)
|
||||
data_[i] = 0;
|
||||
}
|
||||
|
||||
//! \~english Construct from long
|
||||
//! \~russian Конструктор из long
|
||||
uint_cl(long v) {
|
||||
int l = piMin<uint>(L / 8, sizeof(v));
|
||||
memcpy(data_, &v, l);
|
||||
for (int i = l; i < L / 8; ++i)
|
||||
data_[i] = 0;
|
||||
}
|
||||
|
||||
//! \~english Construct from unsigned long long
|
||||
//! \~russian Конструктор из unsigned long long
|
||||
uint_cl(ullong v) {
|
||||
int l = piMin<uint>(L / 8, sizeof(v));
|
||||
memcpy(data_, &v, l);
|
||||
for (int i = l; i < L / 8; ++i)
|
||||
data_[i] = 0;
|
||||
}
|
||||
|
||||
//! \~english Construct from long long
|
||||
//! \~russian Конструктор из long long
|
||||
uint_cl(llong v) {
|
||||
int l = piMin<uint>(L / 8, sizeof(v));
|
||||
memcpy(data_, &v, l);
|
||||
@@ -142,87 +96,55 @@ public:
|
||||
data_[i] = 0;
|
||||
}
|
||||
|
||||
//! \~english Convert to bool
|
||||
//! \~russian Преобразование в bool
|
||||
operator bool() {
|
||||
for (int i = 0; i < L / 8; ++i)
|
||||
if (data_[i] > 0) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
//! \~english Convert to char
|
||||
//! \~russian Преобразование в char
|
||||
operator char() { return (char)data_[0]; }
|
||||
|
||||
//! \~english Convert to short
|
||||
//! \~russian Преобразование в short
|
||||
operator short() {
|
||||
short t(0);
|
||||
int l = piMin<uint>(L / 8, sizeof(t));
|
||||
memcpy(&t, data_, l);
|
||||
return t;
|
||||
}
|
||||
|
||||
//! \~english Convert to int
|
||||
//! \~russian Преобразование в int
|
||||
operator int() {
|
||||
int t(0);
|
||||
int l = piMin<uint>(L / 8, sizeof(t));
|
||||
memcpy(&t, data_, l);
|
||||
return t;
|
||||
}
|
||||
|
||||
//! \~english Convert to long
|
||||
//! \~russian Преобразование в long
|
||||
operator long() {
|
||||
long t(0);
|
||||
int l = piMin<uint>(L / 8, sizeof(t));
|
||||
memcpy(&t, data_, l);
|
||||
return t;
|
||||
}
|
||||
|
||||
//! \~english Convert to long long
|
||||
//! \~russian Преобразование в long long
|
||||
operator llong() {
|
||||
llong t(0);
|
||||
int l = piMin<uint>(L / 8, sizeof(t));
|
||||
memcpy(&t, data_, l);
|
||||
return t;
|
||||
}
|
||||
|
||||
//! \~english Convert to unsigned char
|
||||
//! \~russian Преобразование в unsigned char
|
||||
operator uchar() { return data_[0]; }
|
||||
|
||||
//! \~english Convert to unsigned short
|
||||
//! \~russian Преобразование в unsigned short
|
||||
operator ushort() {
|
||||
ushort t(0);
|
||||
int l = piMin<uint>(L / 8, sizeof(t));
|
||||
memcpy(&t, data_, l);
|
||||
return t;
|
||||
}
|
||||
|
||||
//! \~english Convert to unsigned int
|
||||
//! \~russian Преобразование в unsigned int
|
||||
operator uint() {
|
||||
uint t(0);
|
||||
int l = piMin<uint>(L / 8, sizeof(t));
|
||||
memcpy(&t, data_, l);
|
||||
return t;
|
||||
}
|
||||
|
||||
//! \~english Convert to unsigned long
|
||||
//! \~russian Преобразование в unsigned long
|
||||
operator ulong() {
|
||||
ulong t(0);
|
||||
int l = piMin<uint>(L / 8, sizeof(t));
|
||||
memcpy(&t, data_, l);
|
||||
return t;
|
||||
}
|
||||
|
||||
//! \~english Convert to unsigned long long
|
||||
//! \~russian Преобразование в unsigned long long
|
||||
operator ullong() {
|
||||
ullong t(0);
|
||||
int l = piMin<uint>(L / 8, sizeof(t));
|
||||
@@ -230,8 +152,6 @@ public:
|
||||
return t;
|
||||
}
|
||||
|
||||
//! \~english Addition operator
|
||||
//! \~russian Оператор сложения
|
||||
uint_cl<L> operator+(const uint_cl<L> & v) {
|
||||
uint_cl<L> t;
|
||||
uint cv;
|
||||
@@ -245,15 +165,12 @@ public:
|
||||
return t;
|
||||
}
|
||||
|
||||
//! \~english Bitwise AND operator
|
||||
//! \~russian Побитовый оператор И
|
||||
uint_cl<L> operator&(const uint_cl<L> & v) const {
|
||||
uint_cl<L> t;
|
||||
for (int i = 0; i < L / 8; ++i)
|
||||
t.data_[i] = v.data_[i] & data_[i];
|
||||
return t;
|
||||
}
|
||||
|
||||
uint_cl<L> operator&(const uchar & v) const { return *this & uint_cl<L>(v); }
|
||||
uint_cl<L> operator&(const ushort & v) const { return *this & uint_cl<L>(v); }
|
||||
uint_cl<L> operator&(const uint & v) const { return *this & uint_cl<L>(v); }
|
||||
@@ -265,15 +182,12 @@ public:
|
||||
uint_cl<L> operator&(const long & v) const { return *this & uint_cl<L>(v); }
|
||||
uint_cl<L> operator&(const llong & v) const { return *this & uint_cl<L>(v); }
|
||||
|
||||
//! \~english Bitwise OR operator
|
||||
//! \~russian Побитовый оператор ИЛИ
|
||||
uint_cl<L> operator|(const uint_cl<L> & v) const {
|
||||
uint_cl<L> t;
|
||||
for (int i = 0; i < L / 8; ++i)
|
||||
t.data_[i] = v.data_[i] | data_[i];
|
||||
return t;
|
||||
}
|
||||
|
||||
uint_cl<L> operator|(const uchar & v) const { return *this | uint_cl<L>(v); }
|
||||
uint_cl<L> operator|(const ushort & v) const { return *this | uint_cl<L>(v); }
|
||||
uint_cl<L> operator|(const uint & v) const { return *this | uint_cl<L>(v); }
|
||||
@@ -285,15 +199,12 @@ public:
|
||||
uint_cl<L> operator|(const long & v) const { return *this | uint_cl<L>(v); }
|
||||
uint_cl<L> operator|(const llong & v) const { return *this | uint_cl<L>(v); }
|
||||
|
||||
//! \~english Bitwise XOR operator
|
||||
//! \~russian Побитовый оператор исключающее ИЛИ
|
||||
uint_cl<L> operator^(const uint_cl<L> & v) const {
|
||||
uint_cl<L> t;
|
||||
for (int i = 0; i < L / 8; ++i)
|
||||
t.data_[i] = v.data_[i] ^ data_[i];
|
||||
return t;
|
||||
}
|
||||
|
||||
uint_cl<L> operator^(const uchar & v) const { return *this ^ uint_cl<L>(v); }
|
||||
uint_cl<L> operator^(const ushort & v) const { return *this ^ uint_cl<L>(v); }
|
||||
uint_cl<L> operator^(const uint & v) const { return *this ^ uint_cl<L>(v); }
|
||||
@@ -305,8 +216,6 @@ public:
|
||||
uint_cl<L> operator^(const long & v) const { return *this ^ uint_cl<L>(v); }
|
||||
uint_cl<L> operator^(const llong & v) const { return *this ^ uint_cl<L>(v); }
|
||||
|
||||
//! \~english Less than operator
|
||||
//! \~russian Оператор меньше
|
||||
bool operator<(const uint_cl<L> & v) const {
|
||||
for (int i = 0; i < L / 8; ++i) {
|
||||
if (v.data_[i] > data_[i]) return true;
|
||||
@@ -314,9 +223,6 @@ public:
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//! \~english Less than or equal operator
|
||||
//! \~russian Оператор меньше или равно
|
||||
bool operator<=(const uint_cl<L> & v) const {
|
||||
for (int i = 0; i < L / 8; ++i) {
|
||||
if (v.data_[i] > data_[i]) return true;
|
||||
@@ -324,9 +230,6 @@ public:
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//! \~english Greater than operator
|
||||
//! \~russian Оператор больше
|
||||
bool operator>(const uint_cl<L> & v) const {
|
||||
for (int i = 0; i < L / 8; ++i) {
|
||||
if (v.data_[i] < data_[i]) return true;
|
||||
@@ -334,9 +237,6 @@ public:
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//! \~english Greater than or equal operator
|
||||
//! \~russian Оператор больше или равно
|
||||
bool operator>=(const uint_cl<L> & v) const {
|
||||
for (int i = 0; i < L / 8; ++i) {
|
||||
if (v.data_[i] < data_[i]) return true;
|
||||
@@ -344,27 +244,18 @@ public:
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//! \~english Equality operator
|
||||
//! \~russian Оператор равенства
|
||||
bool operator==(const uint_cl<L> & v) const {
|
||||
for (int i = 0; i < L / 8; ++i)
|
||||
if (v.data_[i] != data_[i]) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
//! \~english Inequality operator
|
||||
//! \~russian Оператор неравенства
|
||||
bool operator!=(const uint_cl<L> & v) const {
|
||||
for (int i = 0; i < L / 8; ++i)
|
||||
if (v.data_[i] != data_[i]) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator<=(const uint_cl<8> & v1) { return (*(uchar *)data()) <= (*(uchar *)v1.data()); }
|
||||
|
||||
//! \~english Right shift operator
|
||||
//! \~russian Оператор побитового сдвига вправо
|
||||
uint_cl<L> operator>>(const int & c) const {
|
||||
uint_cl<L> t;
|
||||
int l = L - c;
|
||||
@@ -379,11 +270,7 @@ public:
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
uint_cl<L> operator>>(const uint & c) const { return (*this << (int)c); }
|
||||
|
||||
//! \~english Left shift operator
|
||||
//! \~russian Оператор побитового сдвига влево
|
||||
uint_cl<L> operator<<(const int & c) const {
|
||||
uint_cl<L> t;
|
||||
int l = L - c;
|
||||
@@ -398,28 +285,19 @@ public:
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
uint_cl<L> operator<<(const uint & c) const { return (*this >> (int)c); }
|
||||
|
||||
//! \~english In-place bitwise inversion
|
||||
//! \~russian Побитовая инверсия на месте
|
||||
uint_cl<L> & inverse() const {
|
||||
for (int i = 0; i < L / 8; ++i)
|
||||
data_[i] = ~data_[i];
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Returns bitwise inverted copy
|
||||
//! \~russian Возвращает копию с побитовой инверсией
|
||||
uint_cl<L> inversed() const {
|
||||
uint_cl<L> t(*this);
|
||||
for (int i = 0; i < L / 8; ++i)
|
||||
t.data_[i] = ~t.data_[i];
|
||||
return t;
|
||||
}
|
||||
|
||||
//! \~english Returns bit-reversed copy
|
||||
//! \~russian Возвращает копию с переставленными битами
|
||||
uint_cl<L> reversed() const {
|
||||
uint_cl<L> t;
|
||||
bool bit;
|
||||
@@ -433,16 +311,8 @@ public:
|
||||
return t;
|
||||
}
|
||||
|
||||
//! \~english Get const pointer to data
|
||||
//! \~russian Получить константный указатель на данные
|
||||
const uchar * data() const { return data_; }
|
||||
|
||||
//! \~english Get pointer to data
|
||||
//! \~russian Получить указатель на данные
|
||||
uchar * data() { return data_; }
|
||||
|
||||
//! \~english Get data length in bytes
|
||||
//! \~russian Получить длину данных в байтах
|
||||
uint length() const { return L / 8; }
|
||||
|
||||
private:
|
||||
@@ -450,11 +320,6 @@ private:
|
||||
};
|
||||
|
||||
|
||||
//! \~english Reverse byte order
|
||||
//! \~russian Реверс порядка байтов
|
||||
//! \details
|
||||
//! \~english Reverses the bit order within a byte
|
||||
//! \~russian Инвертирует порядок битов в байте
|
||||
inline uchar reverseByte(uchar b) {
|
||||
uchar ret = 0;
|
||||
bool bit;
|
||||
@@ -465,26 +330,9 @@ inline uchar reverseByte(uchar b) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
//! \addtogroup Math
|
||||
//! \{
|
||||
//! \class PICRC
|
||||
//! \brief
|
||||
//! \~english CRC calculator class
|
||||
//! \~russian Класс калькулятора CRC
|
||||
//! \details
|
||||
//! \~english Calculates CRC checksum using configurable polynomial and parameters
|
||||
//! \~russian Вычисляет контрольную сумму CRC с использованием настраиваемого полинома и параметров
|
||||
//! \sa CRC_32, CRC_16, CRC_8
|
||||
//! \}
|
||||
|
||||
template<uint L, typename N = uint_cl<L>>
|
||||
class PIP_EXPORT PICRC {
|
||||
public:
|
||||
//! \~english Default constructor
|
||||
//! \~russian Конструктор по умолчанию
|
||||
//! \note
|
||||
//! \~english Polynomial value defaults to zero
|
||||
//! \~russian Значение полинома по умолчанию ноль
|
||||
PICRC(const N & poly = N()) {
|
||||
poly_ = poly;
|
||||
reverse_poly = true;
|
||||
@@ -493,13 +341,6 @@ public:
|
||||
reverse_before_xor = reverse_data = false;
|
||||
initTable();
|
||||
}
|
||||
|
||||
//! \~english Constructor with full parameters
|
||||
//! \~russian Конструктор с полными параметрами
|
||||
//! \param poly polynomial value
|
||||
//! \param reverse_poly_ whether to reverse polynomial bits
|
||||
//! \param initial initial CRC value
|
||||
//! \param out_xor XOR value for output
|
||||
PICRC(const N & poly, bool reverse_poly_, const N & initial, const N & out_xor) {
|
||||
poly_ = poly;
|
||||
reverse_poly = reverse_poly_;
|
||||
@@ -509,33 +350,18 @@ public:
|
||||
initTable();
|
||||
}
|
||||
|
||||
//! \~english Set initial CRC value
|
||||
//! \~russian Установить начальное значение CRC
|
||||
void setInitial(const N & v) { init_ = v; }
|
||||
|
||||
//! \~english Set output XOR value
|
||||
//! \~russian Установить значение XOR для вывода
|
||||
void setOutXor(const N & v) { out_ = v; }
|
||||
|
||||
//! \~english Set polynomial bit reversal
|
||||
//! \~russian Установить реверс битов полинома
|
||||
void setReversePolynome(bool yes) {
|
||||
reverse_poly = yes;
|
||||
initTable();
|
||||
}
|
||||
|
||||
//! \~english Set output bit reversal before XOR
|
||||
//! \~russian Установить реверс битов вывода перед XOR
|
||||
void setReverseOutBeforeXOR(bool yes) { reverse_before_xor = yes; }
|
||||
|
||||
//! \~english Set data byte reversal
|
||||
//! \~russian Установить реверс байтов данных
|
||||
void setReverseDataBytes(bool yes) { reverse_data = yes; }
|
||||
|
||||
//! \~english Initialize lookup table
|
||||
//! \~russian Инициализировать таблицу поиска
|
||||
void initTable() {
|
||||
N tmp, pol = reverse_poly ? reversed(poly_) : poly_;
|
||||
// cout << std::hex << "poly " << (uint)N(poly_) << " -> " << (uint)N(pol) << endl;
|
||||
for (int i = 0; i < 256; ++i) {
|
||||
tmp = uchar(i);
|
||||
for (int j = 0; j < 8; ++j)
|
||||
@@ -544,11 +370,10 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
//! \~english Calculate CRC from raw data
|
||||
//! \~russian Вычислить CRC из сырых данных
|
||||
N calculate(const void * data, int size) {
|
||||
N crc = init_;
|
||||
uchar *data_ = (uchar *)data, cb;
|
||||
// cout << "process " << size << endl;
|
||||
uchar nTemp;
|
||||
for (int i = 0; i < size; ++i) {
|
||||
cb = data_[i];
|
||||
@@ -560,13 +385,7 @@ public:
|
||||
if (reverse_before_xor) crc = reversed(crc);
|
||||
return crc ^ out_;
|
||||
}
|
||||
|
||||
//! \~english Calculate CRC from PIByteArray
|
||||
//! \~russian Вычислить CRC из PIByteArray
|
||||
N calculate(const PIByteArray & d) { return calculate(d.data(), d.size()); }
|
||||
|
||||
//! \~english Calculate CRC from null-terminated string
|
||||
//! \~russian Вычислить CRC из нуль-терминированной строки
|
||||
N calculate(const char * str) {
|
||||
PIByteArray s(PIString(str).toByteArray());
|
||||
return calculate(s.data(), s.size_s());
|
||||
@@ -606,46 +425,22 @@ inline uint PICRC<32, uint>::inversed(const uint & v) {
|
||||
return ~v;
|
||||
}
|
||||
|
||||
//! \~english Standard CRC-32 (Ethernet, ZIP, etc.)
|
||||
//! \~russian Стандартный CRC-32 (Ethernet, ZIP и т.д.)
|
||||
typedef PICRC<32, uint> CRC_32;
|
||||
|
||||
//! \~english Standard CRC-24
|
||||
//! \~russian Стандартный CRC-24
|
||||
typedef PICRC<24> CRC_24;
|
||||
|
||||
//! \~english Standard CRC-16
|
||||
//! \~russian Стандартный CRC-16
|
||||
typedef PICRC<16, ushort> CRC_16;
|
||||
|
||||
//! \~english Standard CRC-8
|
||||
//! \~russian Стандартный CRC-8
|
||||
typedef PICRC<8, uchar> CRC_8;
|
||||
|
||||
//! \~english Create standard CRC-32 calculator
|
||||
//! \~russian Создать стандартный калькулятор CRC-32
|
||||
inline CRC_32 standardCRC_32() {
|
||||
return CRC_32(0x04C11DB7, true, 0xFFFFFFFF, 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
//! \~english Create standard CRC-16 calculator
|
||||
//! \~russian Создать стандартный калькулятор CRC-16
|
||||
inline CRC_16 standardCRC_16() {
|
||||
return CRC_16(0x8005, true, 0x0, 0x0);
|
||||
}
|
||||
|
||||
//! \~english Create standard CRC-16 Modbus calculator
|
||||
//! \~russian Создать стандартный калькулятор CRC-16 Modbus
|
||||
inline CRC_16 standardCRC_16_Modbus() {
|
||||
return CRC_16(0x8005, 0xFFFF, 0xFFFF, false);
|
||||
}
|
||||
|
||||
//! \~english Create standard CRC-8 calculator
|
||||
//! \~russian Создать стандартный калькулятор CRC-8
|
||||
inline CRC_8 standardCRC_8() {
|
||||
return CRC_8(0xD5, true, 0x0, 0x0);
|
||||
}
|
||||
|
||||
//! \}
|
||||
|
||||
#endif // CRC_H
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
//! \addtogroup Math
|
||||
//! \{
|
||||
//! \file pifft.h
|
||||
//! \brief
|
||||
//! \~english Declares \a PIFFT classes
|
||||
//! \~russian Объявление классов \a PIFFT
|
||||
//! \~\authors
|
||||
//! \~english Ivan Pelipenko peri4ko@yandex.ru; Andrey Bychkov work.a.b@yandex.ru
|
||||
//! \~russian Иван Пелипенко peri4ko@yandex.ru; Андрей Бычков work.a.b@yandex.ru
|
||||
//! \~\}
|
||||
/*! \file pifft.h
|
||||
* \ingroup Math
|
||||
* \ingroup FFTW
|
||||
* \~\brief
|
||||
* \~english FFT, IFFT and Hilbert transformations
|
||||
* \~russian БПФ, ОБПФ и преобразования Гильберта
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Class for FFT, IFFT and Hilbert transformations
|
||||
@@ -67,40 +64,16 @@
|
||||
|
||||
# include "pip_fftw_export.h"
|
||||
|
||||
//! \addtogroup Math
|
||||
//! \{
|
||||
//! \class PIFFT_double
|
||||
//! \brief
|
||||
//! \~english Fast Fourier Transform implementation for double precision.
|
||||
//! \~russian Реализация быстрого преобразования Фурье для двойной точности.
|
||||
//! \~\}
|
||||
//! \sa \a PIFFT_float, \a PIFFTW
|
||||
class PIP_EXPORT PIFFT_double {
|
||||
public:
|
||||
//! \~english Default constructor.
|
||||
//! \~russian Конструктор по умолчанию.
|
||||
PIFFT_double();
|
||||
|
||||
//! \~english Calculate FFT from complex vector.
|
||||
//! \~russian Вычисление БПФ из комплексного вектора.
|
||||
PIVector<complexd> * calcFFT(const PIVector<complexd> & val);
|
||||
//! \~english Calculate FFT from real vector.
|
||||
//! \~russian Вычисление БПФ из вещественного вектора.
|
||||
PIVector<complexd> * calcFFT(const PIVector<double> & val);
|
||||
//! \~english Calculate inverse FFT.
|
||||
//! \~russian Вычисление обратного БПФ.
|
||||
PIVector<complexd> * calcFFTinverse(const PIVector<complexd> & val);
|
||||
//! \~english Calculate Hilbert transform.
|
||||
//! \~russian Вычисление преобразования Гильберта.
|
||||
PIVector<complexd> * calcHilbert(const PIVector<double> & val);
|
||||
//! \~english Get amplitude spectrum.
|
||||
//! \~russian Получить амплитудный спектр.
|
||||
PIVector<double> getAmplitude() const;
|
||||
//! \~english Get real part.
|
||||
//! \~russian Получить действительную часть.
|
||||
PIVector<double> getReal() const;
|
||||
//! \~english Get imaginary part.
|
||||
//! \~russian Получить мнимую часть.
|
||||
PIVector<double> getImag() const;
|
||||
|
||||
private:
|
||||
@@ -145,40 +118,16 @@ private:
|
||||
void ftbase_ffttwcalc(PIVector<double> * a, int aoffset, int n1, int n2);
|
||||
};
|
||||
|
||||
//! \addtogroup Math
|
||||
//! \{
|
||||
//! \class PIFFT_float
|
||||
//! \brief
|
||||
//! \~english Fast Fourier Transform implementation for single precision.
|
||||
//! \~russian Реализация быстрого преобразования Фурье для одинарной точности.
|
||||
//! \~\}
|
||||
//! \sa \a PIFFT_double, \a PIFFTW
|
||||
class PIP_EXPORT PIFFT_float {
|
||||
public:
|
||||
//! \~english Default constructor.
|
||||
//! \~russian Конструктор по умолчанию.
|
||||
PIFFT_float();
|
||||
|
||||
//! \~english Calculate FFT from complex vector.
|
||||
//! \~russian Вычисление БПФ из комплексного вектора.
|
||||
PIVector<complexf> * calcFFT(const PIVector<complexf> & val);
|
||||
//! \~english Calculate FFT from real vector.
|
||||
//! \~russian Вычисление БПФ из вещественного вектора.
|
||||
PIVector<complexf> * calcFFT(const PIVector<float> & val);
|
||||
//! \~english Calculate inverse FFT.
|
||||
//! \~russian Вычисление обратного БПФ.
|
||||
PIVector<complexf> * calcFFTinverse(const PIVector<complexf> & val);
|
||||
//! \~english Calculate Hilbert transform.
|
||||
//! \~russian Вычисление преобразования Гильберта.
|
||||
PIVector<complexf> * calcHilbert(const PIVector<float> & val);
|
||||
//! \~english Get amplitude spectrum.
|
||||
//! \~russian Получить амплитудный спектр.
|
||||
PIVector<float> getAmplitude() const;
|
||||
//! \~english Get real part.
|
||||
//! \~russian Получить действительную часть.
|
||||
PIVector<float> getReal() const;
|
||||
//! \~english Get imaginary part.
|
||||
//! \~russian Получить мнимую часть.
|
||||
PIVector<float> getImag() const;
|
||||
|
||||
private:
|
||||
@@ -222,7 +171,6 @@ private:
|
||||
void ftbase_fftirltrec(PIVector<float> * a, int astart, int astride, PIVector<float> * b, int bstart, int bstride, int m, int n);
|
||||
void ftbase_ffttwcalc(PIVector<float> * a, int aoffset, int n1, int n2);
|
||||
};
|
||||
//! \~\}
|
||||
|
||||
typedef PIFFT_double PIFFT;
|
||||
typedef PIFFT_double PIFFTd;
|
||||
@@ -230,63 +178,40 @@ typedef PIFFT_float PIFFTf;
|
||||
|
||||
# ifndef CC_VC
|
||||
|
||||
# define _PIFFTW_H(type) \
|
||||
class PIP_FFTW_EXPORT _PIFFTW_P_##type##_ { \
|
||||
public: \
|
||||
_PIFFTW_P_##type##_(); \
|
||||
~_PIFFTW_P_##type##_(); \
|
||||
const PIVector<complex<type>> & calcFFT(const PIVector<complex<type>> & in); \
|
||||
const PIVector<complex<type>> & calcFFTR(const PIVector<type> & in); \
|
||||
const PIVector<complex<type>> & calcFFTI(const PIVector<complex<type>> & in); \
|
||||
void preparePlan(int size, int op); \
|
||||
void * impl; \
|
||||
};
|
||||
# define _PIFFTW_H(type) \
|
||||
class PIP_FFTW_EXPORT _PIFFTW_P_##type##_ { \
|
||||
public: \
|
||||
_PIFFTW_P_##type##_(); \
|
||||
~_PIFFTW_P_##type##_(); \
|
||||
const PIVector<complex<type>> & calcFFT(const PIVector<complex<type>> & in); \
|
||||
const PIVector<complex<type>> & calcFFTR(const PIVector<type> & in); \
|
||||
const PIVector<complex<type>> & calcFFTI(const PIVector<complex<type>> & in); \
|
||||
void preparePlan(int size, int op); \
|
||||
void * impl; \
|
||||
};
|
||||
_PIFFTW_H(float)
|
||||
_PIFFTW_H(double)
|
||||
_PIFFTW_H(ldouble)
|
||||
|
||||
//! \addtogroup FFTW
|
||||
//! \{
|
||||
//! \class PIFFTW
|
||||
//! \brief
|
||||
//! \~english FFTW wrapper for arbitrary precision types.
|
||||
//! \~russian Обёртка FFTW для типов произвольной точности.
|
||||
//! \~\}
|
||||
//! \note Requires linking against libfftw3
|
||||
//! \sa \a PIFFT_double, \a PIFFT_float
|
||||
template<typename T>
|
||||
class PIFFTW {
|
||||
public:
|
||||
//! \~english Default constructor.
|
||||
//! \~russian Конструктор по умолчанию.
|
||||
explicit PIFFTW() {
|
||||
p = 0;
|
||||
newP(p);
|
||||
}
|
||||
//! \~english Destructor.
|
||||
//! \~russian Деструктор.
|
||||
~PIFFTW() { deleteP(p); }
|
||||
|
||||
//! \~english Calculate FFT from complex vector.
|
||||
//! \~russian Вычисление БПФ из комплексного вектора.
|
||||
inline const PIVector<complex<T>> & calcFFT(const PIVector<complex<T>> & in) { return PIVector<complex<T>>().resize(in.size()); }
|
||||
//! \~english Calculate FFT from real vector.
|
||||
//! \~russian Вычисление БПФ из вещественного вектора.
|
||||
inline const PIVector<complex<T>> & calcFFT(const PIVector<T> & in) { return PIVector<complex<T>>().resize(in.size()); }
|
||||
//! \~english Calculate inverse FFT.
|
||||
//! \~russian Вычисление обратного БПФ.
|
||||
inline const PIVector<complex<T>> & calcFFTinverse(const PIVector<complex<T>> & in) { return PIVector<complex<T>>().resize(in.size()); }
|
||||
|
||||
//! \~english FFT operation type.
|
||||
//! \~russian Тип операции БПФ.
|
||||
enum FFT_Operation {
|
||||
foReal,
|
||||
foComplex,
|
||||
foInverse
|
||||
};
|
||||
|
||||
//! \~english Prepare computation plan.
|
||||
//! \~russian Подготовить план вычислений.
|
||||
inline void preparePlan(int size, FFT_Operation op) {}
|
||||
|
||||
private:
|
||||
@@ -297,7 +222,6 @@ private:
|
||||
|
||||
void * p;
|
||||
};
|
||||
//! \~\}
|
||||
|
||||
|
||||
template<>
|
||||
|
||||
@@ -1,13 +1,21 @@
|
||||
//! \addtogroup Math
|
||||
//! \{
|
||||
//! \file pigeometry.h
|
||||
//! \brief
|
||||
//! \~english Geometry utilities
|
||||
//! \~russian Геометрические утилиты
|
||||
//! \~\authors
|
||||
//! \~english Ivan Pelipenko peri4ko@yandex.ru; Andrey Bychkov work.a.b@yandex.ru
|
||||
//! \~russian Иван Пелипенко peri4ko@yandex.ru; Андрей Бычков work.a.b@yandex.ru
|
||||
//! \~\}
|
||||
/*! \file pigeometry.h
|
||||
* \ingroup Math
|
||||
* \brief
|
||||
* \~english Geometry base classes
|
||||
* \~russian Базовые геометрические классы
|
||||
* \~\details
|
||||
* \~english
|
||||
* Add \a PIPoint, \a PILine and \a PIRect classes.
|
||||
* \~russian
|
||||
* Содержит классы: \a PIPoint, \a PILine и \a PIRect.
|
||||
* * \~\authors
|
||||
* \~english
|
||||
* Ivan Pelipenko peri4ko@yandex.ru;
|
||||
* Andrey Bychkov work.a.b@yandex.ru;
|
||||
* \~russian
|
||||
* Иван Пелипенко peri4ko@yandex.ru;
|
||||
* Андрей Бычков work.a.b@yandex.ru;
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Geometry base classes
|
||||
|
||||
@@ -315,7 +315,7 @@ public:
|
||||
}
|
||||
|
||||
static _CVector cross(const _CVector & v1, const _CVector & v2) { return v1.cross(v2); }
|
||||
static Type dot(const _CVector & v1, const _CVector & v2) { return v1.dot(v2); }
|
||||
static _CVector dot(const _CVector & v1, const _CVector & v2) { return v1.dot(v2); }
|
||||
static _CVector mul(const _CVector & v1, const _CVector & v2) { return v1.mul(v2); }
|
||||
static _CVector mul(const Type & v1, const _CVector & v2) { return v2 * v1; }
|
||||
static _CVector mul(const _CVector & v1, const Type & v2) { return v1 * v2; }
|
||||
@@ -581,7 +581,7 @@ public:
|
||||
|
||||
|
||||
static _CVector cross(const _CVector & v1, const _CVector & v2) { return v1.cross(v2); }
|
||||
static Type dot(const _CVector & v1, const _CVector & v2) { return v1.dot(v2); }
|
||||
static _CVector dot(const _CVector & v1, const _CVector & v2) { return v1.dot(v2); }
|
||||
static _CVector mul(const _CVector & v1, const _CVector & v2) { return v1.mul(v2); }
|
||||
static _CVector mul(const Type & v1, const _CVector & v2) { return v2 * v1; }
|
||||
static _CVector mul(const _CVector & v1, const Type & v2) { return v1 * v2; }
|
||||
|
||||
@@ -46,8 +46,8 @@ public:
|
||||
bool calculate(const PIVector<T> & val, const T & given_mean) {
|
||||
T v = T(), v1 = T(), v2 = T(), stddev = T(), var = T();
|
||||
int i, n = val.size();
|
||||
mean = given_mean;
|
||||
if (n < 2) return false;
|
||||
mean = given_mean;
|
||||
variance = skewness = kurtosis = T();
|
||||
// Variance (using corrected two-pass algorithm)
|
||||
for (i = 0; i < n; i++)
|
||||
|
||||
@@ -21,10 +21,7 @@
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//! \~english OpenCL module
|
||||
//! \~russian Модуль OpenCL
|
||||
*/
|
||||
//! \defgroup OpenCL OpenCL
|
||||
//! \~\brief
|
||||
//! \~english OpenCL support
|
||||
@@ -66,41 +63,17 @@
|
||||
|
||||
class PIP_OPENCL_EXPORT PIOpenCL {
|
||||
public:
|
||||
//! \~english Kernel argument structure
|
||||
//! \~russian Структура аргумента ядра
|
||||
struct KernelArg;
|
||||
|
||||
//! \~english Device structure
|
||||
//! \~russian Структура устройства
|
||||
struct Device;
|
||||
|
||||
//! \~english Platform structure
|
||||
//! \~russian Структура платформы
|
||||
struct Platform;
|
||||
|
||||
//! \~english OpenCL context class
|
||||
//! \~russian Класс контекста OpenCL
|
||||
class Context;
|
||||
|
||||
//! \~english OpenCL buffer class
|
||||
//! \~russian Класс буфера OpenCL
|
||||
class Buffer;
|
||||
|
||||
//! \~english OpenCL program class
|
||||
//! \~russian Класс программы OpenCL
|
||||
class Program;
|
||||
|
||||
//! \~english OpenCL kernel class
|
||||
//! \~russian Класс ядра OpenCL
|
||||
class Kernel;
|
||||
|
||||
//! \~english List of devices
|
||||
//! \~russian Список устройств
|
||||
typedef PIVector<Device> DeviceList;
|
||||
|
||||
|
||||
//! \~english Address space qualifiers
|
||||
//! \~russian Квалификаторы адресного пространства
|
||||
enum AddressQualifier {
|
||||
AddressGlobal,
|
||||
AddressLocal,
|
||||
@@ -108,8 +81,6 @@ public:
|
||||
AddressPrivate,
|
||||
};
|
||||
|
||||
//! \~english Access qualifiers
|
||||
//! \~russian Квалификаторы доступа
|
||||
enum AccessQualifier {
|
||||
AccessReadOnly,
|
||||
AccessWriteOnly,
|
||||
@@ -117,16 +88,12 @@ public:
|
||||
AccessNone,
|
||||
};
|
||||
|
||||
//! \~english Buffer direction
|
||||
//! \~russian Направление буфера
|
||||
enum Direction {
|
||||
Input = 0x01,
|
||||
Output = 0x02,
|
||||
InputOutput = Input | Output,
|
||||
};
|
||||
|
||||
//! \~english Type qualifiers
|
||||
//! \~russian Квалификаторы типа
|
||||
enum TypeQualifier {
|
||||
TypeConst,
|
||||
TypeRestrict,
|
||||
@@ -134,8 +101,6 @@ public:
|
||||
TypeNone,
|
||||
};
|
||||
|
||||
//! \~english Argument types
|
||||
//! \~russian Типы аргументов
|
||||
enum ArgType {
|
||||
Char = 1,
|
||||
UChar,
|
||||
@@ -150,51 +115,17 @@ public:
|
||||
};
|
||||
|
||||
|
||||
//! \~english Kernel argument information
|
||||
//! \~russian Информация об аргументе ядра
|
||||
struct PIP_OPENCL_EXPORT KernelArg {
|
||||
//! \~english Default constructor
|
||||
//! \~russian Конструктор по умолчанию
|
||||
KernelArg();
|
||||
|
||||
//! \~english Address qualifier
|
||||
//! \~russian Квалификатор адреса
|
||||
AddressQualifier address_qualifier;
|
||||
|
||||
//! \~english Access qualifier
|
||||
//! \~russian Квалификатор доступа
|
||||
AccessQualifier access_qualifier;
|
||||
|
||||
//! \~english Buffer direction
|
||||
//! \~russian Направление буфера
|
||||
Direction direction;
|
||||
|
||||
//! \~english Type qualifier
|
||||
//! \~russian Квалификатор типа
|
||||
TypeQualifier type_qualifier;
|
||||
|
||||
//! \~english Argument name
|
||||
//! \~russian Имя аргумента
|
||||
PIString arg_name;
|
||||
|
||||
//! \~english Type name
|
||||
//! \~russian Имя типа
|
||||
PIString type_name;
|
||||
|
||||
//! \~english Base type name
|
||||
//! \~russian Имя базового типа
|
||||
PIString base_type_name;
|
||||
|
||||
//! \~english Is pointer
|
||||
//! \~russian Является указателем
|
||||
bool is_pointer;
|
||||
|
||||
//! \~english Argument type
|
||||
//! \~russian Тип аргумента
|
||||
ArgType arg_type;
|
||||
|
||||
//! \~english Dimensions
|
||||
//! \~russian Размерности
|
||||
int dims;
|
||||
|
||||
private:
|
||||
@@ -203,180 +134,68 @@ public:
|
||||
};
|
||||
|
||||
|
||||
//! \~english OpenCL device information
|
||||
//! \~russian Информация об устройстве OpenCL
|
||||
struct PIP_OPENCL_EXPORT Device {
|
||||
//! \~english Default constructor
|
||||
//! \~russian Конструктор по умолчанию
|
||||
Device() {
|
||||
id = platform_id = 0;
|
||||
max_compute_units = max_clock_frequency = 0;
|
||||
max_memory_size = 0;
|
||||
}
|
||||
|
||||
//! \~english Check if device is valid
|
||||
//! \~russian Проверить устройство на корректность
|
||||
bool isValid() const { return id != 0; }
|
||||
|
||||
//! \~english Get display text
|
||||
//! \~russian Получить текст для отображения
|
||||
PIString displayText() const { return name.trimmed() + " (" + device_version.trimmed() + ")"; }
|
||||
|
||||
//! \~english Device handle
|
||||
//! \~russian Дескриптор устройства
|
||||
void * id;
|
||||
|
||||
//! \~english Platform ID
|
||||
//! \~russian ID платформы
|
||||
void * platform_id;
|
||||
|
||||
//! \~english Device name
|
||||
//! \~russian Имя устройства
|
||||
PIString name;
|
||||
|
||||
//! \~english Vendor name
|
||||
//! \~russian Имя производителя
|
||||
PIString vendor;
|
||||
|
||||
//! \~english Device version
|
||||
//! \~russian Версия устройства
|
||||
PIString device_version;
|
||||
|
||||
//! \~english Driver version
|
||||
//! \~russian Версия драйвера
|
||||
PIString driver_version;
|
||||
|
||||
//! \~english Maximum compute units
|
||||
//! \~russian Максимум вычислительных блоков
|
||||
int max_compute_units;
|
||||
|
||||
//! \~english Maximum clock frequency
|
||||
//! \~russian Максимальная тактовая частота
|
||||
int max_clock_frequency;
|
||||
|
||||
//! \~english Maximum memory size
|
||||
//! \~russian Максимальный размер памяти
|
||||
ullong max_memory_size;
|
||||
};
|
||||
|
||||
|
||||
//! \~english OpenCL platform information
|
||||
//! \~russian Информация о платформе OpenCL
|
||||
struct PIP_OPENCL_EXPORT Platform {
|
||||
//! \~english Default constructor
|
||||
//! \~russian Конструктор по умолчанию
|
||||
Platform() { id = 0; }
|
||||
|
||||
//! \~english Check if platform is valid
|
||||
//! \~russian Проверить платформу на корректность
|
||||
bool isValid() const { return id != 0; }
|
||||
|
||||
//! \~english Get display text
|
||||
//! \~russian Получить текст для отображения
|
||||
PIString displayText() const { return name.trimmed() + " (" + version.trimmed() + ", " + profile.trimmed() + ")"; }
|
||||
|
||||
//! \~english Platform handle
|
||||
//! \~russian Дескриптор платформы
|
||||
void * id;
|
||||
|
||||
//! \~english Platform name
|
||||
//! \~russian Имя платформы
|
||||
PIString name;
|
||||
|
||||
//! \~english Vendor name
|
||||
//! \~russian Имя производителя
|
||||
PIString vendor;
|
||||
|
||||
//! \~english Profile
|
||||
//! \~russian Профиль
|
||||
PIString profile;
|
||||
|
||||
//! \~english Version
|
||||
//! \~russian Версия
|
||||
PIString version;
|
||||
|
||||
//! \~english Extensions
|
||||
//! \~russian Расширения
|
||||
PIStringList extensions;
|
||||
|
||||
//! \~english Available devices
|
||||
//! \~russian Доступные устройства
|
||||
PIVector<Device> devices;
|
||||
};
|
||||
|
||||
|
||||
//! \~english OpenCL context for managing devices and resources
|
||||
//! \~russian Контекст OpenCL для управления устройствами и ресурсами
|
||||
class PIP_OPENCL_EXPORT Context {
|
||||
friend class Buffer;
|
||||
friend class Program;
|
||||
friend class Kernel;
|
||||
|
||||
public:
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
~Context();
|
||||
|
||||
//! \~english Get context handle
|
||||
//! \~russian Получить дескриптор контекста
|
||||
void * handle();
|
||||
|
||||
//! \~english Get command queue
|
||||
//! \~russian Получить очередь команд
|
||||
void * queue();
|
||||
|
||||
//! \~english Create context for device list
|
||||
//! \~russian Создать контекст для списка устройств
|
||||
//! \param dl List of devices
|
||||
//! \return New context or nullptr
|
||||
static Context * create(const DeviceList & dl);
|
||||
|
||||
//! \~english Create context for single device
|
||||
//! \~russian Создать контекст для одного устройства
|
||||
//! \param d Device
|
||||
//! \return New context or nullptr
|
||||
static Context * create(const Device & d) { return create(DeviceList() << d); }
|
||||
|
||||
//! \~english Create context by platform name
|
||||
//! \~russian Создать контекст по имени платформы
|
||||
//! \param part_name Platform name pattern
|
||||
//! \return New context or nullptr
|
||||
static Context * create(const PIString & part_name);
|
||||
|
||||
//! \~english Create program from source
|
||||
//! \~russian Создать программу из исходного кода
|
||||
//! \param source OpenCL source code
|
||||
//! \param args Build arguments
|
||||
//! \param error Error message output
|
||||
//! \return New program or nullptr
|
||||
Program * createProgram(const PIString & source, const PIStringList & args = PIStringList(), PIString * error = 0);
|
||||
|
||||
//! \~english Create buffer from vector
|
||||
//! \~russian Создать буфер из вектора
|
||||
template<typename T>
|
||||
Buffer * createBuffer(PIOpenCL::Direction dir, PIVector<T> & container) {
|
||||
T def = T();
|
||||
return createBuffer(dir, &container, Buffer::cVector, PIByteArray(&def, sizeof(T)), container.size());
|
||||
}
|
||||
|
||||
//! \~english Create buffer from deque
|
||||
//! \~russian Создать буфер из deque
|
||||
template<typename T>
|
||||
Buffer * createBuffer(PIOpenCL::Direction dir, PIDeque<T> & container) {
|
||||
T def = T();
|
||||
return createBuffer(dir, &container, Buffer::cDeque, PIByteArray(&def, sizeof(T)), container.size());
|
||||
}
|
||||
|
||||
//! \~english Create buffer from 2D vector
|
||||
//! \~russian Создать буфер из 2D вектора
|
||||
template<typename T>
|
||||
Buffer * createBuffer(PIOpenCL::Direction dir, PIVector2D<T> & container) {
|
||||
T def = T();
|
||||
return createBuffer(dir, &container, Buffer::cVector2D, PIByteArray(&def, sizeof(T)), container.size());
|
||||
}
|
||||
|
||||
//! \~english Create buffer for elements
|
||||
//! \~russian Создать буфер для элементов
|
||||
template<typename T>
|
||||
Buffer * createBuffer(PIOpenCL::Direction dir, uint elements) {
|
||||
T def = T();
|
||||
@@ -397,70 +216,26 @@ public:
|
||||
};
|
||||
|
||||
|
||||
//! \~english OpenCL buffer for data storage
|
||||
//! \~russian Буфер OpenCL для хранения данных
|
||||
class PIP_OPENCL_EXPORT Buffer {
|
||||
friend class Context;
|
||||
friend class Kernel;
|
||||
|
||||
public:
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
~Buffer();
|
||||
|
||||
//! \~english Get buffer handle
|
||||
//! \~russian Получить дескриптор буфера
|
||||
void * handle();
|
||||
|
||||
//! \~english Resize buffer
|
||||
//! \~russian Изменить размер буфера
|
||||
//! \param new_elements New number of elements
|
||||
//! \return true if successful
|
||||
bool resize(uint new_elements);
|
||||
|
||||
//! \~english Clear buffer
|
||||
//! \~russian Очистить буфер
|
||||
void clear();
|
||||
|
||||
//! \~english Copy to container
|
||||
//! \~russian Копировать в контейнер
|
||||
void copyToContainer();
|
||||
|
||||
//! \~english Copy to memory
|
||||
//! \~russian Копировать в память
|
||||
void copyTo(void * data);
|
||||
|
||||
//! \~english Copy to memory with offset
|
||||
//! \~russian Копировать в память со смещением
|
||||
void copyTo(void * data, int elements_count, int elements_offset = 0);
|
||||
|
||||
//! \~english Copy to another buffer
|
||||
//! \~russian Копировать в другой буфер
|
||||
void copyTo(Buffer * buffer, int elements_count = -1, int elements_from_offset = 0, int elements_to_offset = 0);
|
||||
|
||||
//! \~english Copy from container
|
||||
//! \~russian Копировать из контейнера
|
||||
void copyFromContainer();
|
||||
|
||||
//! \~english Copy from memory
|
||||
//! \~russian Копировать из памяти
|
||||
void copyFrom(void * data);
|
||||
|
||||
//! \~english Copy from memory with offset
|
||||
//! \~russian Копировать из памяти со смещением
|
||||
void copyFrom(void * data, int elements_count, int elements_offset = 0);
|
||||
|
||||
//! \~english Copy from another buffer
|
||||
//! \~russian Копировать из другого буфера
|
||||
void copyFrom(Buffer * buffer, int elements_count = -1, int elements_from_offset = 0, int elements_to_offset = 0);
|
||||
|
||||
//! \~english Get elements count
|
||||
//! \~russian Получить количество элементов
|
||||
uint elementsCount() const { return elements; }
|
||||
|
||||
private:
|
||||
//! \~english Container types
|
||||
//! \~russian Типы контейнеров
|
||||
enum Container {
|
||||
cNone,
|
||||
cVector,
|
||||
@@ -482,32 +257,16 @@ public:
|
||||
};
|
||||
|
||||
|
||||
//! \~english OpenCL program containing kernels
|
||||
//! \~russian Программа OpenCL содержащая ядра
|
||||
class PIP_OPENCL_EXPORT Program {
|
||||
friend class Context;
|
||||
friend class Kernel;
|
||||
friend class Buffer;
|
||||
|
||||
public:
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
~Program();
|
||||
|
||||
//! \~english Get context
|
||||
//! \~russian Получить контекст
|
||||
Context * context() const { return context_; }
|
||||
|
||||
//! \~english Get source code
|
||||
//! \~russian Получить исходный код
|
||||
const PIString & sourceCode() const { return source_; }
|
||||
|
||||
//! \~english Get kernel by index
|
||||
//! \~russian Получить ядро по индексу
|
||||
Kernel * kernel(int index = 0) const { return kernels_[index]; }
|
||||
|
||||
//! \~english Get all kernels
|
||||
//! \~russian Получить все ядра
|
||||
const PIVector<Kernel *> & kernels() const { return kernels_; }
|
||||
|
||||
private:
|
||||
@@ -521,68 +280,28 @@ public:
|
||||
};
|
||||
|
||||
|
||||
//! \~english OpenCL kernel for execution
|
||||
//! \~russian Ядро OpenCL для выполнения
|
||||
class PIP_OPENCL_EXPORT Kernel {
|
||||
friend class Program;
|
||||
friend class Buffer;
|
||||
|
||||
public:
|
||||
//! \~english Get parent program
|
||||
//! \~russian Получить родительскую программу
|
||||
Program * program() const { return program_; }
|
||||
|
||||
//! \~english Execute kernel
|
||||
//! \~russian Выполнить ядро
|
||||
//! \return true if successful
|
||||
bool execute();
|
||||
|
||||
//! \~english Wait for execution to finish
|
||||
//! \~russian Ждать завершения выполнения
|
||||
void waitForFinish();
|
||||
|
||||
//! \~english Set execution range (1D)
|
||||
//! \~russian Установить диапазон выполнения (1D)
|
||||
//! \param size Number of work items
|
||||
void setExecuteRange(int size) { setExecuteRanges(PIVector<int>() << size); }
|
||||
|
||||
//! \~english Set execution ranges (ND)
|
||||
//! \~russian Установить диапазоны выполнения (ND)
|
||||
//! \param ranges Array of sizes per dimension
|
||||
void setExecuteRanges(const PIVector<int> & ranges);
|
||||
|
||||
//! \~english Get kernel name
|
||||
//! \~russian Получить имя ядра
|
||||
const PIString & name() const { return name_; }
|
||||
|
||||
//! \~english Get kernel arguments
|
||||
//! \~russian Получить аргументы ядра
|
||||
const PIVector<KernelArg> & args() const { return args_; }
|
||||
|
||||
//! \~english Set argument value by index
|
||||
//! \~russian Установить значение аргумента по индексу
|
||||
template<typename T>
|
||||
bool setArgValue(int index, const T & value) {
|
||||
return setArgValueS(index, PIVariant::fromValue(value));
|
||||
}
|
||||
|
||||
//! \~english Set argument value by name
|
||||
//! \~russian Установить значение аргумента по имени
|
||||
template<typename T>
|
||||
bool setArgValue(const PIString & arg, const T & value) {
|
||||
return setArgValue(argIndex(arg), value);
|
||||
}
|
||||
|
||||
//! \~english Set variant argument value
|
||||
//! \~russian Установить значение аргумента variant
|
||||
bool setArgValue(const PIString & arg, const PIVariant & value) { return setArgValueS(argIndex(arg), value); }
|
||||
|
||||
//! \~english Bind buffer to argument
|
||||
//! \~russian Привязать буфер к аргументу
|
||||
bool bindArgValue(int index, Buffer * buffer);
|
||||
|
||||
//! \~english Bind buffer to argument by name
|
||||
//! \~russian Привязать буфер к аргументу по имени
|
||||
bool bindArgValue(const PIString & arg, Buffer * buffer) { return bindArgValue(argIndex(arg), buffer); }
|
||||
|
||||
private:
|
||||
@@ -602,37 +321,15 @@ public:
|
||||
};
|
||||
|
||||
|
||||
//! \~english Initialize OpenCL
|
||||
//! \~russian Инициализировать OpenCL
|
||||
static void init();
|
||||
|
||||
//! \~english Get available platforms
|
||||
//! \~russian Получить доступные платформы
|
||||
//! \return Vector of platforms
|
||||
static const PIVector<Platform> & platforms();
|
||||
|
||||
//! \~english Get all available devices
|
||||
//! \~russian Получить все доступные устройства
|
||||
//! \return Vector of devices
|
||||
static const PIVector<Device> devices();
|
||||
|
||||
//! \~english Get device by ID
|
||||
//! \~russian Получить устройство по ID
|
||||
//! \param id Device handle
|
||||
//! \return Device info
|
||||
static Device deviceByID(void * id);
|
||||
|
||||
//! \~english Prepare program source
|
||||
//! \~russian Подготовить исходный код программы
|
||||
//! \param prog Program source
|
||||
//! \return Prepared source
|
||||
static PIString prepareProgram(const PIString & prog);
|
||||
|
||||
private:
|
||||
static PIString prog_header;
|
||||
PIOpenCL() { ; }
|
||||
//! \~english Initialization helper
|
||||
//! \~russian Помощник инициализации
|
||||
class PIP_OPENCL_EXPORT Initializer {
|
||||
public:
|
||||
Initializer();
|
||||
@@ -644,8 +341,6 @@ private:
|
||||
};
|
||||
|
||||
|
||||
//! \~english Output stream operator for KernelArg
|
||||
//! \~russian Оператор вывода в поток для KernelArg
|
||||
PIP_OPENCL_EXPORT PICout operator<<(PICout s, const PIOpenCL::KernelArg & v);
|
||||
|
||||
|
||||
|
||||
@@ -17,40 +17,6 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//! \~english PIP - Platform Independent Primitives
|
||||
//! \~russian PIP - Кроссплатформенные примитивы
|
||||
//! \mainpage
|
||||
//!
|
||||
//! \~\brief
|
||||
//! \~english Main include file for PIP library
|
||||
//! \~russian Главный включаемый файл библиотеки PIP
|
||||
//!
|
||||
//! \~\details
|
||||
//! \~english \section overview Overview
|
||||
//! \~russian \section overview Обзор
|
||||
//!
|
||||
//! \~english
|
||||
//! PIP is a C++ cross-platform library providing platform-independent abstractions for:
|
||||
//! * Core/Types: Strings, variants, containers, datetime, networks
|
||||
//! * Threading: Mutexes, semaphores, thread pools, timers
|
||||
//! * I/O: Files, serial, CAN, GPIO, SPI, Ethernet
|
||||
//! * Math: Vectors, matrices, FFT, quaternions
|
||||
//! * Crypto: MD5, SHA, BLAKE2, SipHash
|
||||
//! * Compression: zlib support
|
||||
//! * HTTP: Client and server support
|
||||
//! * Serialization: JSON, binary, XML
|
||||
//!
|
||||
//! \~russian
|
||||
//! PIP - это кроссплатформенная C++ библиотека, предоставляющая платформонезависимые абстракции для:
|
||||
//! * Ядро/Типы: Строки, варианты, контейнеры, дата/время, сети
|
||||
//! * Потоки: Мьютексы, семафоры, пулы потоков, таймеры
|
||||
//! * Ввод/Вывод: Файлы, последовательные порты, CAN, GPIO, SPI, Ethernet
|
||||
//! * Математика: Векторы, матрицы, FFT, кватернионы
|
||||
//! * Криптография: MD5, SHA, BLAKE2, SipHash
|
||||
//! * Сжатие: Поддержка zlib
|
||||
//! * HTTP: Клиент и сервер
|
||||
//! * Сериализация: JSON, бинарная, XML
|
||||
|
||||
#ifndef PIP_H
|
||||
#define PIP_H
|
||||
|
||||
|
||||
@@ -22,15 +22,12 @@
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
//! \~english Resources subsystem
|
||||
//! \~russian Подсистема ресурсов
|
||||
//! \defgroup Resources Resources
|
||||
//! \~\brief
|
||||
//! \~english Resources subsystem
|
||||
//! \~russian Подсистема ресурсов
|
||||
//!
|
||||
//! \~\details
|
||||
//! \~
|
||||
//! \~english \section cmake_module_Resources Building with CMake
|
||||
//! \~russian \section cmake_module_Resources Сборка с использованием CMake
|
||||
//!
|
||||
@@ -62,31 +59,18 @@
|
||||
|
||||
#include "pistring.h"
|
||||
|
||||
//! \~english Macro for initializing compiled-in resources
|
||||
//! \~russian Макрос для инициализации вкомпиленных ресурсов
|
||||
#define INIT_RESOURCE(name) \
|
||||
{ \
|
||||
extern void _pirc_##name##_init_(); \
|
||||
_pirc_##name##_init_(); \
|
||||
}
|
||||
#define INIT_RESOURCE(name) \
|
||||
{ \
|
||||
extern void _pirc_##name##_init_(); \
|
||||
_pirc_##name##_init_(); \
|
||||
}
|
||||
|
||||
//! \~english Class for accessing compiled-in resources
|
||||
//! \~russian Класс для доступа к вкомпиленным ресурсам
|
||||
class PIP_EXPORT PIResources {
|
||||
public:
|
||||
//! \~english Get resource by section and name
|
||||
//! \~russian Получить ресурс по секции и имени
|
||||
//! \details
|
||||
//! \~english Searches for resource in specified section
|
||||
//! \~russian Ищет ресурс в указанной секции
|
||||
//!
|
||||
static PIByteArray get(const PIString & section, const PIString & name);
|
||||
|
||||
//! \~english Get resource by name (searches all sections)
|
||||
//! \~russian Получить ресурс по имени (ищет во всех секциях)
|
||||
static PIByteArray get(const PIString & name);
|
||||
|
||||
//! \~english Dump all resources to console
|
||||
//! \~russian Вывести все ресурсы в консоль
|
||||
static void dump();
|
||||
|
||||
private:
|
||||
|
||||
@@ -17,13 +17,6 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//! \~english Resources storage subsystem
|
||||
//! \~russian Подсистема хранения ресурсов
|
||||
//! \defgroup Resources Resources
|
||||
//! \~\brief
|
||||
//! \~english Resources storage subsystem
|
||||
//! \~russian Подсистема хранения ресурсов
|
||||
|
||||
#ifndef PIRESOURCES_P_H
|
||||
#define PIRESOURCES_P_H
|
||||
|
||||
@@ -33,36 +26,17 @@
|
||||
|
||||
class PIResources;
|
||||
|
||||
//! \~english Storage for compiled-in resources
|
||||
//! \~russian Хранилище вкомпиленных ресурсов
|
||||
class PIP_EXPORT PIResourcesStorage {
|
||||
friend class PIResources;
|
||||
|
||||
public:
|
||||
//! \~english Get singleton instance
|
||||
//! \~russian Получить синглтон
|
||||
static PIResourcesStorage * instance();
|
||||
|
||||
//! \~english Section containing resource entries
|
||||
//! \~russian Секция, содержащая записи ресурсов
|
||||
struct PIP_EXPORT Section {
|
||||
//! \~english Constructor
|
||||
//! \~russian Конструктор
|
||||
Section();
|
||||
//! \~english Destructor
|
||||
//! \~russian Деструктор
|
||||
~Section();
|
||||
|
||||
//! \~english Add another section to this one
|
||||
//! \~russian Добавить другую секцию к этой
|
||||
void add(const Section & s);
|
||||
|
||||
//! \~english Clear all entries
|
||||
//! \~russian Очистить все записи
|
||||
void purge();
|
||||
|
||||
//! \~english Map of resource names to data
|
||||
//! \~russian Карта имен ресурсов к данным
|
||||
PIMap<PIString, PIByteArray *> entries;
|
||||
};
|
||||
|
||||
@@ -82,65 +56,21 @@ public:
|
||||
size = si;
|
||||
flags = fl;
|
||||
}
|
||||
|
||||
//! \~english Section name
|
||||
//! \~russian Имя секции
|
||||
PIString section;
|
||||
|
||||
//! \~english Resource name
|
||||
//! \~russian Имя ресурса
|
||||
PIString name;
|
||||
|
||||
//! \~english Alias
|
||||
//! \~russian Псевдоним
|
||||
PIString alias;
|
||||
|
||||
//! \~english Source file
|
||||
//! \~russian Исходный файл
|
||||
PIString file;
|
||||
|
||||
//! \~english Offset in file
|
||||
//! \~russian Смещение в файле
|
||||
llong offset;
|
||||
|
||||
//! \~english Size
|
||||
//! \~russian Размер
|
||||
llong size;
|
||||
|
||||
//! \~english Flags
|
||||
//! \~russian Флаги
|
||||
int flags;
|
||||
};
|
||||
|
||||
//! \~english Register a section with data
|
||||
//! \~russian Зарегистрировать секцию с данными
|
||||
//! \param section_name Name of the section
|
||||
//! \param data Section data
|
||||
void registerSection(const PIString & section_name, const Section & data);
|
||||
|
||||
//! \~english Register from raw data
|
||||
//! \~russian Зарегистрировать из сырых данных
|
||||
//! \param rc_data Resource data
|
||||
//! \param rc_desc Resource description
|
||||
//! \param rc_desc_size Description size
|
||||
void registerSection(const uchar * rc_data, const uchar * rc_desc, int rc_desc_size);
|
||||
|
||||
//! \~english Get section by name
|
||||
//! \~russian Получить секцию по имени
|
||||
//! \param section_name Name of section
|
||||
//! \return Pointer to section or nullptr
|
||||
Section * section(const PIString & section_name) const;
|
||||
|
||||
//! \~english Get resource by section and name
|
||||
//! \~russian Получить ресурс по секции и имени
|
||||
PIByteArray get(const PIString & section_name, const PIString & entry_name) const;
|
||||
|
||||
//! \~english Get resource by name (searches all sections)
|
||||
//! \~russian Получить ресурс по имени (ищет во всех секциях)
|
||||
PIByteArray get(const PIString & entry_name) const;
|
||||
|
||||
//! \~english Clear all sections
|
||||
//! \~russian Очистить все секции
|
||||
void clear();
|
||||
|
||||
private:
|
||||
|
||||
@@ -400,9 +400,9 @@ PIJSON PIJSON::parseValue(PIString & s) {
|
||||
s.trim();
|
||||
if (s.isEmpty()) return ret;
|
||||
if (s[0] == '{') {
|
||||
ret = parseObject(s.takeRange('{', '}').trim());
|
||||
ret = parseObject(s.takeRange('{', '}'));
|
||||
} else if (s[0] == '[') {
|
||||
ret = parseArray(s.takeRange('[', ']').trim());
|
||||
ret = parseArray(s.takeRange('[', ']'));
|
||||
} else {
|
||||
s.trim();
|
||||
if (s.startsWith('"')) {
|
||||
|
||||
@@ -42,14 +42,6 @@ PIString mask(const PIString & str) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
PIString overrideFile(PIString path) {
|
||||
if (path.isEmpty()) return {};
|
||||
PIFile::FileInfo fi(path);
|
||||
auto ext = fi.extension();
|
||||
path.insert(path.size_s() - ext.size_s() - (ext.isEmpty() ? 0 : 1), ".override");
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
PIValueTree PIValueTreeConversions::fromPropertyStorage(const PIPropertyStorage & ps) {
|
||||
PIValueTree ret;
|
||||
@@ -300,11 +292,7 @@ PIString toTextTree(const PIValueTree & root, PIString prefix, PIValueTreeConver
|
||||
ret += "\n[" + prefix + "]\n";
|
||||
if (root.isArray() && options[PIValueTreeConversions::WithAttributes]) ret += toTextTreeAttributes(root, "", options);
|
||||
for (const auto & c: root.children()) {
|
||||
if (c.hasChildren()) continue;
|
||||
ret += toTextTree(c, prefix, options);
|
||||
}
|
||||
for (const auto & c: root.children()) {
|
||||
if (!c.hasChildren()) continue;
|
||||
PIString cp = prefix;
|
||||
ret += toTextTree(c, prefix, options);
|
||||
}
|
||||
} else {
|
||||
@@ -327,13 +315,9 @@ PIString toTextTree(const PIValueTree & root, PIString prefix, PIValueTreeConver
|
||||
PIString PIValueTreeConversions::toText(const PIValueTree & root, Options options) {
|
||||
PIString ret;
|
||||
for (const auto & c: root.children()) {
|
||||
if (c.hasChildren()) continue;
|
||||
ret += toTextTree(c, {}, options);
|
||||
}
|
||||
for (const auto & c: root.children()) {
|
||||
if (!c.hasChildren()) continue;
|
||||
ret += toTextTree(c, {}, options);
|
||||
ret += toTextTree(c, PIString(), options);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -345,26 +329,13 @@ PIValueTree PIValueTreeConversions::fromText(const PIString & str) {
|
||||
|
||||
|
||||
PIValueTree PIValueTreeConversions::fromJSONFile(const PIString & path) {
|
||||
auto ret = PIValueTreeConversions::fromJSON(PIJSON::fromJSON(PIString::fromUTF8(PIFile::readAll(path))));
|
||||
auto ofp = overrideFile(path);
|
||||
if (PIFile::isExists(ofp)) {
|
||||
auto override_vt = PIValueTreeConversions::fromJSON(PIJSON::fromJSON(PIString::fromUTF8(PIFile::readAll(ofp))));
|
||||
ret.merge(override_vt);
|
||||
}
|
||||
return ret;
|
||||
return PIValueTreeConversions::fromJSON(PIJSON::fromJSON(PIString::fromUTF8(PIFile::readAll(path))));
|
||||
}
|
||||
|
||||
|
||||
PIValueTree PIValueTreeConversions::fromTextFile(const PIString & path) {
|
||||
PIFile f(path, PIIODevice::ReadOnly);
|
||||
auto ret = PIValueTreeConversions::fromText(&f);
|
||||
auto ofp = overrideFile(path);
|
||||
if (PIFile::isExists(ofp)) {
|
||||
PIFile of(ofp, PIIODevice::ReadOnly);
|
||||
auto override_vt = PIValueTreeConversions::fromText(&of);
|
||||
ret.merge(override_vt);
|
||||
}
|
||||
return ret;
|
||||
return PIValueTreeConversions::fromText(&f);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -31,16 +31,12 @@
|
||||
|
||||
namespace PIStateMachineHelpers {
|
||||
|
||||
//! \~english Base class for function wrappers
|
||||
//! \~russian Базовый класс для обёрток функций
|
||||
class FunctionBase {
|
||||
public:
|
||||
virtual ~FunctionBase() {}
|
||||
virtual uint formatHash() = 0;
|
||||
};
|
||||
|
||||
//! \~english Template class for function wrappers
|
||||
//! \~russian Шаблонный класс для обёрток функций
|
||||
template<typename... Args>
|
||||
class Function: public FunctionBase {
|
||||
public:
|
||||
@@ -51,8 +47,6 @@ public:
|
||||
std::function<bool(Args...)> func;
|
||||
};
|
||||
|
||||
//! \~english Creates function wrapper from std::function
|
||||
//! \~russian Создает обёртку функции из std::function
|
||||
template<typename Ret, typename... Args>
|
||||
FunctionBase * makeFunction(std::function<Ret(Args...)> func) {
|
||||
auto * ret = new Function<Args...>();
|
||||
|
||||
@@ -31,117 +31,50 @@
|
||||
#include "pisystemtime.h"
|
||||
|
||||
|
||||
//! \~english Base class for state machine states
|
||||
//! \~russian Базовый класс для состояний машины состояний
|
||||
//! \ingroup StateMachine
|
||||
//! \~\brief
|
||||
//! \~english
|
||||
//! \~russian
|
||||
class PIP_EXPORT PIStateBase {
|
||||
friend class PIStateMachine;
|
||||
friend class PITransitionBase;
|
||||
friend class PIStateFinal;
|
||||
|
||||
public:
|
||||
//! \~english Creates state with name
|
||||
//! \~russian Создает состояние с именем
|
||||
PIStateBase(const PIString & n = {}): name_(n) { ; }
|
||||
virtual ~PIStateBase();
|
||||
|
||||
//! \~english Called when state is \~russian Вы entered
|
||||
//! зывается при входе в состояние
|
||||
virtual void onEnter() {}
|
||||
|
||||
//! \~english Called when state is exited
|
||||
//! \~russian Вызывается при выходе из состояния
|
||||
virtual void onExit() {}
|
||||
|
||||
//! \~english Called when state machine finishes (for final states)
|
||||
//! \~russian Вызывается при завершении машины состояний (для финальных состояний)
|
||||
virtual void onFinish() {}
|
||||
|
||||
//! \~english Returns state machine this state belongs to
|
||||
//! \~russian Возвращает машину состояний, которой принадлежит это состояние
|
||||
PIStateMachine * machine() const { return root; }
|
||||
|
||||
//! \~english Returns parent state
|
||||
//! \~russian Возвращает родительское состояние
|
||||
PIStateBase * parent() const { return parent_state; }
|
||||
|
||||
//! \~english Returns active child state
|
||||
//! \~russian Возвращает активное дочернее состояние
|
||||
PIStateBase * activeChild() const { return active_state; }
|
||||
|
||||
//! \~english Returns all active child states
|
||||
//! \~russian Возвращает все активные дочерние состояния
|
||||
PIVector<PIStateBase *> activeChildren() const;
|
||||
|
||||
//! \~english Returns all active atomic states
|
||||
//! \~russian Возвращает все активные атомарные состояния
|
||||
PIVector<PIStateBase *> activeAtomics() const;
|
||||
|
||||
//! \~english Adds child state
|
||||
//! \~russian Добавляет дочернее состояние
|
||||
void addState(PIStateBase * s);
|
||||
|
||||
//! \~english Adds multiple child states
|
||||
//! \~russian Добавляет несколько дочерних состояний
|
||||
void addStates(PIVector<PIStateBase *> s);
|
||||
|
||||
//! \~english Sets initial state for compound state
|
||||
//! \~russian Устанавливает начальное состояние для составного состояния
|
||||
void setInitialState(PIStateBase * s);
|
||||
|
||||
//! \~english Adds transition to target state on event
|
||||
//! \~russian Добавляет переход к целевому состоянию по событию
|
||||
PITransitionBase * addTransition(PIStateBase * target, int event_id);
|
||||
|
||||
//! \~english Adds timeout transition to target state
|
||||
//! \~russian Добавляет переход по таймауту к целевому состоянию
|
||||
PITransitionTimeout * addTimeoutTransition(PIStateBase * target, PISystemTime timeout);
|
||||
|
||||
//! \~english Sets parallel mode for state
|
||||
//! \~russian Устанавливает параллельный режим для состояния
|
||||
void setParallel(bool yes) { is_parallel = yes; }
|
||||
|
||||
//! \~english Returns state name
|
||||
//! \~russian Возвращает имя состояния
|
||||
const PIString & getName() const { return name_; }
|
||||
|
||||
//! \~english Checks if this is root state machine
|
||||
//! \~russian Проверяет является ли это корневой машиной состояний
|
||||
bool isStateMachine() const { return is_root; }
|
||||
|
||||
//! \~english Checks if state is active
|
||||
//! \~russian Проверяет активно ли состояние
|
||||
bool isActive() const { return is_active; }
|
||||
|
||||
//! \~english Checks if state is in parallel mode
|
||||
//! \~russian Проверяет находится ли состояние в параллельном режиме
|
||||
bool isParallel() const { return is_parallel; }
|
||||
|
||||
//! \~english Checks if state is final
|
||||
//! \~russian Проверяет является ли состояние финальным
|
||||
bool isFinal() const { return is_final; }
|
||||
|
||||
//! \~english Checks if state is atomic (no children)
|
||||
//! \~russian Проверяет является ли состояние атомарным (нет потомков)
|
||||
bool isAtomic() const { return children.isEmpty(); }
|
||||
|
||||
//! \~english Checks if state is compound (has children)
|
||||
//! \~russian Проверяет является ли состояние составным (есть потомки)
|
||||
bool isCompound() const { return children.isNotEmpty(); }
|
||||
|
||||
//! \~english Returns child states
|
||||
//! \~russian Возвращает дочерние состояния
|
||||
const PIVector<PIStateBase *> & getChildren() const { return children; }
|
||||
|
||||
//! \~english Returns transitions from this state
|
||||
//! \~russian Возвращает переходы из этого состояния
|
||||
const PIVector<PITransitionBase *> & getTransitions() const { return transitions; }
|
||||
|
||||
//! \~english Prints state tree to string
|
||||
//! \~russian Выводит дерево состояний в строку
|
||||
void print(PIString prefix = {});
|
||||
|
||||
//! \~english Returns all states in machine
|
||||
//! \~russian Возвращает все состояния в машине
|
||||
PIVector<PIStateBase *> gatherStates();
|
||||
|
||||
private:
|
||||
@@ -167,12 +100,8 @@ private:
|
||||
};
|
||||
|
||||
|
||||
//! \~english State with lambda callbacks
|
||||
//! \~russian Состояние с lambda коллбэками
|
||||
class PIP_EXPORT PIStateLambda: public PIStateBase {
|
||||
public:
|
||||
//! \~english Creates lambda state with callbacks
|
||||
//! \~russian Создает lambda состояние с коллбэками
|
||||
PIStateLambda(std::function<void()> on_enter, std::function<void()> on_exit = nullptr, const PIString & n = {}): PIStateBase(n) {
|
||||
enter = on_enter;
|
||||
exit = on_exit;
|
||||
@@ -189,12 +118,8 @@ private:
|
||||
};
|
||||
|
||||
|
||||
//! \~english Final state of state machine
|
||||
//! \~russian Финальное состояние машины состояний
|
||||
class PIP_EXPORT PIStateFinal: public PIStateBase {
|
||||
public:
|
||||
//! \~english Creates final state with finish callback
|
||||
//! \~russian Создает финальное состояние с коллбэком завершения
|
||||
PIStateFinal(std::function<void()> on_finish = nullptr, const PIString & n = {}): PIStateBase(n) {
|
||||
is_final = true;
|
||||
enter = on_finish;
|
||||
|
||||
@@ -30,32 +30,22 @@
|
||||
#include "pitimer.h"
|
||||
|
||||
|
||||
//! \~english Base class for state machine transitions
|
||||
//! \~russian Базовый класс для переходов машины состояний
|
||||
//! \ingroup StateMachine
|
||||
//! \~\brief
|
||||
//! \~english
|
||||
//! \~russian
|
||||
class PIP_EXPORT PITransitionBase {
|
||||
friend class PIStateMachine;
|
||||
friend class PIStateBase;
|
||||
|
||||
public:
|
||||
//! \~english Creates transition from source to target on event
|
||||
//! \~russian Создает переход от source к target по событию
|
||||
PITransitionBase(PIStateBase * source, PIStateBase * target, int event_id);
|
||||
virtual ~PITransitionBase();
|
||||
|
||||
//! \~english Returns state machine this transition belongs to
|
||||
//! \~russian Возвращает машину состояний, которой принадлежит этот переход
|
||||
PIStateMachine * machine() const { return root; }
|
||||
|
||||
//! \~english Returns source state
|
||||
//! \~russian Возвращает исходное состояние
|
||||
PIStateBase * source() const { return source_state; }
|
||||
|
||||
//! \~english Returns target state
|
||||
//! \~russian Возвращает целевое состояние
|
||||
PIStateBase * target() const { return target_state; }
|
||||
|
||||
//! \~english Adds guard function to transition
|
||||
//! \~russian Добавляет сторожевую функцию к переходу
|
||||
template<typename R, typename... Args>
|
||||
PITransitionBase * addGuard(std::function<R(Args...)> f) {
|
||||
static_assert(std::is_same<R, bool>::value, "guard function should return bool!");
|
||||
@@ -64,15 +54,11 @@ public:
|
||||
return this;
|
||||
}
|
||||
|
||||
//! \~english Adds guard function to transition (callable)
|
||||
//! \~russian Добавляет сторожевую функцию к переходу (callable)
|
||||
template<typename L>
|
||||
PITransitionBase * addGuard(L f) {
|
||||
return addGuard(toStdFunction(f));
|
||||
}
|
||||
|
||||
//! \~english Tests guard function with arguments
|
||||
//! \~russian Тестирует сторожевую функцию с аргументами
|
||||
template<typename... Args>
|
||||
bool testGuard(Args... args) {
|
||||
if (!guard) return true;
|
||||
@@ -83,25 +69,13 @@ public:
|
||||
return reinterpret_cast<PIStateMachineHelpers::Function<Args...> *>(guard)->func(args...);
|
||||
}
|
||||
|
||||
//! \~english Adds action to transition
|
||||
//! \~russian Добавляет действие к переходу
|
||||
PITransitionBase * addAction(std::function<void()> a);
|
||||
|
||||
//! \~english Executes transition action
|
||||
//! \~russian Выполняет действие перехода
|
||||
void makeAction();
|
||||
|
||||
//! \~english Triggers transition
|
||||
//! \~russian Запускает переход
|
||||
void trigger();
|
||||
|
||||
protected:
|
||||
//! \~english Called when transition becomes enabled
|
||||
//! \~russian Вызывается когда переход становится доступным
|
||||
virtual void enabled() {}
|
||||
|
||||
//! \~english Called when transition becomes disabled
|
||||
//! \~russian Вызывается когда переход становится недоступным
|
||||
virtual void disabled() {}
|
||||
|
||||
int eventID = 0;
|
||||
@@ -112,12 +86,8 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
//! \~english Timeout transition
|
||||
//! \~russian Переход по таймауту
|
||||
class PIP_EXPORT PITransitionTimeout: public PITransitionBase {
|
||||
public:
|
||||
//! \~english Creates timeout transition
|
||||
//! \~russian Создает переход по таймауту
|
||||
PITransitionTimeout(PIStateBase * source, PIStateBase * target, PISystemTime timeout);
|
||||
~PITransitionTimeout();
|
||||
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
# include <unistd.h>
|
||||
#else
|
||||
// clang-format off
|
||||
# undef _WIN32_WINNT
|
||||
# define _WIN32_WINNT 0x0600
|
||||
# include <windows.h>
|
||||
# include <setupapi.h>
|
||||
extern "C" {
|
||||
@@ -122,10 +120,6 @@ bool PIHIDevice::open(const PIHIDeviceInfo & device) {
|
||||
return false;
|
||||
}
|
||||
HidD_GetPreparsedData(PRIVATE->deviceHandle, &PRIVATE->preparsed);
|
||||
if (!PRIVATE->preparsed) {
|
||||
close();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
@@ -528,7 +522,6 @@ PIVector<PIHIDeviceInfo> PIHIDevice::allDevices(bool try_open) {
|
||||
PHIDP_PREPARSED_DATA preparsed = nullptr;
|
||||
if (HidD_GetPreparsedData(deviceHandle, &preparsed) == FALSE) {
|
||||
piCout << "HidD_GetPreparsedData error:" << errorString();
|
||||
CloseHandle(deviceHandle);
|
||||
continue;
|
||||
}
|
||||
// auto pp = PIByteArray(preparsed, 64);
|
||||
|
||||
@@ -29,98 +29,37 @@
|
||||
#include "pithread.h"
|
||||
|
||||
|
||||
//! \~english HID device information
|
||||
//! \~russian Информация об HID устройстве
|
||||
struct PIP_EXPORT PIHIDeviceInfo {
|
||||
friend class PIHIDevice;
|
||||
|
||||
//! \~english Base class for value info
|
||||
//! \~russian Базовый класс для информации о значении
|
||||
struct PIP_EXPORT ValueInfoBase {
|
||||
//! \~english Checks if info is valid
|
||||
//! \~russian Проверяет валидна ли информация
|
||||
bool isValid() const { return index >= 0; }
|
||||
int index = -1;
|
||||
int data_index = -1;
|
||||
};
|
||||
|
||||
//! \~english Axis information
|
||||
//! \~russian Информация об оси
|
||||
struct PIP_EXPORT AxisInfo: public ValueInfoBase {
|
||||
int bits = 0;
|
||||
int min = 0;
|
||||
int max = 1;
|
||||
bool is_relative = false;
|
||||
};
|
||||
|
||||
//! \~english Button information
|
||||
//! \~russian Информация о кнопке
|
||||
struct PIP_EXPORT ButtonInfo: public ValueInfoBase {
|
||||
int code = 0;
|
||||
};
|
||||
|
||||
//! \~english Device path
|
||||
//! \~russian Путь к устройству
|
||||
PIString path;
|
||||
|
||||
//! \~english Manufacturer name
|
||||
//! \~russian Имя производителя
|
||||
PIString manufacturer;
|
||||
|
||||
//! \~english Product name
|
||||
//! \~russian Название продукта
|
||||
PIString product;
|
||||
|
||||
//! \~english Serial number
|
||||
//! \~russian Серийный номер
|
||||
PIString serial;
|
||||
|
||||
//! \~english Version
|
||||
//! \~russian Версия
|
||||
PIString version;
|
||||
|
||||
//! \~english Vendor ID
|
||||
//! \~russian Идентификатор производителя
|
||||
PIString VID;
|
||||
|
||||
//! \~english Product ID
|
||||
//! \~russian Идентификатор продукта
|
||||
PIString PID;
|
||||
|
||||
//! \~english List of axes
|
||||
//! \~russian Список осей
|
||||
PIVector<AxisInfo> axes;
|
||||
|
||||
//! \~english List of buttons
|
||||
//! \~russian Список кнопок
|
||||
PIVector<ButtonInfo> buttons;
|
||||
|
||||
//! \~english Checks if info is null
|
||||
//! \~russian Проверяет является ли информация пустой
|
||||
bool isNull() const { return path.isEmpty(); }
|
||||
|
||||
//! \~english Checks if info is not null
|
||||
//! \~russian Проверяет является ли информация не пустой
|
||||
bool isNotNull() const { return !isNull(); }
|
||||
|
||||
//! \~english Matches device by string
|
||||
//! \~russian Сопоставляет устройство по строке
|
||||
bool match(const PIString & str) const;
|
||||
|
||||
//! \~english Returns axes count
|
||||
//! \~russian Возвращает количество осей
|
||||
int axesCount() const { return axes.size_s(); }
|
||||
|
||||
//! \~english Returns absolute axes count
|
||||
//! \~russian Возвращает количество абсолютных осей
|
||||
int axesAbsoluteCount() const;
|
||||
|
||||
//! \~english Returns relative axes count
|
||||
//! \~russian Возвращает количество относительных осей
|
||||
int axesRelativeCount() const;
|
||||
|
||||
//! \~english Returns buttons count
|
||||
//! \~russian Возвращает количество кнопок
|
||||
int buttonsCount() const { return buttons.size_s(); }
|
||||
|
||||
private:
|
||||
@@ -135,19 +74,13 @@ private:
|
||||
PIP_EXPORT PICout operator<<(PICout s, const PIHIDeviceInfo & v);
|
||||
|
||||
|
||||
//! \~english HID device
|
||||
//! \~russian HID устройство
|
||||
class PIP_EXPORT PIHIDevice: public PIThread {
|
||||
PIOBJECT_SUBCLASS(PIHIDevice, PIThread)
|
||||
|
||||
public:
|
||||
~PIHIDevice();
|
||||
|
||||
//! \~english HID event
|
||||
//! \~russian Событие HID
|
||||
struct PIP_EXPORT Event {
|
||||
//! \~english Event type
|
||||
//! \~russian Тип события
|
||||
enum Type {
|
||||
tNone,
|
||||
tButton,
|
||||
@@ -159,48 +92,19 @@ public:
|
||||
float value = 0.;
|
||||
};
|
||||
|
||||
//! \~english Checks if device is opened
|
||||
//! \~russian Проверяет открыто ли устройство
|
||||
bool isOpened() const;
|
||||
|
||||
//! \~english Opens device by info
|
||||
//! \~russian Открывает устройство по информации
|
||||
bool open(const PIHIDeviceInfo & device);
|
||||
|
||||
//! \~english Opens device
|
||||
//! \~russian Открывает устройство
|
||||
bool open();
|
||||
|
||||
//! \~english Closes device
|
||||
//! \~russian Закрывает устройство
|
||||
void close();
|
||||
|
||||
//! \~english Starts reading device
|
||||
//! \~russian Начинает чтение устройства
|
||||
void start();
|
||||
|
||||
//! \~english Stops reading device
|
||||
//! \~russian Останавливает чтение устройства
|
||||
void stop();
|
||||
|
||||
//! \~english Sets dead zone for axes
|
||||
//! \~russian Устанавливает мёртвую зону для осей
|
||||
void setDeadZone(float v) { dead_zone = v; }
|
||||
|
||||
//! \~english Returns dead zone
|
||||
//! \~russian Возвращает мёртвую зону
|
||||
float deadZone() const { return dead_zone; }
|
||||
|
||||
//! \~english Event fired on device event
|
||||
//! \~russian Событие при событии устройства
|
||||
EVENT1(event, PIHIDevice::Event, e);
|
||||
|
||||
//! \~english Returns all available HID devices
|
||||
//! \~russian Возвращает все доступные HID устройства
|
||||
static PIVector<PIHIDeviceInfo> allDevices(bool try_open = true);
|
||||
|
||||
//! \~english Finds device by name
|
||||
//! \~russian Находит устройство по имени
|
||||
static PIHIDeviceInfo findDevice(const PIString & name);
|
||||
|
||||
private:
|
||||
|
||||
@@ -30,54 +30,36 @@
|
||||
|
||||
#include <functional>
|
||||
|
||||
//! \~english System signals handler
|
||||
//! \~russian Обработчик системных сигналов
|
||||
class PIP_EXPORT PISignals {
|
||||
public:
|
||||
//! \~english Signal types
|
||||
//! \~russian Типы сигналов
|
||||
enum Signal {
|
||||
Interrupt = 0x01, //!< Interrupt from keyboard
|
||||
Illegal = 0x02, //!< Illegal Instruction
|
||||
Abort = 0x04, //!< Abort signal
|
||||
FPE = 0x08, //!< Floating point exception
|
||||
SegFault = 0x10, //!< Invalid memory reference
|
||||
Termination = 0x20, //!< Termination signal
|
||||
Hangup = 0x40, //!< Hangup detected
|
||||
Quit = 0x80, //!< Quit from keyboard
|
||||
Kill = 0x100, //!< Kill signal
|
||||
BrokenPipe = 0x200, //!< Broken pipe
|
||||
Timer = 0x400, //!< Timer signal
|
||||
UserDefined1 = 0x800, //!< User-defined signal 1
|
||||
UserDefined2 = 0x1000, //!< User-defined signal 2
|
||||
ChildStopped = 0x2000, //!< Child stopped or terminated
|
||||
Continue = 0x4000, //!< Continue if stopped
|
||||
StopProcess = 0x8000, //!< Stop process
|
||||
StopTTY = 0x10000, //!< Stop typed at tty
|
||||
StopTTYInput = 0x20000, //!< Stop tty input
|
||||
StopTTYOutput = 0x40000, //!< Stop tty output
|
||||
All = 0xFFFFF //!< All signals
|
||||
Interrupt /** Interrupt from keyboard */ = 0x01, // Term Interrupt from keyboard
|
||||
Illegal /** Illegal Instruction */ = 0x02, // Core Illegal Instruction
|
||||
Abort /** Abort signal */ = 0x04, // Core Abort signal from abort
|
||||
FPE /** Floating point exception */ = 0x08, // Core Floating point exception
|
||||
SegFault /** Invalid memory reference */ = 0x10, // Core Invalid memory reference
|
||||
Termination /** Termination signal */ = 0x20, // Term Termination signal
|
||||
Hangup = 0x40, // Term Hangup detected on controlling terminal or death of controlling process
|
||||
Quit = 0x80, // Core Quit from keyboard
|
||||
Kill = 0x100, // Term Kill signal
|
||||
BrokenPipe = 0x200, // Term Broken pipe: write to pipe with no readers
|
||||
Timer = 0x400, // Term Timer signal from alarm
|
||||
UserDefined1 = 0x800, // Term User-defined signal 1
|
||||
UserDefined2 = 0x1000, // Term User-defined signal 2
|
||||
ChildStopped = 0x2000, // Ign Child stopped or terminated
|
||||
Continue = 0x4000, // Cont Continue if stopped
|
||||
StopProcess = 0x8000, // Stop Stop process
|
||||
StopTTY = 0x10000, // Stop Stop typed at tty
|
||||
StopTTYInput = 0x20000, // Stop tty input for background process
|
||||
StopTTYOutput = 0x40000, // Stop tty output for background process
|
||||
All = 0xFFFFF
|
||||
};
|
||||
|
||||
//! \~english Signal handler callback type
|
||||
//! \~russian Тип коллбэка обработчика сигналов
|
||||
//! \note slot is any function with format "void(PISignals::Signal)"
|
||||
typedef std::function<void(PISignals::Signal)> SignalEvent;
|
||||
|
||||
//! \~english Sets signal handler callback
|
||||
//! \~russian Устанавливает коллбэк обработчика сигналов
|
||||
// slot is any function format "void(PISignals::Signal)"
|
||||
static void setSlot(SignalEvent slot) { ret_func = slot; }
|
||||
|
||||
//! \~english Grabs specified signals
|
||||
//! \~russian Перехватывает указанные сигналы
|
||||
static void grabSignals(PIFlags<PISignals::Signal> signals_);
|
||||
|
||||
//! \~english Releases specified signals
|
||||
//! \~russian Освобождает указанные сигналы
|
||||
static void releaseSignals(PIFlags<PISignals::Signal> signals_);
|
||||
|
||||
//! \~english Raises signal
|
||||
//! \~russian Генерирует сигнал
|
||||
static void raiseSignal(PISignals::Signal signal);
|
||||
|
||||
private:
|
||||
|
||||
@@ -35,25 +35,25 @@
|
||||
//! \~russian Класс C-строки.
|
||||
class PIP_EXPORT PIConstChars {
|
||||
public:
|
||||
//! \~english Constructs an null string.
|
||||
//! \~english Contructs an null string.
|
||||
//! \~russian Создает нулевую строку.
|
||||
PIConstChars() {}
|
||||
|
||||
//! \~english Constructs string from C-string "string".
|
||||
//! \~english Contructs string from C-string "string".
|
||||
//! \~russian Создает строку из C-строки "string".
|
||||
PIConstChars(const char * string) {
|
||||
str = string;
|
||||
len = strlen(string);
|
||||
}
|
||||
|
||||
//! \~english Constructs string from "size" characters of buffer "data".
|
||||
//! \~english Contructs string from "size" characters of buffer "data".
|
||||
//! \~russian Создает строку из "size" символов массива "data".
|
||||
PIConstChars(const char * data, size_t size) {
|
||||
str = data;
|
||||
len = size;
|
||||
}
|
||||
|
||||
//! \~english Constructs a copy of string.
|
||||
//! \~english Contructs a copy of string.
|
||||
//! \~russian Создает копию строки.
|
||||
PIConstChars(const PIConstChars & o) {
|
||||
str = o.str;
|
||||
|
||||
@@ -206,10 +206,7 @@ PIString PIString::dtos(const double num, char format, int precision) {
|
||||
if (wr > 4) wr = 4;
|
||||
f[2 + wr] = format;
|
||||
f[3 + wr] = 0;
|
||||
char ch[256];
|
||||
piZeroMemory(ch, 256);
|
||||
snprintf(ch, 256, f, num);
|
||||
return PIStringAscii(ch).replaceAll(',', '.');
|
||||
pisprintf(f, num);
|
||||
}
|
||||
#undef pisprintf
|
||||
|
||||
@@ -469,7 +466,7 @@ void PIString::buildData(const char * cp) const {
|
||||
UErrorCode e((UErrorCode)0);
|
||||
UConverter * cc = ucnv_open(cp, &e);
|
||||
if (cc) {
|
||||
const size_t len = UCNV_GET_MAX_BYTES_FOR_STRING(size(), ucnv_getMaxCharSize(cc)) + 1; // MB_CUR_MAX * size() + 1;
|
||||
const size_t len = MB_CUR_MAX * size() + 1;
|
||||
data_ = (char *)malloc(len);
|
||||
int sz = ucnv_fromUChars(cc, data_, len, (const UChar *)(d.data()), d.size_s(), &e);
|
||||
ucnv_close(cc);
|
||||
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
typedef const PIChar & const_reference;
|
||||
typedef size_t size_type;
|
||||
|
||||
//! \~english Constructs an empty string.
|
||||
//! \~english Contructs an empty string.
|
||||
//! \~russian Создает пустую строку.
|
||||
PIString() {}
|
||||
|
||||
@@ -106,7 +106,7 @@ public:
|
||||
PIString & operator+=(llong) = delete;
|
||||
PIString & operator+=(ullong) = delete;
|
||||
|
||||
//! \~english Constructs a copy of string.
|
||||
//! \~english Contructs a copy of string.
|
||||
//! \~russian Создает копию строки.
|
||||
PIString(const PIString & o) {
|
||||
d = o.d;
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
//! \file piblockingqueue.h
|
||||
//! \ingroup Thread
|
||||
//! \brief
|
||||
//! \~english Queue with blocking
|
||||
//! \~russian Блокирующая очередь
|
||||
//!
|
||||
//! \details
|
||||
//! \~english Thread-safe queue that supports blocking operations - waits for space when storing and waits for element when retrieving.
|
||||
//! \~russian Потокобезопасная очередь с поддержкой блокирующих операций - ожидает место при добавлении и ожидает элемент при получении.
|
||||
/*! \file piblockingqueue.h
|
||||
* \ingroup Thread
|
||||
* \~\brief
|
||||
* \~english Queue with blocking
|
||||
* \~russian Блокирующая очередь
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
|
||||
@@ -36,13 +33,12 @@
|
||||
* \brief A Queue that supports operations that wait for the queue to become non-empty when retrieving an element, and
|
||||
* wait for space to become available in the queue when storing an element.
|
||||
*/
|
||||
//! \~english Thread-safe blocking queue template class
|
||||
//! \~russian Шаблонный класс потокобезопасной блокирующей очереди
|
||||
template<typename T>
|
||||
class PIBlockingQueue: private PIQueue<T> {
|
||||
public:
|
||||
//! \~english Constructs queue with specified capacity
|
||||
//! \~russian Создает очередь с указанной емкостью
|
||||
/**
|
||||
* \brief Constructor
|
||||
*/
|
||||
explicit inline PIBlockingQueue(size_t capacity = SIZE_MAX,
|
||||
PIConditionVariable * cond_var_add = new PIConditionVariable(),
|
||||
PIConditionVariable * cond_var_rem = new PIConditionVariable())
|
||||
@@ -50,8 +46,9 @@ public:
|
||||
, cond_var_rem(cond_var_rem)
|
||||
, max_size(capacity) {}
|
||||
|
||||
//! \~english Copy constructor from PIDeque
|
||||
//! \~russian Конструктор копирования из PIDeque
|
||||
/**
|
||||
* \brief Copy constructor. Initialize queue with copy of other queue elements. Not thread-safe for other queue.
|
||||
*/
|
||||
explicit inline PIBlockingQueue(const PIDeque<T> & other)
|
||||
: cond_var_add(new PIConditionVariable())
|
||||
, cond_var_rem(new PIConditionVariable()) {
|
||||
@@ -61,8 +58,9 @@ public:
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
//! \~english Thread-safe copy constructor from another PIBlockingQueue
|
||||
//! \~russian Потокобезопасный конструктор копирования из другой PIBlockingQueue
|
||||
/**
|
||||
* \brief Thread-safe copy constructor. Initialize queue with copy of other queue elements.
|
||||
*/
|
||||
inline PIBlockingQueue(PIBlockingQueue<T> & other): cond_var_add(new PIConditionVariable()), cond_var_rem(new PIConditionVariable()) {
|
||||
other.mutex.lock();
|
||||
mutex.lock();
|
||||
@@ -77,8 +75,11 @@ public:
|
||||
delete cond_var_rem;
|
||||
}
|
||||
|
||||
//! \~english Inserts element waiting for space to become available
|
||||
//! \~russian Вставляет элемент, ожидая освобождения места
|
||||
/**
|
||||
* \brief Inserts the specified element into this queue, waiting if necessary for space to become available.
|
||||
*
|
||||
* @param v the element to add
|
||||
*/
|
||||
PIBlockingQueue<T> & put(const T & v) {
|
||||
mutex.lock();
|
||||
cond_var_rem->wait(mutex, [&]() { return PIDeque<T>::size() < max_size; });
|
||||
@@ -90,8 +91,14 @@ public:
|
||||
|
||||
PIBlockingQueue<T> & enqueue(const T & v) { return put(v); }
|
||||
|
||||
//! \~english Inserts element if possible without exceeding capacity
|
||||
//! \~russian Вставляет элемент если возможно без превышения емкости
|
||||
/**
|
||||
* \brief Inserts the specified element at the end of this queue if it is possible to do so immediately without
|
||||
* exceeding the queue's capacity, returning true upon success and false if this queue is full.
|
||||
*
|
||||
* @param v the element to add
|
||||
* @param timeout the timeout waiting for inserting if que is full, if timeout is null, then returns immediately
|
||||
* @return true if the element was added to this queue, else false
|
||||
*/
|
||||
bool offer(const T & v, PISystemTime timeout = {}) {
|
||||
bool isOk;
|
||||
mutex.lock();
|
||||
@@ -122,8 +129,16 @@ public:
|
||||
|
||||
T dequeue() { return take(); }
|
||||
|
||||
//! \~english Retrieves and removes head, waiting until element becomes available
|
||||
//! \~russian Извлекает и удаляет голову очереди, ожидая появления элемента
|
||||
/**
|
||||
* \brief Retrieves and removes the head of this queue, waiting up to the specified wait time if necessary for an
|
||||
* element to become available.
|
||||
*
|
||||
* @param timeout how long to wait before giving up
|
||||
* @param defaultVal value, which returns if the specified waiting time elapses before an element is available
|
||||
* @param isOk flag, which indicates result of method execution. It will be set to false if timeout, or true if
|
||||
* return value is retrieved value
|
||||
* @return the head of this queue, or defaultVal if the specified waiting time elapses before an element is available
|
||||
*/
|
||||
T poll(PISystemTime timeout = {}, const T & defaultVal = T(), bool * isOk = nullptr) {
|
||||
T t = defaultVal;
|
||||
bool isNotEmpty;
|
||||
@@ -139,8 +154,12 @@ public:
|
||||
return t;
|
||||
}
|
||||
|
||||
//! \~english Returns queue capacity
|
||||
//! \~russian Возвращает емкость очереди
|
||||
/**
|
||||
* \brief Returns the number of elements that this queue can ideally (in the absence of memory or resource
|
||||
* constraints) contains. This is always equal to the initial capacity of this queue less the current size of this queue.
|
||||
*
|
||||
* @return the capacity
|
||||
*/
|
||||
size_t capacity() {
|
||||
size_t c;
|
||||
mutex.lock();
|
||||
@@ -149,8 +168,12 @@ public:
|
||||
return c;
|
||||
}
|
||||
|
||||
//! \~english Returns remaining capacity
|
||||
//! \~russian Возвращает оставшуюся емкость
|
||||
/**
|
||||
* \brief Returns the number of additional elements that this queue can ideally (in the absence of memory or resource
|
||||
* constraints) accept. This is always equal to the initial capacity of this queue less the current size of this queue.
|
||||
*
|
||||
* @return the remaining capacity
|
||||
*/
|
||||
size_t remainingCapacity() {
|
||||
mutex.lock();
|
||||
size_t c = max_size - PIDeque<T>::size();
|
||||
@@ -158,8 +181,9 @@ public:
|
||||
return c;
|
||||
}
|
||||
|
||||
//! \~english Returns number of elements in queue
|
||||
//! \~russian Возвращает количество элементов в очереди
|
||||
/**
|
||||
* \brief Returns the number of elements in this collection.
|
||||
*/
|
||||
size_t size() {
|
||||
mutex.lock();
|
||||
size_t s = PIDeque<T>::size();
|
||||
@@ -167,8 +191,9 @@ public:
|
||||
return s;
|
||||
}
|
||||
|
||||
//! \~english Removes all available elements and adds them to another queue
|
||||
//! \~russian Удаляет все доступные элементы и добавляет их в другую очередь
|
||||
/**
|
||||
* \brief Removes all available elements from this queue and adds them to other given queue.
|
||||
*/
|
||||
size_t drainTo(PIDeque<T> & other, size_t maxCount = SIZE_MAX) {
|
||||
mutex.lock();
|
||||
size_t count = ((maxCount > PIDeque<T>::size()) ? PIDeque<T>::size() : maxCount);
|
||||
@@ -178,8 +203,9 @@ public:
|
||||
return count;
|
||||
}
|
||||
|
||||
//! \~english Removes all available elements and adds them to another blocking queue
|
||||
//! \~russian Удаляет все доступные элементы и добавляет их в другую блокирующую очередь
|
||||
/**
|
||||
* \brief Removes all available elements from this queue and adds them to other given queue.
|
||||
*/
|
||||
size_t drainTo(PIBlockingQueue<T> & other, size_t maxCount = SIZE_MAX) {
|
||||
mutex.lock();
|
||||
other.mutex.lock();
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
//! \file piconditionvar.h
|
||||
//! \ingroup Thread
|
||||
//! \brief
|
||||
//! \~english Conditional variable
|
||||
//! \~russian Условная переменная
|
||||
//!
|
||||
//! \details
|
||||
//! \~english Object able to block the calling thread until notified to resume.
|
||||
//! \~russian Объект, способный заблокировать вызывающий поток до уведомления о продолжении.
|
||||
/*! \file piconditionvar.h
|
||||
* \ingroup Thread
|
||||
* \~\brief
|
||||
* \~english Conditional variable
|
||||
* \~russian Conditional variable
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
|
||||
@@ -39,39 +36,27 @@
|
||||
* It uses a PIMutex to lock the thread when one of its wait functions is called. The thread remains
|
||||
* blocked until woken up by another thread that calls a notification function on the same PIConditionVariable object.
|
||||
*/
|
||||
//! \~english Condition variable for thread synchronization
|
||||
//! \~russian Условная переменная для синхронизации потоков
|
||||
class PIP_EXPORT PIConditionVariable {
|
||||
public:
|
||||
NO_COPY_CLASS(PIConditionVariable);
|
||||
//! \~english Constructs condition variable
|
||||
//! \~russian Создает условную переменную
|
||||
explicit PIConditionVariable();
|
||||
//! \~english Destroys condition variable
|
||||
//! \~russian Уничтожает условную переменную
|
||||
virtual ~PIConditionVariable();
|
||||
|
||||
/**
|
||||
* \brief Unblocks one of the threads currently waiting for this condition. If no threads are waiting, the function
|
||||
* does nothing. If more than one, it is unspecified which of the threads is selected.
|
||||
*/
|
||||
//! \~english Wakes one waiting thread
|
||||
//! \~russian Будит один ожидающий поток
|
||||
void notifyOne();
|
||||
|
||||
/**
|
||||
* \brief Unblocks all threads currently waiting for this condition. If no threads are waiting, the function does
|
||||
* nothing.
|
||||
*/
|
||||
//! \~english Wakes all waiting threads
|
||||
//! \~russian Будит все ожидающие потоки
|
||||
void notifyAll();
|
||||
|
||||
/**
|
||||
* \brief see wait(PIMutex &, const std::function<bool()>&)
|
||||
*/
|
||||
//! \~english Wait until notified
|
||||
//! \~russian Ожидает уведомления
|
||||
virtual void wait(PIMutex & lk);
|
||||
|
||||
/**
|
||||
@@ -98,15 +83,11 @@ public:
|
||||
* @param condition A callable object or function that takes no arguments and returns a value that can be evaluated
|
||||
* as a bool. This is called repeatedly until it evaluates to true.
|
||||
*/
|
||||
//! \~english Wait until notified with condition predicate
|
||||
//! \~russian Ожидает уведомления с условием
|
||||
virtual void wait(PIMutex & lk, const std::function<bool()> & condition);
|
||||
|
||||
/**
|
||||
* \brief see waitFor(PIMutex &, int, const std::function<bool()>&)
|
||||
*/
|
||||
//! \~english Wait for timeout
|
||||
//! \~russian Ожидает таймаут
|
||||
virtual bool waitFor(PIMutex & lk, PISystemTime timeout);
|
||||
|
||||
/**
|
||||
@@ -134,8 +115,6 @@ public:
|
||||
* as a bool. This is called repeatedly until it evaluates to true.
|
||||
* @return false if timeout reached or true if wakeup condition is true
|
||||
*/
|
||||
//! \~english Wait for timeout or until notified with condition predicate
|
||||
//! \~russian Ожидает таймаут или уведомление с условием
|
||||
virtual bool waitFor(PIMutex & lk, PISystemTime timeout, const std::function<bool()> & condition);
|
||||
|
||||
private:
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
//! \file pigrabberbase.h
|
||||
//! \ingroup Thread
|
||||
//! \brief
|
||||
//! \~english Abstract class for creating grabbers
|
||||
//! \~russian Базовый класс для создания грабберов
|
||||
//!
|
||||
//! \details
|
||||
//! \~english Base class for thread-based data acquisition with queue support.
|
||||
//! \~russian Базовый класс для получения данных в потоке с поддержкой очереди.
|
||||
/*! \file pigrabberbase.h
|
||||
* \ingroup Thread
|
||||
* \~\brief
|
||||
* \~english Abstract class for create grabbers
|
||||
* \~russian Базовый класс для создания грабберов
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Abstract class for create grabbers
|
||||
@@ -34,33 +31,18 @@
|
||||
#include "pitime.h"
|
||||
|
||||
|
||||
//! \~english Base class for data grabber threads
|
||||
//! \~russian Базовый класс для потоков получения данных
|
||||
template<typename T = PIByteArray>
|
||||
class PIGrabberBase: public PIThread {
|
||||
PIOBJECT_SUBCLASS(PIGrabberBase, PIThread);
|
||||
|
||||
public:
|
||||
//! \~english Constructs grabber
|
||||
//! \~russian Создает граббер
|
||||
PIGrabberBase() {
|
||||
is_opened = false;
|
||||
is_recording = false;
|
||||
}
|
||||
//! \~english Destroys grabber
|
||||
//! \~russian Уничтожает граббер
|
||||
virtual ~PIGrabberBase() { stopGrabber(false); }
|
||||
|
||||
//! \~english Returns if grabber is opened
|
||||
//! \~russian Возвращает открыт ли граббер
|
||||
virtual bool isOpened() const { return is_opened; }
|
||||
|
||||
//! \~english Returns if grabber is recording
|
||||
//! \~russian Возвращает записывает ли граббер
|
||||
virtual bool isRecording() const { return is_recording; }
|
||||
|
||||
//! \~english Start recording to file
|
||||
//! \~russian Начинает запись в файл
|
||||
virtual void startRecord(const PIString & filename) {
|
||||
if (!isOpened()) return;
|
||||
if (isRecording()) return;
|
||||
@@ -69,8 +51,6 @@ public:
|
||||
is_recording = true;
|
||||
rec_mutex.unlock();
|
||||
}
|
||||
//! \~english Stop recording
|
||||
//! \~russian Останавливает запись
|
||||
virtual void stopRecord() {
|
||||
if (!isOpened()) return;
|
||||
if (!isRecording()) return;
|
||||
@@ -79,9 +59,6 @@ public:
|
||||
stopRecordInternal();
|
||||
rec_mutex.unlock();
|
||||
}
|
||||
|
||||
//! \~english Returns last grabbed data
|
||||
//! \~russian Возвращает последние полученные данные
|
||||
T last() const {
|
||||
T ret;
|
||||
last_mutex.lock();
|
||||
@@ -89,9 +66,6 @@ public:
|
||||
last_mutex.unlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
//! \~english Returns if queue is empty
|
||||
//! \~russian Возвращает пустая ли очередь
|
||||
bool isEmpty() {
|
||||
bool ret;
|
||||
que_mutex.lock();
|
||||
@@ -99,9 +73,6 @@ public:
|
||||
que_mutex.unlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
//! \~english Returns queue size
|
||||
//! \~russian Возвращает размер очереди
|
||||
int queSize() {
|
||||
int ret;
|
||||
que_mutex.lock();
|
||||
@@ -109,9 +80,6 @@ public:
|
||||
que_mutex.unlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
//! \~english Dequeues data from queue
|
||||
//! \~russian Извлекает данные из очереди
|
||||
T dequeue() {
|
||||
T ret;
|
||||
// piCoutObj << "start";
|
||||
@@ -124,9 +92,6 @@ public:
|
||||
que_mutex.unlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
//! \~english Stop grabber thread
|
||||
//! \~russian Останавливает поток граббера
|
||||
void stopGrabber(bool wait_forever = true) {
|
||||
if (isRunning()) {
|
||||
stop();
|
||||
@@ -139,18 +104,12 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//! \~english Open grabber
|
||||
//! \~russian Открывает граббер
|
||||
bool open() {
|
||||
bool ret = openInternal();
|
||||
if (!is_opened && ret) opened();
|
||||
is_opened = ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
//! \~english Close grabber
|
||||
//! \~russian Закрывает граббер
|
||||
void close() {
|
||||
bool em = is_opened;
|
||||
closeInternal();
|
||||
@@ -158,21 +117,12 @@ public:
|
||||
if (em) closed();
|
||||
is_opened = false;
|
||||
}
|
||||
|
||||
//! \~english Returns diagnostics
|
||||
//! \~russian Возвращает диагностику
|
||||
const PIDiagnostics & diag() const { return diag_; }
|
||||
|
||||
//! \~english Clear queue
|
||||
//! \~russian Очищает очередь
|
||||
void clear() {
|
||||
que_mutex.lock();
|
||||
que.clear();
|
||||
que_mutex.unlock();
|
||||
}
|
||||
|
||||
//! \~english Restart grabber
|
||||
//! \~russian Перезапускает граббер
|
||||
void restart() {
|
||||
clear();
|
||||
close();
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
//! \file pipipelinethread.h
|
||||
//! \ingroup Thread
|
||||
//! \brief
|
||||
//! \~english Class for creating multithread pipeline
|
||||
//! \~russian Класс для создания многопоточного конвейера
|
||||
//!
|
||||
//! \details
|
||||
//! \~english Pipeline thread for processing data through stages in separate threads.
|
||||
//! \~russian Конвейерный поток для обработки данных через этапы в отдельных потоках.
|
||||
/*! \file pipipelinethread.h
|
||||
* \ingroup Thread
|
||||
* \~\brief
|
||||
* \~english Class for create multihread pipeline
|
||||
* \~russian Класс для создания многопоточного конвейера
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Class for create multihread pipeline
|
||||
@@ -34,22 +31,16 @@
|
||||
#include "pithread.h"
|
||||
|
||||
|
||||
//! \~english Pipeline thread template class
|
||||
//! \~russian Шаблонный класс конвейерного потока
|
||||
template<typename Tin, typename Tout>
|
||||
class PIPipelineThread: public PIThread {
|
||||
PIOBJECT_SUBCLASS(PIPipelineThread, PIThread);
|
||||
|
||||
public:
|
||||
//! \~english Constructs pipeline thread
|
||||
//! \~russian Создает конвейерный поток
|
||||
PIPipelineThread() {
|
||||
cnt = 0;
|
||||
max_size = 0;
|
||||
wait_next_pipe = false;
|
||||
}
|
||||
//! \~english Destroys pipeline thread
|
||||
//! \~russian Уничтожает конвейерный поток
|
||||
~PIPipelineThread() {
|
||||
stop();
|
||||
cv.notifyAll();
|
||||
@@ -58,8 +49,6 @@ public:
|
||||
terminate();
|
||||
}
|
||||
}
|
||||
//! \~english Connect to next pipeline stage
|
||||
//! \~russian Подключает к следующему этапу конвейера
|
||||
template<typename T>
|
||||
void connectTo(PIPipelineThread<Tout, T> * next) {
|
||||
CONNECT3(void, Tout, bool, bool *, this, calculated, next, enqueue);
|
||||
@@ -83,21 +72,9 @@ public:
|
||||
}
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
//! \~english Enqueue data for processing
|
||||
//! \~russian Добавляет данные в очередь на обработку
|
||||
void enqueue(const Tin & v, bool wait = false) { enqueue(v, wait, nullptr); }
|
||||
|
||||
//! \~english Returns pointer to counter
|
||||
//! \~russian Возвращает указатель на счетчик
|
||||
const ullong * counterPtr() const { return &cnt; }
|
||||
|
||||
//! \~english Returns items processed counter
|
||||
//! \~russian Возвращает количество обработанных элементов
|
||||
ullong counter() const { return cnt; }
|
||||
|
||||
//! \~english Returns if input queue is empty
|
||||
//! \~russian Возвращает пустая ли входная очередь
|
||||
bool isEmpty() {
|
||||
bool ret;
|
||||
mutex.lock();
|
||||
@@ -105,9 +82,6 @@ public:
|
||||
mutex.unlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
//! \~english Returns input queue size
|
||||
//! \~russian Возвращает размер входной очереди
|
||||
int queSize() {
|
||||
int ret;
|
||||
mutex.lock();
|
||||
@@ -115,9 +89,6 @@ public:
|
||||
mutex.unlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
//! \~english Clear input queue
|
||||
//! \~russian Очищает входную очередь
|
||||
void clear() {
|
||||
mutex.lock();
|
||||
mutex_wait.lock();
|
||||
@@ -126,9 +97,6 @@ public:
|
||||
mutex_wait.unlock();
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
//! \~english Stop calculation
|
||||
//! \~russian Останавливает вычисления
|
||||
void stopCalc(int wait_delay = 100) {
|
||||
if (isRunning()) {
|
||||
stop();
|
||||
@@ -140,9 +108,6 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//! \~english Returns last processed result
|
||||
//! \~russian Возвращает последний обработанный результат
|
||||
Tout getLast() {
|
||||
Tout ret;
|
||||
mutex_last.lock();
|
||||
@@ -151,12 +116,8 @@ public:
|
||||
return ret;
|
||||
}
|
||||
|
||||
//! \~english Returns max queue size
|
||||
//! \~russian Возвращает максимальный размер очереди
|
||||
uint maxQueSize() { return max_size; }
|
||||
|
||||
//! \~english Set max queue size
|
||||
//! \~russian Устанавливает максимальный размер очереди
|
||||
void setMaxQueSize(uint count) {
|
||||
mutex.lock();
|
||||
max_size = count;
|
||||
@@ -164,17 +125,10 @@ public:
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
//! \~english Returns if waiting for next pipeline
|
||||
//! \~russian Возвращает ожидает ли следующий конвейер
|
||||
bool isWaitNextPipe() { return wait_next_pipe; }
|
||||
|
||||
//! \~english Set waiting for next pipeline
|
||||
//! \~russian Устанавливает ожидание следующего конвейера
|
||||
void setWaitNextPipe(bool wait) { wait_next_pipe = wait; }
|
||||
|
||||
protected:
|
||||
//! \~english Processing function - must be implemented
|
||||
//! \~russian Функция обработки - должна быть реализована
|
||||
virtual Tout calc(Tin & v, bool & ok) = 0;
|
||||
|
||||
uint max_size;
|
||||
|
||||
@@ -1,29 +1,26 @@
|
||||
//! \file piprotectedvariable.h
|
||||
//! \ingroup Thread
|
||||
//! \brief
|
||||
//! \~english Thread-safe variable
|
||||
//! \~russian Потокобезопасная переменная
|
||||
//!
|
||||
//! \details
|
||||
//! \~english Template class for thread-safe variable access with mutex protection.
|
||||
//! \~russian Шаблонный класс для потокобезопасного доступа к переменной с защитой мьютексом.
|
||||
/*! \file piprotectedvariable.h
|
||||
* \ingroup Thread
|
||||
* \~\brief
|
||||
* \~english Thread-safe variable
|
||||
* \~russian Потокобезопасная переменная
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Thread-safe variable
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Stephan Fomenko, Andrey Bychkov work.a.b@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
Thread-safe variable
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Stephan Fomenko, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program 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 3 of the License, or
|
||||
(at your option) any later version.
|
||||
This program 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 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 Lesser General Public License for more details.
|
||||
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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PIPROTECTEDVARIABLE_H
|
||||
@@ -32,37 +29,25 @@
|
||||
#include "pimutex.h"
|
||||
|
||||
|
||||
//! \~english Thread-safe variable template class
|
||||
//! \~russian Шаблонный класс потокобезопасной переменной
|
||||
template<typename T>
|
||||
class PIP_EXPORT PIProtectedVariable {
|
||||
public:
|
||||
//! \~english Pointer wrapper for thread-safe access
|
||||
//! \~russian Обертка указателя для потокобезопасного доступа
|
||||
//! \~english
|
||||
//! \~russian
|
||||
class PIP_EXPORT Pointer {
|
||||
friend class PIProtectedVariable<T>;
|
||||
|
||||
public:
|
||||
//! \~english Copy constructor
|
||||
//! \~russian Конструктор копирования
|
||||
Pointer(const Pointer & v): pv(v.pv), counter(v.counter + 1) {}
|
||||
//! \~english Destructor - unlocks mutex
|
||||
//! \~russian Деструктор - разблокирует мьютекс
|
||||
~Pointer() {
|
||||
if (counter == 0) pv.mutex.unlock();
|
||||
}
|
||||
|
||||
//! \~english Access member
|
||||
//! \~russian Доступ к члену
|
||||
T * operator->() { return &pv.var; }
|
||||
//! \~english Access value
|
||||
//! \~russian Доступ к значению
|
||||
T & operator*() { return pv.var; }
|
||||
|
||||
private:
|
||||
Pointer() = delete;
|
||||
//! \~english Construct from PIProtectedVariable
|
||||
//! \~russian Конструктор из PIProtectedVariable
|
||||
Pointer(PIProtectedVariable<T> & v): pv(v) {}
|
||||
|
||||
PIProtectedVariable<T> & pv;
|
||||
|
||||
@@ -1,12 +1,3 @@
|
||||
//! \file pithreadpoolexecutor.h
|
||||
//! \ingroup Thread
|
||||
//! \brief
|
||||
//! \~english Thread pool executor
|
||||
//! \~russian Исполнитель пула потоков
|
||||
//!
|
||||
//! \details
|
||||
//! \~english Executes tasks in a pool of worker threads.
|
||||
//! \~russian Выполняет задачи в пуле рабочих потоков.
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
|
||||
@@ -35,16 +26,10 @@
|
||||
#include <atomic>
|
||||
|
||||
|
||||
//! \~english Thread pool executor for running tasks
|
||||
//! \~russian Исполнитель пула потоков для выполнения задач
|
||||
class PIP_EXPORT PIThreadPoolExecutor {
|
||||
public:
|
||||
//! \~english Constructs executor with core pool size
|
||||
//! \~russian Создает исполнитель с размером ядра пула
|
||||
explicit PIThreadPoolExecutor(int corePoolSize);
|
||||
|
||||
//! \~english Destroys executor
|
||||
//! \~russian Уничтожает исполнитель
|
||||
virtual ~PIThreadPoolExecutor();
|
||||
|
||||
//! \brief Executes the given task sometime in the future. The task execute in an existing pooled thread. If the task
|
||||
@@ -52,27 +37,17 @@ public:
|
||||
//! reached.
|
||||
//!
|
||||
//! \param runnable not empty function for thread pool execution
|
||||
//! \~english Execute task in thread pool
|
||||
//! \~russian Выполняет задачу в пуле потоков
|
||||
void execute(const std::function<void()> & runnable);
|
||||
|
||||
//! \~english Stop all threads immediately
|
||||
//! \~russian Немедленно останавливает все потоки
|
||||
void shutdownNow();
|
||||
|
||||
//! \brief Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be
|
||||
//! accepted. Invocation has no additional effect if already shut down. This method does not wait for previously
|
||||
//! submitted tasks to complete execution. Use awaitTermination to do that.
|
||||
//! \~english Initiates orderly shutdown
|
||||
//! \~russian Инициирует упорядоченное завершение
|
||||
void shutdown();
|
||||
|
||||
//! \~english Returns if executor is shutdown
|
||||
//! \~russian Возвращает остановлен ли исполнитель
|
||||
bool isShutdown() const;
|
||||
|
||||
//! \~english Wait for termination
|
||||
//! \~russian Ожидает завершения
|
||||
bool awaitTermination(PISystemTime timeout);
|
||||
|
||||
private:
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
//! \file colors_p.h
|
||||
//! \ingroup Types
|
||||
//! \~\brief
|
||||
//! \~english Color collection
|
||||
//! \~russian Коллекция цветов
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Color collection
|
||||
@@ -28,27 +23,13 @@
|
||||
#include "pivarianttypes.h"
|
||||
|
||||
|
||||
//! \ingroup Types
|
||||
//! \~\brief
|
||||
//! \~english Color collection singleton for CSS color names.
|
||||
//! \~russian Синглтон коллекции цветов для CSS имен цветов.
|
||||
class PIColorCollection {
|
||||
public:
|
||||
//! \~english Returns singleton instance of color collection.
|
||||
//! \~russian Возвращает синглтон экземпляр коллекции цветов.
|
||||
static PIColorCollection & instance();
|
||||
|
||||
//! \~english Returns color by CSS name.
|
||||
//! \~russian Возвращает цвет по CSS имени.
|
||||
PIVariantTypes::Color getCSSColor(const PIString & name) const { return css_color.value(name); }
|
||||
|
||||
//! \~english Returns CSS name by color.
|
||||
//! \~russian Возвращает CSS имя по цвету.
|
||||
PIString getCSSName(const PIVariantTypes::Color color) const { return css_name.value(color); }
|
||||
|
||||
private:
|
||||
//! \~english Private constructor.
|
||||
//! \~russian Приватный конструктор.
|
||||
PIColorCollection();
|
||||
PIMap<PIString, PIVariantTypes::Color> css_color;
|
||||
PIMap<PIVariantTypes::Color, PIString> css_name;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
//! \file pibitarray.h
|
||||
//! \ingroup Types
|
||||
//! \~\brief
|
||||
//! \~english Bit array
|
||||
//! \~russian Битовый массив
|
||||
/*! \file pibitarray.h
|
||||
* \~\brief
|
||||
* \~english Bit array
|
||||
* \~russian Битовый массив
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Bit array
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
//! \file pibytearray.h
|
||||
//! \ingroup Types
|
||||
//! \~\brief
|
||||
//! \~english Byte array
|
||||
//! \~russian Байтовый массив
|
||||
/*! \file pibytearray.h
|
||||
* \ingroup Types
|
||||
* \~\brief
|
||||
* \~english Byte array
|
||||
* \~russian Байтовый массив
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Byte array
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
//! \file pidatetime.h
|
||||
//! \ingroup Types
|
||||
//! \~\brief
|
||||
//! \~english Time and date structs
|
||||
//! \~russian Типы времени и даты
|
||||
/*! \file pidatetime.h
|
||||
* \ingroup Types
|
||||
* \~\brief
|
||||
* \~english Time and date structs
|
||||
* \~russian Типы времени и даты
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Time and date structs
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
//! \file piflags.h
|
||||
//! \ingroup Types
|
||||
//! \~\brief
|
||||
//! \~english General flags class
|
||||
//! \~russian Универсальные флаги
|
||||
/*! \file piflags.h
|
||||
* \ingroup Types
|
||||
* \~\brief
|
||||
* \~english General flags class
|
||||
* \~russian Универсальные флаги
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
General flags class
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
//! \file pinetworkaddress.h
|
||||
//! \ingroup Types
|
||||
//! \~\brief
|
||||
//! \~english Network address
|
||||
//! \~russian Сетевой адрес
|
||||
/*! \file pinetworkaddress.h
|
||||
* \ingroup Types
|
||||
* \~\brief
|
||||
* \~english Network address
|
||||
* \~russian Сетевой адрес
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Network address
|
||||
Network address
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
//! \file pipropertystorage.h
|
||||
//! \ingroup Types
|
||||
//! \~\brief
|
||||
//! \~english Properties array
|
||||
//! \~russian Массив свойств
|
||||
/*! \file pipropertystorage.h
|
||||
* \ingroup Types
|
||||
* \~\brief
|
||||
* \~english Properties array
|
||||
* \~russian Массив свойств
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Storage of properties for GUI usage
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
//! \file pisystemtime.h
|
||||
//! \ingroup Types
|
||||
//! \~\brief
|
||||
//! \~english System time structs and methods
|
||||
//! \~russian Типы и методы системного времени
|
||||
/*! \file pisystemtime.h
|
||||
* \ingroup Types
|
||||
* \~\brief
|
||||
* \~english System time structs and methods
|
||||
* \~russian Типы и методы системного времени
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Time structs
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
//! \file pitime.h
|
||||
//! \ingroup Types
|
||||
//! \~\brief
|
||||
//! \~english System time, time and date
|
||||
//! \~russian Системное время, время и дата
|
||||
/*! \file pitime.h
|
||||
* \ingroup Types
|
||||
* \~\brief
|
||||
* \~english System time, time and date
|
||||
* \~russian Системное время, время и дата
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
@@ -124,23 +124,6 @@ void PIValueTree::applyValues(const PIValueTree & root, bool recursive) {
|
||||
}
|
||||
|
||||
|
||||
void PIValueTree::merge(const PIValueTree & root) {
|
||||
if (_is_null) return;
|
||||
for (const auto & c: root._children) {
|
||||
bool found = false;
|
||||
for (auto & i: _children) {
|
||||
if (c.name() == i.name()) {
|
||||
if (c.isValid()) i._value = c._value;
|
||||
i.merge(c);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) _children << c;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PIVariant PIValueTree::childValue(const PIString & child_name, const PIVariant & default_value, bool * exists) const {
|
||||
const PIValueTree & node = child(child_name);
|
||||
if (node.isNull()) {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
//! \file pivaluetree.h
|
||||
//! \ingroup Types
|
||||
//! \~\brief
|
||||
//! \~english Attributed values tree
|
||||
//! \~russian Дерево атрибутированных значений
|
||||
/*! \file pivaluetree.h
|
||||
* \ingroup Types
|
||||
* \brief
|
||||
* \~english Attributed values tree
|
||||
* \~russian Дерево атрибутированных значений
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Attributed values tree
|
||||
@@ -169,13 +170,6 @@ public:
|
||||
//! \param recursive Если установлено в true, то значения будут применяться рекурсивно к дочерним узлам.
|
||||
void applyValues(const PIValueTree & root, bool recursive = true);
|
||||
|
||||
//! \~\brief
|
||||
//! \~english Set or add the values of a given %PIValueTree object to the current %PIValueTree object.
|
||||
//! \param root The %PIValueTree object whose values are to be merged.
|
||||
//! \~russian Устанавливает или добавляет значения данного объекта %PIValueTree к текущему объекту %PIValueTree.
|
||||
//! \param root Объект %PIValueTree, значения которого должны быть добавлены.
|
||||
void merge(const PIValueTree & root);
|
||||
|
||||
//! \~\brief
|
||||
//! \~english Returns the children of the current %PIValueTree object.
|
||||
//! \~russian Возвращает дочерние элементы текущего объекта %PIValueTree.
|
||||
|
||||
@@ -130,18 +130,6 @@ void PIVariant::setValueFromString(const PIString & v) {
|
||||
case PIVariant::pivLDouble: {
|
||||
setValue(v.toLDouble());
|
||||
} break;
|
||||
case PIVariant::pivComplexf: {
|
||||
PIStringList sl = v.mid(1, v.size_s() - 2).split(';');
|
||||
setValue(complexf(sl.size() > 0 ? sl[0].toFloat() : 0.f, sl.size() > 1 ? sl[1].toFloat() : 0.f));
|
||||
}
|
||||
case PIVariant::pivComplexd: {
|
||||
PIStringList sl = v.mid(1, v.size_s() - 2).split(';');
|
||||
setValue(complexd(sl.size() > 0 ? sl[0].toDouble() : 0., sl.size() > 1 ? sl[1].toDouble() : 0.));
|
||||
}
|
||||
case PIVariant::pivComplexld: {
|
||||
PIStringList sl = v.mid(1, v.size_s() - 2).split(';');
|
||||
setValue(complexld(sl.size() > 0 ? sl[0].toLDouble() : 0.L, sl.size() > 1 ? sl[1].toLDouble() : 0.L));
|
||||
}
|
||||
case PIVariant::pivTime: {
|
||||
setValue(PITime::fromString(v));
|
||||
} break;
|
||||
@@ -254,7 +242,6 @@ PIVariant::Type PIVariant::typeFromName(const PIString & tname) {
|
||||
if (s == "float") return PIVariant::pivFloat;
|
||||
if (s == "double" || s == "real") return PIVariant::pivDouble;
|
||||
if (s == "ldouble" || s == "longdouble") return PIVariant::pivLDouble;
|
||||
if (s == "complexf" || s == "complex<float>") return PIVariant::pivComplexf;
|
||||
if (s == "complexd" || s == "complex<double>") return PIVariant::pivComplexd;
|
||||
if (s == "complexld" || s == "complex<ldouble>" || s == "complex<longdouble>") return PIVariant::pivComplexld;
|
||||
if (s == "pibitarray" || s == "bitarray") return PIVariant::pivBitArray;
|
||||
@@ -299,7 +286,6 @@ PIVariant::Type PIVariant::typeFromID(uint type_id) {
|
||||
if (type_id == typeID<float>()) return PIVariant::pivFloat;
|
||||
if (type_id == typeID<double>()) return PIVariant::pivDouble;
|
||||
if (type_id == typeID<ldouble>()) return PIVariant::pivLDouble;
|
||||
if (type_id == typeID<complexf>()) return PIVariant::pivComplexf;
|
||||
if (type_id == typeID<complexd>()) return PIVariant::pivComplexd;
|
||||
if (type_id == typeID<complexld>()) return PIVariant::pivComplexld;
|
||||
if (type_id == typeID<PIBitArray>()) return PIVariant::pivBitArray;
|
||||
@@ -350,7 +336,6 @@ uint PIVariant::typeIDFromType(Type type) {
|
||||
case (PIVariant::pivFloat ): return typeID<float >();
|
||||
case (PIVariant::pivDouble ): return typeID<double >();
|
||||
case (PIVariant::pivLDouble ): return typeID<ldouble >();
|
||||
case (PIVariant::pivComplexf ): return typeID<complexf >();
|
||||
case (PIVariant::pivComplexd ): return typeID<complexd >();
|
||||
case (PIVariant::pivComplexld ): return typeID<complexld >();
|
||||
case (PIVariant::pivBitArray ): return typeID<PIBitArray >();
|
||||
@@ -466,7 +451,6 @@ PIString PIVariant::typeName(PIVariant::Type type) {
|
||||
case PIVariant::pivFloat: return "Float";
|
||||
case PIVariant::pivDouble: return "Double";
|
||||
case PIVariant::pivLDouble: return "LDouble";
|
||||
case PIVariant::pivComplexf: return "Complexf";
|
||||
case PIVariant::pivComplexd: return "Complexd";
|
||||
case PIVariant::pivComplexld: return "Complexld";
|
||||
case PIVariant::pivBitArray: return "BitArray";
|
||||
@@ -707,21 +691,6 @@ int PIVariant::toInt() const {
|
||||
ba >> r;
|
||||
return r;
|
||||
}
|
||||
case PIVariant::pivComplexf: {
|
||||
complexf r;
|
||||
ba >> r;
|
||||
return r.real();
|
||||
}
|
||||
case PIVariant::pivComplexd: {
|
||||
complexd r;
|
||||
ba >> r;
|
||||
return r.real();
|
||||
}
|
||||
case PIVariant::pivComplexld: {
|
||||
complexld r;
|
||||
ba >> r;
|
||||
return r.real();
|
||||
}
|
||||
case PIVariant::pivString: {
|
||||
PIString r;
|
||||
ba >> r;
|
||||
@@ -837,21 +806,6 @@ llong PIVariant::toLLong() const {
|
||||
ba >> r;
|
||||
return r;
|
||||
}
|
||||
case PIVariant::pivComplexf: {
|
||||
complexf r;
|
||||
ba >> r;
|
||||
return r.real();
|
||||
}
|
||||
case PIVariant::pivComplexd: {
|
||||
complexd r;
|
||||
ba >> r;
|
||||
return r.real();
|
||||
}
|
||||
case PIVariant::pivComplexld: {
|
||||
complexld r;
|
||||
ba >> r;
|
||||
return r.real();
|
||||
}
|
||||
case PIVariant::pivString: {
|
||||
PIString r;
|
||||
ba >> r;
|
||||
@@ -962,21 +916,6 @@ float PIVariant::toFloat() const {
|
||||
ba >> r;
|
||||
return r;
|
||||
}
|
||||
case PIVariant::pivComplexf: {
|
||||
complexf r;
|
||||
ba >> r;
|
||||
return r.real();
|
||||
}
|
||||
case PIVariant::pivComplexd: {
|
||||
complexd r;
|
||||
ba >> r;
|
||||
return r.real();
|
||||
}
|
||||
case PIVariant::pivComplexld: {
|
||||
complexld r;
|
||||
ba >> r;
|
||||
return r.real();
|
||||
}
|
||||
case PIVariant::pivString: {
|
||||
PIString r;
|
||||
ba >> r;
|
||||
@@ -1087,21 +1026,6 @@ double PIVariant::toDouble() const {
|
||||
ba >> r;
|
||||
return r;
|
||||
}
|
||||
case PIVariant::pivComplexf: {
|
||||
complexf r;
|
||||
ba >> r;
|
||||
return r.real();
|
||||
}
|
||||
case PIVariant::pivComplexd: {
|
||||
complexd r;
|
||||
ba >> r;
|
||||
return r.real();
|
||||
}
|
||||
case PIVariant::pivComplexld: {
|
||||
complexld r;
|
||||
ba >> r;
|
||||
return r.real();
|
||||
}
|
||||
case PIVariant::pivString: {
|
||||
PIString r;
|
||||
ba >> r;
|
||||
@@ -1212,21 +1136,6 @@ ldouble PIVariant::toLDouble() const {
|
||||
ba >> r;
|
||||
return r;
|
||||
}
|
||||
case PIVariant::pivComplexf: {
|
||||
complexf r;
|
||||
ba >> r;
|
||||
return r.real();
|
||||
}
|
||||
case PIVariant::pivComplexd: {
|
||||
complexd r;
|
||||
ba >> r;
|
||||
return r.real();
|
||||
}
|
||||
case PIVariant::pivComplexld: {
|
||||
complexld r;
|
||||
ba >> r;
|
||||
return r.real();
|
||||
}
|
||||
case PIVariant::pivString: {
|
||||
PIString r;
|
||||
ba >> r;
|
||||
@@ -1255,96 +1164,6 @@ ldouble PIVariant::toLDouble() const {
|
||||
}
|
||||
|
||||
|
||||
complexf PIVariant::toComplexF() const {
|
||||
PIByteArray ba(_content);
|
||||
switch (_type) {
|
||||
case PIVariant::pivComplexf: {
|
||||
complexf r;
|
||||
ba >> r;
|
||||
return r;
|
||||
}
|
||||
case PIVariant::pivComplexd: {
|
||||
complexd r;
|
||||
ba >> r;
|
||||
return complexf(r.real(), r.imag());
|
||||
}
|
||||
case PIVariant::pivComplexld: {
|
||||
complexld r;
|
||||
ba >> r;
|
||||
return complexf(r.real(), r.imag());
|
||||
}
|
||||
case PIVariant::pivMathVector: {
|
||||
PIMathVectord r;
|
||||
ba >> r;
|
||||
return complexf(r.size() > 0 ? r[0] : 0., r.size() > 1 ? r[1] : 0.);
|
||||
}
|
||||
case PIVariant::pivCustom: return getAsValue<complexf>(*this);
|
||||
default: return complexf(toFloat(), 0.f);
|
||||
}
|
||||
return complexf();
|
||||
}
|
||||
|
||||
|
||||
complexd PIVariant::toComplexD() const {
|
||||
PIByteArray ba(_content);
|
||||
switch (_type) {
|
||||
case PIVariant::pivComplexf: {
|
||||
complexf r;
|
||||
ba >> r;
|
||||
return complexd(r.real(), r.imag());
|
||||
}
|
||||
case PIVariant::pivComplexd: {
|
||||
complexd r;
|
||||
ba >> r;
|
||||
return r;
|
||||
}
|
||||
case PIVariant::pivComplexld: {
|
||||
complexld r;
|
||||
ba >> r;
|
||||
return complexd(r.real(), r.imag());
|
||||
}
|
||||
case PIVariant::pivMathVector: {
|
||||
PIMathVectord r;
|
||||
ba >> r;
|
||||
return complexd(r.size() > 0 ? r[0] : 0., r.size() > 1 ? r[1] : 0.);
|
||||
}
|
||||
case PIVariant::pivCustom: return getAsValue<complexd>(*this);
|
||||
default: return complexd(toDouble(), 0.f);
|
||||
}
|
||||
return complexd();
|
||||
}
|
||||
|
||||
|
||||
complexld PIVariant::toComplexLD() const {
|
||||
PIByteArray ba(_content);
|
||||
switch (_type) {
|
||||
case PIVariant::pivComplexf: {
|
||||
complexf r;
|
||||
return complexld(r.real(), r.imag());
|
||||
ba >> r;
|
||||
}
|
||||
case PIVariant::pivComplexd: {
|
||||
complexd r;
|
||||
ba >> r;
|
||||
return complexld(r.real(), r.imag());
|
||||
}
|
||||
case PIVariant::pivComplexld: {
|
||||
complexld r;
|
||||
ba >> r;
|
||||
return r;
|
||||
}
|
||||
case PIVariant::pivMathVector: {
|
||||
PIMathVectord r;
|
||||
ba >> r;
|
||||
return complexld(r.size() > 0 ? r[0] : 0., r.size() > 1 ? r[1] : 0.);
|
||||
}
|
||||
case PIVariant::pivCustom: return getAsValue<complexld>(*this);
|
||||
default: return complexld(toLDouble(), 0.f);
|
||||
}
|
||||
return complexld();
|
||||
}
|
||||
|
||||
|
||||
//! \~\brief
|
||||
//! \~english Returns variant content as time
|
||||
//! \~russian Возвращает содержимое как время
|
||||
@@ -1599,21 +1418,6 @@ PIString PIVariant::toString() const {
|
||||
ba >> r;
|
||||
return PIString::fromNumber(r);
|
||||
}
|
||||
case PIVariant::pivComplexf: {
|
||||
complexf r;
|
||||
ba >> r;
|
||||
return "(" + PIString::fromNumber(r.real()) + ";" + PIString::fromNumber(r.imag()) + ")";
|
||||
}
|
||||
case PIVariant::pivComplexd: {
|
||||
complexd r;
|
||||
ba >> r;
|
||||
return "(" + PIString::fromNumber(r.real()) + ";" + PIString::fromNumber(r.imag()) + ")";
|
||||
}
|
||||
case PIVariant::pivComplexld: {
|
||||
complexld r;
|
||||
ba >> r;
|
||||
return "(" + PIString::fromNumber(r.real()) + ";" + PIString::fromNumber(r.imag()) + ")";
|
||||
}
|
||||
case PIVariant::pivTime: {
|
||||
PITime r;
|
||||
ba >> r;
|
||||
@@ -2106,45 +1910,21 @@ PINetworkAddress PIVariant::toNetworkAddress() const {
|
||||
//! Для остальных типов возвращает пустой PIMathVectord.
|
||||
//!
|
||||
PIMathVectord PIVariant::toMathVector() const {
|
||||
PIMathVectord ret;
|
||||
PIByteArray ba(_content);
|
||||
if (_type == PIVariant::pivComplexf) {
|
||||
complexf r;
|
||||
ba >> r;
|
||||
ret.resize(2);
|
||||
ret[0] = r.real();
|
||||
ret[1] = r.imag();
|
||||
return ret;
|
||||
}
|
||||
if (_type == PIVariant::pivComplexd) {
|
||||
complexd r;
|
||||
ba >> r;
|
||||
ret.resize(2);
|
||||
ret[0] = r.real();
|
||||
ret[1] = r.imag();
|
||||
return ret;
|
||||
}
|
||||
if (_type == PIVariant::pivComplexld) {
|
||||
complexld r;
|
||||
ba >> r;
|
||||
ret.resize(2);
|
||||
ret[0] = r.real();
|
||||
ret[1] = r.imag();
|
||||
return ret;
|
||||
}
|
||||
if (_type == PIVariant::pivMathVector) {
|
||||
ba >> ret;
|
||||
return ret;
|
||||
PIMathVectord r;
|
||||
ba >> r;
|
||||
return r;
|
||||
}
|
||||
if (_type == PIVariant::pivPoint) {
|
||||
PIPointd r;
|
||||
ba >> r;
|
||||
ret.resize(2);
|
||||
PIMathVectord ret(2);
|
||||
ret[0] = r.x;
|
||||
ret[1] = r.y;
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
return PIMathVectord();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
//! \file pivariant.h
|
||||
//! \ingroup Types
|
||||
//! \~\brief
|
||||
//! \~english Variant type
|
||||
//! \~russian Вариативный тип
|
||||
/*! \file pivariant.h
|
||||
* \ingroup Types
|
||||
* \brief
|
||||
* \~english Variant type
|
||||
* \~russian Вариативный тип
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Variant type
|
||||
@@ -101,21 +102,21 @@ struct __PIVariantTypeInfo__ {
|
||||
typedef const T & ConstReferenceType;
|
||||
};
|
||||
|
||||
# define __TYPEINFO_SINGLE(PT, T) \
|
||||
template<> \
|
||||
struct __PIVariantTypeInfo__<T> { \
|
||||
typedef PT PureType; \
|
||||
typedef const PT ConstPureType; \
|
||||
typedef PT * PointerType; \
|
||||
typedef const PT * ConstPointerType; \
|
||||
typedef PT & ReferenceType; \
|
||||
typedef const PT & ConstReferenceType; \
|
||||
};
|
||||
# define __TYPEINFO_SINGLE(PT, T) \
|
||||
template<> \
|
||||
struct __PIVariantTypeInfo__<T> { \
|
||||
typedef PT PureType; \
|
||||
typedef const PT ConstPureType; \
|
||||
typedef PT * PointerType; \
|
||||
typedef const PT * ConstPointerType; \
|
||||
typedef PT & ReferenceType; \
|
||||
typedef const PT & ConstReferenceType; \
|
||||
};
|
||||
|
||||
# define REGISTER_VARIANT_TYPEINFO(T) \
|
||||
__TYPEINFO_SINGLE(T, T &) \
|
||||
__TYPEINFO_SINGLE(T, const T) \
|
||||
__TYPEINFO_SINGLE(T, const T &)
|
||||
__TYPEINFO_SINGLE(T, T &) \
|
||||
__TYPEINFO_SINGLE(T, const T) \
|
||||
__TYPEINFO_SINGLE(T, const T &)
|
||||
|
||||
|
||||
class PIP_EXPORT __PIVariantInfoStorage__ {
|
||||
@@ -124,67 +125,72 @@ public:
|
||||
};
|
||||
|
||||
|
||||
# define REGISTER_VARIANT(classname) \
|
||||
template<> \
|
||||
inline PIString __PIVariantFunctions__<classname>::typeNameHelper() { \
|
||||
static PIString tn = PIStringAscii(#classname); \
|
||||
return tn; \
|
||||
} \
|
||||
template<> \
|
||||
inline uint __PIVariantFunctions__<classname>::typeIDHelper() { \
|
||||
static uint ret = PIStringAscii(#classname).hash(); \
|
||||
return ret; \
|
||||
} \
|
||||
REGISTER_VARIANT_TYPEINFO(classname) \
|
||||
STATIC_INITIALIZER_BEGIN \
|
||||
uint type_id = __PIVariantFunctions__<classname>::typeIDHelper(); \
|
||||
PIString type_name = __PIVariantFunctions__<classname>::typeNameHelper(); \
|
||||
if (__PIVariantInfoStorage__::get().contains(type_id)) return; \
|
||||
PIByteArray empty; \
|
||||
empty << classname(); \
|
||||
__PIVariantInfoStorage__::get()[type_id] = new __PIVariantInfo__(type_name, empty); \
|
||||
STATIC_INITIALIZER_END
|
||||
# define REGISTER_VARIANT(classname) \
|
||||
template<> \
|
||||
inline PIString __PIVariantFunctions__<classname>::typeNameHelper() { \
|
||||
static PIString tn = PIStringAscii(#classname); \
|
||||
return tn; \
|
||||
} \
|
||||
template<> \
|
||||
inline uint __PIVariantFunctions__<classname>::typeIDHelper() { \
|
||||
static uint ret = PIStringAscii(#classname).hash(); \
|
||||
return ret; \
|
||||
} \
|
||||
REGISTER_VARIANT_TYPEINFO(classname) \
|
||||
STATIC_INITIALIZER_BEGIN \
|
||||
uint type_id = __PIVariantFunctions__<classname>::typeIDHelper(); \
|
||||
PIString type_name = __PIVariantFunctions__<classname>::typeNameHelper(); \
|
||||
if (__PIVariantInfoStorage__::get().contains(type_id)) return; \
|
||||
PIByteArray empty; \
|
||||
empty << classname(); \
|
||||
__PIVariantInfoStorage__::get()[type_id] = new __PIVariantInfo__(type_name, empty); \
|
||||
STATIC_INITIALIZER_END
|
||||
|
||||
|
||||
# define REGISTER_VARIANT_CAST_H(classname_from, classname_to) \
|
||||
template<> \
|
||||
template<> \
|
||||
inline classname_to __PIVariantFunctions__<classname_from>::castVariant<classname_to>(const classname_from & v);
|
||||
template<> \
|
||||
template<> \
|
||||
inline classname_to __PIVariantFunctions__<classname_from>::castVariant<classname_to>(const classname_from & v);
|
||||
|
||||
# define REGISTER_VARIANT_CAST_CPP(classname_from, classname_to) \
|
||||
template<> \
|
||||
template<> \
|
||||
inline PIByteArray __PIVariantFunctions__<classname_from>::castHelper<classname_to>(PIByteArray v) { \
|
||||
classname_from f; \
|
||||
v >> f; \
|
||||
classname_to t = __PIVariantFunctions__<classname_from>::castVariant<classname_to>(f); \
|
||||
PIByteArray ret; \
|
||||
ret << t; \
|
||||
return ret; \
|
||||
} \
|
||||
STATIC_INITIALIZER_BEGIN \
|
||||
__PIVariantInfo__ * vi(__PIVariantInfoStorage__::get().value(__PIVariantFunctions__<classname_from>::typeIDHelper(), nullptr)); \
|
||||
if (!vi) { \
|
||||
piCout << "Warning! Using REGISTER_VARIANT_CAST(" #classname_from ", " #classname_to ") before REGISTER_VARIANT(" #classname_from \
|
||||
"), ignore."; \
|
||||
return; \
|
||||
template<> \
|
||||
template<> \
|
||||
inline PIByteArray __PIVariantFunctions__<classname_from>::castHelper<classname_to>(PIByteArray v) { \
|
||||
classname_from f; \
|
||||
v >> f; \
|
||||
classname_to t = __PIVariantFunctions__<classname_from>::castVariant<classname_to>(f); \
|
||||
PIByteArray ret; \
|
||||
ret << t; \
|
||||
return ret; \
|
||||
} \
|
||||
vi->cast[__PIVariantFunctions__<classname_to>::typeIDHelper()] = __PIVariantFunctions__<classname_from>::castHelper<classname_to>; \
|
||||
STATIC_INITIALIZER_END \
|
||||
template<> \
|
||||
template<> \
|
||||
classname_to __PIVariantFunctions__<classname_from>::castVariant<classname_to>(const classname_from & v)
|
||||
STATIC_INITIALIZER_BEGIN \
|
||||
__PIVariantInfo__ * vi(__PIVariantInfoStorage__::get().value(__PIVariantFunctions__<classname_from>::typeIDHelper(), nullptr)); \
|
||||
if (!vi) { \
|
||||
piCout << "Warning! Using REGISTER_VARIANT_CAST(" #classname_from ", " #classname_to \
|
||||
") before REGISTER_VARIANT(" #classname_from "), ignore."; \
|
||||
return; \
|
||||
} \
|
||||
vi->cast[__PIVariantFunctions__<classname_to>::typeIDHelper()] = \
|
||||
__PIVariantFunctions__<classname_from>::castHelper<classname_to>; \
|
||||
STATIC_INITIALIZER_END \
|
||||
template<> \
|
||||
template<> \
|
||||
classname_to __PIVariantFunctions__<classname_from>::castVariant<classname_to>(const classname_from & v)
|
||||
|
||||
# define REGISTER_VARIANT_CAST(classname_from, classname_to) \
|
||||
REGISTER_VARIANT_CAST_H(classname_from, classname_to) \
|
||||
REGISTER_VARIANT_CAST_CPP(classname_from, classname_to)
|
||||
REGISTER_VARIANT_CAST_H(classname_from, classname_to) \
|
||||
REGISTER_VARIANT_CAST_CPP(classname_from, classname_to)
|
||||
|
||||
|
||||
# define REGISTER_VARIANT_CAST_SIMPLE(classname_from, classname_to) \
|
||||
REGISTER_VARIANT_CAST(classname_from, classname_to) { return classname_to(v); }
|
||||
REGISTER_VARIANT_CAST(classname_from, classname_to) { \
|
||||
return classname_to(v); \
|
||||
}
|
||||
# define REGISTER_VARIANT_CAST_SIMPLE_H(classname_from, classname_to) REGISTER_VARIANT_CAST_H(classname_from, classname_to)
|
||||
# define REGISTER_VARIANT_CAST_SIMPLE_CPP(classname_from, classname_to) \
|
||||
REGISTER_VARIANT_CAST_CPP(classname_from, classname_to) { return classname_to(v); }
|
||||
REGISTER_VARIANT_CAST_CPP(classname_from, classname_to) { \
|
||||
return classname_to(v); \
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
@@ -254,7 +260,6 @@ public:
|
||||
pivMathMatrix /** PIMathMatrix<double> */,
|
||||
pivLine /** PILine<double> */,
|
||||
pivNetworkAddress /** PINetworkAddress */,
|
||||
pivComplexf /** complexf */,
|
||||
pivCustom /** \~english Custom \~russian Свой тип */ = 0xFF
|
||||
};
|
||||
|
||||
@@ -322,18 +327,6 @@ public:
|
||||
//! \~russian Создает %PIVariant из вещественного числа.
|
||||
PIVariant(const ldouble & v) { initType(v); }
|
||||
|
||||
//! \~english Constructs %PIVariant from complex number.
|
||||
//! \~russian Создает %PIVariant из комплексного числа.
|
||||
PIVariant(const complexf & v) { initType(v); }
|
||||
|
||||
//! \~english Constructs %PIVariant from complex number.
|
||||
//! \~russian Создает %PIVariant из комплексного числа.
|
||||
PIVariant(const complexd & v) { initType(v); }
|
||||
|
||||
//! \~english Constructs %PIVariant from complex number.
|
||||
//! \~russian Создает %PIVariant из комплексного числа.
|
||||
PIVariant(const complexld & v) { initType(v); }
|
||||
|
||||
//! \~english Constructs %PIVariant from bit array.
|
||||
//! \~russian Создает %PIVariant из массива битов.
|
||||
PIVariant(const PIBitArray & v) { initType(v); }
|
||||
@@ -463,18 +456,6 @@ public:
|
||||
//! \~russian Устанавливает значение и тип из вещественного числа
|
||||
void setValue(const ldouble & v) { initType(v); }
|
||||
|
||||
//! \~english Set variant content and type to complex
|
||||
//! \~russian Устанавливает значение и тип из комплексного числа
|
||||
void setValue(const complexf & v) { initType(v); }
|
||||
|
||||
//! \~english Set variant content and type to complex
|
||||
//! \~russian Устанавливает значение и тип из комплексного числа
|
||||
void setValue(const complexd & v) { initType(v); }
|
||||
|
||||
//! \~english Set variant content and type to complex
|
||||
//! \~russian Устанавливает значение и тип из комплексного числа
|
||||
void setValue(const complexld & v) { initType(v); }
|
||||
|
||||
//! \~english Set variant content and type to bit array
|
||||
//! \~russian Устанавливает значение и тип из массива битов
|
||||
void setValue(const PIBitArray & v) { initType(v); }
|
||||
@@ -564,9 +545,6 @@ public:
|
||||
float toFloat() const;
|
||||
double toDouble() const;
|
||||
ldouble toLDouble() const;
|
||||
complexf toComplexF() const;
|
||||
complexd toComplexD() const;
|
||||
complexld toComplexLD() const;
|
||||
PITime toTime() const;
|
||||
PIDate toDate() const;
|
||||
PIDateTime toDateTime() const;
|
||||
@@ -702,27 +680,6 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Assign operator.
|
||||
//! \~russian Оператор присваивания.
|
||||
PIVariant & operator=(const complexf & v) {
|
||||
setValue(v);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Assign operator.
|
||||
//! \~russian Оператор присваивания.
|
||||
PIVariant & operator=(const complexd & v) {
|
||||
setValue(v);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Assign operator.
|
||||
//! \~russian Оператор присваивания.
|
||||
PIVariant & operator=(const complexld & v) {
|
||||
setValue(v);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \~english Assign operator.
|
||||
//! \~russian Оператор присваивания.
|
||||
PIVariant & operator=(const PIBitArray & v) {
|
||||
@@ -1037,9 +994,6 @@ template<> inline ullong PIVariant::value() const {return (ullong)toLLong();}
|
||||
template<> inline float PIVariant::value() const {return toFloat();}
|
||||
template<> inline double PIVariant::value() const {return toDouble();}
|
||||
template<> inline ldouble PIVariant::value() const {return toLDouble();}
|
||||
template<> inline complexf PIVariant::value() const {return toComplexF();}
|
||||
template<> inline complexd PIVariant::value() const {return toComplexD();}
|
||||
template<> inline complexld PIVariant::value() const {return toComplexLD();}
|
||||
template<> inline void* PIVariant::value() const {return (void*)toLLong();}
|
||||
template<> inline const char* PIVariant::value() const {return toString().data();}
|
||||
template<> inline PITime PIVariant::value() const {return toTime();}
|
||||
@@ -1073,9 +1027,6 @@ template<> inline PIVariant PIVariant::fromValue(const ullong & v) {return PIVar
|
||||
template<> inline PIVariant PIVariant::fromValue(const float & v) {return PIVariant(v);}
|
||||
template<> inline PIVariant PIVariant::fromValue(const double & v) {return PIVariant(v);}
|
||||
template<> inline PIVariant PIVariant::fromValue(const ldouble & v) {return PIVariant(v);}
|
||||
template<> inline PIVariant PIVariant::fromValue(const complexf & v) {return PIVariant(v);}
|
||||
template<> inline PIVariant PIVariant::fromValue(const complexd & v) {return PIVariant(v);}
|
||||
template<> inline PIVariant PIVariant::fromValue(const complexld & v) {return PIVariant(v);}
|
||||
template<> inline PIVariant PIVariant::fromValue(const PIBitArray & v) {return PIVariant(v);}
|
||||
template<> inline PIVariant PIVariant::fromValue(const PIByteArray & v) {return PIVariant(v);}
|
||||
template<> inline PIVariant PIVariant::fromValue(const PIString & v) {return PIVariant(v);}
|
||||
@@ -1109,9 +1060,6 @@ template<> inline PIVariant::Type PIVariant::getType<ullong>() {return PIVariant
|
||||
template<> inline PIVariant::Type PIVariant::getType<float>() {return PIVariant::pivFloat;}
|
||||
template<> inline PIVariant::Type PIVariant::getType<double>() {return PIVariant::pivDouble;}
|
||||
template<> inline PIVariant::Type PIVariant::getType<ldouble>() {return PIVariant::pivLDouble;}
|
||||
template<> inline PIVariant::Type PIVariant::getType<complexf>() {return PIVariant:: pivComplexf;}
|
||||
template<> inline PIVariant::Type PIVariant::getType<complexd>() {return PIVariant:: pivComplexd;}
|
||||
template<> inline PIVariant::Type PIVariant::getType<complexld>() {return PIVariant::pivComplexld;}
|
||||
template<> inline PIVariant::Type PIVariant::getType<PIBitArray>() {return PIVariant::pivBitArray;}
|
||||
template<> inline PIVariant::Type PIVariant::getType<PIByteArray>() {return PIVariant::pivByteArray;}
|
||||
template<> inline PIVariant::Type PIVariant::getType<PIString>() {return PIVariant::pivString;}
|
||||
@@ -1145,9 +1093,6 @@ REGISTER_VARIANT(ullong)
|
||||
REGISTER_VARIANT(float)
|
||||
REGISTER_VARIANT(double)
|
||||
REGISTER_VARIANT(ldouble)
|
||||
REGISTER_VARIANT(complexf)
|
||||
REGISTER_VARIANT(complexd)
|
||||
REGISTER_VARIANT(complexld)
|
||||
REGISTER_VARIANT(PIBitArray)
|
||||
REGISTER_VARIANT(PIByteArray)
|
||||
REGISTER_VARIANT(PIString)
|
||||
@@ -1176,7 +1121,7 @@ REGISTER_VARIANT_CAST(PIGeoPosition, PIString) {
|
||||
g.setEllipsoidModel(PIEllipsoidModel::WGS84Ellipsoid());
|
||||
g.transformTo(PIGeoPosition::Geodetic);
|
||||
return PIString::fromNumber(g.latitudeGeodetic(), 'f', 8) + ", " + PIString::fromNumber(g.longitude(), 'f', 8) + ", " +
|
||||
PIString::fromNumber(g.height(), 'f', 2);
|
||||
PIString::fromNumber(g.height(), 'f', 2);
|
||||
};
|
||||
|
||||
REGISTER_VARIANT_CAST(PIString, PIGeoPosition) {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
//! \file pivariantsimple.h
|
||||
//! \ingroup Types
|
||||
//! \~\brief
|
||||
//! \~english Simple variant type
|
||||
//! \~russian Простой вариативный тип
|
||||
/*! \file pivariantsimple.h
|
||||
* \ingroup Types
|
||||
* \brief
|
||||
* \~english Simple variant type
|
||||
* \~russian Простой вариативный тип
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Variant simple type
|
||||
@@ -177,27 +178,35 @@ private:
|
||||
};
|
||||
|
||||
|
||||
#define REGISTER_PIVARIANTSIMPLE(Type) \
|
||||
template<> \
|
||||
class __VariantFunctions__<Type>: public __VariantFunctionsBase__ { \
|
||||
public: \
|
||||
__VariantFunctionsBase__ * instance() final { \
|
||||
static __VariantFunctions__<Type> ret; \
|
||||
return &ret; \
|
||||
} \
|
||||
PIString typeName() const final { \
|
||||
static PIString ret(#Type); \
|
||||
return ret; \
|
||||
} \
|
||||
uint hash() const final { \
|
||||
static uint ret = typeName().hash(); \
|
||||
return ret; \
|
||||
} \
|
||||
void newT(void *& ptr, const void * value) final { ptr = (void *)(new Type(*(const Type *)value)); } \
|
||||
void newNullT(void *& ptr) final { ptr = (void *)(new Type()); } \
|
||||
void assignT(void *& ptr, const void * value) final { *(Type *)ptr = *(const Type *)value; } \
|
||||
void deleteT(void *& ptr) final { delete (Type *)(ptr); } \
|
||||
};
|
||||
#define REGISTER_PIVARIANTSIMPLE(Type) \
|
||||
template<> \
|
||||
class __VariantFunctions__<Type>: public __VariantFunctionsBase__ { \
|
||||
public: \
|
||||
__VariantFunctionsBase__ * instance() final { \
|
||||
static __VariantFunctions__<Type> ret; \
|
||||
return &ret; \
|
||||
} \
|
||||
PIString typeName() const final { \
|
||||
static PIString ret(#Type); \
|
||||
return ret; \
|
||||
} \
|
||||
uint hash() const final { \
|
||||
static uint ret = typeName().hash(); \
|
||||
return ret; \
|
||||
} \
|
||||
void newT(void *& ptr, const void * value) final { \
|
||||
ptr = (void *)(new Type(*(const Type *)value)); \
|
||||
} \
|
||||
void newNullT(void *& ptr) final { \
|
||||
ptr = (void *)(new Type()); \
|
||||
} \
|
||||
void assignT(void *& ptr, const void * value) final { \
|
||||
*(Type *)ptr = *(const Type *)value; \
|
||||
} \
|
||||
void deleteT(void *& ptr) final { \
|
||||
delete (Type *)(ptr); \
|
||||
} \
|
||||
};
|
||||
|
||||
REGISTER_PIVARIANTSIMPLE(std::function<void(void *)>)
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
//! \file pivarianttypes.h
|
||||
//! \ingroup Types
|
||||
//! \~\brief
|
||||
//! \~english Types for PIVariant
|
||||
//! \~russian Типы для PIVariant
|
||||
/*! \file pivarianttypes.h
|
||||
* \ingroup Types
|
||||
* \brief
|
||||
* \~english Types for PIVariant
|
||||
* \~russian Типы для PIVariant
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Variant types
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
/*! \file piunits.h
|
||||
* \ingroup Core
|
||||
* \~\brief
|
||||
* \~english Unit conversions
|
||||
* \~russian Преобразование единиц измерения
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Unit conversions
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program 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 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PIUNITS_H
|
||||
#define PIUNITS_H
|
||||
|
||||
#include "piunits_class_angle.h"
|
||||
#include "piunits_class_distance.h"
|
||||
#include "piunits_class_information.h"
|
||||
#include "piunits_class_mass.h"
|
||||
#include "piunits_class_pressure.h"
|
||||
#include "piunits_class_temperature.h"
|
||||
#include "piunits_class_time.h"
|
||||
#include "piunits_value.h"
|
||||
|
||||
#endif
|
||||
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Unit conversions
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program 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 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "piunits_base.h"
|
||||
|
||||
#include "piliterals_string.h"
|
||||
|
||||
PIMap<int, PIUnits::Class::Internal::ClassBase *> PIUnits::Class::Internal::typeClasses;
|
||||
PIVector<PIUnits::Class::Internal::ClassBase *> PIUnits::Class::Internal::allTypeClasses;
|
||||
const PIString PIUnits::Class::Internal::unknown = "?"_a;
|
||||
|
||||
|
||||
PIString PIUnits::className(int type) {
|
||||
auto * uc = Class::Internal::typeClasses.value(type);
|
||||
if (!uc) return Class::Internal::unknown;
|
||||
return uc->className();
|
||||
}
|
||||
|
||||
|
||||
PIString PIUnits::name(int type) {
|
||||
auto * uc = Class::Internal::typeClasses.value(type);
|
||||
if (!uc) return Class::Internal::unknown;
|
||||
return uc->name(type);
|
||||
}
|
||||
|
||||
|
||||
PIString PIUnits::unit(int type) {
|
||||
auto * uc = Class::Internal::typeClasses.value(type);
|
||||
if (!uc) return Class::Internal::unknown;
|
||||
return uc->unit(type);
|
||||
}
|
||||
|
||||
|
||||
PIVector<PIUnits::Class::Internal::ClassBase *> PIUnits::allClasses() {
|
||||
return Class::Internal::allTypeClasses;
|
||||
}
|
||||
@@ -1,224 +0,0 @@
|
||||
/*! \file piunits_base.h
|
||||
* \ingroup Core
|
||||
* \~\brief
|
||||
* \~english Unit conversions
|
||||
* \~russian Преобразование единиц измерения
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Unit conversions
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program 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 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//! \~english Units base classes
|
||||
//! \~russian Базовые классы единиц измерения
|
||||
//! \defgroup Units Units
|
||||
//! \~\brief
|
||||
//! \~english Unit conversions
|
||||
//! \~russian Преобразование единиц измерения
|
||||
//!
|
||||
//! \~\details
|
||||
//! \~english \section cmake_module_Units Building with CMake
|
||||
//! \~russian \section cmake_module_Units Сборка с использованием CMake
|
||||
//!
|
||||
//! \~\code
|
||||
//! find_package(PIP REQUIRED)
|
||||
//! target_link_libraries([target] PIP)
|
||||
//! \endcode
|
||||
//!
|
||||
//! \~english \par Common
|
||||
//! \~russian \par Общее
|
||||
//!
|
||||
//! \~english
|
||||
//! These files provides unit conversion framework.
|
||||
//!
|
||||
//! \~russian
|
||||
//! Эти файлы обеспечивают фреймворк преобразования единиц.
|
||||
//!
|
||||
//! \~\authors
|
||||
//! \~english
|
||||
//! Ivan Pelipenko peri4ko@yandex.ru;
|
||||
//! Andrey Bychkov work.a.b@yandex.ru;
|
||||
//! \~russian
|
||||
//! Иван Пелипенко peri4ko@yandex.ru;
|
||||
//! Андрей Бычков work.a.b@yandex.ru;
|
||||
//!
|
||||
|
||||
#ifndef PIUNITS_BASE_H
|
||||
#define PIUNITS_BASE_H
|
||||
|
||||
#include "pitranslator.h"
|
||||
|
||||
//! \~english Macro to declare unit class beginning
|
||||
//! \~russian Макрос для объявления начала класса единиц
|
||||
#define DECLARE_UNIT_CLASS_BEGIN(Name, StartIndex) \
|
||||
namespace PIUnits { \
|
||||
namespace Class { \
|
||||
class PIP_EXPORT Name \
|
||||
: public Internal::ClassBase \
|
||||
, public Internal::Registrator<Name> { \
|
||||
private: \
|
||||
friend class Internal::Registrator<Name>; \
|
||||
constexpr static int typeStart = StartIndex; \
|
||||
PIString name(int type) const override; \
|
||||
PIString unit(int type) const override; \
|
||||
PIString valueToString(double v, char format, int prec) const override; \
|
||||
double convert(double v, int from, int to) const override; \
|
||||
bool supportPrefixes(int type) const override; \
|
||||
bool supportPrefixesNon3(int type) const override; \
|
||||
bool supportPrefixesGreater(int type) const override; \
|
||||
bool supportPrefixesSmaller(int type) const override; \
|
||||
\
|
||||
public: \
|
||||
PIString className() const override { return piTr(#Name, "PIUnits"); } \
|
||||
uint classID() const override { \
|
||||
static uint ret = PIStringAscii(#Name).hash(); \
|
||||
return ret; \
|
||||
}
|
||||
|
||||
|
||||
//! \~english Macro to declare unit class end
|
||||
//! \~russian Макрос для объявления конца класса единиц
|
||||
#define DECLARE_UNIT_CLASS_END(Name) \
|
||||
} \
|
||||
; \
|
||||
} \
|
||||
} \
|
||||
STATIC_INITIALIZER_BEGIN \
|
||||
PIUnits::Class::Name::registerSelf(); \
|
||||
STATIC_INITIALIZER_END
|
||||
|
||||
namespace PIUnits {
|
||||
|
||||
//! \~english Get class name for type
|
||||
//! \~russian Получить имя класса для типа
|
||||
PIP_EXPORT PIString className(int type);
|
||||
|
||||
//! \~english Get unit name for type
|
||||
//! \~russian Получить имя единицы для типа
|
||||
PIP_EXPORT PIString name(int type);
|
||||
|
||||
//! \~english Get unit symbol for type
|
||||
//! \~russian Получить символ единицы для типа
|
||||
PIP_EXPORT PIString unit(int type);
|
||||
|
||||
namespace Class {
|
||||
|
||||
//! \~english Invalid type marker
|
||||
//! \~russian Маркер недопустимого типа
|
||||
enum {
|
||||
Invalid = -1
|
||||
};
|
||||
|
||||
//! \~english Internal namespace for unit classes implementation
|
||||
//! \~russian Внутреннее пространство имен для реализации классов единиц
|
||||
class PIP_EXPORT Internal {
|
||||
public:
|
||||
//! \~english Base class for all unit classes
|
||||
//! \~russian Базовый класс для всех классов единиц
|
||||
class PIP_EXPORT ClassBase {
|
||||
public:
|
||||
//! \~english Get class ID
|
||||
//! \~russian Получить ID класса
|
||||
virtual uint classID() const = 0;
|
||||
|
||||
//! \~english Get class name
|
||||
//! \~russian Получить имя класса
|
||||
virtual PIString className() const = 0;
|
||||
|
||||
//! \~english Get name for unit type
|
||||
//! \~russian Получить имя для типа единицы
|
||||
virtual PIString name(int type) const = 0;
|
||||
|
||||
//! \~english Get unit symbol for type
|
||||
//! \~russian Получить символ единицы для типа
|
||||
virtual PIString unit(int type) const = 0;
|
||||
|
||||
//! \~english Convert value to string
|
||||
//! \~russian Преобразовать значение в строку
|
||||
virtual PIString valueToString(double v, char format = 'g', int prec = 5) const = 0;
|
||||
|
||||
//! \~english Convert value between units
|
||||
//! \~russian Преобразовать значение между единицами
|
||||
virtual double convert(double v, int from, int to) const = 0;
|
||||
|
||||
//! \~english Check if prefixes are supported
|
||||
//! \~russian Проверить поддерживаются ли префиксы
|
||||
virtual bool supportPrefixes(int type) const { return true; }
|
||||
|
||||
//! \~english Check if non-3 prefixes are supported
|
||||
//! \~russian Проверить поддерживаются ли не-3 префиксы
|
||||
virtual bool supportPrefixesNon3(int type) const { return false; }
|
||||
|
||||
//! \~english Check if greater prefixes are supported
|
||||
//! \~russian Проверить поддерживаются ли большие префиксы
|
||||
virtual bool supportPrefixesGreater(int type) const { return true; }
|
||||
|
||||
//! \~english Check if smaller prefixes are supported
|
||||
//! \~russian Проверить поддерживаются ли меньшие префиксы
|
||||
virtual bool supportPrefixesSmaller(int type) const { return true; }
|
||||
|
||||
//! \~english Get all available types
|
||||
//! \~russian Получить все доступные типы
|
||||
const PIVector<int> & allTypes() const { return types; }
|
||||
|
||||
protected:
|
||||
//! \~english List of types
|
||||
//! \~russian Список типов
|
||||
PIVector<int> types;
|
||||
};
|
||||
|
||||
//! \~english Template for self-registration of unit classes
|
||||
//! \~russian Шаблон для саморегистрации классов единиц
|
||||
template<typename P>
|
||||
class Registrator {
|
||||
public:
|
||||
//! \~english Register unit class
|
||||
//! \~russian Зарегистрировать класс единиц
|
||||
static void registerSelf() {
|
||||
auto * uc = new P();
|
||||
for (int t = P::typeStart; t < P::_LastType; ++t) {
|
||||
uc->types << t;
|
||||
Internal::typeClasses[t] = uc;
|
||||
}
|
||||
if (!Internal::allTypeClasses.contains(uc)) Internal::allTypeClasses << uc;
|
||||
}
|
||||
};
|
||||
|
||||
//! \~english Map of type to class instance
|
||||
//! \~russian Карта типа к экземпляру класса
|
||||
static PIMap<int, ClassBase *> typeClasses;
|
||||
|
||||
//! \~english List of all registered classes
|
||||
//! \~russian Список всех зарегистрированных классов
|
||||
static PIVector<ClassBase *> allTypeClasses;
|
||||
|
||||
//! \~english Unknown name placeholder
|
||||
//! \~russian Заполнитель для неизвестного имени
|
||||
static const PIString unknown;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Class
|
||||
|
||||
//! \~english Get all registered unit classes
|
||||
//! \~russian Получить все зарегистрированные классы единиц
|
||||
PIP_EXPORT PIVector<Class::Internal::ClassBase *> allClasses();
|
||||
|
||||
} // namespace PIUnits
|
||||
|
||||
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user