casadi 3.6.5__cp35-none-win_amd64.whl → 3.6.7__cp35-none-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- casadi/_casadi.pyd +0 -0
- casadi/bin/libtinyxml2.dll +0 -0
- casadi/blasfeo.lib +0 -0
- casadi/casadi-cli.exe +0 -0
- casadi/casadi.lib +0 -0
- casadi/casadi.py +739 -308
- casadi/cbc.exe +0 -0
- casadi/clp.exe +0 -0
- casadi/cmake/casadi-config-version.cmake +1 -1
- casadi/cmake/highs/highs-config.cmake +7 -14
- casadi/cmake/highs/highs-targets-release.cmake +13 -13
- casadi/cmake/highs/highs-targets.cmake +11 -9
- casadi/daqp.lib +0 -0
- casadi/fatrop.lib +0 -0
- casadi/highs.exe +0 -0
- casadi/highs.lib +0 -0
- casadi/hpipm.lib +0 -0
- casadi/include/casadi/casadi.i +3 -0
- casadi/include/casadi/casadi_c.h +2 -0
- casadi/include/casadi/config.h +8 -8
- casadi/include/casadi/core/casadi_common.hpp +1 -0
- casadi/include/casadi/core/casadi_misc.hpp +52 -0
- casadi/include/casadi/core/casadi_types.hpp +3 -2
- casadi/include/casadi/core/code_generator.hpp +30 -1
- casadi/include/casadi/core/global_options.hpp +2 -0
- casadi/include/casadi/core/mx.hpp +18 -3
- casadi/include/casadi/core/optistack.hpp +23 -0
- casadi/include/casadi/core/runtime/casadi_nlp.hpp +19 -4
- casadi/include/casadi/core/runtime/casadi_ocp_block.hpp +55 -0
- casadi/include/casadi/core/runtime/casadi_oracle.hpp +44 -0
- casadi/include/casadi/core/runtime/casadi_oracle_callback.hpp +39 -0
- casadi/include/casadi/core/runtime/casadi_runtime.hpp +4 -1
- casadi/include/casadi/core/runtime/casadi_scaled_copy.hpp +31 -0
- casadi/include/casadi/core/serializing_stream.hpp +2 -2
- casadi/include/casadi/core/sparsity.hpp +7 -0
- casadi/include/casadi/doc.i +1513 -1016
- casadi/include/casadi/doc_merged.i +965 -719
- casadi/include/casadi/mem.h +1 -0
- casadi/include/daqp/api.h +46 -0
- casadi/include/daqp/auxiliary.h +29 -0
- casadi/include/daqp/bnb.h +32 -0
- casadi/include/daqp/codegen.h +18 -0
- casadi/include/daqp/constants.h +92 -0
- casadi/include/daqp/daqp.h +22 -0
- casadi/include/daqp/daqp_prox.h +18 -0
- casadi/include/daqp/factorization.h +18 -0
- casadi/include/daqp/types.h +161 -0
- casadi/include/daqp/utils.h +44 -0
- casadi/include/dlfcn.h +94 -0
- casadi/include/fatrop/auxiliary/Common.hpp +34 -0
- casadi/include/fatrop/auxiliary/DynamicLib.hpp +34 -0
- casadi/include/fatrop/auxiliary/FatropOptions.hpp +68 -0
- casadi/include/fatrop/auxiliary/FatropVector.hpp +143 -0
- casadi/include/fatrop/auxiliary/LinearAlgebra.hpp +88 -0
- casadi/include/fatrop/auxiliary/VectorUtils.hpp +54 -0
- casadi/include/fatrop/blasfeo_wrapper/LinearAlgebraBlasfeo.hpp +493 -0
- casadi/include/fatrop/fatrop.hpp +39 -0
- casadi/include/fatrop/function_evaluation/CasadiCodegen.hpp +104 -0
- casadi/include/fatrop/function_evaluation/FunctionEvaluation.hpp +60 -0
- casadi/include/fatrop/json/json.h +946 -0
- casadi/include/fatrop/ocp/CasadiCApiUserdataWrap.hpp +87 -0
- casadi/include/fatrop/ocp/DuInfEvaluator.hpp +38 -0
- casadi/include/fatrop/ocp/FatropOCP.hpp +161 -0
- casadi/include/fatrop/ocp/FatropOCPBuilder.hpp +52 -0
- casadi/include/fatrop/ocp/FatropOCPResto.hpp +299 -0
- casadi/include/fatrop/ocp/OCP.hpp +82 -0
- casadi/include/fatrop/ocp/OCPAbstract.hpp +254 -0
- casadi/include/fatrop/ocp/OCPAdapter.hpp +197 -0
- casadi/include/fatrop/ocp/OCPCInterface.h +289 -0
- casadi/include/fatrop/ocp/OCPDims.hpp +60 -0
- casadi/include/fatrop/ocp/OCPInitializer.hpp +41 -0
- casadi/include/fatrop/ocp/OCPKKT.hpp +69 -0
- casadi/include/fatrop/ocp/OCPLSRiccati.hpp +198 -0
- casadi/include/fatrop/ocp/OCPLSScaler.hpp +66 -0
- casadi/include/fatrop/ocp/OCPLinearSolver.hpp +75 -0
- casadi/include/fatrop/ocp/OCPNoScaling.hpp +42 -0
- casadi/include/fatrop/ocp/OCPScalingMethod.hpp +42 -0
- casadi/include/fatrop/ocp/StageOCP.hpp +592 -0
- casadi/include/fatrop/ocp/StageOCPApplication.hpp +242 -0
- casadi/include/fatrop/ocp/StageOCPExpressions.hpp +182 -0
- casadi/include/fatrop/ocp/UStageEvalAbstract.hpp +168 -0
- casadi/include/fatrop/ocp/UStageOCPImpl.hpp +152 -0
- casadi/include/fatrop/quasi_newton/bfgs.hpp +159 -0
- casadi/include/fatrop/solver/AlgBuilder.hpp +76 -0
- casadi/include/fatrop/solver/AlgStrategy.hpp +33 -0
- casadi/include/fatrop/solver/FatropAlg.hpp +121 -0
- casadi/include/fatrop/solver/FatropData.hpp +188 -0
- casadi/include/fatrop/solver/FatropOptions.hpp +95 -0
- casadi/include/fatrop/solver/FatropPrinter.hpp +65 -0
- casadi/include/fatrop/solver/FatropStats.hpp +63 -0
- casadi/include/fatrop/solver/Filter.hpp +54 -0
- casadi/include/fatrop/solver/IterationData.hpp +56 -0
- casadi/include/fatrop/solver/LineSearch.hpp +86 -0
- casadi/include/fatrop/solver/NLPL1.hpp +263 -0
- casadi/include/fatrop/templates/NLPAlg.hpp +104 -0
- casadi/include/highs/HConfig.h +6 -5
- casadi/include/highs/Highs.h +93 -23
- casadi/include/highs/filereaderlp/def.hpp +19 -0
- casadi/include/highs/interfaces/highs_c_api.h +200 -24
- casadi/include/highs/io/Filereader.h +1 -1
- casadi/include/highs/io/FilereaderEms.h +1 -1
- casadi/include/highs/io/FilereaderLp.h +1 -1
- casadi/include/highs/io/FilereaderMps.h +1 -1
- casadi/include/highs/io/HMPSIO.h +1 -1
- casadi/include/highs/io/HMpsFF.h +5 -3
- casadi/include/highs/io/HighsIO.h +18 -8
- casadi/include/highs/io/LoadOptions.h +1 -1
- casadi/include/highs/ipm/IpxSolution.h +35 -0
- casadi/include/highs/ipm/IpxWrapper.h +1 -1
- casadi/include/highs/ipm/basiclu/basiclu.h +161 -0
- casadi/include/highs/ipm/basiclu/basiclu_factorize.h +247 -0
- casadi/include/highs/ipm/basiclu/basiclu_get_factors.h +108 -0
- casadi/include/highs/ipm/basiclu/basiclu_initialize.h +119 -0
- casadi/include/highs/ipm/basiclu/basiclu_obj_factorize.h +34 -0
- casadi/include/highs/ipm/basiclu/basiclu_obj_free.h +19 -0
- casadi/include/highs/ipm/basiclu/basiclu_obj_get_factors.h +34 -0
- casadi/include/highs/ipm/basiclu/basiclu_obj_initialize.h +46 -0
- casadi/include/highs/ipm/basiclu/basiclu_obj_solve_dense.h +29 -0
- casadi/include/highs/ipm/basiclu/basiclu_obj_solve_for_update.h +42 -0
- casadi/include/highs/ipm/basiclu/basiclu_obj_solve_sparse.h +32 -0
- casadi/include/highs/ipm/basiclu/basiclu_obj_update.h +31 -0
- casadi/include/highs/ipm/basiclu/basiclu_object.h +30 -0
- casadi/include/highs/ipm/basiclu/basiclu_solve_dense.h +75 -0
- casadi/include/highs/ipm/basiclu/basiclu_solve_for_update.h +169 -0
- casadi/include/highs/ipm/basiclu/basiclu_solve_sparse.h +112 -0
- casadi/include/highs/ipm/basiclu/basiclu_update.h +125 -0
- casadi/include/highs/ipm/basiclu/lu_def.h +39 -0
- casadi/include/highs/ipm/basiclu/lu_file.h +21 -0
- casadi/include/highs/ipm/basiclu/lu_internal.h +220 -0
- casadi/include/highs/ipm/basiclu/lu_list.h +168 -0
- casadi/include/highs/ipm/ipx/basiclu_kernel.h +20 -0
- casadi/include/highs/ipm/ipx/basiclu_wrapper.h +47 -0
- casadi/include/highs/ipm/ipx/basis.h +351 -0
- casadi/include/highs/ipm/ipx/conjugate_residuals.h +74 -0
- casadi/include/highs/ipm/ipx/control.h +163 -0
- casadi/include/highs/ipm/ipx/crossover.h +157 -0
- casadi/include/highs/ipm/ipx/diagonal_precond.h +45 -0
- casadi/include/highs/ipm/ipx/forrest_tomlin.h +102 -0
- casadi/include/highs/ipm/ipx/guess_basis.h +21 -0
- casadi/include/highs/ipm/ipx/indexed_vector.h +113 -0
- casadi/include/highs/ipm/ipx/info.h +27 -0
- casadi/include/highs/ipm/ipx/ipm.h +94 -0
- casadi/include/highs/ipm/ipx/ipx_c.h +47 -0
- casadi/include/highs/ipm/ipx/ipx_config.h +9 -0
- casadi/include/highs/ipm/ipx/ipx_info.h +111 -0
- casadi/include/highs/ipm/ipx/ipx_internal.h +88 -0
- casadi/include/highs/ipm/ipx/ipx_parameters.h +75 -0
- casadi/include/highs/ipm/ipx/ipx_status.h +57 -0
- casadi/include/highs/ipm/ipx/iterate.h +328 -0
- casadi/include/highs/ipm/ipx/kkt_solver.h +70 -0
- casadi/include/highs/ipm/ipx/kkt_solver_basis.h +66 -0
- casadi/include/highs/ipm/ipx/kkt_solver_diag.h +48 -0
- casadi/include/highs/ipm/ipx/linear_operator.h +26 -0
- casadi/include/highs/ipm/ipx/lp_solver.h +201 -0
- casadi/include/highs/ipm/ipx/lu_factorization.h +79 -0
- casadi/include/highs/ipm/ipx/lu_update.h +129 -0
- casadi/include/highs/ipm/ipx/maxvolume.h +54 -0
- casadi/include/highs/ipm/ipx/model.h +409 -0
- casadi/include/highs/ipm/ipx/multistream.h +52 -0
- casadi/include/highs/ipm/ipx/normal_matrix.h +44 -0
- casadi/include/highs/ipm/ipx/power_method.h +44 -0
- casadi/include/highs/ipm/ipx/sparse_matrix.h +195 -0
- casadi/include/highs/ipm/ipx/sparse_utils.h +58 -0
- casadi/include/highs/ipm/ipx/splitted_normal_matrix.h +63 -0
- casadi/include/highs/ipm/ipx/starting_basis.h +39 -0
- casadi/include/highs/ipm/ipx/symbolic_invert.h +29 -0
- casadi/include/highs/ipm/ipx/timer.h +24 -0
- casadi/include/highs/ipm/ipx/utils.h +39 -0
- casadi/include/highs/lp_data/HConst.h +20 -10
- casadi/include/highs/lp_data/HStruct.h +23 -1
- casadi/include/highs/lp_data/HighsAnalysis.h +1 -1
- casadi/include/highs/lp_data/HighsCallback.h +10 -3
- casadi/include/highs/lp_data/HighsCallbackStruct.h +31 -5
- casadi/include/highs/lp_data/HighsDebug.h +1 -1
- casadi/include/highs/lp_data/HighsInfo.h +20 -2
- casadi/include/highs/lp_data/HighsInfoDebug.h +1 -1
- casadi/include/highs/lp_data/HighsLp.h +17 -1
- casadi/include/highs/lp_data/HighsLpSolverObject.h +1 -1
- casadi/include/highs/lp_data/HighsLpUtils.h +19 -19
- casadi/include/highs/lp_data/HighsModelUtils.h +1 -1
- casadi/include/highs/lp_data/HighsOptions.h +237 -10
- casadi/include/highs/lp_data/HighsRanging.h +1 -1
- casadi/include/highs/lp_data/HighsRuntimeOptions.h +2 -2
- casadi/include/highs/lp_data/HighsSolution.h +2 -2
- casadi/include/highs/lp_data/HighsSolutionDebug.h +1 -1
- casadi/include/highs/lp_data/HighsSolve.h +3 -1
- casadi/include/highs/lp_data/HighsStatus.h +1 -1
- casadi/include/highs/mip/HighsCliqueTable.h +4 -4
- casadi/include/highs/mip/HighsConflictPool.h +1 -1
- casadi/include/highs/mip/HighsCutGeneration.h +1 -1
- casadi/include/highs/mip/HighsCutPool.h +2 -2
- casadi/include/highs/mip/HighsDebugSol.h +22 -29
- casadi/include/highs/mip/HighsDomain.h +10 -2
- casadi/include/highs/mip/HighsDomainChange.h +1 -1
- casadi/include/highs/mip/HighsDynamicRowMatrix.h +5 -3
- casadi/include/highs/mip/HighsGFkSolve.h +3 -3
- casadi/include/highs/mip/HighsImplications.h +3 -3
- casadi/include/highs/mip/HighsLpAggregator.h +1 -1
- casadi/include/highs/mip/HighsLpRelaxation.h +6 -1
- casadi/include/highs/mip/HighsMipSolver.h +4 -2
- casadi/include/highs/mip/HighsMipSolverData.h +47 -4
- casadi/include/highs/mip/HighsModkSeparator.h +2 -2
- casadi/include/highs/mip/HighsNodeQueue.h +5 -3
- casadi/include/highs/mip/HighsObjectiveFunction.h +1 -1
- casadi/include/highs/mip/HighsPathSeparator.h +2 -2
- casadi/include/highs/mip/HighsPrimalHeuristics.h +1 -1
- casadi/include/highs/mip/HighsPseudocost.h +35 -23
- casadi/include/highs/mip/HighsRedcostFixing.h +1 -1
- casadi/include/highs/mip/HighsSearch.h +2 -1
- casadi/include/highs/mip/HighsSeparation.h +1 -1
- casadi/include/highs/mip/HighsSeparator.h +1 -1
- casadi/include/highs/mip/HighsTableauSeparator.h +1 -1
- casadi/include/highs/mip/HighsTransformedLp.h +1 -1
- casadi/include/highs/model/HighsHessian.h +5 -0
- casadi/include/highs/model/HighsHessianUtils.h +2 -0
- casadi/include/highs/model/HighsModel.h +10 -1
- casadi/include/highs/parallel/HighsMutex.h +2 -1
- casadi/include/highs/parallel/HighsParallel.h +7 -2
- casadi/include/highs/parallel/HighsTask.h +1 -2
- casadi/include/highs/pdlp/CupdlpWrapper.h +93 -0
- casadi/include/highs/pdlp/cupdlp/cupdlp_cs.h +41 -0
- casadi/include/highs/pdlp/cupdlp/cupdlp_defs.h +423 -0
- casadi/include/highs/pdlp/cupdlp/cupdlp_linalg.h +183 -0
- casadi/include/highs/pdlp/cupdlp/cupdlp_proj.h +19 -0
- casadi/include/highs/pdlp/cupdlp/cupdlp_restart.h +31 -0
- casadi/include/highs/pdlp/cupdlp/cupdlp_scaling_cuda.h +28 -0
- casadi/include/highs/pdlp/cupdlp/cupdlp_solver.h +98 -0
- casadi/include/highs/pdlp/cupdlp/cupdlp_step.h +33 -0
- casadi/include/highs/pdlp/cupdlp/cupdlp_utils.c +1726 -0
- casadi/include/highs/pdqsort/pdqsort.h +532 -0
- casadi/include/highs/presolve/HPresolve.h +27 -14
- casadi/include/highs/presolve/HPresolveAnalysis.h +1 -1
- casadi/include/highs/presolve/HighsPostsolveStack.h +92 -68
- casadi/include/highs/presolve/HighsSymmetry.h +6 -5
- casadi/include/highs/presolve/ICrash.h +8 -2
- casadi/include/highs/presolve/ICrashUtil.h +1 -1
- casadi/include/highs/presolve/ICrashX.h +1 -1
- casadi/include/highs/presolve/PresolveComponent.h +1 -1
- casadi/include/highs/qpsolver/a_asm.hpp +23 -12
- casadi/include/highs/qpsolver/a_quass.hpp +8 -1
- casadi/include/highs/qpsolver/basis.hpp +150 -0
- casadi/include/highs/qpsolver/crashsolution.hpp +12 -0
- casadi/include/highs/qpsolver/dantzigpricing.hpp +72 -0
- casadi/include/highs/qpsolver/devexpricing.hpp +99 -0
- casadi/include/highs/qpsolver/eventhandler.hpp +23 -0
- casadi/include/highs/qpsolver/factor.hpp +400 -0
- casadi/include/highs/qpsolver/feasibility_bounded.hpp +105 -0
- casadi/include/highs/qpsolver/feasibility_highs.hpp +270 -0
- casadi/include/highs/qpsolver/gradient.hpp +39 -0
- casadi/include/highs/qpsolver/instance.hpp +63 -0
- casadi/include/highs/qpsolver/matrix.hpp +335 -0
- casadi/include/highs/qpsolver/pricing.hpp +15 -0
- casadi/include/highs/qpsolver/qpconst.hpp +27 -0
- casadi/include/highs/qpsolver/{vector.hpp → qpvector.hpp} +25 -25
- casadi/include/highs/qpsolver/quass.hpp +1 -1
- casadi/include/highs/qpsolver/ratiotest.hpp +19 -0
- casadi/include/highs/qpsolver/runtime.hpp +38 -0
- casadi/include/highs/qpsolver/settings.hpp +57 -0
- casadi/include/highs/qpsolver/snippets.hpp +29 -0
- casadi/include/highs/qpsolver/statistics.hpp +23 -0
- casadi/include/highs/qpsolver/steepestedgepricing.hpp +167 -0
- casadi/include/highs/simplex/HApp.h +1 -1
- casadi/include/highs/simplex/HEkk.h +52 -18
- casadi/include/highs/simplex/HEkkDual.h +1 -1
- casadi/include/highs/simplex/HEkkDualRHS.h +6 -7
- casadi/include/highs/simplex/HEkkDualRow.h +2 -2
- casadi/include/highs/simplex/HEkkPrimal.h +6 -1
- casadi/include/highs/simplex/HSimplex.h +1 -3
- casadi/include/highs/simplex/HSimplexDebug.h +1 -1
- casadi/include/highs/simplex/HSimplexNla.h +1 -1
- casadi/include/highs/simplex/HSimplexReport.h +1 -1
- casadi/include/highs/simplex/HighsSimplexAnalysis.h +228 -100
- casadi/include/highs/simplex/SimplexConst.h +1 -1
- casadi/include/highs/simplex/SimplexStruct.h +2 -2
- casadi/include/highs/simplex/SimplexTimer.h +1 -1
- casadi/include/highs/test/DevKkt.h +1 -1
- casadi/include/highs/test/KktCh2.h +1 -1
- casadi/include/highs/util/FactorTimer.h +1 -1
- casadi/include/highs/util/HFactor.h +35 -6
- casadi/include/highs/util/HFactorConst.h +1 -1
- casadi/include/highs/util/HFactorDebug.h +1 -1
- casadi/include/highs/util/HSet.h +1 -1
- casadi/include/highs/util/HVector.h +1 -1
- casadi/include/highs/util/HVectorBase.h +1 -1
- casadi/include/highs/util/HighsCDouble.h +3 -3
- casadi/include/highs/util/HighsComponent.h +1 -1
- casadi/include/highs/util/HighsDataStack.h +4 -4
- casadi/include/highs/util/HighsDisjointSets.h +1 -1
- casadi/include/highs/util/HighsHash.h +28 -21
- casadi/include/highs/util/HighsHashTree.h +63 -63
- casadi/include/highs/util/HighsInt.h +1 -1
- casadi/include/highs/util/HighsIntegers.h +8 -9
- casadi/include/highs/util/HighsLinearSumBounds.h +1 -1
- casadi/include/highs/util/HighsMatrixPic.h +1 -1
- casadi/include/highs/util/HighsMatrixSlice.h +9 -6
- casadi/include/highs/util/HighsMatrixUtils.h +1 -1
- casadi/include/highs/util/HighsMemoryAllocation.h +55 -0
- casadi/include/highs/util/HighsRandom.h +27 -15
- casadi/include/highs/util/HighsRbTree.h +2 -2
- casadi/include/highs/util/HighsSort.h +7 -7
- casadi/include/highs/util/HighsSparseMatrix.h +5 -2
- casadi/include/highs/util/HighsSparseVectorSum.h +2 -2
- casadi/include/highs/util/HighsSplay.h +1 -1
- casadi/include/highs/util/HighsTimer.h +18 -9
- casadi/include/highs/util/HighsUtils.h +15 -8
- casadi/include/highs/util/stringutil.h +9 -4
- casadi/include/highs/zstr/strict_fstream.hpp +237 -0
- casadi/include/highs/zstr/zstr.hpp +472 -0
- casadi/include/highs_export.h +42 -0
- casadi/include/licenses/daqp-external/LICENSE +21 -0
- casadi/include/licenses/fatrop-external/LICENSE.txt +165 -0
- casadi/include/licenses/fatrop-external/external/blasfeo/LICENSE.txt +26 -0
- casadi/include/licenses/fatrop-external/external/pybind11/LICENSE +29 -0
- casadi/include/licenses/highs-external/{LICENSE → LICENSE.txt} +1 -1
- casadi/include/osqp/constants.h +2 -3
- casadi/include/osqp/version.h +9 -0
- casadi/include/sleqp/defs.h +2 -2
- casadi/ipopt.lib +0 -0
- casadi/lapack.lib +0 -0
- casadi/lib/libtinyxml2.dll.a +0 -0
- casadi/libCbc-3.dll +0 -0
- casadi/libCbc.dll.a +0 -0
- casadi/libCbcSolver-3.dll +0 -0
- casadi/libCbcSolver.dll.a +0 -0
- casadi/libCgl-1.dll +0 -0
- casadi/libCgl.dll.a +0 -0
- casadi/libClp-1.dll +0 -0
- casadi/libClp.dll.a +0 -0
- casadi/libClpSolver-1.dll +0 -0
- casadi/libClpSolver.dll.a +0 -0
- casadi/libCoinUtils-3.dll +0 -0
- casadi/libCoinUtils.dll.a +0 -0
- casadi/libOsi-1.dll +0 -0
- casadi/libOsi.dll.a +0 -0
- casadi/libOsiCbc-3.dll +0 -0
- casadi/libOsiCbc.dll.a +0 -0
- casadi/libOsiClp-1.dll +0 -0
- casadi/libOsiClp.dll.a +0 -0
- casadi/libOsiCommonTests-1.dll +0 -0
- casadi/libOsiCommonTests.dll.a +0 -0
- casadi/libalpaqa.dll +0 -0
- casadi/libalpaqa.dll.a +0 -0
- casadi/libblasfeo.dll +0 -0
- casadi/libblasfeo.dll.a +0 -0
- casadi/libbonmin-4.dll +0 -0
- casadi/libbonmin.dll.a +0 -0
- casadi/libcasadi-tp-openblas.dll +0 -0
- casadi/libcasadi-tp-openblas.dll.a +0 -0
- casadi/libcasadi.dll +0 -0
- casadi/libcasadi.dll.a +0 -0
- casadi/libcasadi_conic_cbc.dll +0 -0
- casadi/libcasadi_conic_cbc.dll.a +0 -0
- casadi/libcasadi_conic_clp.dll +0 -0
- casadi/libcasadi_conic_clp.dll.a +0 -0
- casadi/libcasadi_conic_cplex.dll +0 -0
- casadi/libcasadi_conic_cplex.dll.a +0 -0
- casadi/libcasadi_conic_daqp.dll +0 -0
- casadi/libcasadi_conic_daqp.dll.a +0 -0
- casadi/libcasadi_conic_fatrop.dll +0 -0
- casadi/libcasadi_conic_fatrop.dll.a +0 -0
- casadi/libcasadi_conic_gurobi.dll +0 -0
- casadi/libcasadi_conic_gurobi.dll.a +0 -0
- casadi/libcasadi_conic_highs.dll +0 -0
- casadi/libcasadi_conic_highs.dll.a +0 -0
- casadi/libcasadi_conic_hpipm.dll +0 -0
- casadi/libcasadi_conic_hpipm.dll.a +0 -0
- casadi/libcasadi_conic_ipqp.dll +0 -0
- casadi/libcasadi_conic_ipqp.dll.a +0 -0
- casadi/libcasadi_conic_nlpsol.dll +0 -0
- casadi/libcasadi_conic_nlpsol.dll.a +0 -0
- casadi/libcasadi_conic_osqp.dll +0 -0
- casadi/libcasadi_conic_osqp.dll.a +0 -0
- casadi/libcasadi_conic_proxqp.dll +0 -0
- casadi/libcasadi_conic_proxqp.dll.a +0 -0
- casadi/libcasadi_conic_qpoases.dll +0 -0
- casadi/libcasadi_conic_qpoases.dll.a +0 -0
- casadi/libcasadi_conic_qrqp.dll +0 -0
- casadi/libcasadi_conic_qrqp.dll.a +0 -0
- casadi/libcasadi_conic_superscs.dll +0 -0
- casadi/libcasadi_conic_superscs.dll.a +0 -0
- casadi/libcasadi_importer_shell.dll +0 -0
- casadi/libcasadi_importer_shell.dll.a +0 -0
- casadi/libcasadi_integrator_collocation.dll +0 -0
- casadi/libcasadi_integrator_collocation.dll.a +0 -0
- casadi/libcasadi_integrator_cvodes.dll +0 -0
- casadi/libcasadi_integrator_cvodes.dll.a +0 -0
- casadi/libcasadi_integrator_idas.dll +0 -0
- casadi/libcasadi_integrator_idas.dll.a +0 -0
- casadi/libcasadi_integrator_rk.dll +0 -0
- casadi/libcasadi_integrator_rk.dll.a +0 -0
- casadi/libcasadi_interpolant_bspline.dll +0 -0
- casadi/libcasadi_interpolant_bspline.dll.a +0 -0
- casadi/libcasadi_interpolant_linear.dll +0 -0
- casadi/libcasadi_interpolant_linear.dll.a +0 -0
- casadi/libcasadi_linsol_csparse.dll +0 -0
- casadi/libcasadi_linsol_csparse.dll.a +0 -0
- casadi/libcasadi_linsol_csparsecholesky.dll +0 -0
- casadi/libcasadi_linsol_csparsecholesky.dll.a +0 -0
- casadi/libcasadi_linsol_lapacklu.dll +0 -0
- casadi/libcasadi_linsol_lapacklu.dll.a +0 -0
- casadi/libcasadi_linsol_lapackqr.dll +0 -0
- casadi/libcasadi_linsol_lapackqr.dll.a +0 -0
- casadi/libcasadi_linsol_ldl.dll +0 -0
- casadi/libcasadi_linsol_ldl.dll.a +0 -0
- casadi/libcasadi_linsol_lsqr.dll +0 -0
- casadi/libcasadi_linsol_lsqr.dll.a +0 -0
- casadi/libcasadi_linsol_ma27.dll +0 -0
- casadi/libcasadi_linsol_ma27.dll.a +0 -0
- casadi/libcasadi_linsol_mumps.dll +0 -0
- casadi/libcasadi_linsol_mumps.dll.a +0 -0
- casadi/libcasadi_linsol_qr.dll +0 -0
- casadi/libcasadi_linsol_qr.dll.a +0 -0
- casadi/libcasadi_linsol_symbolicqr.dll +0 -0
- casadi/libcasadi_linsol_symbolicqr.dll.a +0 -0
- casadi/libcasadi_linsol_tridiag.dll +0 -0
- casadi/libcasadi_linsol_tridiag.dll.a +0 -0
- casadi/libcasadi_nlpsol_alpaqa.dll +0 -0
- casadi/libcasadi_nlpsol_alpaqa.dll.a +0 -0
- casadi/libcasadi_nlpsol_ampl.dll +0 -0
- casadi/libcasadi_nlpsol_ampl.dll.a +0 -0
- casadi/libcasadi_nlpsol_blocksqp.dll +0 -0
- casadi/libcasadi_nlpsol_blocksqp.dll.a +0 -0
- casadi/libcasadi_nlpsol_bonmin.dll +0 -0
- casadi/libcasadi_nlpsol_bonmin.dll.a +0 -0
- casadi/libcasadi_nlpsol_fatrop.dll +0 -0
- casadi/libcasadi_nlpsol_fatrop.dll.a +0 -0
- casadi/libcasadi_nlpsol_feasiblesqpmethod.dll +0 -0
- casadi/libcasadi_nlpsol_feasiblesqpmethod.dll.a +0 -0
- casadi/libcasadi_nlpsol_ipopt.dll +0 -0
- casadi/libcasadi_nlpsol_ipopt.dll.a +0 -0
- casadi/libcasadi_nlpsol_knitro.dll +0 -0
- casadi/libcasadi_nlpsol_knitro.dll.a +0 -0
- casadi/libcasadi_nlpsol_madnlp.dll +0 -0
- casadi/libcasadi_nlpsol_madnlp.dll.a +0 -0
- casadi/libcasadi_nlpsol_qrsqp.dll +0 -0
- casadi/libcasadi_nlpsol_qrsqp.dll.a +0 -0
- casadi/libcasadi_nlpsol_scpgen.dll +0 -0
- casadi/libcasadi_nlpsol_scpgen.dll.a +0 -0
- casadi/libcasadi_nlpsol_sleqp.dll +0 -0
- casadi/libcasadi_nlpsol_sleqp.dll.a +0 -0
- casadi/libcasadi_nlpsol_snopt.dll +0 -0
- casadi/libcasadi_nlpsol_snopt.dll.a +0 -0
- casadi/libcasadi_nlpsol_sqpmethod.dll +0 -0
- casadi/libcasadi_nlpsol_sqpmethod.dll.a +0 -0
- casadi/libcasadi_nlpsol_worhp.dll +0 -0
- casadi/libcasadi_nlpsol_worhp.dll.a +0 -0
- casadi/libcasadi_rootfinder_fast_newton.dll +0 -0
- casadi/libcasadi_rootfinder_fast_newton.dll.a +0 -0
- casadi/libcasadi_rootfinder_kinsol.dll +0 -0
- casadi/libcasadi_rootfinder_kinsol.dll.a +0 -0
- casadi/libcasadi_rootfinder_newton.dll +0 -0
- casadi/libcasadi_rootfinder_newton.dll.a +0 -0
- casadi/libcasadi_rootfinder_nlpsol.dll +0 -0
- casadi/libcasadi_rootfinder_nlpsol.dll.a +0 -0
- casadi/libcasadi_sundials_common.dll +0 -0
- casadi/libcasadi_sundials_common.dll.a +0 -0
- casadi/libcasadi_xmlfile_tinyxml.dll +0 -0
- casadi/libcasadi_xmlfile_tinyxml.dll.a +0 -0
- casadi/libcoinmetis-2.dll +0 -0
- casadi/libcoinmetis.dll.a +0 -0
- casadi/libcoinmetis.la +1 -1
- casadi/libcoinmumps-3.dll +0 -0
- casadi/libcoinmumps.dll.a +0 -0
- casadi/libcplex_adaptor.dll +0 -0
- casadi/libdaqp.dll +0 -0
- casadi/libdaqp.dll.a +0 -0
- casadi/libdaqpstat.a +0 -0
- casadi/{libFortranHighs.dll → libdl.dll} +0 -0
- casadi/libdl.dll.a +0 -0
- casadi/libfatrop.dll +0 -0
- casadi/libfatrop.dll.a +0 -0
- casadi/libgurobi_adaptor.dll +0 -0
- casadi/libhighs.dll +0 -0
- casadi/libhighs.dll.a +0 -0
- casadi/libhpipm.dll +0 -0
- casadi/libhpipm.dll.a +0 -0
- casadi/libipopt-3.dll +0 -0
- casadi/libipopt.dll.a +0 -0
- casadi/libmatlab_ipc.dll +0 -0
- casadi/libmatlab_ipc.dll.a +0 -0
- casadi/libosqp.a +0 -0
- casadi/libosqp.dll +0 -0
- casadi/libosqp.dll.a +0 -0
- casadi/libqdldl.dll +0 -0
- casadi/libqdldl.dll.a +0 -0
- casadi/libsipopt-3.dll +0 -0
- casadi/libsipopt.dll.a +0 -0
- casadi/libsleqp.dll +0 -0
- casadi/libsleqp.dll.a +0 -0
- casadi/libtinyxml2.dll +0 -0
- casadi/libtrlib.dll +0 -0
- casadi/libtrlib.dll.a +0 -0
- casadi/matlab_ipc.lib +0 -0
- casadi/osqp.lib +0 -0
- casadi/pkgconfig/casadi.pc +1 -1
- casadi/pkgconfig/highs.pc +1 -1
- casadi/sleqp.lib +0 -0
- casadi/spral_ssids.exe +0 -0
- casadi/tools/__init__.py +4 -0
- casadi/tools/bounds.py +3 -3
- {casadi-3.6.5.dist-info → casadi-3.6.7.dist-info}/METADATA +2 -2
- {casadi-3.6.5.dist-info → casadi-3.6.7.dist-info}/RECORD +503 -325
- casadi/include/highs/fortran/highs_fortran_api.mod +0 -0
- casadi/libFortranHighs.dll.a +0 -0
- {casadi-3.6.5.dist-info → casadi-3.6.7.dist-info}/WHEEL +0 -0
@@ -0,0 +1,946 @@
|
|
1
|
+
/*
|
2
|
+
* Fatrop - A fast trajectory optimization solver
|
3
|
+
* Copyright (C) 2022 - 2024 Lander Vanroye, KU Leuven. All rights reserved.
|
4
|
+
*
|
5
|
+
* This file is part of Fatrop.
|
6
|
+
*
|
7
|
+
* Fatrop is free software: you can redistribute it and/or modify
|
8
|
+
* it under the terms of the GNU Lesser General Public License as published by
|
9
|
+
* the Free Software Foundation, either version 3 of the License, or
|
10
|
+
* (at your option) any later version.
|
11
|
+
*
|
12
|
+
* Fatrop is distributed in the hope that it will be useful,
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
* GNU Lesser General Public License for more details.
|
16
|
+
*
|
17
|
+
* You should have received a copy of the GNU Lesser General Public License
|
18
|
+
* along with Fatrop. If not, see <http://www.gnu.org/licenses/>. */
|
19
|
+
#ifndef JSON_H
|
20
|
+
#define JSON_H
|
21
|
+
|
22
|
+
/*! \file json.h
|
23
|
+
* \brief Simpleson header file
|
24
|
+
*/
|
25
|
+
|
26
|
+
#include <cstdlib>
|
27
|
+
#include <string>
|
28
|
+
#include <vector>
|
29
|
+
#include <cstdio>
|
30
|
+
#include <utility>
|
31
|
+
#include <stdexcept>
|
32
|
+
#include <cctype>
|
33
|
+
#include <string.h>
|
34
|
+
#include <limits>
|
35
|
+
|
36
|
+
/*! \brief Base namespace for simpleson */
|
37
|
+
namespace json
|
38
|
+
{
|
39
|
+
/*! \brief Exception used for invalid JSON keys */
|
40
|
+
class invalid_key : public std::exception
|
41
|
+
{
|
42
|
+
public:
|
43
|
+
/*! \brief The key used that was invalid */
|
44
|
+
const std::string key;
|
45
|
+
|
46
|
+
/*! \brief Constructor
|
47
|
+
*
|
48
|
+
* @param key The key that was not valid
|
49
|
+
*/
|
50
|
+
inline invalid_key(const std::string &key) : key(key) {}
|
51
|
+
|
52
|
+
/*! \brief Destructor */
|
53
|
+
inline virtual ~invalid_key() throw() {}
|
54
|
+
|
55
|
+
/*! \brief Returns the invalid key */
|
56
|
+
virtual const char *what() const throw()
|
57
|
+
{
|
58
|
+
return key.c_str();
|
59
|
+
}
|
60
|
+
};
|
61
|
+
|
62
|
+
/*! \brief Exception used when invalid JSON is encountered */
|
63
|
+
class parsing_error : public std::invalid_argument
|
64
|
+
{
|
65
|
+
public:
|
66
|
+
/*! \brief Constructor
|
67
|
+
*
|
68
|
+
* @param message Details regarding the parsing error
|
69
|
+
*/
|
70
|
+
inline parsing_error(const char *message) : std::invalid_argument(message) {}
|
71
|
+
|
72
|
+
/*! \brief Destructor */
|
73
|
+
inline virtual ~parsing_error() throw() {}
|
74
|
+
};
|
75
|
+
|
76
|
+
/* \brief Namespace for handling of JSON data types */
|
77
|
+
namespace jtype
|
78
|
+
{
|
79
|
+
/*! \brief Descriptor for the type of JSON data */
|
80
|
+
enum jtype
|
81
|
+
{
|
82
|
+
jstring, ///< String value
|
83
|
+
jnumber, ///< Number value
|
84
|
+
jinfinity,
|
85
|
+
jobject, ///< JSON object
|
86
|
+
jarray, ///< JSON array
|
87
|
+
jbool, ///< Boolean value
|
88
|
+
jnull, ///< Null value
|
89
|
+
not_valid ///< Value does not conform to JSON standard
|
90
|
+
};
|
91
|
+
|
92
|
+
/*! \brief Geven a string, determines the type of value the string contains
|
93
|
+
*
|
94
|
+
* @param input The string to be tested
|
95
|
+
* @return The type of JSON value encountered
|
96
|
+
*
|
97
|
+
* \note The function will only determine the type of the first value encountered in the string.
|
98
|
+
*/
|
99
|
+
jtype detect(const char *input);
|
100
|
+
}
|
101
|
+
|
102
|
+
/*! \brief Namespace used for JSON parsing functions */
|
103
|
+
namespace parsing
|
104
|
+
{
|
105
|
+
/*! \brief (t)rims (l)eading (w)hite (s)pace
|
106
|
+
*
|
107
|
+
* \details Given a string, returns a pointer to the first character that is not white space. Spaces, tabs, and carriage returns are all considered white space.
|
108
|
+
* @param start The string to examine
|
109
|
+
* @return A pointer within the input string that points at the first charactor that is not white space
|
110
|
+
* \note If the string consists of entirely white space, then the null terminator is returned
|
111
|
+
* \warning The behavior of this function with string that is not null-terminated is undefined
|
112
|
+
*/
|
113
|
+
const char *tlws(const char *start);
|
114
|
+
|
115
|
+
/*! \brief Reads a set of digits from a string
|
116
|
+
*
|
117
|
+
* \details This function will take an input string and read the digits at the front of the string until a character other than a digit (0-9) is encountered.
|
118
|
+
* @param input A string that starts with a set of digits (0-9)
|
119
|
+
* @return A string containing the digits
|
120
|
+
*/
|
121
|
+
std::string read_digits(const char *input);
|
122
|
+
|
123
|
+
/*! \brief Escape quotes in a string
|
124
|
+
*
|
125
|
+
* \details See json::parsing::unescape_quotes() for the reverse function
|
126
|
+
* @param input A string potentially containing quotes
|
127
|
+
* @return A string that has all quotes escaped
|
128
|
+
* @see unescape_quotes()
|
129
|
+
*/
|
130
|
+
std::string escape_quotes(const char *input);
|
131
|
+
|
132
|
+
/*! \brief Removes the escape charater from quotes
|
133
|
+
*
|
134
|
+
* \details See json::parsing::escape_quotes for the reverse function
|
135
|
+
* @param input A string potentially containing escaped quotes
|
136
|
+
* @return A string with quotes that are not escaped
|
137
|
+
* @see escape_quotes()
|
138
|
+
*/
|
139
|
+
std::string unescape_quotes(const char *input);
|
140
|
+
|
141
|
+
/*! \brief Structure for capturing the results of parsing */
|
142
|
+
struct parse_results
|
143
|
+
{
|
144
|
+
/*! \brief The type of value encountered while parsing */
|
145
|
+
jtype::jtype type;
|
146
|
+
|
147
|
+
/*! \brief The parsed value encountered */
|
148
|
+
std::string value;
|
149
|
+
|
150
|
+
/*! \brief A pointer to the first character after the parsed value */
|
151
|
+
const char *remainder;
|
152
|
+
};
|
153
|
+
|
154
|
+
/*! \brief Parses the first value encountered in a JSON string
|
155
|
+
*
|
156
|
+
* @param input The string to be parsed
|
157
|
+
* @return Details regarding the first value encountered
|
158
|
+
* \exception json::parsing_error Exception thrown when the input is not valid JSON
|
159
|
+
*/
|
160
|
+
parse_results parse(const char *input);
|
161
|
+
|
162
|
+
/*! \brief Template for reading a numeric value
|
163
|
+
*
|
164
|
+
* @tparam T The C data type the input will be convered to
|
165
|
+
* @param input The string to conver to a number
|
166
|
+
* @param format The format to use when converting the string to a number
|
167
|
+
* @return The numeric value contained by the input
|
168
|
+
*/
|
169
|
+
template <typename T>
|
170
|
+
T get_number(const char *input, const char *format)
|
171
|
+
{
|
172
|
+
T result;
|
173
|
+
if (strncmp(input, "Infinity", 8)==0)
|
174
|
+
{
|
175
|
+
return std::numeric_limits<T>::infinity();
|
176
|
+
};
|
177
|
+
if (strncmp(input, "-Infinity", 8)==0)
|
178
|
+
{
|
179
|
+
return -std::numeric_limits<T>::infinity();
|
180
|
+
};
|
181
|
+
std::sscanf(input, format, &result);
|
182
|
+
return result;
|
183
|
+
}
|
184
|
+
|
185
|
+
/*! \brief Converts a number to a string
|
186
|
+
*
|
187
|
+
* @tparam The C data type of the number to be converted
|
188
|
+
* @param number A reference to the number to be converted
|
189
|
+
* @param format The format to be used when converting the number
|
190
|
+
* @return A string representation of the input number
|
191
|
+
*/
|
192
|
+
template <typename T>
|
193
|
+
std::string get_number_string(const T &number, const char *format)
|
194
|
+
{
|
195
|
+
std::vector<char> cstr(6);
|
196
|
+
int remainder = std::snprintf(&cstr[0], cstr.size(), format, number);
|
197
|
+
if (remainder < 0)
|
198
|
+
{
|
199
|
+
return std::string();
|
200
|
+
}
|
201
|
+
else if (remainder >= (int)cstr.size())
|
202
|
+
{
|
203
|
+
cstr.resize(remainder + 1);
|
204
|
+
std::snprintf(&cstr[0], cstr.size(), format, number);
|
205
|
+
}
|
206
|
+
std::string result(&cstr[0]);
|
207
|
+
return result;
|
208
|
+
}
|
209
|
+
|
210
|
+
/*! \brief Parses a JSON array
|
211
|
+
*
|
212
|
+
* \details Converts a serialized JSON array into a vector of the values in the array
|
213
|
+
* @param input The serialized JSON array
|
214
|
+
* @return A vector containing each element of the array with each element being serialized JSON
|
215
|
+
*/
|
216
|
+
std::vector<std::string> parse_array(const char *input);
|
217
|
+
}
|
218
|
+
|
219
|
+
/*! \brief (k)ey (v)alue (p)air */
|
220
|
+
typedef std::pair<std::string, std::string> kvp;
|
221
|
+
|
222
|
+
/*! \class jobject
|
223
|
+
* \brief The class used for manipulating JSON objects and arrays
|
224
|
+
*
|
225
|
+
* \example jobject.cpp
|
226
|
+
* This is a basic of example of using simpleson for manipulating JSON
|
227
|
+
*
|
228
|
+
* \example rootarray.cppc
|
229
|
+
* This is an example of how to handle JSON where the root object is an array
|
230
|
+
*
|
231
|
+
* \example objectarray.cpp
|
232
|
+
* This is an example of how to handle an array of JSON objects
|
233
|
+
*/
|
234
|
+
class jobject
|
235
|
+
{
|
236
|
+
private:
|
237
|
+
/*! \brief The container used to store the object's data */
|
238
|
+
std::vector<kvp> data;
|
239
|
+
|
240
|
+
/*! \brief Flag for marking whether the object is actually a JSON array
|
241
|
+
*
|
242
|
+
* \details When true, the class should be interpreted as a JSON array
|
243
|
+
*/
|
244
|
+
bool array_flag;
|
245
|
+
|
246
|
+
public:
|
247
|
+
std::vector<std::string> keys()
|
248
|
+
{
|
249
|
+
std::vector<std::string> res(data.size());
|
250
|
+
for(size_t i=0; i<data.size(); i++)
|
251
|
+
{
|
252
|
+
res.at(i) = data.at(i).first;
|
253
|
+
}
|
254
|
+
return res;
|
255
|
+
}
|
256
|
+
/*! \brief Default constructor
|
257
|
+
*
|
258
|
+
* @param array If true, the instance is initialized as an array. If false, the instance is initalized as an object.
|
259
|
+
*/
|
260
|
+
inline jobject(bool array = false)
|
261
|
+
: array_flag(array)
|
262
|
+
{
|
263
|
+
}
|
264
|
+
|
265
|
+
/*! \brief Copy constructor */
|
266
|
+
inline jobject(const jobject &other)
|
267
|
+
: data(other.data),
|
268
|
+
array_flag(other.array_flag)
|
269
|
+
{
|
270
|
+
}
|
271
|
+
|
272
|
+
/*! \brief Destructor */
|
273
|
+
inline virtual ~jobject() {}
|
274
|
+
|
275
|
+
/*! \brief Flag for differentiating objects and arrays
|
276
|
+
*
|
277
|
+
* @return True if the instance represents an array, false if the instance represents an object
|
278
|
+
*/
|
279
|
+
bool is_array() const { return this->array_flag; }
|
280
|
+
|
281
|
+
/*! \brief Returns the number of entries in the JSON object or array */
|
282
|
+
inline size_t size() const { return this->data.size(); }
|
283
|
+
|
284
|
+
/*! \brief Clears the JSON object or array */
|
285
|
+
inline void clear() { this->data.resize(0); }
|
286
|
+
|
287
|
+
/*! \brief Comparison operator
|
288
|
+
*
|
289
|
+
* \todo Currently, the comparison just seralizes both objects and compares the strings, which is probably not as efficent as it could be
|
290
|
+
*/
|
291
|
+
bool operator==(const json::jobject other) const { return ((std::string)(*this)) == (std::string)other; }
|
292
|
+
|
293
|
+
/*! \brief Comparison operator */
|
294
|
+
bool operator!=(const json::jobject other) const { return ((std::string)(*this)) != (std::string)other; }
|
295
|
+
|
296
|
+
/*! \brief Assignment operator */
|
297
|
+
inline jobject &operator=(const jobject rhs)
|
298
|
+
{
|
299
|
+
this->array_flag = rhs.array_flag;
|
300
|
+
this->data = rhs.data;
|
301
|
+
return *this;
|
302
|
+
}
|
303
|
+
|
304
|
+
/*! \brief Appends a key-value pair to a JSON object
|
305
|
+
*
|
306
|
+
* \exception json::parsing_error Thrown if the key-value is incompatable with the existing object (object/array mismatch)
|
307
|
+
*/
|
308
|
+
jobject &operator+=(const kvp &other)
|
309
|
+
{
|
310
|
+
if (!this->array_flag && this->has_key(other.first))
|
311
|
+
throw json::parsing_error("Key conflict");
|
312
|
+
if (this->array_flag && other.first != "")
|
313
|
+
throw json::parsing_error("Array cannot have key");
|
314
|
+
if (!this->array_flag && other.first == "")
|
315
|
+
throw json::parsing_error("Missing key");
|
316
|
+
this->data.push_back(other);
|
317
|
+
return *this;
|
318
|
+
}
|
319
|
+
|
320
|
+
/*! \brief Appends one JSON object to another */
|
321
|
+
jobject &operator+=(const jobject &other)
|
322
|
+
{
|
323
|
+
if (this->array_flag != other.array_flag)
|
324
|
+
throw json::parsing_error("Array/object mismatch");
|
325
|
+
json::jobject copy(other);
|
326
|
+
for (size_t i = 0; i < copy.size(); i++)
|
327
|
+
{
|
328
|
+
this->operator+=(copy.data.at(i));
|
329
|
+
}
|
330
|
+
return *this;
|
331
|
+
}
|
332
|
+
|
333
|
+
/*! \brief Merges two JSON objects */
|
334
|
+
jobject operator+(jobject &other)
|
335
|
+
{
|
336
|
+
jobject result = *this;
|
337
|
+
result += other;
|
338
|
+
return result;
|
339
|
+
}
|
340
|
+
|
341
|
+
/*! \brief Parses a serialized JSON string
|
342
|
+
*
|
343
|
+
* @param input Serialized JSON string
|
344
|
+
* @return JSON object or array
|
345
|
+
* \exception json::parsing_error Thrown when the input string is not valid JSON
|
346
|
+
*/
|
347
|
+
static jobject parse(const char *input);
|
348
|
+
|
349
|
+
/*! \brief Parses a serialized JSON string
|
350
|
+
*
|
351
|
+
* @see json::jobject::parse(const char*)
|
352
|
+
*/
|
353
|
+
static inline jobject parse(const std::string input) { return parse(input.c_str()); }
|
354
|
+
|
355
|
+
/*! /brief Attempts to parse the input string
|
356
|
+
*
|
357
|
+
* @param input A serialized JSON object or array
|
358
|
+
* @param[out] output Should the parsing attempt be successful, the resultant JSON object or array
|
359
|
+
* @return True of the parsing attempt was successful and false if the parsing attempt was not successful
|
360
|
+
*/
|
361
|
+
inline bool static tryparse(const char *input, jobject &output)
|
362
|
+
{
|
363
|
+
try
|
364
|
+
{
|
365
|
+
output = parse(input);
|
366
|
+
}
|
367
|
+
catch (...)
|
368
|
+
{
|
369
|
+
return false;
|
370
|
+
}
|
371
|
+
return true;
|
372
|
+
}
|
373
|
+
|
374
|
+
/*! \brief Determines if an object contains a key
|
375
|
+
*
|
376
|
+
* @param key The key to check for
|
377
|
+
* @return True if the object contains the provided key and false if the object does not contain the key
|
378
|
+
* \note If the object represents a JSON array, then this function will always return false
|
379
|
+
*/
|
380
|
+
inline bool has_key(const std::string &key) const
|
381
|
+
{
|
382
|
+
if (this->array_flag)
|
383
|
+
return false;
|
384
|
+
for (size_t i = 0; i < this->size(); i++)
|
385
|
+
if (this->data.at(i).first == key)
|
386
|
+
return true;
|
387
|
+
return false;
|
388
|
+
}
|
389
|
+
|
390
|
+
/*! \brief Sets the value assocaited with the key
|
391
|
+
*
|
392
|
+
* \details If the key exists, then the value is updated. If the key does not exist, then the key value pair is added to the object.
|
393
|
+
* @param key The key for the entry
|
394
|
+
* @param value The value for the entry
|
395
|
+
* \exception json::invalid_key Exception thrown if the object actually represents a JSON array
|
396
|
+
*/
|
397
|
+
void set(const std::string &key, const std::string &value);
|
398
|
+
|
399
|
+
/*! \brief Returns the serialized value at a given index
|
400
|
+
*
|
401
|
+
* @param index The index of the desired element
|
402
|
+
* @return A serialized representation of the value at the given index
|
403
|
+
*/
|
404
|
+
inline std::string get(const size_t index) const
|
405
|
+
{
|
406
|
+
return this->data.at(index).second;
|
407
|
+
}
|
408
|
+
|
409
|
+
/*! \brief Returns the serialized value associated with a key
|
410
|
+
*
|
411
|
+
* @param key The key for the desired element
|
412
|
+
* @return A serialized representation of the value associated with the key
|
413
|
+
* \exception json::invalid_key Exception thrown if the key does not exist in the object or the object actually represents a JSON array
|
414
|
+
*/
|
415
|
+
inline std::string get(const std::string &key) const
|
416
|
+
{
|
417
|
+
if (this->array_flag)
|
418
|
+
throw json::invalid_key(key);
|
419
|
+
for (size_t i = 0; i < this->size(); i++)
|
420
|
+
if (this->data.at(i).first == key)
|
421
|
+
return this->get(i);
|
422
|
+
throw json::invalid_key(key);
|
423
|
+
}
|
424
|
+
|
425
|
+
/*! \brief Removes the entry associated with the key
|
426
|
+
*
|
427
|
+
* @param key The key of the key value pair to be removed
|
428
|
+
* \note If the key is not found in the object, no action is taken
|
429
|
+
*/
|
430
|
+
void remove(const std::string &key);
|
431
|
+
|
432
|
+
/*! \brief Removes the entry at the specified index
|
433
|
+
*
|
434
|
+
* @param index The index of the element to be removed
|
435
|
+
*/
|
436
|
+
void remove(const size_t index)
|
437
|
+
{
|
438
|
+
this->data.erase(this->data.begin() + index);
|
439
|
+
}
|
440
|
+
|
441
|
+
/*! \brief Representation of a value in the object */
|
442
|
+
class entry
|
443
|
+
{
|
444
|
+
protected:
|
445
|
+
/*! \brief A method for reference the entry's value
|
446
|
+
*
|
447
|
+
* @return A string represnting the entry's serialized value
|
448
|
+
*/
|
449
|
+
virtual const std::string &ref() const = 0;
|
450
|
+
|
451
|
+
/*! \brief Converts an serialzed value to a numeric value
|
452
|
+
*
|
453
|
+
* @tparam The C data type used to represent the value
|
454
|
+
* @param format The format used to convert the serialized value to a numeric value
|
455
|
+
* @return The value as a number
|
456
|
+
*/
|
457
|
+
template <typename T>
|
458
|
+
inline T get_number(const char *format) const
|
459
|
+
{
|
460
|
+
if (strncmp(this->ref().c_str(), "Infinity", 8)==0)
|
461
|
+
{
|
462
|
+
return std::numeric_limits<T>::infinity();
|
463
|
+
};
|
464
|
+
if (strncmp(this->ref().c_str(), "-Infinity", 8)==0)
|
465
|
+
{
|
466
|
+
return -std::numeric_limits<T>::infinity();
|
467
|
+
};
|
468
|
+
return json::parsing::get_number<T>(this->ref().c_str(), format);
|
469
|
+
}
|
470
|
+
|
471
|
+
public:
|
472
|
+
/*! \brief Converts a serialized array of numbers to a vector of numbers
|
473
|
+
*
|
474
|
+
* @tparam The C data type used to represent the values in the array
|
475
|
+
* @param format The format used to convert the serialized values in the array to numeric values
|
476
|
+
* @return The value as a vector of numbers
|
477
|
+
*/
|
478
|
+
template <typename T>
|
479
|
+
inline std::vector<T> get_number_array(const char *format) const
|
480
|
+
{
|
481
|
+
std::vector<std::string> numbers = json::parsing::parse_array(this->ref().c_str());
|
482
|
+
std::vector<T> result;
|
483
|
+
for (size_t i = 0; i < numbers.size(); i++)
|
484
|
+
{
|
485
|
+
result.push_back(json::parsing::get_number<T>(numbers[i].c_str(), format));
|
486
|
+
}
|
487
|
+
return result;
|
488
|
+
}
|
489
|
+
|
490
|
+
public:
|
491
|
+
/*! \brief Returns a string representation of the value */
|
492
|
+
inline std::string as_string() const
|
493
|
+
{
|
494
|
+
return json::parsing::unescape_quotes(
|
495
|
+
json::parsing::parse(this->ref().c_str()).value.c_str());
|
496
|
+
}
|
497
|
+
|
498
|
+
/*! @see json::jobject::entry::as_string() */
|
499
|
+
inline operator std::string() const
|
500
|
+
{
|
501
|
+
return this->as_string();
|
502
|
+
}
|
503
|
+
|
504
|
+
/*! \brief Comparison operator */
|
505
|
+
bool operator==(const std::string other) const { return ((std::string)(*this)) == other; }
|
506
|
+
|
507
|
+
/*! \brief Comparison operator */
|
508
|
+
bool operator!=(const std::string other) const { return !(((std::string)(*this)) == other); }
|
509
|
+
|
510
|
+
/*! \brief Casts the value as an integer */
|
511
|
+
operator int() const;
|
512
|
+
|
513
|
+
/*! \brief Casts the value as an unsigned integer */
|
514
|
+
operator unsigned int() const;
|
515
|
+
|
516
|
+
/*! \brief Casts teh value as a long integer */
|
517
|
+
operator long() const;
|
518
|
+
|
519
|
+
/*! \brief Casts the value as an unsigned long integer */
|
520
|
+
operator unsigned long() const;
|
521
|
+
|
522
|
+
/*! \brief Casts teh value as a char */
|
523
|
+
operator char() const;
|
524
|
+
|
525
|
+
/*! \brief Casts the value as a floating point numer */
|
526
|
+
operator float() const;
|
527
|
+
|
528
|
+
/*! \brief Casts the value as a double-precision floating point number */
|
529
|
+
operator double() const;
|
530
|
+
|
531
|
+
/*! \brief Casts the value as a JSON object
|
532
|
+
*
|
533
|
+
* \note This method also works for JSON arrays
|
534
|
+
*/
|
535
|
+
inline json::jobject as_object() const
|
536
|
+
{
|
537
|
+
return json::jobject::parse(this->ref().c_str());
|
538
|
+
}
|
539
|
+
|
540
|
+
/*! \see json::jobject::entry::as_object() */
|
541
|
+
inline operator json::jobject() const
|
542
|
+
{
|
543
|
+
return this->as_object();
|
544
|
+
}
|
545
|
+
|
546
|
+
/*! \brief Casts an array of integers */
|
547
|
+
operator std::vector<int>() const;
|
548
|
+
|
549
|
+
/*! \brief Casts an array of unsigned integers */
|
550
|
+
operator std::vector<unsigned int>() const;
|
551
|
+
|
552
|
+
/*! \brief Casts an array of long integers */
|
553
|
+
operator std::vector<long>() const;
|
554
|
+
|
555
|
+
/*! \brief Casts an array of unsigned long integers */
|
556
|
+
operator std::vector<unsigned long>() const;
|
557
|
+
|
558
|
+
/*! \brief Casts an array of chars */
|
559
|
+
operator std::vector<char>() const;
|
560
|
+
|
561
|
+
/*! \brief Casts an array of floating-point numbers */
|
562
|
+
operator std::vector<float>() const;
|
563
|
+
|
564
|
+
/*! \brief Casts an array of double floating-point numbers */
|
565
|
+
operator std::vector<double>() const;
|
566
|
+
|
567
|
+
/*! \brief Casts an array of JSON objects */
|
568
|
+
operator std::vector<json::jobject>() const
|
569
|
+
{
|
570
|
+
const std::vector<std::string> objs = json::parsing::parse_array(this->ref().c_str());
|
571
|
+
std::vector<json::jobject> results;
|
572
|
+
for (size_t i = 0; i < objs.size(); i++)
|
573
|
+
results.push_back(json::jobject::parse(objs[i].c_str()));
|
574
|
+
return results;
|
575
|
+
}
|
576
|
+
|
577
|
+
/*! \brief Casts an array of strings */
|
578
|
+
operator std::vector<std::string>() const { return json::parsing::parse_array(this->ref().c_str()); }
|
579
|
+
|
580
|
+
/*! \brief Casts an array
|
581
|
+
*
|
582
|
+
* @tparam T The type of array to be cast to
|
583
|
+
*/
|
584
|
+
template <typename T>
|
585
|
+
inline std::vector<T> as_array() const
|
586
|
+
{
|
587
|
+
return (std::vector<T>)(*this);
|
588
|
+
}
|
589
|
+
|
590
|
+
/*! \brief Returns true if the value is a boolean and set to true */
|
591
|
+
inline bool is_true() const
|
592
|
+
{
|
593
|
+
json::parsing::parse_results result = json::parsing::parse(this->ref().c_str());
|
594
|
+
return (result.type == json::jtype::jbool && result.value == "true");
|
595
|
+
}
|
596
|
+
|
597
|
+
/*! \brief Returns true if the value is a null value */
|
598
|
+
inline bool is_null() const
|
599
|
+
{
|
600
|
+
return json::parsing::parse(this->ref().c_str()).type == json::jtype::jnull;
|
601
|
+
}
|
602
|
+
// template <typename T>
|
603
|
+
// std::vector<T> as_vector() const
|
604
|
+
// {
|
605
|
+
// std::vector<T> res;
|
606
|
+
// res.reserve(this->ref().data.size());
|
607
|
+
// for (size_t i = 0; i < this->ref().data.size(); i++)
|
608
|
+
// {
|
609
|
+
// res.push_back((T)this->array(i));
|
610
|
+
// }
|
611
|
+
// return res;
|
612
|
+
// }
|
613
|
+
};
|
614
|
+
|
615
|
+
/*! \brief Represents an entry as a constant value */
|
616
|
+
class const_value : public entry
|
617
|
+
{
|
618
|
+
private:
|
619
|
+
/*! \brief A copy of the entry data */
|
620
|
+
std::string data;
|
621
|
+
|
622
|
+
protected:
|
623
|
+
/*! \brief Reference to the entry data
|
624
|
+
*
|
625
|
+
* @return A reference to the copied entry data
|
626
|
+
*/
|
627
|
+
inline const std::string &ref() const
|
628
|
+
{
|
629
|
+
return this->data;
|
630
|
+
}
|
631
|
+
|
632
|
+
public:
|
633
|
+
/*! \brief Constructs a proxy with the provided value
|
634
|
+
*
|
635
|
+
* @param value The entry value to copy
|
636
|
+
*/
|
637
|
+
inline const_value(std::string value)
|
638
|
+
: data(value)
|
639
|
+
{
|
640
|
+
}
|
641
|
+
|
642
|
+
/*! \brief Returns another constant value from this object
|
643
|
+
*
|
644
|
+
* This method assumed the entry contains a JSON object and returns another constant value from within
|
645
|
+
*
|
646
|
+
* @param key The key of the subvalue to return
|
647
|
+
* @return A proxy for the value for the key
|
648
|
+
*/
|
649
|
+
inline const_value get(const std::string &key) const
|
650
|
+
{
|
651
|
+
return const_value(json::jobject::parse(this->data).get(key));
|
652
|
+
}
|
653
|
+
|
654
|
+
/*! \brief Returns another constant value from this array
|
655
|
+
*
|
656
|
+
* This method assumed the entry contains a JSON array and returns another constant value from within
|
657
|
+
*
|
658
|
+
* @param index The index of the subvalue to return
|
659
|
+
* @return A proxy for the value for the index
|
660
|
+
*/
|
661
|
+
inline const_value array(const size_t index) const
|
662
|
+
{
|
663
|
+
return const_value(json::jobject::parse(this->data).get(index));
|
664
|
+
}
|
665
|
+
};
|
666
|
+
|
667
|
+
/*! \brief Represents an entry as a constant proxy to the value
|
668
|
+
*
|
669
|
+
* This proxy is more memory-efficent than a json::jobject::const_value but cannot use a JSON array as a source
|
670
|
+
*/
|
671
|
+
class const_proxy : public entry
|
672
|
+
{
|
673
|
+
private:
|
674
|
+
/*! \brief The source object the value is referencing */
|
675
|
+
const jobject &source;
|
676
|
+
|
677
|
+
protected:
|
678
|
+
/*! \brief The key for the referenced value */
|
679
|
+
const std::string key;
|
680
|
+
|
681
|
+
/*! \brief Returns a reference to the value */
|
682
|
+
inline const std::string &ref() const
|
683
|
+
{
|
684
|
+
for (size_t i = 0; i < this->source.size(); i++)
|
685
|
+
if (this->source.data.at(i).first == key)
|
686
|
+
return this->source.data.at(i).second;
|
687
|
+
throw json::invalid_key(key);
|
688
|
+
}
|
689
|
+
|
690
|
+
public:
|
691
|
+
/*! \brief Constructor
|
692
|
+
*
|
693
|
+
* @param source The JSON object the value is being sourced from
|
694
|
+
* @param key The key for the value being referenced
|
695
|
+
*/
|
696
|
+
const_proxy(const jobject &source, const std::string key) : source(source), key(key)
|
697
|
+
{
|
698
|
+
if (source.array_flag)
|
699
|
+
throw std::logic_error("Source cannot be an array");
|
700
|
+
}
|
701
|
+
|
702
|
+
/*! \brief Returns another constant value from this array
|
703
|
+
*
|
704
|
+
* This method assumed the entry contains a JSON array and returns another constant value from within
|
705
|
+
*
|
706
|
+
* @param index The index of the subvalue to return
|
707
|
+
* @return A proxy for the value for the index
|
708
|
+
*/
|
709
|
+
const_value array(size_t index) const
|
710
|
+
{
|
711
|
+
const char *value = this->ref().c_str();
|
712
|
+
if (json::jtype::detect(value) != json::jtype::jarray)
|
713
|
+
throw std::invalid_argument("Input is not an array");
|
714
|
+
const std::vector<std::string> values = json::parsing::parse_array(value);
|
715
|
+
return const_value(values[index]);
|
716
|
+
}
|
717
|
+
};
|
718
|
+
|
719
|
+
/*! \brief A proxy that allows modification of the value
|
720
|
+
*
|
721
|
+
* \todo Currently, proxies only support JSON object and not arrays
|
722
|
+
*/
|
723
|
+
class proxy : public json::jobject::const_proxy
|
724
|
+
{
|
725
|
+
private:
|
726
|
+
/*! \brief The parent object to be manipulated */
|
727
|
+
jobject &sink;
|
728
|
+
|
729
|
+
protected:
|
730
|
+
/*! \brief Sets a number value in the parent object
|
731
|
+
*
|
732
|
+
* @tparam T The data type to be translated into JSON
|
733
|
+
* @param value The value to be translated to JSON
|
734
|
+
* @param format The format to use when translating the number
|
735
|
+
*/
|
736
|
+
template <typename T>
|
737
|
+
inline void set_number(const T value, const char *format)
|
738
|
+
{
|
739
|
+
this->sink.set(key, json::parsing::get_number_string(value, format));
|
740
|
+
}
|
741
|
+
|
742
|
+
/*! \brief Stores an array of values
|
743
|
+
*
|
744
|
+
* @param values The values to store as an array
|
745
|
+
* @param wrap When true, the values are wrapped in quotes. When false, the values are stored as-is
|
746
|
+
*/
|
747
|
+
void set_array(const std::vector<std::string> &values, const bool wrap = false);
|
748
|
+
|
749
|
+
/*! \brief Stores an array of numbers
|
750
|
+
*
|
751
|
+
* @tparam T The data type to be translated into JSON
|
752
|
+
* @param values The array of values to be translated into JSON
|
753
|
+
* @param format The format to use when translating the numbers
|
754
|
+
*/
|
755
|
+
template <typename T>
|
756
|
+
inline void set_number_array(const std::vector<T> &values, const char *format)
|
757
|
+
{
|
758
|
+
std::vector<std::string> numbers;
|
759
|
+
for (size_t i = 0; i < values.size(); i++)
|
760
|
+
{
|
761
|
+
numbers.push_back(json::parsing::get_number_string(values[i], format));
|
762
|
+
}
|
763
|
+
this->set_array(numbers);
|
764
|
+
}
|
765
|
+
|
766
|
+
public:
|
767
|
+
/*! \brief Constructor
|
768
|
+
*
|
769
|
+
* @param source The JSON object that will be updated when a value is assigned
|
770
|
+
* @param key The key for the value to be updated
|
771
|
+
*/
|
772
|
+
proxy(jobject &source, const std::string key)
|
773
|
+
: json::jobject::const_proxy(source, key),
|
774
|
+
sink(source)
|
775
|
+
{
|
776
|
+
}
|
777
|
+
|
778
|
+
/*! \brief Assigns a string value */
|
779
|
+
inline void operator=(const std::string value)
|
780
|
+
{
|
781
|
+
this->sink.set(this->key, "\"" + json::parsing::escape_quotes(value.c_str()) + "\"");
|
782
|
+
}
|
783
|
+
|
784
|
+
/*! \brief Assigns a string value */
|
785
|
+
inline void operator=(const char *value)
|
786
|
+
{
|
787
|
+
this->operator=(std::string(value));
|
788
|
+
}
|
789
|
+
|
790
|
+
/*! \brief Assigns an integer */
|
791
|
+
void operator=(const int input) { this->set_number(input, "%i"); }
|
792
|
+
|
793
|
+
/*! \brief Assigns an unsigned integer */
|
794
|
+
void operator=(const unsigned int input) { this->set_number(input, "%u"); }
|
795
|
+
|
796
|
+
/*! \brief Assigns a long integer */
|
797
|
+
void operator=(const long input) { this->set_number(input, "%li"); }
|
798
|
+
|
799
|
+
/*! \brief Assigns a long unsigned integer */
|
800
|
+
void operator=(const unsigned long input) { this->set_number(input, "%lu"); }
|
801
|
+
|
802
|
+
/*! \brief Assigns an character */
|
803
|
+
void operator=(const char input) { this->set_number(input, "%c"); }
|
804
|
+
|
805
|
+
/*! \brief Assigns an double floating-point integer */
|
806
|
+
void operator=(const double input) { this->set_number(input, "%e"); }
|
807
|
+
|
808
|
+
/*! \brief Assigns an floating-point integer */
|
809
|
+
void operator=(const float input) { this->set_number(input, "%e"); }
|
810
|
+
|
811
|
+
/*! \brief Assigns a JSON object or array */
|
812
|
+
void operator=(json::jobject input)
|
813
|
+
{
|
814
|
+
this->sink.set(key, (std::string)input);
|
815
|
+
}
|
816
|
+
|
817
|
+
/*! \brief Assigns an array of integers */
|
818
|
+
void operator=(const std::vector<int> input) { this->set_number_array(input, "%i"); }
|
819
|
+
|
820
|
+
/*! \brief Assigns an array of unsigned integers */
|
821
|
+
void operator=(const std::vector<unsigned int> input) { this->set_number_array(input, "%u"); }
|
822
|
+
|
823
|
+
/*! \brief Assigns an array of long integers */
|
824
|
+
void operator=(const std::vector<long> input) { this->set_number_array(input, "%li"); }
|
825
|
+
|
826
|
+
/*! \brief Assigns an array of unsigned long integers */
|
827
|
+
void operator=(const std::vector<unsigned long> input) { this->set_number_array(input, "%lu"); }
|
828
|
+
|
829
|
+
/*! \brief Assigns an array of characters */
|
830
|
+
void operator=(const std::vector<char> input) { this->set_number_array(input, "%c"); }
|
831
|
+
|
832
|
+
/*! \brief Assigns an array of floating-point numbers */
|
833
|
+
void operator=(const std::vector<float> input) { this->set_number_array(input, "%e"); }
|
834
|
+
|
835
|
+
/*! \brief Assigns an array of double floating-point numbers */
|
836
|
+
void operator=(const std::vector<double> input) { this->set_number_array(input, "%e"); }
|
837
|
+
|
838
|
+
/*! \brief Assigns an array of strings */
|
839
|
+
void operator=(const std::vector<std::string> input) { this->set_array(input, true); }
|
840
|
+
|
841
|
+
/*! \brief Assigns an array of JSON objects */
|
842
|
+
void operator=(const std::vector<json::jobject> input)
|
843
|
+
{
|
844
|
+
std::vector<std::string> objs;
|
845
|
+
for (size_t i = 0; i < input.size(); i++)
|
846
|
+
{
|
847
|
+
objs.push_back((std::string)input[i]);
|
848
|
+
}
|
849
|
+
this->set_array(objs, false);
|
850
|
+
}
|
851
|
+
|
852
|
+
/*! \brief Sets a boolean value
|
853
|
+
*
|
854
|
+
* This method is required because operator=(bool value) conflict with number-based assignments
|
855
|
+
*/
|
856
|
+
inline void set_boolean(const bool value)
|
857
|
+
{
|
858
|
+
if (value)
|
859
|
+
this->sink.set(key, "true");
|
860
|
+
else
|
861
|
+
this->sink.set(key, "false");
|
862
|
+
}
|
863
|
+
|
864
|
+
/*! Sets a null value */
|
865
|
+
inline void set_null()
|
866
|
+
{
|
867
|
+
this->sink.set(key, "null");
|
868
|
+
}
|
869
|
+
|
870
|
+
/*! Clears the value */
|
871
|
+
inline void clear()
|
872
|
+
{
|
873
|
+
this->sink.remove(key);
|
874
|
+
}
|
875
|
+
};
|
876
|
+
|
877
|
+
/*! \brief Returns an element of the JSON object
|
878
|
+
*
|
879
|
+
* @param key The key of the element to be returned
|
880
|
+
* @return A proxy for the value paired with the key
|
881
|
+
* \exception json::invalid_key Exception thrown if the object is actually a JSON array
|
882
|
+
*/
|
883
|
+
inline virtual jobject::proxy operator[](const std::string key)
|
884
|
+
{
|
885
|
+
if (this->array_flag)
|
886
|
+
throw json::invalid_key(key);
|
887
|
+
return jobject::proxy(*this, key);
|
888
|
+
}
|
889
|
+
|
890
|
+
/*! \brief Returns an element of the JSON object
|
891
|
+
*
|
892
|
+
* @param key The key of the element to be returned
|
893
|
+
* @return A proxy for the value paired with the key
|
894
|
+
* \exception json::invalid_key Exception thrown if the object is actually a JSON array
|
895
|
+
*/
|
896
|
+
inline virtual const jobject::const_proxy operator[](const std::string key) const
|
897
|
+
{
|
898
|
+
if (this->array_flag)
|
899
|
+
throw json::invalid_key(key);
|
900
|
+
return jobject::const_proxy(*this, key);
|
901
|
+
}
|
902
|
+
|
903
|
+
/*! \brief Returns the value of an element in an array
|
904
|
+
*
|
905
|
+
* @param index The index of the element to be returned
|
906
|
+
* @return A proxy for the value
|
907
|
+
*
|
908
|
+
* \note While this method is intended for JSON arrays, this method is also valid for JSON objects
|
909
|
+
*/
|
910
|
+
inline const jobject::const_value array(const size_t index) const
|
911
|
+
{
|
912
|
+
return jobject::const_value(this->data.at(index).second);
|
913
|
+
}
|
914
|
+
|
915
|
+
/*! \see json::jobject::as_string() */
|
916
|
+
operator std::string() const;
|
917
|
+
|
918
|
+
/*! \brief Serialzes the object or array
|
919
|
+
* \note The serialized object or array will be in the most compact form and will not contain any extra white space, even if the serialized string used to generate the object or array contained extra white space.
|
920
|
+
*/
|
921
|
+
inline std::string as_string() const
|
922
|
+
{
|
923
|
+
return this->operator std::string();
|
924
|
+
}
|
925
|
+
// template <typename T>
|
926
|
+
// std::vector<T> as_vector()
|
927
|
+
// {
|
928
|
+
// std::vector<T> res;
|
929
|
+
// res.reserve(this->data.size());
|
930
|
+
// for (size_t i = 0; i < data.size(); i++)
|
931
|
+
// {
|
932
|
+
// res.push_back((T)this->array(i));
|
933
|
+
// }
|
934
|
+
// return res;
|
935
|
+
// }
|
936
|
+
|
937
|
+
/*! \brief Returns a pretty (multi-line indented) serialzed representation of the object or array
|
938
|
+
*
|
939
|
+
* @param indent_level The number of indents (tabs) to start with
|
940
|
+
* @return A "pretty" version of the serizlied object or array
|
941
|
+
*/
|
942
|
+
std::string pretty(unsigned int indent_level = 0) const;
|
943
|
+
};
|
944
|
+
}
|
945
|
+
|
946
|
+
#endif // !JSON_H
|