diff --git a/.github/workflows/docker-CI.yml b/.github/workflows/docker-CI.yml index 9909fda..2169bf2 100644 --- a/.github/workflows/docker-CI.yml +++ b/.github/workflows/docker-CI.yml @@ -1,107 +1,107 @@ -name: Build xApp Binary - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -env: - # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) - BUILD_TYPE: Release - E2AP_VERSION: E2AP_V3 - KPM_VERSION: KPM_V3_00 - C_COMPILER: gcc-13 - CPP_COMPILER: g++-13 - -jobs: - build: - runs-on: ubuntu-24.04 - - steps: - - uses: actions/checkout@v4 - with: - submodules: 'true' - - - name: Setup and install Swig - uses: mmomtchev/setup-swig@v1 - with: - version: v4.2.1 - - - name: Install dependencies - uses: awalsh128/cache-apt-pkgs-action@latest - with: - packages: | - libsctp-dev \ - libpcre2-dev \ - ninja-build - - - name: Configure CMake - run: | - cmake -B ${{github.workspace}}/build \ - -GNinja -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \ - -DE2AP_VERSION=${{env.E2AP_VERSION}} \ - -DKPM_VERSION=${{env.KPM_VERSION}} \ - -DCMAKE_C_FLAGS_RELEASE="-O3" \ - -DCMAKE_CXX_FLAGS_RELEASE="-O3" \ - -DCMAKE_C_COMPILER=${{env.C_COMPILER}} \ - -DCMAKE_CXX_COMPILER=${{env.CPP_COMPILER}} - - - name: Build xApp and service models - working-directory: ${{github.workspace}}/build - run: | - ninja xapp_iqos \ - libkpm_sm.so \ - librc_sm.so \ - libmac_sm.so \ - libslice_sm.so \ - libpdcp_sm.so \ - libgtp_sm.so \ - libtc_sm.so \ - librlc_sm.so - - - name: Test - working-directory: ${{github.workspace}}/build - run: ctest -C ${{env.BUILD_TYPE}} - - - name: Copy binaries - run: bash scripts/cpRicFiles.sh - - - name: Docker metadata - id: meta - uses: docker/metadata-action@v5 - with: - # list of Docker images to use as base name for tags - images: | - muriloavlis/iqos-xapp - # generate Docker tags based on the following events/attributes - tags: | - type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and push Docker image to Docker Hub - uses: docker/build-push-action@v5 - with: - context: . - file: "docker/Dockerfile" - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - - - +name: Build xApp Binary + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release + E2AP_VERSION: E2AP_V3 + KPM_VERSION: KPM_V3_00 + C_COMPILER: gcc-13 + CPP_COMPILER: g++-13 + +jobs: + build: + runs-on: ubuntu-24.04 + + steps: + - uses: actions/checkout@v4 + with: + submodules: 'true' + + - name: Setup and install Swig + uses: mmomtchev/setup-swig@v1 + with: + version: v4.2.1 + + - name: Install dependencies + uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: | + libsctp-dev \ + libpcre2-dev \ + ninja-build + + - name: Configure CMake + run: | + cmake -B ${{github.workspace}}/build \ + -GNinja -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \ + -DE2AP_VERSION=${{env.E2AP_VERSION}} \ + -DKPM_VERSION=${{env.KPM_VERSION}} \ + -DCMAKE_C_FLAGS_RELEASE="-O3" \ + -DCMAKE_CXX_FLAGS_RELEASE="-O3" \ + -DCMAKE_C_COMPILER=${{env.C_COMPILER}} \ + -DCMAKE_CXX_COMPILER=${{env.CPP_COMPILER}} + + - name: Build xApp and service models + working-directory: ${{github.workspace}}/build + run: | + ninja xapp_iqos \ + libkpm_sm.so \ + librc_sm.so \ + libmac_sm.so \ + libslice_sm.so \ + libpdcp_sm.so \ + libgtp_sm.so \ + libtc_sm.so \ + librlc_sm.so + + - name: Test + working-directory: ${{github.workspace}}/build + run: ctest -C ${{env.BUILD_TYPE}} + + - name: Copy binaries + run: bash scripts/cpRicFiles.sh + + - name: Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + # list of Docker images to use as base name for tags + images: | + muriloavlis/iqos-xapp + # generate Docker tags based on the following events/attributes + tags: | + type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker image to Docker Hub + uses: docker/build-push-action@v5 + with: + context: . + file: "docker/Dockerfile" + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + + diff --git a/.gitignore b/.gitignore index 633b30e..081b8b9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ -cmake-build-debug -.idea -compile_commands.json -build +cmake-build-debug +.idea +compile_commands.json +build configs/xApp.conf \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index e01003e..5e6e155 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ -[submodule "flexric"] - path = libs/flexric - url = https://gitlab.eurecom.fr/mosaic5g/flexric.git - branch = dev +[submodule "flexric"] + path = libs/flexric + url = https://gitlab.eurecom.fr/mosaic5g/flexric.git + branch = dev diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..049ce8f --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "files.associations": { + "assert.h": "c", + "runprediction_initialize.h": "c", + "elementwiseoperationinplace.h": "c" + } +} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index a762bef..ea26d8d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,43 +1,75 @@ -cmake_minimum_required(VERSION 3.15) -project(xapp_iqos VERSION 0.0.1 LANGUAGES CXX) - -set(CMAKE_CXX_STANDARD 23) -set(CMAKE_C_FLAGS_RELEASE "-O3") -set(CMAKE_CXX_FLAGS_RELEASE "-O3") - -## Definitions -add_compile_definitions(SPDLOG_ACTIVE_LEVEL) - -## Add libs -add_subdirectory(libs) - -## build external libs -### SPDLOG for logs -Include(FetchContent) -FetchContent_Declare( - spdlog - GIT_REPOSITORY https://github.com/gabime/spdlog.git - GIT_TAG v1.14.1 -) -FetchContent_MakeAvailable(spdlog) - -## Config executable -add_executable(xapp_iqos src/main.cpp - src/logger.cpp - src/kpmManager.cpp - src/e2Info.cpp -) - -## Link libraries -target_include_directories(xapp_iqos PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${CMAKE_CURRENT_SOURCE_DIR}/libs - ${CMAKE_CURRENT_SOURCE_DIR}/libs/flexric/src/xApp -) -target_link_libraries(xapp_iqos PUBLIC - e42_xapp - spdlog::spdlog $<$:ws2_32> - -pthread - -lsctp - -ldl -) \ No newline at end of file +enable_language(OBJC) +cmake_minimum_required(VERSION 3.15) +project(xapp_iqos VERSION 0.0.1 LANGUAGES CXX C ASM) + +set(CMAKE_CXX_STANDARD 23) +set(CMAKE_C_FLAGS_RELEASE "-O3") +set(CMAKE_CXX_FLAGS_RELEASE "-O3") + +## Enable OpenMP +find_package(OpenMP) +if(OpenMP_FOUND) + message(STATUS "OpenMP found: ${OpenMP_CXX_FLAGS}") + add_compile_definitions(_OPENMP) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") +else() + message(WARNING "OpenMP not found. Ensure it is installed for your compiler.") +endif() + +## Definitions +add_compile_definitions(SPDLOG_ACTIVE_LEVEL) + +## Add libs +add_subdirectory(libs) + +## build external libs +### SPDLOG for logs +Include(FetchContent) +FetchContent_Declare( + spdlog + GIT_REPOSITORY https://github.com/gabime/spdlog.git + GIT_TAG v1.14.1 +) +FetchContent_MakeAvailable(spdlog) + +## Config executable +add_executable(xapp_iqos src/main.cpp + src/logger.cpp + src/kpmManager.cpp + src/e2Info.cpp + src/cellstr_sort.c + src/elementwiseOperationInPlace.c + src/find.c + src/getCategoryNames.c + src/insertionsort.c + src/internal_softmax.c + src/introsort.c + src/postProcessOutputToReturnCategorical.c + src/predict.c + src/predictForRNN.c + src/rtGetInf.c + src/rtGetNaN.c + src/rt_nonfinite.c + src/runPrediction.c + src/runPrediction_data.c + src/runPrediction_initialize.c + src/runPrediction_terminate.c + src/SoftmaxLayer.c + src/strcmp.c + src/strtrim.c +) + +## Link libraries +target_include_directories(xapp_iqos PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${CMAKE_CURRENT_SOURCE_DIR}/libs + ${CMAKE_CURRENT_SOURCE_DIR}/libs/flexric/src/xApp +) +target_link_libraries(xapp_iqos PUBLIC + e42_xapp + spdlog::spdlog $<$:ws2_32> + -pthread + -lsctp + -ldl +) diff --git a/README.md b/README.md index 9f0cb4d..779c05b 100644 --- a/README.md +++ b/README.md @@ -1,51 +1,51 @@ -# Application for Intelligent QoS Management for O-RAN Networks (IQoS-xApp) - -Add a paragraph about the application here... - -## Requirements - -- python3-dev; -- libsctp-dev; -- librdkafka-dev; -- ninja-build; -- swig v4.1 or newer; - -## Getting Started - -## Using Docker image - -```shell -docker container run -itd --name iqos-xapp -e NEAR_RIC_IP="" muriloavlis/iqos-xapp:latest -``` - -### Building the xApp - -Clone the xApp repository with the following command. - -```shell -git clone --recurse-submodules -j8 git@github.com:gercom-ufpa/iqos-xapp.git -``` - -Copy service models libraries to system. - -```shell -cd iqos-xapp -sudo mkdir -p /usr/local/etc/ -sudo cp -R libs/serviceModels /usr/local/lib/flexric -``` - -Build the xApp. - -```shell -mkdir -p build && cd build -cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DE2AP_VERSION=E2AP_V3 -DKPM_VERSION=KPM_V3_00 .. -ninja xapp_iqos -``` - -### Running the xApp - -After building, the xApp can be run with the following command. - -```shell -./xapp_iqos -c ../configs/xApp.conf +# Application for Intelligent QoS Management for O-RAN Networks (IQoS-xApp) + +Add a paragraph about the application here... + +## Requirements + +- python3-dev; +- libsctp-dev; +- librdkafka-dev; +- ninja-build; +- swig v4.1 or newer; + +## Getting Started + +## Using Docker image + +```shell +docker container run -itd --name iqos-xapp -e NEAR_RIC_IP="" muriloavlis/iqos-xapp:latest +``` + +### Building the xApp + +Clone the xApp repository with the following command. + +```shell +git clone --recurse-submodules -j8 git@github.com:gercom-ufpa/iqos-xapp.git +``` + +Copy service models libraries to system. + +```shell +cd iqos-xapp +sudo mkdir -p /usr/local/etc/ +sudo cp -R libs/serviceModels /usr/local/lib/flexric +``` + +Build the xApp. + +```shell +mkdir -p build && cd build +cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DE2AP_VERSION=E2AP_V3 -DKPM_VERSION=KPM_V3_00 .. +ninja xapp_iqos +``` + +### Running the xApp + +After building, the xApp can be run with the following command. + +```shell +./xapp_iqos -c ../configs/xApp.conf ``` \ No newline at end of file diff --git a/configs/xApp.conf b/configs/xApp.conf index 3a5aca5..86c8ff4 100644 --- a/configs/xApp.conf +++ b/configs/xApp.conf @@ -1,6 +1,6 @@ -[NEAR-RIC] -NEAR_RIC_IP = 127.0.0.1 - -[XAPP] -DB_DIR = /tmp/ +[NEAR-RIC] +NEAR_RIC_IP = 127.0.0.1 + +[XAPP] +DB_DIR = /tmp/ DB_NAME = iqos_xapp_db \ No newline at end of file diff --git a/deployments/compose.yaml b/deployments/compose.yaml index c92e136..08aed34 100644 --- a/deployments/compose.yaml +++ b/deployments/compose.yaml @@ -1,74 +1,74 @@ -x-kafka-common: &kafka-common - image: 'bitnami/kafka:3.3.2' - ports: - - "9092/tcp" - - "9093/tcp" - healthcheck: - test: "bash -c 'printf \"\" > /dev/tcp/127.0.0.1/9092; exit $$?;'" - interval: 5s - timeout: 10s - retries: 3 - start_period: 30s - restart: on-failure - -x-kafka-env-common: &kafka-env-common - KAFKA_KRAFT_CLUSTER_ID: 3WaQdTLLSJaCfQor3bUAXA - KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: 0@kafka-0:9093,1@kafka-1:9093 - KAFKA_CFG_PROCESS_ROLES: controller,broker - KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER - KAFKA_CFG_LISTENERS: PLAINTEXT://:9092,CONTROLLER://:9093 - -services: - kafka-0: - container_name: kafka-0 - <<: *kafka-common - environment: - <<: *kafka-env-common - KAFKA_CFG_NODE_ID: 0 - volumes: - - kafka_0_data:/bitnami/kafka - - kafka-1: - container_name: kafka-1 - <<: *kafka-common - environment: - <<: *kafka-env-common - KAFKA_CFG_NODE_ID: 1 - volumes: - - kafka_1_data:/bitnami/kafka - - kafka-ui: - container_name: kafka-ui - image: provectuslabs/kafka-ui:v0.7.2 - environment: - AUTH_TYPE: "LOGIN_FORM" - SPRING_SECURITY_USER_NAME: admin - SPRING_SECURITY_USER_PASSWORD: iqosxapp - KAFKA_CLUSTERS_0_NAME: iqos-kafka - KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: kafka-0:9092,kafka-1:9092 - depends_on: - - kafka-0 - - kafka-1 - ports: - - '8080:8080/tcp' - healthcheck: - test: wget --no-verbose --tries=1 --spider localhost:8080 || exit 1 - interval: 5s - timeout: 10s - retries: 3 - start_period: 30s - -iqos-xapp: - container_name: iqos-xapp - image: muriloavlis/iqos-xapp:latest - depends_on: - - kafka-0 - - kafka-1 - ports: - - "36422/sctp" - -volumes: - kafka_0_data: - driver: local - kafka_1_data: +x-kafka-common: &kafka-common + image: 'bitnami/kafka:3.3.2' + ports: + - "9092/tcp" + - "9093/tcp" + healthcheck: + test: "bash -c 'printf \"\" > /dev/tcp/127.0.0.1/9092; exit $$?;'" + interval: 5s + timeout: 10s + retries: 3 + start_period: 30s + restart: on-failure + +x-kafka-env-common: &kafka-env-common + KAFKA_KRAFT_CLUSTER_ID: 3WaQdTLLSJaCfQor3bUAXA + KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: 0@kafka-0:9093,1@kafka-1:9093 + KAFKA_CFG_PROCESS_ROLES: controller,broker + KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER + KAFKA_CFG_LISTENERS: PLAINTEXT://:9092,CONTROLLER://:9093 + +services: + kafka-0: + container_name: kafka-0 + <<: *kafka-common + environment: + <<: *kafka-env-common + KAFKA_CFG_NODE_ID: 0 + volumes: + - kafka_0_data:/bitnami/kafka + + kafka-1: + container_name: kafka-1 + <<: *kafka-common + environment: + <<: *kafka-env-common + KAFKA_CFG_NODE_ID: 1 + volumes: + - kafka_1_data:/bitnami/kafka + + kafka-ui: + container_name: kafka-ui + image: provectuslabs/kafka-ui:v0.7.2 + environment: + AUTH_TYPE: "LOGIN_FORM" + SPRING_SECURITY_USER_NAME: admin + SPRING_SECURITY_USER_PASSWORD: iqosxapp + KAFKA_CLUSTERS_0_NAME: iqos-kafka + KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: kafka-0:9092,kafka-1:9092 + depends_on: + - kafka-0 + - kafka-1 + ports: + - '8080:8080/tcp' + healthcheck: + test: wget --no-verbose --tries=1 --spider localhost:8080 || exit 1 + interval: 5s + timeout: 10s + retries: 3 + start_period: 30s + +iqos-xapp: + container_name: iqos-xapp + image: muriloavlis/iqos-xapp:latest + depends_on: + - kafka-0 + - kafka-1 + ports: + - "36422/sctp" + +volumes: + kafka_0_data: + driver: local + kafka_1_data: driver: local \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile index 283ee1e..fc69a83 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,59 +1,59 @@ -#--------------------------------------------------------------------- -# IQoS-xApp IMAGE -#--------------------------------------------------------------------- - -## ubuntu:24.04 -ARG BASE_IMAGE=ubuntu:noble - -FROM $BASE_IMAGE - -ENV DEBIAN_FRONTEND=noninteractive -ENV TZ=America/Belem -ENV NEAR_RIC_IP=${NEAR_RIC_IP} - -#install pkg/repo needed to run -RUN apt-get update && \ - DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && \ - DEBIAN_FRONTEND=noninteractive apt-get install --yes \ - psmisc \ - gpg \ - wget \ - libsctp1 \ - python3 \ - python3-pip \ - net-tools && \ - apt-get autoremove -y && \ - apt-get autoclean -y - -WORKDIR / - -### Copy service models and binary from git action build -COPY out/serviceModels /usr/local/lib/flexric -COPY out/bin/xapp_iqos /usr/local/bin/xapp_iqos - -## Copy Config file -COPY configs/xApp.conf /usr/local/etc/flexric/flexric.conf - -## Copy initialization script -COPY scripts/run.sh /run.sh -RUN chmod +x /run.sh - -RUN ldconfig && \ - echo "--- Check shared objects dependencies for executable nearRT-RIC ---" && \ - ldd /usr/local/bin/xapp_iqos && \ - echo "--- Check shared objects dependencies for flexric shared libraries ---" && \ - ldd /usr/local/lib/flexric/*.so - -LABEL br.ufpa.gercom.image.title="IQoS-xApp" \ - br.ufpa.gercom.image.description="xApp for QoS management in O-RAN network contexts" \ - br.ufpa.gercom.image.url="https://github.com/gercom-ufpa/iqos-xapp" \ - br.ufpa.gercom.image.source="https://github.com/gercom-ufpa/iqos-xapp" \ - br.ufpa.gercom.image.maintainer="GT-IQoS/UFPA" \ - br.ufpa.gercom.image.contact="murilosilva@itec.ufpa.br" \ - br.ufpa.gercom.image.version="0.0.1" \ - br.ufpa.gercom.image.licenses="" - -## E42 -- xApp -EXPOSE 36422/sctp - +#--------------------------------------------------------------------- +# IQoS-xApp IMAGE +#--------------------------------------------------------------------- + +## ubuntu:24.04 +ARG BASE_IMAGE=ubuntu:noble + +FROM $BASE_IMAGE + +ENV DEBIAN_FRONTEND=noninteractive +ENV TZ=America/Belem +ENV NEAR_RIC_IP=${NEAR_RIC_IP} + +#install pkg/repo needed to run +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && \ + DEBIAN_FRONTEND=noninteractive apt-get install --yes \ + psmisc \ + gpg \ + wget \ + libsctp1 \ + python3 \ + python3-pip \ + net-tools && \ + apt-get autoremove -y && \ + apt-get autoclean -y + +WORKDIR / + +### Copy service models and binary from git action build +COPY out/serviceModels /usr/local/lib/flexric +COPY out/bin/xapp_iqos /usr/local/bin/xapp_iqos + +## Copy Config file +COPY configs/xApp.conf /usr/local/etc/flexric/flexric.conf + +## Copy initialization script +COPY scripts/run.sh /run.sh +RUN chmod +x /run.sh + +RUN ldconfig && \ + echo "--- Check shared objects dependencies for executable nearRT-RIC ---" && \ + ldd /usr/local/bin/xapp_iqos && \ + echo "--- Check shared objects dependencies for flexric shared libraries ---" && \ + ldd /usr/local/lib/flexric/*.so + +LABEL br.ufpa.gercom.image.title="IQoS-xApp" \ + br.ufpa.gercom.image.description="xApp for QoS management in O-RAN network contexts" \ + br.ufpa.gercom.image.url="https://github.com/gercom-ufpa/iqos-xapp" \ + br.ufpa.gercom.image.source="https://github.com/gercom-ufpa/iqos-xapp" \ + br.ufpa.gercom.image.maintainer="GT-IQoS/UFPA" \ + br.ufpa.gercom.image.contact="murilosilva@itec.ufpa.br" \ + br.ufpa.gercom.image.version="0.0.1" \ + br.ufpa.gercom.image.licenses="" + +## E42 -- xApp +EXPOSE 36422/sctp + ENTRYPOINT ["/run.sh"] \ No newline at end of file diff --git a/docs/28_552_kpm_meas.txt b/docs/28_552_kpm_meas.txt index 9226cb2..153c714 100644 --- a/docs/28_552_kpm_meas.txt +++ b/docs/28_552_kpm_meas.txt @@ -1,832 +1,832 @@ -5QI1QoSflow.Rel.AbnormCallDurationBinX -5QI1QoSflow.Rel.Average.AbnormCallDuration -5QI1QoSflow.Rel.Average.NormCallDuration -5QI1QoSflow.Rel.NormCallDurationBinX -AFQ.CreateFail.cause -AFQ.CreateReq -AFQ.CreateSucc -AFQ.NbrNotify -AFQ.RevokeFail.cause -AFQ.RevokeReq -AFQ.RevokeSucc -AFQ.UpdateFail.cause -AFQ.UpdateReq -AFQ.UpdateSucc -AMF.AuthFail -AMF.AuthFail.20 -AMF.AuthFail.21 -AMF.AuthFail.26 -AMF.AuthReject -AMF.AuthReq -AT.AppTriggerAcc -AT.AppTriggerRej.DeliveryResult -AT.AppTriggerRej.ErrorCode -AT.AppTriggerReq -BDTP.CreateFail.cause -BDTP.CreateReq -BDTP.CreateSucc -BDTP.NbrApplyCreatFail.cause -BDTP.NbrApplyCreatReq -BDTP.NbrApplyCreatSucc -BDTP.NbrApplyDelFail.cause -BDTP.NbrApplyDelReq -BDTP.NbrApplyDelSucc -BDTP.NbrApplyUpdateFail.cause -BDTP.NbrApplyUpdateReq -BDTP.NbrApplyUpdateSucc -BDTP.NbrNegCreatFail.cause -BDTP.NbrNegCreatReq -BDTP.NbrNegCreatSucc -BDTP.NbrNegUpdateFail.cause -BDTP.NbrNegUpdateReq -BDTP.NbrNegUpdateSucc -CARR.AverageLayersDl -CARR.AverageLayersUl -CARR.MaxTxPwr -CARR.MeanTxPwr -CARR.MUPDSCHMCSDist.BinX -CARR.MUPDSCHRB.BINX -CARR.MUPUSCHMCSDist.BinX -CARR.MUPUSCHRB.BINX -CARR.PDSCHMCSDist.BinX.BinY.BinZ -CARR.PUSCHMCSDist.BinX.BinY.BinZ -CARR.WBCQIDist.BinX.BinY.BinZ -CE.NbrSmfNefCreatFail.cause -CE.NbrSmfNefCreatReq -CE.NbrSmfNefCreatSucc -CE.NbrSmfNefRelFail.cause -CE.NbrSmfNefRelReq -CE.NbrSmfNefRelSucc -DataVolum.InBytesEAS -DataVolum.InPacketsEAS -DataVolum.OutBytesEAS -DataVolum.OutPacketsEAS -DIS.EasDisFail.geoloc -DIS.EasDisFail.id -DIS.EasDisFail.provider -DIS.EasDisFail.schedule -DIS.EasDisFail.srvCont -DIS.EasDisFail.srvFeature -DIS.EasDisFail.srvPerm -DIS.EasDisFail.toploc -DIS.EasDisFail.type -DIS.EasDisFail.UeLocation.EasType -DIS.EasDisReq -DIS.EasDisSucc -DM.CreateFail.cause -DM.CreateReq -DM.CreateSucc -DM.DeleteFail.cause -DM.DeleteReq -DM.DeleteSucc -DM.QueryFail.cause -DM.QueryReq -DM.QuerySucc -DM.SubscribeFail.cause -DM.SubscribeReq -DM.SubscribeSucc -DM.UpdateFail.cause -DM.UpdateReq -DM.UpdateSucc -DRB.AirIfDelayDist.Bin_Filter -DRB.AirIfDelayDl_Filter -DRB.AirIfDelayUl_Filter -DRB.DelayDlNgranUeDist.Bin_Filter -DRB.DelayUlNgranUeDist.Bin_Filter -DRB.EstabAtt.5QI -DRB.EstabAtt.SNSSAI -DRB.EstabSucc.5QI -DRB.EstabSucc.SNSSAI -DRB.F1UpacketLossRateDl -DRB.F1UPacketLossRateDl.QOS -DRB.F1UPacketLossRateDl.SNSSAI -DRB.F1UpacketLossRateUl -DRB.F1UPacketLossRateUl.QOS -DRB.F1UPacketLossRateUl.SNSSAI -DRB.F1uPdcpSduVolumeDL_Filter -DRB.F1uPdcpSduVolumeUL_Filter -DRB.GtpF1DelayDlDist.Bin_Filter -DRB.GTPUPathFailure.5QI -DRB.GTPUPathFailure.SNSSAI -DRB.InitialEstabAtt.5QI -DRB.InitialEstabAtt.SNSSAI -DRB.InitialEstabSucc.5QI -DRB.InitialEstabSucc.SNSSAI -DRB.MaxActiveUeDl_Filter -DRB.MaxActiveUeUl -DRB.MaxActiveUeUl.QOS -DRB.MaxActiveUeUl.SNSSAI -DRB.MaxEstabSucc.5QI -DRB.MaxEstabSucc.SNSSAI -DRB.MeanActiveUeDl_Filter -DRB.MeanActiveUeUl_Filter -DRB.MeanEstabSucc.5QI -DRB.MeanEstabSucc.SNSSAI -DRB.PacketLossRateUl -DRB.PacketLossRateUl.QOS -DRB.PacketLossRateUl.SNSSAI -DRB.PacketSuccessRateUlgNBUu -DRB.PacketSuccessRateUlgNBUu.QOS -DRB.PacketSuccessRateUlgNBUu.SNSSAI -DRB.PdcpF1DelayDl_Filter -DRB.PdcpPacketDropRateDl -DRB.PdcpPacketDropRateDl.QOS -DRB.PdcpPacketDropRateDl.SNSSAI -DRB.PdcpReordDelayUl_Filter -DRB.PdcpSduDelayDlDist.Bin_Filter -DRB.PdcpSduDelayDl_Filter -DRB.PdcpSduVolumeDL_Filter -DRB.PdcpSduVolumeUL_Filter -DRB.PdcpSduVolumeX2DL_Filter -DRB.PdcpSduVolumeX2UL_Filter -DRB.PdcpSduVolumeXnDL_Filter -DRB.PdcpSduVolumeXnUL_Filter -DRB.RelActNbr.5QI -DRB.RelActNbr.SNSSAI -DRB.ResumeAtt.5QI -DRB.ResumeAtt.SNSSAI -DRB.ResumeSucc.5QI -DRB.ResumeSucc.SNSSAI -DRB.RlcDelayUl_Filter -DRB.RlcPacketDropRateDl -DRB.RlcPacketDropRateDl.QOS -DRB.RlcPacketDropRateDl.SNSSAI -DRB.RlcSduDelayDl -DRB.RlcSduDelayDlDist.Bin_Filter -DRB.RlcSduLatencyDl -DRB.RlcSduLatencyDlDist.bin.QOS -DRB.RlcSduLatencyDlDist.bin.SNSSAI -DRB.RlcSduLatencyDl.QOS -DRB.RlcSduLatencyDl.SNSSAI -DRB.SessionTime.5QI -DRB.SessionTime.SNSSAI -DRB.UEThpDl -DRB.UEThpDl.BWP -DRB.UEThpDlDist.Bin -DRB.UEThpDlDist.Bin.PLMN -DRB.UEThpDlDist.Bin.QOS -DRB.UEThpDlDist.Bin.SNSSAI -DRB.UEThpDl.QOS -DRB.UEThpDl.SNSSAI -DRB.UEThpUl -DRB.UEThpUl.BWP -DRB.UEThpUlDist.Bin -DRB.UEThpUlDist.Bin.PLMN -DRB.UEThpUlDist.Bin.QOS -DRB.UEThpUlDist.Bin.SNSSAI -DRB.UEThpUl.PLMN -DRB.UEThpUl.QOS -DRB.UEThpUl.SNSSAI -DRB.UEUnresVolDl -DRB.UEUnresVolDl.PLMN -DRB.UEUnresVolDl.QOS -DRB.UEUnresVolDl.SNSSAI -DRB.UEUnresVolUl -DRB.UEUnresVolUl.PLMN -DRB.UEUnresVolUl.QOS -DRB.UEUnresVolUl.SNSSAI -EEX.NotifyNbr -EEX.SubscribeFail.cause -EEX.SubscribeReq -EEX.SubscribeSucc -EEX.UnsubscribeFail.cause -EEX.UnsubscribeReq -EEX.UnsubscribeSucc -EPP.NbrCreatFail.cause -EPP.NbrCreatReq -EPP.NbrCreatSucc -EPP.NbrDelFail.cause -EPP.NbrDelReq -EPP.NbrDelSucc -EPP.NbrUpdateFail.cause -EPP.NbrUpdateReq -EPP.NbrUpdateSucc -GTP.DelayDlInIUpfDist.Bin.5QI -GTP.DelayDlInIUpfDist.Bin.SNSSAI -GTP.DelayDlInIUpfMean.5QI -GTP.DelayDlInIUpfMean.SNSSAI -GTP.DelayDlInPsaUpfDist.Bin.5QI -GTP.DelayDlInPsaUpfDist.Bin.SNSSAI -GTP.DelayDlInPsaUpfMean.5QI -GTP.DelayDlInPsaUpfMean.SNSSAI -GTP.DelayDlPsaUpfNgranDist.5QI.Bin -GTP.DelayDlPsaUpfNgranDist.SNSSAI.bin -GTP.DelayDlPsaUpfNgranMean.5QI -GTP.DelayDlPsaUpfNgranMean.SNSSAI -GTP.DelayDlPsaUpfUeDist.SNSSAI.bin -GTP.DelayDlPsaUpfUeMean.SNSSAI -GTP.DelayUlInIUpfDist.Bin.5QI -GTP.DelayUlInIUpfDist.Bin.SNSSAI -GTP.DelayUlInIUpfMean.5QI -GTP.DelayUlInIUpfMean.SNSSAI -GTP.DelayUlInPsaUpfDist.Bin.5QI -GTP.DelayUlInPsaUpfDist.Bin.SNSSAI -GTP.DelayUlInPsaUpfMean.5QI -GTP.DelayUlInPsaUpfMean.SNSSAI -GTP.DelayUlPsaUpfNgranDist.5QI.Bin -GTP.DelayUlPsaUpfNgranDist.SNSSAI.bin -GTP.DelayUlPsaUpfNgranMean.5QI -GTP.DelayUlPsaUpfNgranMean.SNSSAI -GTP.DelayUlPsaUpfUeDist.SNSSAI.bin -GTP.DelayUlPsaUpfUeMean.SNSSAI -GTP.InDataOctN3UPF -GTP.InDataOctN9PsaUpf -GTP.InDataOctN9PsaUpf.SNSSAI -GTP.InDataPktDisorderN3UPF -GTP.InDataPktDisorderN3UPF.QoS -GTP.InDataPktN3UPF -GTP.InDataPktN3UPF.SNSSAI -GTP.InDataPktN9PsaUpf -GTP.InDataPktN9PsaUpf.SNSSAI -GTP.InDataPktPacketLossN3gNB -GTP.InDataPktPacketLossN3gNB.QoS -GTP.InDataPktPacketLossN3gNB.SNSSAI -GTP.InDataPktPacketLossN3UPF -GTP.InDataPktPacketLossN3UPF.QoS -GTP.InDataPktPacketLossN3UPF.SNSSAI -GTP.InDataPktPacketLossN3UPF.TEID -GTP.InDataPktPacketLossN3UPF.TEID.QoS -GTP.InDataVolumeQoSLevelN3UPF -GTP.OutDataOctN3UPF -GTP.OutDataOctN3UPF.SNSSAI -GTP.OutDataOctN3UPF.SNSSAI -GTP.OutDataOctN9PsaUpf -GTP.OutDataOctN9PsaUpf.SNSSAI -GTP.OutDataPktN3UPF -GTP.OutDataPktN3UPF.SNSSAI -GTP.OutDataPktN9PsaUpf -GTP.OutDataPktN9PsaUpf.SNSSAI -GTP.OutDataPktPacketLossN3UPF -GTP.OutDataPktPacketLossN3UPF.QoS -GTP.OutDataVolumeQoSLevelN3UPF -GTP.RttDelayN3DlPsaUpfMean.DSCP -GTP.RttDelayN3IUpfMean.DSCP -GTP.RttDelayN3IUpfsDist.Bin.DSCP -GTP.RttDelayN3PsaUpfDist.Bin.DSCP -GTP.RttDelayN9IUpfDist.Bin.DSCP -GTP.RttDelayN9IUpfMean.DSCP -GTP.RttDelayN9PsaUpfDist.Bin.DSCP -GTP.RttDelayN9PsaUpfMean.DSCP -GTP.RttDelayPsaUpfNgranDist.5QI.Bin -GTP.RttDelayPsaUpfNgranDist.SNSSAI.bin -GTP.RttDelayPsaUpfNgranMean.5QI -GTP.RttDelayPsaUpfNgranMean.SNSSAI -HO.InterSys.bPingPong.NCI -HO.InterSys.bTooLate.ECGI -HO.InterSys.bUnnecessary.ECGI -HO.InterSys.PingPong -HO.InterSys.TooEarly -HO.InterSys.TooLate -HO.InterSys.Unnecessary -HO.IntraSys.bTooEarly.NCI -HO.IntraSys.bTooLate.NCI -HO.IntraSys.bToWrongCell.NCI -HO.IntraSys.TooEarly -HO.IntraSys.TooLate -HO.IntraSys.ToWrongCell -IP.N6IncLinkUsage.N6RP -IP.N6OutLinkUsage.N6RP -L1M.ATADist.Bin -L1M.PHR1.BinX -L1M.RSRPEutraNbr.Bin -L1M.SSBBeamRelatedUeNbr -L1M.SS-RSRP.Bin -L1M.SS-RSRPNrNbr.SSBIndex.Bin -LM.LocationContextTranFail.Cause -LM.LocationContextTranReq -LM.LocationContextTranSucc -LM.LocationDeterFail.Cause -LM.LocationDeterReq -LM.LocationDeterSucc -LM.LocationNotifFail.Cause -LM.LocationNotifSucc -MeanDiskUsage -MeanMemoryUsage -MeanProcessorUsage -MeanTime5QI1Flow.RelDoubleNG -MM.ChoExeInterReq.TimeMax.SNSSAI -MM.ChoExeInterReq.TimeMean.SNSSAI -MM.ChoExeInterSucc -MM.ChoExeIntraSucc -MM.ChoPrepInterFail.cause -MM.ChoPrepInterFailUes.cause -MM.ChoPrepInterReq -MM.ChoPrepInterReqUes -MM.ChoPrepInterSucc -MM.ChoPrepInterSuccUes -MM.ChoPrepIntraReq -MM.ChoPrepIntraReqUes -MM.ChoPrepIntraSucc -MM.ChoPrepIntraSuccUes -MM.ChoResAlloInterFail.cause -MM.ChoResAlloInterReq -MM.ChoResAlloInterSucc -MM.ConfigInterReqCho -MM.ConfigInterReqChoUes -MM.ConfigIntraReqCho -MM.ConfigIntraReqChoUes -MM.ConfUpdate -MM.ConfUpdateSucc -MM.DapsHoExeInterFail.FailInfo -MM.DapsHoExeInterFail.HoExeSupTimer -MM.DapsHoExeInterFail.RetrUeCtxtReq -MM.DapsHoExeInterFail.RrcReestabReq -MM.DapsHoExeInterFail.UeCtxtRelCmd.cause -MM.DapsHoExeInterReq -MM.DapsHoExeInterSucc -MM.DapsHoExeIntraReq -MM.DapsHoExeIntraSucc -MM.DapsHoPrepInterFail.cause -MM.DapsHoPrepInterReq -MM.DapsHoPrepInterSucc -MM.DapsHoPrepIntraReq -MM.DapsHoPrepIntraSucc -MM.DapsHoResAlloInterFail.cause -MM.DapsHoResAlloInterReq -MM.DapsHoResAlloInterSucc -MM.Ho5gsToEpsFallbackTimeMean -MM.HoExeHo5gsToEpsFallbackTimeMean -MM.HoExeInterFail.HoExeSupTimer -MM.HoExeInterFail.RetrUeCtxtReq -MM.HoExeInterFail.RrcReestabReq -MM.HoExeInterFail.UeCtxtRelCmd.cause -MM.HoExeInterFreqReq -MM.HoExeInterFreqSucc -MM.HoExeInterReq -MM.HoExeInterReq.TimeMax.SNSSAI -MM.HoExeInterReq.TimeMean.SNSSAI -MM.HoExeInterSSBFail.HoExeSupTimer -MM.HoExeInterSSBFail.RetrUeCtxtReq -MM.HoExeInterSSBFail.RrcReestabReq -MM.HoExeInterSSBFail.UeCtxtRelCmd.cause -MM.HoExeInterSSBSucc -MM.HoExeInterSucc -MM.HoExeIntraFreqReq -MM.HoExeIntraFreqSucc -MM.HoExeIntraReq -MM.HoExeIntraSucc -MM.HoIncEpsTo5gsN26Att -MM.HoIncEpsTo5gsN26Fail.cause -MM.HoIncEpsTo5gsN26Succ -MM.HoIncEpsTo5gsResAlloFail.cause -MM.HoIncEpsTo5gsResAlloReq -MM.HoIncEpsTo5gsResAlloSucc -MM.HoOut5gsToEpsFallbackPrepFail.cause -MM.HoOut5gsToEpsFallbackPrepReq -MM.HoOut5gsToEpsFallbackPrepSucc -MM.HoOut5gsToEpsN26Att -MM.HoOut5gsToEpsN26Fail.cause -MM.HoOut5gsToEpsN26Succ -MM.HoOut5gsToEpsPrepFail.cause -MM.HoOut5gsToEpsPrepReq -MM.HoOut5gsToEpsPrepSucc -MM.HoOutExe5gsToEpsFail.cause -MM.HoOutExe5gsToEpsFallbackFail.cause -MM.HoOutExe5gsToEpsFallbackSucc -MM.HoOutExe5gsToEpsReq -MM.HoOutExe5gsToEpsSucc -MM.HoPrepInterFail.cause -MM.HoPrepInterReq -MM.HoPrepInterSucc -MM.HoPrepIntraReq -MM.HoPrepIntraSucc -MM.HoResAlloInterFail.cause -MM.HoResAlloInterReq -MM.HoResAlloInterSucc -MM.NbrPDUFailInterAMFHOInc.cause -MM.NbrPDUFailInterAMFHOInc.SNSSAI -MM.NbrPDUReqInterAMFHOInc.SNSSAI -MM.NbrQoSFlowFailInterAMFHOInc.5QI -MM.NbrQoSFlowFailInterAMFHOInc.cause -MM.NbrQoSFlowFailInterAMFHOInc.SNSSAI -MM.NbrQoSFlowReqInterAMFHOInc.5QI -MM.NbrQoSFlowReqInterAMFHOInc.SNSSAI -MM.Paging5GReq -MM.Paging5GSucc -MM.Redirection.5gsToEpsFallback -MM.ServiceReqNetInitAtt -MM.ServiceReqNetInitSucc -MM.ServiceReqNon3GPPAtt -MM.ServiceReqNon3GPPSucc -MM.ServiceReqTotalAtt -MM.ServiceReqTotalSucc -MM.ServiceReqTrustNon3GPPAtt -MM.ServiceReqTrustNon3GPPSucc -MR.IntraCellSSBSwitchReq -MR.IntrCellSuccSSBSwitch -MR.NRScSSRSRQ.BinX -MR.NRScSSSINR.BinX -MR.SS-RSRQPerSSB.Bin -MR.SS-RSRQ.SSBIndex.Bin -MR.SS-SINRPerSSB.Bin -MR.SS-SINR.SSBIndex.Bin -NFS.DiscFailInputErr -NFS.DiscFailNrfErr -NFS.DiscFailUnauth -NFS.DiscReq -NFS.DiscSucc -NFS.RegFailEncodeErr -NFS.RegFailNrfErr -NFS.RegReq -NFS.RegSucc -NFS.UpdateFailEncodeErr -NFS.UpdateFailNrfErr -NFS.UpdateReq -NFS.UpdateSucc -NIDD.NbrConfigCreatFail.cause -NIDD.NbrConfigCreatReq -NIDD.NbrConfigCreatSucc -NIDD.NbrConfigCreatTriggerNotify -NIDD.NbrConfigDelFail.cause -NIDD.NbrConfigDelReq -NIDD.NbrConfigDelSucc -NIDD.NbrConfigUpdateNotify -NIDD.NbrMODeliveryFail.cause -NIDD.NbrMODeliveryReq -NIDD.NbrMODeliverySucc -NIDD.NbrMTDeliveryFail.cause -NIDD.NbrMTDeliveryReq -NIDD.NbrMTDeliverySucc -NSS.NbrGetFail.cause -NSS.NbrGetReq -NSS.NbrGetSucc -NSS.NbrNSSAIAvailNotify -NSS.NbrNSSAIAvailSubscribeFail.cause -NSS.NbrNSSAIAvailSubscribeReq -NSS.NbrNSSAIAvailSubscribeSucc -NSS.NbrNSSAIAvailUpdateFail.cause -NSS.NbrNSSAIAvailUpdateReq -NSS.NbrNSSAIAvailUpdateSucc -PAG.DiscardedNbr -PAG.DiscardedNbrCnInitiated -PAG.DiscardedNbrRanInitiated -PAG.ReceivedNbr -PAG.ReceivedNbrCnInitiated -PAG.ReceivedNbrRanIntiated -PA.PolicyAMAssoReq.SNSSAI -PA.PolicyAMAssoSucc.SNSSAI -PA.PolicySMAssoReq.SNSSAI -PA.PolicySMAssoSucc.SNSSAI -PA.PolicyUeAssoReq -PA.PolicyUeAssoSucc -PAU.AmCreateFail.cause -PAU.AmCreateReq -PAU.AmCreateSucc -PAU.AmDeleteFail.cause -PAU.AmDeleteReq -PAU.AmDeleteSucc -PAU.AmUpdateFail.cause -PAU.AmUpdateReq -PAU.AmUpdateSucc -PAU.SmCreateFail.cause -PAU.SmCreateReq -PAU.SmCreateSucc -PAU.SmDeleteFail.cause -PAU.SmDeleteReq -PAU.SmDeleteSucc -PAU.SmUpdateFail.cause -PAU.SmUpdateReq -PAU.SmUpdateSucc -PCF.PolicyAmAssocNotifReq.SNSSAI -PCF.PolicyAmAssocNotifSucc.SNSSAI -PCF.PolicyAmAssocUpdateReq -PCF.PolicyAmAssocUpdateSucc -PCF.PolicySmAssocNotifReq.SNSSAI -PCF.PolicySmAssocNotifSucc.SNSSAI -PCF.PolicySmAssocUpdateReq.SNSSAI -PCF.PolicySmAssocUpdateSucc.SNSSAI -PEE.AvgPower -PEE.AvgTemperature -PEE.Current -PEE.Energy -PEE.Humidity -PEE.MaxPower -PEE.MaxTemperature -PEE.MinPower -PEE.MinTemperature -PEE.Voltage -PFD.CreateReq -PFD.CreateSucc -PFD.DeleteReq -PFD.DeleteSucc -PFD.FetchReq -PFD.FetchSucc -PFD.SubscribeReq -PFD.SubscribeSucc -PFD.UpdateReq -PFD.UpdateSucc -PPV.CreateFail.Cause -PPV.CreateReq -PPV.CreateSucc -PPV.DeleteFail.Cause -PPV.DeleteReq -PPV.DeleteSucc -PPV.GetFail.Cause -PPV.GetReq -PPV.GetSucc -PPV.UpdateFail.Cause -PPV.UpdateReq -PPV.UpdateSucc -QF.EstabAttNbr.5QI -QF.EstabAttNbr.SNSSAI -QF.EstabFailNbr.Cause -QF.EstabNbrAddUntrustNon3gppAtt.5QI -QF.EstabNbrAddUntrustNon3gppAtt.SNSSAI -QF.EstabNbrAddUntrustNon3gppFail.cause -QF.EstabNbrAddUntrustNon3gppSucc.5QI -QF.EstabNbrAddUntrustNon3gppSucc.SNSSAI -QF.EstabNbrInitUntrustNon3gppAtt.5QI -QF.EstabNbrInitUntrustNon3gppAtt.SNSSAI -QF.EstabNbrInitUntrustNon3gppFail.cause -QF.EstabNbrInitUntrustNon3gppSucc.5QI -QF.EstabNbrInitUntrustNon3gppSucc.SNSSAI -QF.EstabSuccNbr.5QI -QF.EstabSuccNbr.SNSSAI -QF.InitialEstabAttNbr.5QI -QF.InitialEstabAttNbr.SNSSAI -QF.InitialEstabFailNbr.Cause -QF.InitialEstabSuccNbr.5QI -QF.InitialEstabSuccNbr.SNSSAI -QF.ModNbrAtt.5QI -QF.ModNbrAtt.SNSSAI -QF.ModNbrFail.cause -QF.ModNbrSucc.5QI -QF.ModNbrSucc.SNSSAI -QF.ModNbrUntrustNon3gppAtt.5QI -QF.ModNbrUntrustNon3gppAtt.SNSSAI -QF.ModNbrUntrustNon3gppFail.cause -QF.ModNbrUntrustNon3gppSucc.5QI -QF.ModNbrUntrustNon3gppSucc.SNSSAI -QF.RelActNbr.QoS -QF.RelActNbrUntrustNon3gpp.5QI -QF.RelActNbrUntrustNon3gpp.SNSSAI -QF.ReleaseAttNbr.5QI -QF.ReleaseAttNbr.SNSSAI -QF.RelNbrUntrustNon3gppAtt.5QI -QF.RelNbrUntrustNon3gppAtt.SNSSAI -QF.RelNbrUntrustNon3gppSucc.5QI -QF.RelNbrUntrustNon3gppSucc.SNSSAI -QF.SessionTimeQoS.QoS -QF.SessionTimeUE -QosFlow.PdcpPduVolumeDL_Filter -QosFlow.PdcpPduVolumeUl_Filter -QosFlow.PdcpSduVolumeDl_Filter -RACH.AccessDelayDist.Bin -RACH.PreambleACell -RACH.PreambleA.Ssb -RACH.PreambleBCell -RACH.PreambleB.Ssb -RACH.PreambleDedCell -RACH.PreambleDed.Ssb -RACH.PreambleDist.Bin -RM.EasRegReq -RM.EasRegSucc -RM.EecDeRegReq -RM.EecDeRegSucc -RM.EecRegReq -RM.EecRegSucc -RM.EecRegUpdReq -RM.EecRegUpdSucc -RM.EesRegReq -RM.EesRegSucc -RM.RegEmergReqNon3GPP.SNSSAI -RM.RegEmergReq.SNSSAI -RM.RegEmergReqTrustNon3GPP.SNSSAI -RM.RegEmergSuccNon3GPP.SNSSAI -RM.RegEmergSucc.SNSSAI -RM.RegEmergSuccTrustNon3GPP.SNSSAI -RM.RegInitReqNon3GPP.SNSSAI -RM.RegInitReq.SNSSAI -RM.RegInitReqTrustNon3GPP.SNSSAI -RM.RegInitSuccNon3GPP.SNSSAI -RM.RegInitSucc.SNSSAI -RM.RegInitSuccTrustNon3GPP.SNSSAI -RM.RegisteredSubNbrMax.SNSSAI -RM.RegisteredSubNbrMean.SNSSAI -RM.RegisteredSubUDMNbrMax -RM.RegisteredSubUDMNbrMean -RM.RegMobReqNon3GPP.SNSSAI -RM.RegMobReq.SNSSAI -RM.RegMobReqTrustNon3GPP.SNSSAI -RM.RegMobSuccNon3GPP.SNSSAI -RM.RegMobSucc.SNSSAI -RM.RegMobSuccTrustNon3GPP.SNSSAI -RM.RegPeriodReqNon3GPP.SNSSAI -RM.RegPeriodReq.SNSSAI -RM.RegPeriodReqTrustNon3GPP.SNSSAI -RM.RegPeriodSuccNon3GPP.SNSSAI -RM.RegPeriodSucc.SNSSAI -RM.RegPeriodSuccTrustNon3GPP.SNSSAI -RM.RegTimeMax.SNSSAI.EmergencyReg -RM.RegTimeMax.SNSSAI.InitialReg -RM.RegTimeMax.SNSSAI.MobilityRegUpdate -RM.RegTimeMax.SNSSAI.PeriodicRegUpdate -RM.RegTimeMean.SNSSAI.EmergencyReg -RM.RegTimeMean.SNSSAI.InitialReg -RM.RegTimeMean.SNSSAI.MobilityRegUpdate -RM.RegTimeMean.SNSSAI.PeriodicRegUpdate -RM.SubscriberProfileSizesCount.Bin -RM.SubscriberProfileSizesMean -RM.UdmSdm.GetResponseSize.Bin -RM.UdmSdm.InfoResponseSize.Bin -RM.UdmSdm.NotificationSize.Bin -RM.UnregisteredSubUDMNbrMax -RM.UnregisteredSubUDMNbrMean -RRC.ConnEstabAtt.Cause -RRC.ConnEstabFailCause.NetworkReject -RRC.ConnEstabFailCause.NoReply -RRC.ConnEstabFailCause.Other -RRC.ConnEstabSucc.Cause -RRC.ConnMax -RRC.ConnMax.PLMN -RRC.ConnMean -RRC.ConnMean.PLMN -RRC.InactiveConnMax -RRC.InactiveConnMean -RRC.InactiveConnMean.PLMN -RRC.ReEstabAtt -RRC.ReEstabFallbackToSetupAtt -RRC.ReEstabSuccWithoutUeContext -RRC.ReEstabSuccWithUeContext -RRC.ResumeAtt.cause -RRC.ResumeFallbackToSetupAtt.cause -RRC.ResumeFollowedbyNetworkRelease -RRC.ResumeFollowedbySuspension -RRC.ResumeSuccByFallback.cause -RRC.ResumeSucc.cause -RRU.MaxLayerDlMimo -RRU.MaxLayerUlMimo -RRU.MaxPrbUsedDl -RRU.MaxPrbUsedDl.QoS -RRU.MaxPrbUsedDl.SNSSAI -RRU.MaxPrbUsedUl -RRU.MaxPrbUsedUl.QoS -RRU.MaxPrbUsedUl.SNSSAI -RRU.PrbAvailDl -RRU.PrbAvailUl -RRU.PrbTotDl -RRU.PrbTotDlDist.BinX -RRU.PrbTotDlMimo -RRU.PrbTotSdmDl -RRU.PrbTotSdmUl -RRU.PrbTotUl -RRU.PrbTotUlDist.BinX -RRU.PrbTotUlMimo -RRU.PrbUsedDl -RRU.PrbUsedDl.PLMN -RRU.PrbUsedDl.QoS -RRU.PrbUsedDl.SNSSAI -RRU.PrbUsedUl -RRU.PrbUsedUl.PLMN -RRU.PrbUsedUl.QoS -RRU.PrbUsedUl.SNSSAI -SDM.GetFail.Cause -SDM.GetReq.Type -SDM.GetSucc.Type -SDM.SubDataNotif.Type -SDM.SubscribeFail.Cause -SDM.SubscribeReq.Type -SDM.SubscribeSucc.Type -SM.MaxPDUSessionSetupReq.SNSSAI -SM.MeanPDUSessionSetupReq.SNSSAI -SM.N4SessionDelete -SM.N4SessionDeleteFail.Cause -SM.N4SessionEstabFail.cause -SM.N4SessionEstabReq -SM.N4SessionModify -SM.N4SessionModifyFail.Cause -SM.N4SessionReport -SM.N4SessionReportSucc -SM.PduSessionCreationFail.cause -SM.PduSessionCreationHRroamFail.cause -SM.PduSessionCreationHRroam.ReqType -SM.PduSessionCreationHRroam.SNSSAI -SM.PduSessionCreationHRroamSucc.ReqType -SM.PduSessionCreationHRroamSucc.SNSSAI -SM.PduSessionCreationReqReqType -SM.PduSessionCreationReq.SNSSAI -SM.PduSessionCreationSuccReqType -SM.PduSessionCreationSucc.SNSSAI -SM.PDUSessionModifyNon3GPPFail.Cause -SM.PDUSessionModifyNon3GPPReq.SNSSAI -SM.PDUSessionModifyNon3GPPSucc.SNSSAI -SM.PduSessionModSmfInitFail.Cause -SM.PduSessionModSmfInitReq -SM.PduSessionModSmfInitSucc -SM.PduSessionModUeInitFail.Cause -SM.PduSessionModUeInitReq -SM.PduSessionModUeInitSucc -SM.PduSessionRelAmfInit.cause -SM.PduSessionRelAmfInit.SNSSAI -SM.PDUSessionSetupFail.Cause -SM.PDUSessionSetupNon3GPPFail.Cause -SM.PDUSessionSetupNon3GPPReq.SNSSAI -SM.PDUSessionSetupNon3GPPSucc.SNSSAI -SM.PDUSessionSetupReq.SNSSAI -SM.PDUSessionSetupSucc.SNSSAI -SM.PduSessionTimeMax.SNSSAI -SM.PduSessionTimeMean.SNSSAI -SM.QoSflowCreateFail.cause -SM.QoSflowCreateReq.5QI -SM.QoSflowCreateReq.SNSSAI -SM.QoSflowCreateSucc.5QI -SM.QoSflowCreateSucc.SNSSAI -SM.QoSflowModFail.cause -SM.QoSflowModReq.5QI -SM.QoSflowModReq.SNSSAI -SM.QoSflowModSucc.5QI -SM.QoSflowModSucc.SNSSAI -SM.QoSflowNbrMean.5QI -SM.QoSflowNbrMean.SNSSAI -SM.QoSflowNbrPeak.5QI -SM.QoSflowNbrPeak.SNSSAI -SM.SessionNbrMax.SNSSAI -SM.SessionNbrMean.SNSSAI -SMSF.ActivateReq.SNSSAI -SMSF.ActivateSucc.SNSSAI -SMSF.DeactivateReq.SNSSAI -SMSF.DeactivateSucc.SNSSAI -SMSF.MoReq.SNSSAI -SMSF.MoSucc.SNSSAI -SMSF.MtReq.SNSSAI -SMSF.MtSucc.SNSSAI -SMS.SmsOverNasMo3GPPReq -SMS.SmsOverNasMo3GPPSucc -SMS.SmsOverNasMoNon3GPPReq -SMS.SmsOverNasMoNon3GPPSucc -SMS.SmsOverNasMt3GPPReq -SMS.SmsOverNasMt3GPPSucc -SMS.SmsOverNasMtNon3GPPReq -SMS.SmsOverNasMtNon3GPPSucc -SMS.SmsOverNasReg3GPPReq -SMS.SmsOverNasReg3GPPSucc -SMS.SmsOverNasRegNon3GPPReq -SMS.SmsOverNasRegNon3GPPSucc -SPP.NbrCreatFail.cause -SPP.NbrCreatReq -SPP.NbrCreatSucc -SPP.NbrDelFail.cause -SPP.NbrDelReq -SPP.NbrDelSucc -SPP.NbrUpdateFail.cause -SPP.NbrUpdateReq -SPP.NbrUpdateSucc -SP.SerProvReq -SP.SerProvSucc -TB.ErrNbrUlInitial -TB.ErrNbrUlInitial.16Qam -TB.ErrNbrUlInitial.256Qam -TB.ErrNbrUlInitial.64Qam -TB.ErrNbrUlInitial.Qpsk -TB.ErrToltalNbrDl.X -TB.ErrToltalNbrUl.X -TB.IntialErrNbrDl -TB.IntialErrNbrDl.16Qam -TB.IntialErrNbrDl.256Qam -TB.IntialErrNbrDl.64Qam -TB.IntialErrNbrDl.Qpsk -TB.ResidualErrNbrDl -TB.ResidualErrNbrUl -TB.TotNbrDlInitial -TB.TotNbrDlInitial.16Qam -TB.TotNbrDlInitial.256Qam -TB.TotNbrDlInitial.64Qam -TB.TotNbrDlInitial.Qpsk -TB.TotNbrDl.X -TB.TotNbrUlInit -TB.TotNbrUlInit.16Qam -TB.TotNbrUlInit.256Qam -TB.TotNbrUlInit.64Qam -TB.TotNbrUlInit.Qpsk -TB.TotNbrUl.X -TI.NbrAfCreatFail.cause -TI.NbrAfCreatReq -TI.NbrAfCreatSucc -TI.NbrAfDelFail.cause -TI.NbrAfDelReq -TI.NbrAfDelSucc -TI.NbrAfUpdateFail.cause -TI.NbrAfUpdateReq -TI.NbrAfUpdateSucc -UCM.EntryCreateFail.cause -UCM.EntryCreateReq -UCM.EntryCreateSucc -UCM.EntryDelFail.cause -UCM.EntryDelReq -UCM.EntryDelSucc -UCM.EntryUpdateFail.cause -UCM.EntryUpdateReq -UCM.EntryUpdateSucc -UECNTX.ConnEstabAtt.Cause -UECNTX.ConnEstabSucc.Cause -UECNTX.RelCmd.Cause -UECNTX.RelReq.Cause -UPF.MaxQosFlows -UPF.MaxQosFlows.Dnn -UPF.MaxQosFlows.SNSSAI -UPF.MeanQosFlows -UPF.MeanQosFlows.Dnn -UPF.MeanQosFlows.SNSSAI -VR.VCpuUsageMean -VR.VDiskUsageMean +5QI1QoSflow.Rel.AbnormCallDurationBinX +5QI1QoSflow.Rel.Average.AbnormCallDuration +5QI1QoSflow.Rel.Average.NormCallDuration +5QI1QoSflow.Rel.NormCallDurationBinX +AFQ.CreateFail.cause +AFQ.CreateReq +AFQ.CreateSucc +AFQ.NbrNotify +AFQ.RevokeFail.cause +AFQ.RevokeReq +AFQ.RevokeSucc +AFQ.UpdateFail.cause +AFQ.UpdateReq +AFQ.UpdateSucc +AMF.AuthFail +AMF.AuthFail.20 +AMF.AuthFail.21 +AMF.AuthFail.26 +AMF.AuthReject +AMF.AuthReq +AT.AppTriggerAcc +AT.AppTriggerRej.DeliveryResult +AT.AppTriggerRej.ErrorCode +AT.AppTriggerReq +BDTP.CreateFail.cause +BDTP.CreateReq +BDTP.CreateSucc +BDTP.NbrApplyCreatFail.cause +BDTP.NbrApplyCreatReq +BDTP.NbrApplyCreatSucc +BDTP.NbrApplyDelFail.cause +BDTP.NbrApplyDelReq +BDTP.NbrApplyDelSucc +BDTP.NbrApplyUpdateFail.cause +BDTP.NbrApplyUpdateReq +BDTP.NbrApplyUpdateSucc +BDTP.NbrNegCreatFail.cause +BDTP.NbrNegCreatReq +BDTP.NbrNegCreatSucc +BDTP.NbrNegUpdateFail.cause +BDTP.NbrNegUpdateReq +BDTP.NbrNegUpdateSucc +CARR.AverageLayersDl +CARR.AverageLayersUl +CARR.MaxTxPwr +CARR.MeanTxPwr +CARR.MUPDSCHMCSDist.BinX +CARR.MUPDSCHRB.BINX +CARR.MUPUSCHMCSDist.BinX +CARR.MUPUSCHRB.BINX +CARR.PDSCHMCSDist.BinX.BinY.BinZ +CARR.PUSCHMCSDist.BinX.BinY.BinZ +CARR.WBCQIDist.BinX.BinY.BinZ +CE.NbrSmfNefCreatFail.cause +CE.NbrSmfNefCreatReq +CE.NbrSmfNefCreatSucc +CE.NbrSmfNefRelFail.cause +CE.NbrSmfNefRelReq +CE.NbrSmfNefRelSucc +DataVolum.InBytesEAS +DataVolum.InPacketsEAS +DataVolum.OutBytesEAS +DataVolum.OutPacketsEAS +DIS.EasDisFail.geoloc +DIS.EasDisFail.id +DIS.EasDisFail.provider +DIS.EasDisFail.schedule +DIS.EasDisFail.srvCont +DIS.EasDisFail.srvFeature +DIS.EasDisFail.srvPerm +DIS.EasDisFail.toploc +DIS.EasDisFail.type +DIS.EasDisFail.UeLocation.EasType +DIS.EasDisReq +DIS.EasDisSucc +DM.CreateFail.cause +DM.CreateReq +DM.CreateSucc +DM.DeleteFail.cause +DM.DeleteReq +DM.DeleteSucc +DM.QueryFail.cause +DM.QueryReq +DM.QuerySucc +DM.SubscribeFail.cause +DM.SubscribeReq +DM.SubscribeSucc +DM.UpdateFail.cause +DM.UpdateReq +DM.UpdateSucc +DRB.AirIfDelayDist.Bin_Filter +DRB.AirIfDelayDl_Filter +DRB.AirIfDelayUl_Filter +DRB.DelayDlNgranUeDist.Bin_Filter +DRB.DelayUlNgranUeDist.Bin_Filter +DRB.EstabAtt.5QI +DRB.EstabAtt.SNSSAI +DRB.EstabSucc.5QI +DRB.EstabSucc.SNSSAI +DRB.F1UpacketLossRateDl +DRB.F1UPacketLossRateDl.QOS +DRB.F1UPacketLossRateDl.SNSSAI +DRB.F1UpacketLossRateUl +DRB.F1UPacketLossRateUl.QOS +DRB.F1UPacketLossRateUl.SNSSAI +DRB.F1uPdcpSduVolumeDL_Filter +DRB.F1uPdcpSduVolumeUL_Filter +DRB.GtpF1DelayDlDist.Bin_Filter +DRB.GTPUPathFailure.5QI +DRB.GTPUPathFailure.SNSSAI +DRB.InitialEstabAtt.5QI +DRB.InitialEstabAtt.SNSSAI +DRB.InitialEstabSucc.5QI +DRB.InitialEstabSucc.SNSSAI +DRB.MaxActiveUeDl_Filter +DRB.MaxActiveUeUl +DRB.MaxActiveUeUl.QOS +DRB.MaxActiveUeUl.SNSSAI +DRB.MaxEstabSucc.5QI +DRB.MaxEstabSucc.SNSSAI +DRB.MeanActiveUeDl_Filter +DRB.MeanActiveUeUl_Filter +DRB.MeanEstabSucc.5QI +DRB.MeanEstabSucc.SNSSAI +DRB.PacketLossRateUl +DRB.PacketLossRateUl.QOS +DRB.PacketLossRateUl.SNSSAI +DRB.PacketSuccessRateUlgNBUu +DRB.PacketSuccessRateUlgNBUu.QOS +DRB.PacketSuccessRateUlgNBUu.SNSSAI +DRB.PdcpF1DelayDl_Filter +DRB.PdcpPacketDropRateDl +DRB.PdcpPacketDropRateDl.QOS +DRB.PdcpPacketDropRateDl.SNSSAI +DRB.PdcpReordDelayUl_Filter +DRB.PdcpSduDelayDlDist.Bin_Filter +DRB.PdcpSduDelayDl_Filter +DRB.PdcpSduVolumeDL_Filter +DRB.PdcpSduVolumeUL_Filter +DRB.PdcpSduVolumeX2DL_Filter +DRB.PdcpSduVolumeX2UL_Filter +DRB.PdcpSduVolumeXnDL_Filter +DRB.PdcpSduVolumeXnUL_Filter +DRB.RelActNbr.5QI +DRB.RelActNbr.SNSSAI +DRB.ResumeAtt.5QI +DRB.ResumeAtt.SNSSAI +DRB.ResumeSucc.5QI +DRB.ResumeSucc.SNSSAI +DRB.RlcDelayUl_Filter +DRB.RlcPacketDropRateDl +DRB.RlcPacketDropRateDl.QOS +DRB.RlcPacketDropRateDl.SNSSAI +DRB.RlcSduDelayDl +DRB.RlcSduDelayDlDist.Bin_Filter +DRB.RlcSduLatencyDl +DRB.RlcSduLatencyDlDist.bin.QOS +DRB.RlcSduLatencyDlDist.bin.SNSSAI +DRB.RlcSduLatencyDl.QOS +DRB.RlcSduLatencyDl.SNSSAI +DRB.SessionTime.5QI +DRB.SessionTime.SNSSAI +DRB.UEThpDl +DRB.UEThpDl.BWP +DRB.UEThpDlDist.Bin +DRB.UEThpDlDist.Bin.PLMN +DRB.UEThpDlDist.Bin.QOS +DRB.UEThpDlDist.Bin.SNSSAI +DRB.UEThpDl.QOS +DRB.UEThpDl.SNSSAI +DRB.UEThpUl +DRB.UEThpUl.BWP +DRB.UEThpUlDist.Bin +DRB.UEThpUlDist.Bin.PLMN +DRB.UEThpUlDist.Bin.QOS +DRB.UEThpUlDist.Bin.SNSSAI +DRB.UEThpUl.PLMN +DRB.UEThpUl.QOS +DRB.UEThpUl.SNSSAI +DRB.UEUnresVolDl +DRB.UEUnresVolDl.PLMN +DRB.UEUnresVolDl.QOS +DRB.UEUnresVolDl.SNSSAI +DRB.UEUnresVolUl +DRB.UEUnresVolUl.PLMN +DRB.UEUnresVolUl.QOS +DRB.UEUnresVolUl.SNSSAI +EEX.NotifyNbr +EEX.SubscribeFail.cause +EEX.SubscribeReq +EEX.SubscribeSucc +EEX.UnsubscribeFail.cause +EEX.UnsubscribeReq +EEX.UnsubscribeSucc +EPP.NbrCreatFail.cause +EPP.NbrCreatReq +EPP.NbrCreatSucc +EPP.NbrDelFail.cause +EPP.NbrDelReq +EPP.NbrDelSucc +EPP.NbrUpdateFail.cause +EPP.NbrUpdateReq +EPP.NbrUpdateSucc +GTP.DelayDlInIUpfDist.Bin.5QI +GTP.DelayDlInIUpfDist.Bin.SNSSAI +GTP.DelayDlInIUpfMean.5QI +GTP.DelayDlInIUpfMean.SNSSAI +GTP.DelayDlInPsaUpfDist.Bin.5QI +GTP.DelayDlInPsaUpfDist.Bin.SNSSAI +GTP.DelayDlInPsaUpfMean.5QI +GTP.DelayDlInPsaUpfMean.SNSSAI +GTP.DelayDlPsaUpfNgranDist.5QI.Bin +GTP.DelayDlPsaUpfNgranDist.SNSSAI.bin +GTP.DelayDlPsaUpfNgranMean.5QI +GTP.DelayDlPsaUpfNgranMean.SNSSAI +GTP.DelayDlPsaUpfUeDist.SNSSAI.bin +GTP.DelayDlPsaUpfUeMean.SNSSAI +GTP.DelayUlInIUpfDist.Bin.5QI +GTP.DelayUlInIUpfDist.Bin.SNSSAI +GTP.DelayUlInIUpfMean.5QI +GTP.DelayUlInIUpfMean.SNSSAI +GTP.DelayUlInPsaUpfDist.Bin.5QI +GTP.DelayUlInPsaUpfDist.Bin.SNSSAI +GTP.DelayUlInPsaUpfMean.5QI +GTP.DelayUlInPsaUpfMean.SNSSAI +GTP.DelayUlPsaUpfNgranDist.5QI.Bin +GTP.DelayUlPsaUpfNgranDist.SNSSAI.bin +GTP.DelayUlPsaUpfNgranMean.5QI +GTP.DelayUlPsaUpfNgranMean.SNSSAI +GTP.DelayUlPsaUpfUeDist.SNSSAI.bin +GTP.DelayUlPsaUpfUeMean.SNSSAI +GTP.InDataOctN3UPF +GTP.InDataOctN9PsaUpf +GTP.InDataOctN9PsaUpf.SNSSAI +GTP.InDataPktDisorderN3UPF +GTP.InDataPktDisorderN3UPF.QoS +GTP.InDataPktN3UPF +GTP.InDataPktN3UPF.SNSSAI +GTP.InDataPktN9PsaUpf +GTP.InDataPktN9PsaUpf.SNSSAI +GTP.InDataPktPacketLossN3gNB +GTP.InDataPktPacketLossN3gNB.QoS +GTP.InDataPktPacketLossN3gNB.SNSSAI +GTP.InDataPktPacketLossN3UPF +GTP.InDataPktPacketLossN3UPF.QoS +GTP.InDataPktPacketLossN3UPF.SNSSAI +GTP.InDataPktPacketLossN3UPF.TEID +GTP.InDataPktPacketLossN3UPF.TEID.QoS +GTP.InDataVolumeQoSLevelN3UPF +GTP.OutDataOctN3UPF +GTP.OutDataOctN3UPF.SNSSAI +GTP.OutDataOctN3UPF.SNSSAI +GTP.OutDataOctN9PsaUpf +GTP.OutDataOctN9PsaUpf.SNSSAI +GTP.OutDataPktN3UPF +GTP.OutDataPktN3UPF.SNSSAI +GTP.OutDataPktN9PsaUpf +GTP.OutDataPktN9PsaUpf.SNSSAI +GTP.OutDataPktPacketLossN3UPF +GTP.OutDataPktPacketLossN3UPF.QoS +GTP.OutDataVolumeQoSLevelN3UPF +GTP.RttDelayN3DlPsaUpfMean.DSCP +GTP.RttDelayN3IUpfMean.DSCP +GTP.RttDelayN3IUpfsDist.Bin.DSCP +GTP.RttDelayN3PsaUpfDist.Bin.DSCP +GTP.RttDelayN9IUpfDist.Bin.DSCP +GTP.RttDelayN9IUpfMean.DSCP +GTP.RttDelayN9PsaUpfDist.Bin.DSCP +GTP.RttDelayN9PsaUpfMean.DSCP +GTP.RttDelayPsaUpfNgranDist.5QI.Bin +GTP.RttDelayPsaUpfNgranDist.SNSSAI.bin +GTP.RttDelayPsaUpfNgranMean.5QI +GTP.RttDelayPsaUpfNgranMean.SNSSAI +HO.InterSys.bPingPong.NCI +HO.InterSys.bTooLate.ECGI +HO.InterSys.bUnnecessary.ECGI +HO.InterSys.PingPong +HO.InterSys.TooEarly +HO.InterSys.TooLate +HO.InterSys.Unnecessary +HO.IntraSys.bTooEarly.NCI +HO.IntraSys.bTooLate.NCI +HO.IntraSys.bToWrongCell.NCI +HO.IntraSys.TooEarly +HO.IntraSys.TooLate +HO.IntraSys.ToWrongCell +IP.N6IncLinkUsage.N6RP +IP.N6OutLinkUsage.N6RP +L1M.ATADist.Bin +L1M.PHR1.BinX +L1M.RSRPEutraNbr.Bin +L1M.SSBBeamRelatedUeNbr +L1M.SS-RSRP.Bin +L1M.SS-RSRPNrNbr.SSBIndex.Bin +LM.LocationContextTranFail.Cause +LM.LocationContextTranReq +LM.LocationContextTranSucc +LM.LocationDeterFail.Cause +LM.LocationDeterReq +LM.LocationDeterSucc +LM.LocationNotifFail.Cause +LM.LocationNotifSucc +MeanDiskUsage +MeanMemoryUsage +MeanProcessorUsage +MeanTime5QI1Flow.RelDoubleNG +MM.ChoExeInterReq.TimeMax.SNSSAI +MM.ChoExeInterReq.TimeMean.SNSSAI +MM.ChoExeInterSucc +MM.ChoExeIntraSucc +MM.ChoPrepInterFail.cause +MM.ChoPrepInterFailUes.cause +MM.ChoPrepInterReq +MM.ChoPrepInterReqUes +MM.ChoPrepInterSucc +MM.ChoPrepInterSuccUes +MM.ChoPrepIntraReq +MM.ChoPrepIntraReqUes +MM.ChoPrepIntraSucc +MM.ChoPrepIntraSuccUes +MM.ChoResAlloInterFail.cause +MM.ChoResAlloInterReq +MM.ChoResAlloInterSucc +MM.ConfigInterReqCho +MM.ConfigInterReqChoUes +MM.ConfigIntraReqCho +MM.ConfigIntraReqChoUes +MM.ConfUpdate +MM.ConfUpdateSucc +MM.DapsHoExeInterFail.FailInfo +MM.DapsHoExeInterFail.HoExeSupTimer +MM.DapsHoExeInterFail.RetrUeCtxtReq +MM.DapsHoExeInterFail.RrcReestabReq +MM.DapsHoExeInterFail.UeCtxtRelCmd.cause +MM.DapsHoExeInterReq +MM.DapsHoExeInterSucc +MM.DapsHoExeIntraReq +MM.DapsHoExeIntraSucc +MM.DapsHoPrepInterFail.cause +MM.DapsHoPrepInterReq +MM.DapsHoPrepInterSucc +MM.DapsHoPrepIntraReq +MM.DapsHoPrepIntraSucc +MM.DapsHoResAlloInterFail.cause +MM.DapsHoResAlloInterReq +MM.DapsHoResAlloInterSucc +MM.Ho5gsToEpsFallbackTimeMean +MM.HoExeHo5gsToEpsFallbackTimeMean +MM.HoExeInterFail.HoExeSupTimer +MM.HoExeInterFail.RetrUeCtxtReq +MM.HoExeInterFail.RrcReestabReq +MM.HoExeInterFail.UeCtxtRelCmd.cause +MM.HoExeInterFreqReq +MM.HoExeInterFreqSucc +MM.HoExeInterReq +MM.HoExeInterReq.TimeMax.SNSSAI +MM.HoExeInterReq.TimeMean.SNSSAI +MM.HoExeInterSSBFail.HoExeSupTimer +MM.HoExeInterSSBFail.RetrUeCtxtReq +MM.HoExeInterSSBFail.RrcReestabReq +MM.HoExeInterSSBFail.UeCtxtRelCmd.cause +MM.HoExeInterSSBSucc +MM.HoExeInterSucc +MM.HoExeIntraFreqReq +MM.HoExeIntraFreqSucc +MM.HoExeIntraReq +MM.HoExeIntraSucc +MM.HoIncEpsTo5gsN26Att +MM.HoIncEpsTo5gsN26Fail.cause +MM.HoIncEpsTo5gsN26Succ +MM.HoIncEpsTo5gsResAlloFail.cause +MM.HoIncEpsTo5gsResAlloReq +MM.HoIncEpsTo5gsResAlloSucc +MM.HoOut5gsToEpsFallbackPrepFail.cause +MM.HoOut5gsToEpsFallbackPrepReq +MM.HoOut5gsToEpsFallbackPrepSucc +MM.HoOut5gsToEpsN26Att +MM.HoOut5gsToEpsN26Fail.cause +MM.HoOut5gsToEpsN26Succ +MM.HoOut5gsToEpsPrepFail.cause +MM.HoOut5gsToEpsPrepReq +MM.HoOut5gsToEpsPrepSucc +MM.HoOutExe5gsToEpsFail.cause +MM.HoOutExe5gsToEpsFallbackFail.cause +MM.HoOutExe5gsToEpsFallbackSucc +MM.HoOutExe5gsToEpsReq +MM.HoOutExe5gsToEpsSucc +MM.HoPrepInterFail.cause +MM.HoPrepInterReq +MM.HoPrepInterSucc +MM.HoPrepIntraReq +MM.HoPrepIntraSucc +MM.HoResAlloInterFail.cause +MM.HoResAlloInterReq +MM.HoResAlloInterSucc +MM.NbrPDUFailInterAMFHOInc.cause +MM.NbrPDUFailInterAMFHOInc.SNSSAI +MM.NbrPDUReqInterAMFHOInc.SNSSAI +MM.NbrQoSFlowFailInterAMFHOInc.5QI +MM.NbrQoSFlowFailInterAMFHOInc.cause +MM.NbrQoSFlowFailInterAMFHOInc.SNSSAI +MM.NbrQoSFlowReqInterAMFHOInc.5QI +MM.NbrQoSFlowReqInterAMFHOInc.SNSSAI +MM.Paging5GReq +MM.Paging5GSucc +MM.Redirection.5gsToEpsFallback +MM.ServiceReqNetInitAtt +MM.ServiceReqNetInitSucc +MM.ServiceReqNon3GPPAtt +MM.ServiceReqNon3GPPSucc +MM.ServiceReqTotalAtt +MM.ServiceReqTotalSucc +MM.ServiceReqTrustNon3GPPAtt +MM.ServiceReqTrustNon3GPPSucc +MR.IntraCellSSBSwitchReq +MR.IntrCellSuccSSBSwitch +MR.NRScSSRSRQ.BinX +MR.NRScSSSINR.BinX +MR.SS-RSRQPerSSB.Bin +MR.SS-RSRQ.SSBIndex.Bin +MR.SS-SINRPerSSB.Bin +MR.SS-SINR.SSBIndex.Bin +NFS.DiscFailInputErr +NFS.DiscFailNrfErr +NFS.DiscFailUnauth +NFS.DiscReq +NFS.DiscSucc +NFS.RegFailEncodeErr +NFS.RegFailNrfErr +NFS.RegReq +NFS.RegSucc +NFS.UpdateFailEncodeErr +NFS.UpdateFailNrfErr +NFS.UpdateReq +NFS.UpdateSucc +NIDD.NbrConfigCreatFail.cause +NIDD.NbrConfigCreatReq +NIDD.NbrConfigCreatSucc +NIDD.NbrConfigCreatTriggerNotify +NIDD.NbrConfigDelFail.cause +NIDD.NbrConfigDelReq +NIDD.NbrConfigDelSucc +NIDD.NbrConfigUpdateNotify +NIDD.NbrMODeliveryFail.cause +NIDD.NbrMODeliveryReq +NIDD.NbrMODeliverySucc +NIDD.NbrMTDeliveryFail.cause +NIDD.NbrMTDeliveryReq +NIDD.NbrMTDeliverySucc +NSS.NbrGetFail.cause +NSS.NbrGetReq +NSS.NbrGetSucc +NSS.NbrNSSAIAvailNotify +NSS.NbrNSSAIAvailSubscribeFail.cause +NSS.NbrNSSAIAvailSubscribeReq +NSS.NbrNSSAIAvailSubscribeSucc +NSS.NbrNSSAIAvailUpdateFail.cause +NSS.NbrNSSAIAvailUpdateReq +NSS.NbrNSSAIAvailUpdateSucc +PAG.DiscardedNbr +PAG.DiscardedNbrCnInitiated +PAG.DiscardedNbrRanInitiated +PAG.ReceivedNbr +PAG.ReceivedNbrCnInitiated +PAG.ReceivedNbrRanIntiated +PA.PolicyAMAssoReq.SNSSAI +PA.PolicyAMAssoSucc.SNSSAI +PA.PolicySMAssoReq.SNSSAI +PA.PolicySMAssoSucc.SNSSAI +PA.PolicyUeAssoReq +PA.PolicyUeAssoSucc +PAU.AmCreateFail.cause +PAU.AmCreateReq +PAU.AmCreateSucc +PAU.AmDeleteFail.cause +PAU.AmDeleteReq +PAU.AmDeleteSucc +PAU.AmUpdateFail.cause +PAU.AmUpdateReq +PAU.AmUpdateSucc +PAU.SmCreateFail.cause +PAU.SmCreateReq +PAU.SmCreateSucc +PAU.SmDeleteFail.cause +PAU.SmDeleteReq +PAU.SmDeleteSucc +PAU.SmUpdateFail.cause +PAU.SmUpdateReq +PAU.SmUpdateSucc +PCF.PolicyAmAssocNotifReq.SNSSAI +PCF.PolicyAmAssocNotifSucc.SNSSAI +PCF.PolicyAmAssocUpdateReq +PCF.PolicyAmAssocUpdateSucc +PCF.PolicySmAssocNotifReq.SNSSAI +PCF.PolicySmAssocNotifSucc.SNSSAI +PCF.PolicySmAssocUpdateReq.SNSSAI +PCF.PolicySmAssocUpdateSucc.SNSSAI +PEE.AvgPower +PEE.AvgTemperature +PEE.Current +PEE.Energy +PEE.Humidity +PEE.MaxPower +PEE.MaxTemperature +PEE.MinPower +PEE.MinTemperature +PEE.Voltage +PFD.CreateReq +PFD.CreateSucc +PFD.DeleteReq +PFD.DeleteSucc +PFD.FetchReq +PFD.FetchSucc +PFD.SubscribeReq +PFD.SubscribeSucc +PFD.UpdateReq +PFD.UpdateSucc +PPV.CreateFail.Cause +PPV.CreateReq +PPV.CreateSucc +PPV.DeleteFail.Cause +PPV.DeleteReq +PPV.DeleteSucc +PPV.GetFail.Cause +PPV.GetReq +PPV.GetSucc +PPV.UpdateFail.Cause +PPV.UpdateReq +PPV.UpdateSucc +QF.EstabAttNbr.5QI +QF.EstabAttNbr.SNSSAI +QF.EstabFailNbr.Cause +QF.EstabNbrAddUntrustNon3gppAtt.5QI +QF.EstabNbrAddUntrustNon3gppAtt.SNSSAI +QF.EstabNbrAddUntrustNon3gppFail.cause +QF.EstabNbrAddUntrustNon3gppSucc.5QI +QF.EstabNbrAddUntrustNon3gppSucc.SNSSAI +QF.EstabNbrInitUntrustNon3gppAtt.5QI +QF.EstabNbrInitUntrustNon3gppAtt.SNSSAI +QF.EstabNbrInitUntrustNon3gppFail.cause +QF.EstabNbrInitUntrustNon3gppSucc.5QI +QF.EstabNbrInitUntrustNon3gppSucc.SNSSAI +QF.EstabSuccNbr.5QI +QF.EstabSuccNbr.SNSSAI +QF.InitialEstabAttNbr.5QI +QF.InitialEstabAttNbr.SNSSAI +QF.InitialEstabFailNbr.Cause +QF.InitialEstabSuccNbr.5QI +QF.InitialEstabSuccNbr.SNSSAI +QF.ModNbrAtt.5QI +QF.ModNbrAtt.SNSSAI +QF.ModNbrFail.cause +QF.ModNbrSucc.5QI +QF.ModNbrSucc.SNSSAI +QF.ModNbrUntrustNon3gppAtt.5QI +QF.ModNbrUntrustNon3gppAtt.SNSSAI +QF.ModNbrUntrustNon3gppFail.cause +QF.ModNbrUntrustNon3gppSucc.5QI +QF.ModNbrUntrustNon3gppSucc.SNSSAI +QF.RelActNbr.QoS +QF.RelActNbrUntrustNon3gpp.5QI +QF.RelActNbrUntrustNon3gpp.SNSSAI +QF.ReleaseAttNbr.5QI +QF.ReleaseAttNbr.SNSSAI +QF.RelNbrUntrustNon3gppAtt.5QI +QF.RelNbrUntrustNon3gppAtt.SNSSAI +QF.RelNbrUntrustNon3gppSucc.5QI +QF.RelNbrUntrustNon3gppSucc.SNSSAI +QF.SessionTimeQoS.QoS +QF.SessionTimeUE +QosFlow.PdcpPduVolumeDL_Filter +QosFlow.PdcpPduVolumeUl_Filter +QosFlow.PdcpSduVolumeDl_Filter +RACH.AccessDelayDist.Bin +RACH.PreambleACell +RACH.PreambleA.Ssb +RACH.PreambleBCell +RACH.PreambleB.Ssb +RACH.PreambleDedCell +RACH.PreambleDed.Ssb +RACH.PreambleDist.Bin +RM.EasRegReq +RM.EasRegSucc +RM.EecDeRegReq +RM.EecDeRegSucc +RM.EecRegReq +RM.EecRegSucc +RM.EecRegUpdReq +RM.EecRegUpdSucc +RM.EesRegReq +RM.EesRegSucc +RM.RegEmergReqNon3GPP.SNSSAI +RM.RegEmergReq.SNSSAI +RM.RegEmergReqTrustNon3GPP.SNSSAI +RM.RegEmergSuccNon3GPP.SNSSAI +RM.RegEmergSucc.SNSSAI +RM.RegEmergSuccTrustNon3GPP.SNSSAI +RM.RegInitReqNon3GPP.SNSSAI +RM.RegInitReq.SNSSAI +RM.RegInitReqTrustNon3GPP.SNSSAI +RM.RegInitSuccNon3GPP.SNSSAI +RM.RegInitSucc.SNSSAI +RM.RegInitSuccTrustNon3GPP.SNSSAI +RM.RegisteredSubNbrMax.SNSSAI +RM.RegisteredSubNbrMean.SNSSAI +RM.RegisteredSubUDMNbrMax +RM.RegisteredSubUDMNbrMean +RM.RegMobReqNon3GPP.SNSSAI +RM.RegMobReq.SNSSAI +RM.RegMobReqTrustNon3GPP.SNSSAI +RM.RegMobSuccNon3GPP.SNSSAI +RM.RegMobSucc.SNSSAI +RM.RegMobSuccTrustNon3GPP.SNSSAI +RM.RegPeriodReqNon3GPP.SNSSAI +RM.RegPeriodReq.SNSSAI +RM.RegPeriodReqTrustNon3GPP.SNSSAI +RM.RegPeriodSuccNon3GPP.SNSSAI +RM.RegPeriodSucc.SNSSAI +RM.RegPeriodSuccTrustNon3GPP.SNSSAI +RM.RegTimeMax.SNSSAI.EmergencyReg +RM.RegTimeMax.SNSSAI.InitialReg +RM.RegTimeMax.SNSSAI.MobilityRegUpdate +RM.RegTimeMax.SNSSAI.PeriodicRegUpdate +RM.RegTimeMean.SNSSAI.EmergencyReg +RM.RegTimeMean.SNSSAI.InitialReg +RM.RegTimeMean.SNSSAI.MobilityRegUpdate +RM.RegTimeMean.SNSSAI.PeriodicRegUpdate +RM.SubscriberProfileSizesCount.Bin +RM.SubscriberProfileSizesMean +RM.UdmSdm.GetResponseSize.Bin +RM.UdmSdm.InfoResponseSize.Bin +RM.UdmSdm.NotificationSize.Bin +RM.UnregisteredSubUDMNbrMax +RM.UnregisteredSubUDMNbrMean +RRC.ConnEstabAtt.Cause +RRC.ConnEstabFailCause.NetworkReject +RRC.ConnEstabFailCause.NoReply +RRC.ConnEstabFailCause.Other +RRC.ConnEstabSucc.Cause +RRC.ConnMax +RRC.ConnMax.PLMN +RRC.ConnMean +RRC.ConnMean.PLMN +RRC.InactiveConnMax +RRC.InactiveConnMean +RRC.InactiveConnMean.PLMN +RRC.ReEstabAtt +RRC.ReEstabFallbackToSetupAtt +RRC.ReEstabSuccWithoutUeContext +RRC.ReEstabSuccWithUeContext +RRC.ResumeAtt.cause +RRC.ResumeFallbackToSetupAtt.cause +RRC.ResumeFollowedbyNetworkRelease +RRC.ResumeFollowedbySuspension +RRC.ResumeSuccByFallback.cause +RRC.ResumeSucc.cause +RRU.MaxLayerDlMimo +RRU.MaxLayerUlMimo +RRU.MaxPrbUsedDl +RRU.MaxPrbUsedDl.QoS +RRU.MaxPrbUsedDl.SNSSAI +RRU.MaxPrbUsedUl +RRU.MaxPrbUsedUl.QoS +RRU.MaxPrbUsedUl.SNSSAI +RRU.PrbAvailDl +RRU.PrbAvailUl +RRU.PrbTotDl +RRU.PrbTotDlDist.BinX +RRU.PrbTotDlMimo +RRU.PrbTotSdmDl +RRU.PrbTotSdmUl +RRU.PrbTotUl +RRU.PrbTotUlDist.BinX +RRU.PrbTotUlMimo +RRU.PrbUsedDl +RRU.PrbUsedDl.PLMN +RRU.PrbUsedDl.QoS +RRU.PrbUsedDl.SNSSAI +RRU.PrbUsedUl +RRU.PrbUsedUl.PLMN +RRU.PrbUsedUl.QoS +RRU.PrbUsedUl.SNSSAI +SDM.GetFail.Cause +SDM.GetReq.Type +SDM.GetSucc.Type +SDM.SubDataNotif.Type +SDM.SubscribeFail.Cause +SDM.SubscribeReq.Type +SDM.SubscribeSucc.Type +SM.MaxPDUSessionSetupReq.SNSSAI +SM.MeanPDUSessionSetupReq.SNSSAI +SM.N4SessionDelete +SM.N4SessionDeleteFail.Cause +SM.N4SessionEstabFail.cause +SM.N4SessionEstabReq +SM.N4SessionModify +SM.N4SessionModifyFail.Cause +SM.N4SessionReport +SM.N4SessionReportSucc +SM.PduSessionCreationFail.cause +SM.PduSessionCreationHRroamFail.cause +SM.PduSessionCreationHRroam.ReqType +SM.PduSessionCreationHRroam.SNSSAI +SM.PduSessionCreationHRroamSucc.ReqType +SM.PduSessionCreationHRroamSucc.SNSSAI +SM.PduSessionCreationReqReqType +SM.PduSessionCreationReq.SNSSAI +SM.PduSessionCreationSuccReqType +SM.PduSessionCreationSucc.SNSSAI +SM.PDUSessionModifyNon3GPPFail.Cause +SM.PDUSessionModifyNon3GPPReq.SNSSAI +SM.PDUSessionModifyNon3GPPSucc.SNSSAI +SM.PduSessionModSmfInitFail.Cause +SM.PduSessionModSmfInitReq +SM.PduSessionModSmfInitSucc +SM.PduSessionModUeInitFail.Cause +SM.PduSessionModUeInitReq +SM.PduSessionModUeInitSucc +SM.PduSessionRelAmfInit.cause +SM.PduSessionRelAmfInit.SNSSAI +SM.PDUSessionSetupFail.Cause +SM.PDUSessionSetupNon3GPPFail.Cause +SM.PDUSessionSetupNon3GPPReq.SNSSAI +SM.PDUSessionSetupNon3GPPSucc.SNSSAI +SM.PDUSessionSetupReq.SNSSAI +SM.PDUSessionSetupSucc.SNSSAI +SM.PduSessionTimeMax.SNSSAI +SM.PduSessionTimeMean.SNSSAI +SM.QoSflowCreateFail.cause +SM.QoSflowCreateReq.5QI +SM.QoSflowCreateReq.SNSSAI +SM.QoSflowCreateSucc.5QI +SM.QoSflowCreateSucc.SNSSAI +SM.QoSflowModFail.cause +SM.QoSflowModReq.5QI +SM.QoSflowModReq.SNSSAI +SM.QoSflowModSucc.5QI +SM.QoSflowModSucc.SNSSAI +SM.QoSflowNbrMean.5QI +SM.QoSflowNbrMean.SNSSAI +SM.QoSflowNbrPeak.5QI +SM.QoSflowNbrPeak.SNSSAI +SM.SessionNbrMax.SNSSAI +SM.SessionNbrMean.SNSSAI +SMSF.ActivateReq.SNSSAI +SMSF.ActivateSucc.SNSSAI +SMSF.DeactivateReq.SNSSAI +SMSF.DeactivateSucc.SNSSAI +SMSF.MoReq.SNSSAI +SMSF.MoSucc.SNSSAI +SMSF.MtReq.SNSSAI +SMSF.MtSucc.SNSSAI +SMS.SmsOverNasMo3GPPReq +SMS.SmsOverNasMo3GPPSucc +SMS.SmsOverNasMoNon3GPPReq +SMS.SmsOverNasMoNon3GPPSucc +SMS.SmsOverNasMt3GPPReq +SMS.SmsOverNasMt3GPPSucc +SMS.SmsOverNasMtNon3GPPReq +SMS.SmsOverNasMtNon3GPPSucc +SMS.SmsOverNasReg3GPPReq +SMS.SmsOverNasReg3GPPSucc +SMS.SmsOverNasRegNon3GPPReq +SMS.SmsOverNasRegNon3GPPSucc +SPP.NbrCreatFail.cause +SPP.NbrCreatReq +SPP.NbrCreatSucc +SPP.NbrDelFail.cause +SPP.NbrDelReq +SPP.NbrDelSucc +SPP.NbrUpdateFail.cause +SPP.NbrUpdateReq +SPP.NbrUpdateSucc +SP.SerProvReq +SP.SerProvSucc +TB.ErrNbrUlInitial +TB.ErrNbrUlInitial.16Qam +TB.ErrNbrUlInitial.256Qam +TB.ErrNbrUlInitial.64Qam +TB.ErrNbrUlInitial.Qpsk +TB.ErrToltalNbrDl.X +TB.ErrToltalNbrUl.X +TB.IntialErrNbrDl +TB.IntialErrNbrDl.16Qam +TB.IntialErrNbrDl.256Qam +TB.IntialErrNbrDl.64Qam +TB.IntialErrNbrDl.Qpsk +TB.ResidualErrNbrDl +TB.ResidualErrNbrUl +TB.TotNbrDlInitial +TB.TotNbrDlInitial.16Qam +TB.TotNbrDlInitial.256Qam +TB.TotNbrDlInitial.64Qam +TB.TotNbrDlInitial.Qpsk +TB.TotNbrDl.X +TB.TotNbrUlInit +TB.TotNbrUlInit.16Qam +TB.TotNbrUlInit.256Qam +TB.TotNbrUlInit.64Qam +TB.TotNbrUlInit.Qpsk +TB.TotNbrUl.X +TI.NbrAfCreatFail.cause +TI.NbrAfCreatReq +TI.NbrAfCreatSucc +TI.NbrAfDelFail.cause +TI.NbrAfDelReq +TI.NbrAfDelSucc +TI.NbrAfUpdateFail.cause +TI.NbrAfUpdateReq +TI.NbrAfUpdateSucc +UCM.EntryCreateFail.cause +UCM.EntryCreateReq +UCM.EntryCreateSucc +UCM.EntryDelFail.cause +UCM.EntryDelReq +UCM.EntryDelSucc +UCM.EntryUpdateFail.cause +UCM.EntryUpdateReq +UCM.EntryUpdateSucc +UECNTX.ConnEstabAtt.Cause +UECNTX.ConnEstabSucc.Cause +UECNTX.RelCmd.Cause +UECNTX.RelReq.Cause +UPF.MaxQosFlows +UPF.MaxQosFlows.Dnn +UPF.MaxQosFlows.SNSSAI +UPF.MeanQosFlows +UPF.MeanQosFlows.Dnn +UPF.MeanQosFlows.SNSSAI +VR.VCpuUsageMean +VR.VDiskUsageMean VR.VMemoryUsageMean \ No newline at end of file diff --git a/docs/SM_KPM.md b/docs/SM_KPM.md index 42a2832..2e8b6b5 100644 --- a/docs/SM_KPM.md +++ b/docs/SM_KPM.md @@ -1,42 +1,42 @@ -# Service Model KPM_V3_00 - -## Supported Report Style Types -- **RIC Style Type 1**: E2 Node Measurement. Used to carry measurement report from a target E2 Node. More in details, - it contains measurement types that Near-RT RIC is requesting to subscribe followed by a list - of subcounters to be measured for each measurement type, and a granularity period - indicating collection interval of those measurements. (not implemented) - - -- **RIC Style Type 2**: Used to carry measurement report for a single UE of interest from a target E2 Node. (not implemented) - - -- **RIC Style Type 3**: Used to carry UE-level measurement report for a group of UEs per measurement type matching subscribed conditions from a target E2 Node. (not implemented) - - -- **RIC Style Type 4**: Used to carry measurement report for a group of UEs across a set of measurement types satisfying common subscribed conditions from a target E2 Node. (implemented) - - -- **RIC Style Type 5**: Used to carry measurement report for multiple UE of interest from a target E2 Node (not implemented). - -## Supported measurements - -The document 28_552_kpm_meas.txt contains the list of all measurements defined in 3GPP TS 28.552. - -### The following measurements are supported in OAI-RAN: - -- "DRB.PdcpSduVolumeDL" -- "DRB.PdcpSduVolumeUL" -- "DRB.RlcSduDelayDl" -- "DRB.UEThpDl" -- "DRB.UEThpUl" -- "RRU.PrbTotDl" -- "RRU.PrbTotUl" - -### The following measurements are supported in SRS-RAN: - -- "DRB.UEThpDl" - DL throughput -- "DRB.UEThpUl" - UL throughput -- "DRB.RlcPacketDropRateDl" - UL packet success rate -- "DRB.PacketSuccessRateUlgNBUu" - RLC DL packet drop rate -- "DRB.RlcSduTransmittedVolumeDL" - RLC DL transmitted SDU volume **(not found in spec)** +# Service Model KPM_V3_00 + +## Supported Report Style Types +- **RIC Style Type 1**: E2 Node Measurement. Used to carry measurement report from a target E2 Node. More in details, + it contains measurement types that Near-RT RIC is requesting to subscribe followed by a list + of subcounters to be measured for each measurement type, and a granularity period + indicating collection interval of those measurements. (not implemented) + + +- **RIC Style Type 2**: Used to carry measurement report for a single UE of interest from a target E2 Node. (not implemented) + + +- **RIC Style Type 3**: Used to carry UE-level measurement report for a group of UEs per measurement type matching subscribed conditions from a target E2 Node. (not implemented) + + +- **RIC Style Type 4**: Used to carry measurement report for a group of UEs across a set of measurement types satisfying common subscribed conditions from a target E2 Node. (implemented) + + +- **RIC Style Type 5**: Used to carry measurement report for multiple UE of interest from a target E2 Node (not implemented). + +## Supported measurements + +The document 28_552_kpm_meas.txt contains the list of all measurements defined in 3GPP TS 28.552. + +### The following measurements are supported in OAI-RAN: + +- "DRB.PdcpSduVolumeDL" +- "DRB.PdcpSduVolumeUL" +- "DRB.RlcSduDelayDl" +- "DRB.UEThpDl" +- "DRB.UEThpUl" +- "RRU.PrbTotDl" +- "RRU.PrbTotUl" + +### The following measurements are supported in SRS-RAN: + +- "DRB.UEThpDl" - DL throughput +- "DRB.UEThpUl" - UL throughput +- "DRB.RlcPacketDropRateDl" - UL packet success rate +- "DRB.PacketSuccessRateUlgNBUu" - RLC DL packet drop rate +- "DRB.RlcSduTransmittedVolumeDL" - RLC DL transmitted SDU volume **(not found in spec)** - "DRB.RlcSduTransmittedVolumeUL" - RLC UL transmitted SDU volume **(not found in spec)** \ No newline at end of file diff --git a/include/SoftmaxLayer.h b/include/SoftmaxLayer.h new file mode 100644 index 0000000..569bd75 --- /dev/null +++ b/include/SoftmaxLayer.h @@ -0,0 +1,32 @@ +/* + * File: SoftmaxLayer.h + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +#ifndef SOFTMAXLAYER_H +#define SOFTMAXLAYER_H + +/* Include Files */ +#include "rtwtypes.h" +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Function Declarations */ +void SoftmaxLayer_predict(const float X1_Data[3], float Z1_Data[3]); + +#ifdef __cplusplus +} +#endif + +#endif +/* + * File trailer for SoftmaxLayer.h + * + * [EOF] + */ diff --git a/include/cellstr_sort.h b/include/cellstr_sort.h new file mode 100644 index 0000000..7e65f35 --- /dev/null +++ b/include/cellstr_sort.h @@ -0,0 +1,34 @@ +/* + * File: cellstr_sort.h + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +#ifndef CELLSTR_SORT_H +#define CELLSTR_SORT_H + +/* Include Files */ +#include "rtwtypes.h" +#include "runPrediction_types.h" +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Function Declarations */ +int cellstr_sort(const cell_wrap_1 c_data[], int c_size, + cell_wrap_1 sorted_data[], int idx_data[], int *idx_size); + +#ifdef __cplusplus +} +#endif + +#endif +/* + * File trailer for cellstr_sort.h + * + * [EOF] + */ diff --git a/include/defer.hpp b/include/defer.hpp index d9c4b2e..650a8d5 100644 --- a/include/defer.hpp +++ b/include/defer.hpp @@ -1,27 +1,27 @@ -#ifndef DEFER_HPP -#define DEFER_HPP - -#pragma once - -template -struct privDefer -{ - F f; - explicit privDefer(F f) : f(f) {} - ~privDefer() { f(); } -}; - -template -privDefer defer_func(F f) -{ - return privDefer(f); -} - -#if !defined(DEFER_1) && !defined(DEFER_2) && !defined(DEFER_3) && !defined(defer) -#define DEFER_1(x, y) x##y -#define DEFER_2(x, y) DEFER_1(x, y) -#define DEFER_3(x) DEFER_2(x, __COUNTER__) -#define defer(code) auto DEFER_3(_defer_) = defer_func([&]() { code; }) -#endif - -#endif //DEFER_HPP +#ifndef DEFER_HPP +#define DEFER_HPP + +#pragma once + +template +struct privDefer +{ + F f; + explicit privDefer(F f) : f(f) {} + ~privDefer() { f(); } +}; + +template +privDefer defer_func(F f) +{ + return privDefer(f); +} + +#if !defined(DEFER_1) && !defined(DEFER_2) && !defined(DEFER_3) && !defined(defer) +#define DEFER_1(x, y) x##y +#define DEFER_2(x, y) DEFER_1(x, y) +#define DEFER_3(x) DEFER_2(x, __COUNTER__) +#define defer(code) auto DEFER_3(_defer_) = defer_func([&]() { code; }) +#endif + +#endif //DEFER_HPP diff --git a/include/e2Info.hpp b/include/e2Info.hpp index 341c2e4..934bdb1 100644 --- a/include/e2Info.hpp +++ b/include/e2Info.hpp @@ -1,25 +1,25 @@ -#ifndef E2INFO_HPP -#define E2INFO_HPP - - -#include - -#include "spdlog/spdlog.h" -#include - -#include - -class E2Info -{ -public: - using e2NodesIdLst = std::vector; - e2_node_arr_xapp_t e2Nodes{}; - - explicit E2Info(e2_node_arr_xapp_t &e2Nodes); - - void printE2Nodes() const; - [[nodiscard]] e2NodesIdLst getE2NodesIds() const; -}; - - -#endif //E2INFO_HPP +#ifndef E2INFO_HPP +#define E2INFO_HPP + + +#include + +#include "spdlog/spdlog.h" +#include + +#include + +class E2Info +{ +public: + using e2NodesIdLst = std::vector; + e2_node_arr_xapp_t e2Nodes{}; + + explicit E2Info(e2_node_arr_xapp_t &e2Nodes); + + void printE2Nodes() const; + [[nodiscard]] e2NodesIdLst getE2NodesIds() const; +}; + + +#endif //E2INFO_HPP diff --git a/include/elementwiseOperationInPlace.h b/include/elementwiseOperationInPlace.h new file mode 100644 index 0000000..115a6f7 --- /dev/null +++ b/include/elementwiseOperationInPlace.h @@ -0,0 +1,38 @@ +/* + * File: elementwiseOperationInPlace.h + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +#ifndef ELEMENTWISEOPERATIONINPLACE_H +#define ELEMENTWISEOPERATIONINPLACE_H + +/* Include Files */ +#include "rtwtypes.h" +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Function Declarations */ +void c_lambdaForColumnMajorGeneric(float X[400]); + +void e_lambdaForColumnMajorGeneric(float X[400]); + +void f_lambdaForColumnMajorGeneric(float X[3]); + +void lambdaForColumnMajorGeneric(float X[1200]); + +#ifdef __cplusplus +} +#endif + +#endif +/* + * File trailer for elementwiseOperationInPlace.h + * + * [EOF] + */ diff --git a/include/find.h b/include/find.h new file mode 100644 index 0000000..ccbf0b7 --- /dev/null +++ b/include/find.h @@ -0,0 +1,32 @@ +/* + * File: find.h + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +#ifndef FIND_H +#define FIND_H + +/* Include Files */ +#include "rtwtypes.h" +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Function Declarations */ +int eml_find(const boolean_T x_data[], int x_size, int i_data[]); + +#ifdef __cplusplus +} +#endif + +#endif +/* + * File trailer for find.h + * + * [EOF] + */ diff --git a/include/getCategoryNames.h b/include/getCategoryNames.h new file mode 100644 index 0000000..e0dd431 --- /dev/null +++ b/include/getCategoryNames.h @@ -0,0 +1,35 @@ +/* + * File: getCategoryNames.h + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +#ifndef GETCATEGORYNAMES_H +#define GETCATEGORYNAMES_H + +/* Include Files */ +#include "rtwtypes.h" +#include "runPrediction_types.h" +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Function Declarations */ +int categorical_getCategoryNames(const cell_wrap_1 valueSet_data[], + int valueSet_size, + cell_wrap_1 outCategoryNames_data[]); + +#ifdef __cplusplus +} +#endif + +#endif +/* + * File trailer for getCategoryNames.h + * + * [EOF] + */ diff --git a/include/insertionsort.h b/include/insertionsort.h new file mode 100644 index 0000000..4c22849 --- /dev/null +++ b/include/insertionsort.h @@ -0,0 +1,34 @@ +/* + * File: insertionsort.h + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +#ifndef INSERTIONSORT_H +#define INSERTIONSORT_H + +/* Include Files */ +#include "rtwtypes.h" +#include "runPrediction_types.h" +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Function Declarations */ +void insertionsort(int x_data[], int xend, + const cell_wrap_1 cmp_workspace_c_data[]); + +#ifdef __cplusplus +} +#endif + +#endif +/* + * File trailer for insertionsort.h + * + * [EOF] + */ diff --git a/include/internal_softmax.h b/include/internal_softmax.h new file mode 100644 index 0000000..030570e --- /dev/null +++ b/include/internal_softmax.h @@ -0,0 +1,32 @@ +/* + * File: internal_softmax.h + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +#ifndef INTERNAL_SOFTMAX_H +#define INTERNAL_SOFTMAX_H + +/* Include Files */ +#include "rtwtypes.h" +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Function Declarations */ +void iComputeSoftmaxForCpu(const float xdata[3], float ydata[3]); + +#ifdef __cplusplus +} +#endif + +#endif +/* + * File trailer for internal_softmax.h + * + * [EOF] + */ diff --git a/include/introsort.h b/include/introsort.h new file mode 100644 index 0000000..9640051 --- /dev/null +++ b/include/introsort.h @@ -0,0 +1,34 @@ +/* + * File: introsort.h + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +#ifndef INTROSORT_H +#define INTROSORT_H + +/* Include Files */ +#include "rtwtypes.h" +#include "runPrediction_types.h" +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Function Declarations */ +void introsort(int x_data[], int xend, + const cell_wrap_1 cmp_workspace_c_data[]); + +#ifdef __cplusplus +} +#endif + +#endif +/* + * File trailer for introsort.h + * + * [EOF] + */ diff --git a/include/kpmManager.hpp b/include/kpmManager.hpp index 4c43ad7..4b50be1 100644 --- a/include/kpmManager.hpp +++ b/include/kpmManager.hpp @@ -1,40 +1,40 @@ -#ifndef KPMMANAGER -#define KPMMANAGER - -#include "../libs/flexric/src/xApp/e42_xapp_api.h" -#include "spdlog/spdlog.h" -#include "defer.hpp" - -#include "chrono" -#include -#include -#include -#include - -namespace KpmManager -{ - constexpr u_int32_t EXP_TIME{60}; // experiment time in seconds - constexpr u_int32_t PERIOD_MS{1000}; // granularity period - constexpr u_int16_t KPM_RAN_FUNC_ID{2}; - inline std::vector SUPPORTED_MEASUREMENTS { // is necessary? - "DRB.PdcpSduVolumeDL", - "DRB.PdcpSduVolumeUL", - "DRB.RlcSduDelayDl", - "DRB.UEThpDl", - "DRB.UEThpUl", - "RRU.PrbTotDl", - "RRU.PrbTotUl", - "RlcPacketDropRateDl", - "PacketSuccessRateUlgNBUu", - "RlcSduTransmittedVolumeDL", - "RlcSduTransmittedVolumeUL" - }; - - // used to check message latency - u_int64_t get_time_now_us(); - - // start KPM Manager - void start(e2_node_arr_xapp_t const& e2Nodes); -}; - -#endif // KPMMANAGER +#ifndef KPMMANAGER +#define KPMMANAGER + +#include "../libs/flexric/src/xApp/e42_xapp_api.h" +#include "spdlog/spdlog.h" +#include "defer.hpp" + +#include "chrono" +#include +#include +#include +#include + +namespace KpmManager +{ + constexpr u_int32_t EXP_TIME{60}; // experiment time in seconds + constexpr u_int32_t PERIOD_MS{1000}; // granularity period + constexpr u_int16_t KPM_RAN_FUNC_ID{2}; + inline std::vector SUPPORTED_MEASUREMENTS { // is necessary? + "DRB.PdcpSduVolumeDL", + "DRB.PdcpSduVolumeUL", + "DRB.RlcSduDelayDl", + "DRB.UEThpDl", + "DRB.UEThpUl", + "RRU.PrbTotDl", + "RRU.PrbTotUl", + "RlcPacketDropRateDl", + "PacketSuccessRateUlgNBUu", + "RlcSduTransmittedVolumeDL", + "RlcSduTransmittedVolumeUL" + }; + + // used to check message latency + u_int64_t get_time_now_us(); + + // start KPM Manager + void start(e2_node_arr_xapp_t const& e2Nodes); +}; + +#endif // KPMMANAGER diff --git a/include/logger.hpp b/include/logger.hpp index 9b47c6d..832f2ff 100644 --- a/include/logger.hpp +++ b/include/logger.hpp @@ -1,14 +1,14 @@ -// -// Created by murilo on 31/05/24. -// - -#ifndef LOGGER_HPP -#define LOGGER_HPP - -#include - -#include "spdlog/spdlog.h" - -void configureLogger(const std::string& xAppName, spdlog::level::level_enum logLevel); - +// +// Created by murilo on 31/05/24. +// + +#ifndef LOGGER_HPP +#define LOGGER_HPP + +#include + +#include "spdlog/spdlog.h" + +void configureLogger(const std::string& xAppName, spdlog::level::level_enum logLevel); + #endif //LOGGER_HPP \ No newline at end of file diff --git a/include/postProcessOutputToReturnCategorical.h b/include/postProcessOutputToReturnCategorical.h new file mode 100644 index 0000000..9814f2e --- /dev/null +++ b/include/postProcessOutputToReturnCategorical.h @@ -0,0 +1,37 @@ +/* + * File: postProcessOutputToReturnCategorical.h + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +#ifndef POSTPROCESSOUTPUTTORETURNCATEGORICAL_H +#define POSTPROCESSOUTPUTTORETURNCATEGORICAL_H + +/* Include Files */ +#include "rtwtypes.h" +#include "runPrediction_internal_types.h" +#include "runPrediction_types.h" +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Function Declarations */ +unsigned int +c_DeepLearningNetwork_postProce(const cell_wrap_32 scores, + cell_wrap_1 c_processedOutput_0_categoryNam[], + int *d_processedOutput_0_categoryNam); + +#ifdef __cplusplus +} +#endif + +#endif +/* + * File trailer for postProcessOutputToReturnCategorical.h + * + * [EOF] + */ diff --git a/include/predict.h b/include/predict.h new file mode 100644 index 0000000..1dd42a8 --- /dev/null +++ b/include/predict.h @@ -0,0 +1,36 @@ +/* + * File: predict.h + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +#ifndef PREDICT_H +#define PREDICT_H + +/* Include Files */ +#include "rtwtypes.h" +#include "runPrediction_internal_types.h" +#include "runPrediction_types.h" +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Function Declarations */ +void DeepLearningNetwork_predict(c_coder_internal_ctarget_DeepLe *obj, + const cell_wrap_0 *varargin_1, + float varargout_1[3]); + +#ifdef __cplusplus +} +#endif + +#endif +/* + * File trailer for predict.h + * + * [EOF] + */ diff --git a/include/predictForRNN.h b/include/predictForRNN.h new file mode 100644 index 0000000..52c8a94 --- /dev/null +++ b/include/predictForRNN.h @@ -0,0 +1,35 @@ +/* + * File: predictForRNN.h + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +#ifndef PREDICTFORRNN_H +#define PREDICTFORRNN_H + +/* Include Files */ +#include "rtwtypes.h" +#include "runPrediction_internal_types.h" +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Function Declarations */ +void c_DeepLearningNetwork_predictFo(c_coder_internal_ctarget_DeepLe *obj, + const cell_wrap_7 *inputs, + float outputData[3]); + +#ifdef __cplusplus +} +#endif + +#endif +/* + * File trailer for predictForRNN.h + * + * [EOF] + */ diff --git a/include/rtGetInf.h b/include/rtGetInf.h new file mode 100644 index 0000000..5d16c57 --- /dev/null +++ b/include/rtGetInf.h @@ -0,0 +1,31 @@ +/* + * File: rtGetInf.h + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +#ifndef RTGETINF_H +#define RTGETINF_H + +/* Include Files */ +#include "rtwtypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern real_T rtGetInf(void); +extern real32_T rtGetInfF(void); +extern real_T rtGetMinusInf(void); +extern real32_T rtGetMinusInfF(void); + +#ifdef __cplusplus +} +#endif +#endif +/* + * File trailer for rtGetInf.h + * + * [EOF] + */ diff --git a/include/rtGetNaN.h b/include/rtGetNaN.h new file mode 100644 index 0000000..f2df906 --- /dev/null +++ b/include/rtGetNaN.h @@ -0,0 +1,29 @@ +/* + * File: rtGetNaN.h + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +#ifndef RTGETNAN_H +#define RTGETNAN_H + +/* Include Files */ +#include "rtwtypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern real_T rtGetNaN(void); +extern real32_T rtGetNaNF(void); + +#ifdef __cplusplus +} +#endif +#endif +/* + * File trailer for rtGetNaN.h + * + * [EOF] + */ diff --git a/include/rt_nonfinite.h b/include/rt_nonfinite.h new file mode 100644 index 0000000..dddefac --- /dev/null +++ b/include/rt_nonfinite.h @@ -0,0 +1,38 @@ +/* + * File: rt_nonfinite.h + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +#ifndef RT_NONFINITE_H +#define RT_NONFINITE_H + +/* Include Files */ +#include "rtwtypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern real_T rtInf; +extern real_T rtMinusInf; +extern real_T rtNaN; +extern real32_T rtInfF; +extern real32_T rtMinusInfF; +extern real32_T rtNaNF; + +extern boolean_T rtIsInf(real_T value); +extern boolean_T rtIsInfF(real32_T value); +extern boolean_T rtIsNaN(real_T value); +extern boolean_T rtIsNaNF(real32_T value); + +#ifdef __cplusplus +} +#endif +#endif +/* + * File trailer for rt_nonfinite.h + * + * [EOF] + */ diff --git a/include/rtwtypes.h b/include/rtwtypes.h new file mode 100644 index 0000000..3d9109d --- /dev/null +++ b/include/rtwtypes.h @@ -0,0 +1,45 @@ +/* + * File: rtwtypes.h + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +#ifndef RTWTYPES_H +#define RTWTYPES_H + +/*=======================================================================* + * Fixed width word size data types: * + * int64_T - signed 64 bit integers * + * uint64_T - unsigned 64 bit integers * + *=======================================================================*/ + +#if defined(__APPLE__) +#ifndef INT64_T +#define INT64_T long +#define FMT64 "l" +#if defined(__LP64__) && !defined(INT_TYPE_64_IS_LONG) +#define INT_TYPE_64_IS_LONG +#endif +#endif +#endif + +#if defined(__APPLE__) +#ifndef UINT64_T +#define UINT64_T unsigned long +#define FMT64 "l" +#if defined(__LP64__) && !defined(INT_TYPE_64_IS_LONG) +#define INT_TYPE_64_IS_LONG +#endif +#endif +#endif + +/* Include Files */ +#include "tmwtypes.h" + +#endif +/* + * File trailer for rtwtypes.h + * + * [EOF] + */ diff --git a/include/runPrediction.h b/include/runPrediction.h new file mode 100644 index 0000000..0349acc --- /dev/null +++ b/include/runPrediction.h @@ -0,0 +1,33 @@ +/* + * File: runPrediction.h + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +#ifndef RUNPREDICTION_H +#define RUNPREDICTION_H + +/* Include Files */ +#include "rtwtypes.h" +#include "runPrediction_types.h" +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Function Declarations */ +extern void runPrediction(const cell_wrap_0 A[1], categorical *pred); + +#ifdef __cplusplus +} +#endif + +#endif +/* + * File trailer for runPrediction.h + * + * [EOF] + */ diff --git a/include/runPrediction_data.h b/include/runPrediction_data.h new file mode 100644 index 0000000..5b7c72f --- /dev/null +++ b/include/runPrediction_data.h @@ -0,0 +1,26 @@ +/* + * File: runPrediction_data.h + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +#ifndef RUNPREDICTION_DATA_H +#define RUNPREDICTION_DATA_H + +/* Include Files */ +#include "rtwtypes.h" +#include "omp.h" +#include +#include + +/* Variable Declarations */ +extern omp_nest_lock_t runPrediction_nestLockGlobal; +extern boolean_T isInitialized_runPrediction; + +#endif +/* + * File trailer for runPrediction_data.h + * + * [EOF] + */ diff --git a/include/runPrediction_initialize.h b/include/runPrediction_initialize.h new file mode 100644 index 0000000..90a2a89 --- /dev/null +++ b/include/runPrediction_initialize.h @@ -0,0 +1,32 @@ +/* + * File: runPrediction_initialize.h + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +#ifndef RUNPREDICTION_INITIALIZE_H +#define RUNPREDICTION_INITIALIZE_H + +/* Include Files */ +#include "rtwtypes.h" +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Function Declarations */ +extern void runPrediction_initialize(void); + +#ifdef __cplusplus +} +#endif + +#endif +/* + * File trailer for runPrediction_initialize.h + * + * [EOF] + */ diff --git a/include/runPrediction_internal_types.h b/include/runPrediction_internal_types.h new file mode 100644 index 0000000..0f2cfdb --- /dev/null +++ b/include/runPrediction_internal_types.h @@ -0,0 +1,58 @@ +/* + * File: runPrediction_internal_types.h + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +#ifndef RUNPREDICTION_INTERNAL_TYPES_H +#define RUNPREDICTION_INTERNAL_TYPES_H + +/* Include Files */ +#include "rtwtypes.h" +#include "runPrediction_types.h" + +/* Type Definitions */ +#ifndef typedef_cell_wrap_4 +#define typedef_cell_wrap_4 +typedef struct { + float f1[400]; +} cell_wrap_4; +#endif /* typedef_cell_wrap_4 */ + +#ifndef typedef_cell_wrap_5 +#define typedef_cell_wrap_5 +typedef struct { + cell_wrap_4 f1[2]; +} cell_wrap_5; +#endif /* typedef_cell_wrap_5 */ + +#ifndef c_typedef_c_coder_internal_ctar +#define c_typedef_c_coder_internal_ctar +typedef struct { + boolean_T matlabCodegenIsDeleted; + cell_wrap_5 InternalState[1]; + boolean_T IsNetworkInitialized; +} c_coder_internal_ctarget_DeepLe; +#endif /* c_typedef_c_coder_internal_ctar */ + +#ifndef typedef_cell_wrap_32 +#define typedef_cell_wrap_32 +typedef struct { + float f1[3]; +} cell_wrap_32; +#endif /* typedef_cell_wrap_32 */ + +#ifndef typedef_cell_wrap_7 +#define typedef_cell_wrap_7 +typedef struct { + cell_wrap_0 f1[1]; +} cell_wrap_7; +#endif /* typedef_cell_wrap_7 */ + +#endif +/* + * File trailer for runPrediction_internal_types.h + * + * [EOF] + */ diff --git a/include/runPrediction_terminate.h b/include/runPrediction_terminate.h new file mode 100644 index 0000000..d801c88 --- /dev/null +++ b/include/runPrediction_terminate.h @@ -0,0 +1,32 @@ +/* + * File: runPrediction_terminate.h + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +#ifndef RUNPREDICTION_TERMINATE_H +#define RUNPREDICTION_TERMINATE_H + +/* Include Files */ +#include "rtwtypes.h" +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Function Declarations */ +extern void runPrediction_terminate(void); + +#ifdef __cplusplus +} +#endif + +#endif +/* + * File trailer for runPrediction_terminate.h + * + * [EOF] + */ diff --git a/include/runPrediction_types.h b/include/runPrediction_types.h new file mode 100644 index 0000000..cb610be --- /dev/null +++ b/include/runPrediction_types.h @@ -0,0 +1,62 @@ +/* + * File: runPrediction_types.h + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +#ifndef RUNPREDICTION_TYPES_H +#define RUNPREDICTION_TYPES_H + +/* Include Files */ +#include "rtwtypes.h" + +/* Type Definitions */ +#ifndef typedef_cell_wrap_0 +#define typedef_cell_wrap_0 +typedef struct { + double f1[10]; +} cell_wrap_0; +#endif /* typedef_cell_wrap_0 */ + +#ifndef struct_emxArray_char_T_1x1 +#define struct_emxArray_char_T_1x1 +struct emxArray_char_T_1x1 { + char data[1]; + int size[2]; +}; +#endif /* struct_emxArray_char_T_1x1 */ +#ifndef typedef_emxArray_char_T_1x1 +#define typedef_emxArray_char_T_1x1 +typedef struct emxArray_char_T_1x1 emxArray_char_T_1x1; +#endif /* typedef_emxArray_char_T_1x1 */ + +#ifndef typedef_cell_wrap_1 +#define typedef_cell_wrap_1 +typedef struct { + emxArray_char_T_1x1 f1; +} cell_wrap_1; +#endif /* typedef_cell_wrap_1 */ + +#ifndef typedef_emxArray_cell_wrap_1_3 +#define typedef_emxArray_cell_wrap_1_3 +typedef struct { + cell_wrap_1 data[3]; + int size[1]; +} emxArray_cell_wrap_1_3; +#endif /* typedef_emxArray_cell_wrap_1_3 */ + +#ifndef typedef_categorical +#define typedef_categorical +typedef struct { + unsigned char codes; + emxArray_cell_wrap_1_3 categoryNames; +} categorical; +#endif /* typedef_categorical */ + +#endif +/* + * File trailer for runPrediction_types.h + * + * [EOF] + */ diff --git a/include/strcmp.h b/include/strcmp.h new file mode 100644 index 0000000..9074eb6 --- /dev/null +++ b/include/strcmp.h @@ -0,0 +1,33 @@ +/* + * File: strcmp.h + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +#ifndef STRCMP_H +#define STRCMP_H + +/* Include Files */ +#include "rtwtypes.h" +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Function Declarations */ +boolean_T b_strcmp(const char a_data[], const int a_size[2], + const char b_data[], const int b_size[2]); + +#ifdef __cplusplus +} +#endif + +#endif +/* + * File trailer for strcmp.h + * + * [EOF] + */ diff --git a/include/strtrim.h b/include/strtrim.h new file mode 100644 index 0000000..7e563e6 --- /dev/null +++ b/include/strtrim.h @@ -0,0 +1,33 @@ +/* + * File: strtrim.h + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +#ifndef STRTRIM_H +#define STRTRIM_H + +/* Include Files */ +#include "rtwtypes.h" +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Function Declarations */ +void strtrim(const char x_data[], const int x_size[2], char y_data[], + int y_size[2]); + +#ifdef __cplusplus +} +#endif + +#endif +/* + * File trailer for strtrim.h + * + * [EOF] + */ diff --git a/include/tmwtypes.h b/include/tmwtypes.h new file mode 100644 index 0000000..e7f52fc --- /dev/null +++ b/include/tmwtypes.h @@ -0,0 +1,888 @@ +/* + * Copyright 1984-2018 The MathWorks, Inc. + */ + +#if defined(_MSC_VER) +# pragma once +#endif +#if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3)) +# pragma once +#endif + +#ifndef tmwtypes_h +#define tmwtypes_h + +#ifndef __TMWTYPES__ +#define __TMWTYPES__ +/* + * File : tmwtypes.h + * Abstract: + * Data types for use with MATLAB/SIMULINK and the Real-Time Workshop. + * + * When compiling stand-alone model code, data types can be overridden + * via compiler switches. + * + * Define NO_FLOATS to eliminate reference to real_T, etc. + */ + +#ifdef MW_LIBTOOLING +#include "mwstdint.h" +#endif + +#include + +/* __STDC_VERSION__ version check below means "check for a C99 compiler". + + Visual Studio (checked on versions 2015 and 2017) does + not define __STDC_VERSION__, however it has stdbool.h available, + thus a separate check for _MSC_VER below. + */ +#if defined(__APPLE_CC__) \ + || (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) \ + || (defined(_MSC_VER) && (_MSC_VER >= 1900)) +#ifndef tmwtypes_do_not_include_stdbool +#include +#endif +#endif + +#define LOGICAL_IS_A_TYPE +#define SPARSE_GENERALIZATION + +#ifdef NO_FLOATS +# define double double_not_allowed +# define float float_not_allowed +#endif /*NO_FLOATS*/ + +#ifndef NO_FLOATS + +#ifndef __MWERKS__ +# ifdef __STDC__ +# include +# else +# ifndef FLT_MANT_DIG +# define FLT_MANT_DIG 24 +# endif +# ifndef DBL_MANT_DIG +# define DBL_MANT_DIG 53 +# endif +# endif +#endif + +#endif /*NO_FLOATS*/ + +/* + * The following data types cannot be overridden when building MEX files. + */ +#ifdef MATLAB_MEX_FILE +# undef CHARACTER_T +# undef INTEGER_T +# undef BOOLEAN_T +# undef REAL_T +# undef TIME_T +#endif + +/* + * The uchar_T, ushort_T and ulong_T types are needed for compilers which do + * not allow defines to be specified, at the command line, with spaces in them. + */ + +typedef unsigned char uchar_T; +typedef unsigned short ushort_T; +typedef unsigned long ulong_T; + +#if (defined(_MSC_VER) && _MSC_VER >= 1500) \ + || defined(__x86_64__) || defined(__LP64__) \ + || defined(__LCC64__) + +typedef unsigned long long ulonglong_T; +#endif + + + +/*=======================================================================* + * Fixed width word size data types: * + * int8_T, int16_T, int32_T - signed 8, 16, or 32 bit integers * + * uint8_T, uint16_T, uint32_T - unsigned 8, 16, or 32 bit integers * + * real32_T, real64_T - 32 and 64 bit floating point numbers * + *=======================================================================*/ + +/* When used with Real Time Workshop generated code, this + * header file can be used with a variety of compilers. + * + * The compiler could be for an 8 bit embedded processor that + * only had 8 bits per integer and 16 bits per long. + * In that example, a 32 bit integer size is not even available. + * This header file should be robust to that. + * + * For the case of an 8 bit processor, the preprocessor + * may be limited to 16 bit math like its target. That limitation + * would mean that 32 bit comparisons can't be done accurately. + * To increase robustness to this, comparisons are done against + * smaller values first. An inaccurate 32 bit comparison isn't + * attempted if the 16 bit comparison has already succeeded. + * + * Limitations on preprocessor math can also be stricter than + * for the target. There are known cases where a compiler + * targeting processors with 64 bit longs can't do accurate + * preprocessor comparisons on more than 32 bits. + */ + +/* Determine the number of bits for int, long, short, and char. + * If one fails to be determined, set the number of bits to -1 + */ + +#ifndef TMW_BITS_PER_INT +# if INT_MAX == 0x7FL +# define TMW_BITS_PER_INT 8 +# elif INT_MAX == 0x7FFFL +# define TMW_BITS_PER_INT 16 +# elif INT_MAX == 0x7FFFFFFFL +# define TMW_BITS_PER_INT 32 +# else +# define TMW_BITS_PER_INT -1 +# endif +#endif + +#ifndef TMW_BITS_PER_LONG +# if LONG_MAX == 0x7FL +# define TMW_BITS_PER_LONG 8 +# elif LONG_MAX == 0x7FFFL +# define TMW_BITS_PER_LONG 16 +# elif LONG_MAX == 0x7FFFFFFFL +# define TMW_BITS_PER_LONG 32 +# else +# define TMW_BITS_PER_LONG -1 +# endif +#endif + +#ifndef TMW_BITS_PER_SHRT +# if SHRT_MAX == 0x7FL +# define TMW_BITS_PER_SHRT 8 +# elif SHRT_MAX == 0x7FFFL +# define TMW_BITS_PER_SHRT 16 +# elif SHRT_MAX == 0x7FFFFFFFL +# define TMW_BITS_PER_SHRT 32 +# else +# define TMW_BITS_PER_SHRT -1 +# endif +#endif + +#ifndef TMW_BITS_PER_SCHAR +# if SCHAR_MAX == 0x7FL +# define TMW_BITS_PER_SCHAR 8 +# elif SCHAR_MAX == 0x7FFFL +# define TMW_BITS_PER_SCHAR 16 +# elif SCHAR_MAX == 0x7FFFFFFFL +# define TMW_BITS_PER_SCHAR 32 +# else +# define TMW_BITS_PER_SCHAR -1 +# endif +#endif + +#ifndef TMW_CHAR_SIGNED +# if SCHAR_MAX == CHAR_MAX +# define TMW_CHAR_SIGNED 1 +# else +# define TMW_CHAR_SIGNED 0 +# endif +#endif + +/* It is common for one or more of the integer types + * to be the same size. For example, on many embedded + * processors, both shorts and ints are 16 bits. On + * processors used for workstations, it is quite common + * for both int and long to be 32 bits. + * When there is more than one choice for typdef'ing + * a portable type like int16_T or uint32_T, in + * concept, it should not matter which choice is made. + * However, some style guides and some code checking + * tools do identify and complain about seemingly + * irrelevant differences. For example, a code + * checking tool may complain about an implicit + * conversion from int to short even though both + * are 16 bits. To reduce these types of + * complaints, it is best to make int the + * preferred choice when more than one is available. + */ + +#ifndef INT8_T +# if defined(MW_LIBTOOLING) +# define INT8_T int8_t +# elif TMW_BITS_PER_INT == 8 +# define INT8_T int +# elif TMW_BITS_PER_LONG == 8 +# define INT8_T long +# elif TMW_BITS_PER_SCHAR == 8 +# define INT8_T signed char +# elif TMW_BITS_PER_SHRT == 8 +# define INT8_T short +# endif +#endif +#ifdef INT8_T + typedef INT8_T int8_T; +#endif + +#ifndef UINT8_T +# if defined(MW_LIBTOOLING) +# define UINT8_T uint8_t +# elif TMW_BITS_PER_INT == 8 +# define UINT8_T unsigned int +# elif TMW_BITS_PER_LONG == 8 +# define UINT8_T unsigned long +# elif TMW_BITS_PER_SCHAR == 8 +# define UINT8_T unsigned char +# elif TMW_BITS_PER_SHRT == 8 +# define UINT8_T unsigned short +# endif +#endif +#ifdef UINT8_T + typedef UINT8_T uint8_T; +#endif + + +#ifndef INT16_T +# if defined(MW_LIBTOOLING) +# define INT16_T int16_t +# elif TMW_BITS_PER_INT == 16 +# define INT16_T int +# elif TMW_BITS_PER_LONG == 16 +# define INT16_T long +# elif TMW_BITS_PER_SCHAR == 16 +# define INT16_T signed char +# elif TMW_BITS_PER_SHRT == 16 +# define INT16_T short +# endif +#endif +#ifdef INT16_T + typedef INT16_T int16_T; +#endif + + +#ifndef UINT16_T +# if defined(MW_LIBTOOLING) +# define UINT16_T uint16_t +# elif TMW_BITS_PER_INT == 16 +# define UINT16_T unsigned int +# elif TMW_BITS_PER_LONG == 16 +# define UINT16_T unsigned long +# elif TMW_BITS_PER_SCHAR == 16 +# define UINT16_T unsigned char +# elif TMW_BITS_PER_SHRT == 16 +# define UINT16_T unsigned short +# endif +#endif +#ifdef UINT16_T + typedef UINT16_T uint16_T; +#endif + + +#ifndef INT32_T +# if defined(MW_LIBTOOLING) +# define INT32_T int32_t +# elif TMW_BITS_PER_INT == 32 +# define INT32_T int +# elif TMW_BITS_PER_LONG == 32 +# define INT32_T long +# elif TMW_BITS_PER_SCHAR == 32 +# define INT32_T signed char +# elif TMW_BITS_PER_SHRT == 32 +# define INT32_T short +# endif +#endif +#ifdef INT32_T + typedef INT32_T int32_T; +#endif + + +#ifndef UINT32_T +# if defined(MW_LIBTOOLING) +# define UINT32_T uint32_t +# elif TMW_BITS_PER_INT == 32 +# define UINT32_T unsigned int +# elif TMW_BITS_PER_LONG == 32 +# define UINT32_T unsigned long +# elif TMW_BITS_PER_SCHAR == 32 +# define UINT32_T unsigned char +# elif TMW_BITS_PER_SHRT == 32 +# define UINT32_T unsigned short +# endif +#endif +#ifdef UINT32_T + typedef UINT32_T uint32_T; +#endif + +/* The following is used to emulate smaller integer types when only + * larger types are available. For example, compilers for TI C3x/C4x DSPs + * define char and short to be 32 bits, so 8 and 16 bits are not directly + * available. This target is commonly used with RTW rapid prototyping. + * Other DSPs define char to be 16 bits, so 8 bits is not directly + * available. + */ +#ifndef INT8_T +# ifdef INT16_T +# define INT8_T INT16_T + typedef INT8_T int8_T; +# else +# ifdef INT32_T +# define INT8_T INT32_T + typedef INT8_T int8_T; +# endif +# endif +#endif + +#ifndef UINT8_T +# ifdef UINT16_T +# define UINT8_T UINT16_T + typedef UINT8_T uint8_T; +# else +# ifdef UINT32_T +# define UINT8_T UINT32_T + typedef UINT8_T uint8_T; +# endif +# endif +#endif + +#ifndef INT16_T +# ifdef INT32_T +# define INT16_T INT32_T + typedef INT16_T int16_T; +# endif +#endif + +#ifndef UINT16_T +# ifdef UINT32_T +# define UINT16_T UINT32_T + typedef UINT16_T uint16_T; +# endif +#endif + + +#ifndef NO_FLOATS + +#ifndef REAL32_T +# ifndef __MWERKS__ +# if FLT_MANT_DIG >= 23 +# define REAL32_T float +# endif +# else +# define REAL32_T float +# endif +#endif +#ifdef REAL32_T + typedef REAL32_T real32_T; +#endif + + +#ifndef REAL64_T +# ifndef __MWERKS__ +# if DBL_MANT_DIG >= 52 +# define REAL64_T double +# endif +# else +# define REAL64_T double +# endif +#endif +#ifdef REAL64_T + typedef REAL64_T real64_T; +#endif + +#endif /* NO_FLOATS*/ + +/*=======================================================================* + * Fixed width word size data types: * + * int64_T - signed 64 bit integers * + * uint64_T - unsigned 64 bit integers * + *=======================================================================*/ + +# if defined(MW_LIBTOOLING) +# ifdef INT64_T +# undef INT64_T +# endif +# define INT64_T int64_t +# ifdef UINT64_T +# undef UINT64_T +# endif +# define UINT64_T uint64_t +# endif +#if !defined(INT64_T) || !defined(UINT64_T) || !defined(FMT64) +# if defined(__APPLE__) || defined(__clang__) +# ifndef INT64_T +# define INT64_T long long +# endif +# ifndef UINT64_T +# define UINT64_T unsigned long long +# endif +# ifndef FMT64 +# define FMT64 "ll" +# endif +# if defined(__LP64__) && !defined(INT_TYPE_64_IS_LONG) +# define INT_TYPE_64_IS_LONG +# endif +# elif (defined(__x86_64__) || defined(__LP64__))&& !defined(__MINGW64__) +# ifndef INT64_T +# define INT64_T long +# endif +# ifndef UINT64_T +# define UINT64_T unsigned long +# endif +# ifndef FMT64 +# define FMT64 "l" +# endif +# if !defined(INT_TYPE_64_IS_LONG) +# define INT_TYPE_64_IS_LONG +# endif +# elif defined(_MSC_VER) || (defined(__BORLANDC__) && __BORLANDC__ >= 0x530) \ + || (defined(__WATCOMC__) && __WATCOMC__ >= 1100) +# ifndef INT64_T +# define INT64_T __int64 +# endif +# ifndef UINT64_T +# define UINT64_T unsigned __int64 +# endif +# ifndef FMT64 +# define FMT64 "I64" +# endif +# elif defined(__GNUC__) || defined(TMW_ENABLE_INT64) \ + || defined(__LCC64__) +# ifndef INT64_T +# define INT64_T long long +# endif +# ifndef UINT64_T +# define UINT64_T unsigned long long +# endif +# ifndef FMT64 +# define FMT64 "ll" +# endif +# endif + +#endif + +#if defined(INT64_T) +# if defined(__GNUC__) && \ + ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >=9))) + __extension__ +# endif + typedef INT64_T int64_T; +#endif + +#if defined(_WIN64) || (defined(__APPLE__) && defined(__LP64__)) \ + || defined(__x86_64__) \ + || defined(__LP64__) +# define INT_TYPE_64_IS_SUPPORTED +#endif + +#if defined(UINT64_T) +# if defined(__GNUC__) && \ + ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >=9))) + __extension__ +# endif + typedef UINT64_T uint64_T; +#endif + +/*===========================================================================* + * Format string modifiers for using size_t variables in printf statements. * + *===========================================================================*/ + +#ifndef FMT_SIZE_T +# if (defined( __GNUC__ ) || defined(_STDC_C99))&& !defined(__MINGW64__) +# define FMT_SIZE_T "z" +# elif defined (__WATCOMC__) +# define FMT_SIZE_T "l" +# elif defined (_WIN32 ) +# define FMT_SIZE_T "I" +# else +# define FMT_SIZE_T "l" +# endif +#endif + +#ifndef FMT_PTRDIFF_T +# if defined(__APPLE__) +# define FMT_PTRDIFF_T "l" +# elif defined( __GNUC__ ) || defined(_STDC_C99) +# define FMT_PTRDIFF_T "t" +# elif defined (__WATCOMC__) +# define FMT_PTRDIFF_T "l" +# elif defined (_WIN32 ) +# define FMT_PTRDIFF_T "I" +# else +# define FMT_PTRDIFF_T "l" +# endif +#endif + +/*===========================================================================* + * General or logical data types where the word size is not guaranteed. * + * real_T - possible settings include real32_T or real64_T * + * time_T - possible settings include real32_T or real64_T * + * boolean_T * + * char_T * + * int_T * + * uint_T * + * byte_T * + *===========================================================================*/ + +#ifndef NO_FLOATS + +#ifndef REAL_T +# ifdef REAL64_T +# define REAL_T real64_T +# else +# ifdef REAL32_T +# define REAL_T real32_T +# endif +# endif +#endif +#ifdef REAL_T + typedef REAL_T real_T; +#endif + +#ifndef TIME_T +# ifdef REAL_T +# define TIME_T real_T +# endif +#endif +#ifdef TIME_T + typedef TIME_T time_T; +#endif + +#endif /* NO_FLOATS */ + +#ifndef BOOLEAN_T +# if defined(UINT8_T) +# define BOOLEAN_T UINT8_T +# else +# define BOOLEAN_T unsigned int +# endif +#endif +typedef BOOLEAN_T boolean_T; + + +#ifndef CHARACTER_T +# define CHARACTER_T char +#endif +typedef CHARACTER_T char_T; + + +#ifndef INTEGER_T +# define INTEGER_T int +#endif +typedef INTEGER_T int_T; + + +#ifndef UINTEGER_T +# define UINTEGER_T unsigned +#endif +typedef UINTEGER_T uint_T; + + +#ifndef BYTE_T +# define BYTE_T unsigned char +#endif +typedef BYTE_T byte_T; + + +/*===========================================================================* + * Define Complex Structures * + *===========================================================================*/ +#ifndef NO_FLOATS + +#ifndef CREAL32_T +# ifdef REAL32_T + typedef struct { + real32_T re, im; + } creal32_T; +# define CREAL32_T creal32_T +# endif +#endif + +#ifndef CREAL64_T +# ifdef REAL64_T + typedef struct { + real64_T re, im; + } creal64_T; +# define CREAL64_T creal64_T +# endif +#endif + +#ifndef CREAL_T +# ifdef REAL_T + typedef struct { + real_T re, im; + } creal_T; +# define CREAL_T creal_T +# endif +#endif + +#endif /* NO_FLOATS */ + +#ifndef CINT8_T +# ifdef INT8_T + typedef struct { + int8_T re, im; + } cint8_T; +# define CINT8_T cint8_T +# endif +#endif + +#ifndef CUINT8_T +# ifdef UINT8_T + typedef struct { + uint8_T re, im; + } cuint8_T; +# define CUINT8_T cuint8_T +# endif +#endif + +#ifndef CINT16_T +# ifdef INT16_T + typedef struct { + int16_T re, im; + } cint16_T; +# define CINT16_T cint16_T +# endif +#endif + +#ifndef CUINT16_T +# ifdef UINT16_T + typedef struct { + uint16_T re, im; + } cuint16_T; +# define CUINT16_T cuint16_T +# endif +#endif + +#ifndef CINT32_T +# ifdef INT32_T + typedef struct { + int32_T re, im; + } cint32_T; +# define CINT32_T cint32_T +# endif +#endif + +#ifndef CUINT32_T +# ifdef UINT32_T + typedef struct { + uint32_T re, im; + } cuint32_T; +# define CUINT32_T cuint32_T +# endif +#endif + +#ifndef CINT64_T +# ifdef INT64_T + typedef struct { + int64_T re, im; + } cint64_T; +# define CINT64_T cint64_T +# endif +#endif + +#ifndef CUINT64_T +# ifdef UINT64_T + typedef struct { + uint64_T re, im; + } cuint64_T; +# define CUINT64_T cuint64_T +# endif +#endif + +/*=======================================================================* + * Min and Max: * + * int8_T, int16_T, int32_T - signed 8, 16, or 32 bit integers * + * uint8_T, uint16_T, uint32_T - unsigned 8, 16, or 32 bit integers * + *=======================================================================*/ + +#define MAX_int8_T ((int8_T)(127)) /* 127 */ +#define MIN_int8_T ((int8_T)(-128)) /* -128 */ +#define MAX_uint8_T ((uint8_T)(255)) /* 255 */ +#define MIN_uint8_T ((uint8_T)(0)) + +#define MAX_int16_T ((int16_T)(32767)) /* 32767 */ +#define MIN_int16_T ((int16_T)(-32768)) /* -32768 */ +#define MAX_uint16_T ((uint16_T)(65535)) /* 65535 */ +#define MIN_uint16_T ((uint16_T)(0)) + +#define MAX_int32_T ((int32_T)(2147483647)) /* 2147483647 */ +#define MIN_int32_T ((int32_T)(-2147483647-1)) /* -2147483648 */ +#define MAX_uint32_T ((uint32_T)(0xFFFFFFFFU)) /* 4294967295 */ +#define MIN_uint32_T ((uint32_T)(0)) + +#if defined(_MSC_VER) || (defined(__BORLANDC__) && __BORLANDC__ >= 0x530) \ + || (defined(__WATCOMC__) && __WATCOMC__ >= 1100) \ + || defined(__LCC64__) +# ifdef INT64_T +# define MAX_int64_T ((int64_T)(9223372036854775807LL)) +# define MIN_int64_T ((int64_T)(-9223372036854775807LL-1LL)) +# endif +# ifdef UINT64_T +# define MAX_uint64_T ((uint64_T)(0xFFFFFFFFFFFFFFFFULL)) +# define MIN_uint64_T ((uint64_T)(0)) +# endif +#else +# ifdef INT64_T +# ifdef INT_TYPE_64_IS_LONG +# define MAX_int64_T ((int64_T)(9223372036854775807L)) +# define MIN_int64_T ((int64_T)(-9223372036854775807L-1L)) +# else +# define MAX_int64_T ((int64_T)(9223372036854775807LL)) +# define MIN_int64_T ((int64_T)(-9223372036854775807LL-1LL)) +# endif +# endif +# ifdef UINT64_T +# ifdef INT_TYPE_64_IS_LONG +# define MAX_uint64_T ((uint64_T)(0xFFFFFFFFFFFFFFFFUL)) +# define MIN_uint64_T ((uint64_T)(0)) +# else +# define MAX_uint64_T ((uint64_T)(0xFFFFFFFFFFFFFFFFULL)) +# define MIN_uint64_T ((uint64_T)(0)) +# endif +# endif +#endif + +#if (defined(_MSC_VER) && !defined(__clang__)) + +/* Conversion from unsigned __int64 to double is not implemented in Visual Studio + * and results in a compile error, thus the value must first be cast to + * signed __int64, and then to double. + * + * If the 64 bit int value is greater than 2^63-1, which is the signed int64 max, + * the macro below provides a workaround for casting a uint64 value to a double + * in windows. + */ +# define uint64_to_double(u) ( ((u) > _I64_MAX) ? \ + (double)(__int64)((u) - _I64_MAX - 1) + (double)_I64_MAX + 1: \ + (double)(__int64)(u) ) + +/* The following inline function should only be used in the macro double_to_uint64, + * as it only handles the specfic range of double between 2^63 and 2^64-1 */ +__forceinline +uint64_T double_to_uint64_helper(double d) { + union double_to_uint64_union_type { + double dd; + uint64_T i64; + } di; + di.dd = d; + return (((di.i64 & 0x000fffffffffffff) | 0x0010000000000000) << 11); +} + +/* The largest double value that can be cast to uint64 in windows is the + * signed int64 max, which is 2^63-1. The macro below provides + * a workaround for casting large double values to uint64 in windows. + */ +/* The magic number 18446744073709551616.0 is 2^64 */ +/* The magic number 9223372036854775808.0 is 2^63 */ +# define double_to_uint64(d) ( ((d) >= 18446744073709551616.0) ? \ + 0xffffffffffffffffULL : \ + ((d) >= 0.0) ? \ + ((d) >= 9223372036854775808.0) ? \ + double_to_uint64_helper(d) : \ + (unsigned __int64)(d) : \ + 0ULL ) +#else +# define uint64_to_double(u) ((double)(u)) +# if defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__TICCSC__) +/* double_to_uint64 defined only for MSVC and UNIX */ +# else +# define double_to_uint64(d) ( ((d) >= 18446744073709551616.0) ? \ + (unsigned long long) 0xffffffffffffffffULL : \ + ((d) >= 0) ? (unsigned long long)(d) : (unsigned long long) 0 ) +# endif +#endif + +#if !defined(__cplusplus) && !defined(__bool_true_false_are_defined) + +#ifndef _bool_T +#define _bool_T + +typedef boolean_T bool; + +#ifndef false +#define false (0) +#endif +#ifndef true +#define true (1) +#endif + +#endif /* _bool_T */ + +#endif /* !__cplusplus */ + +/* + * This software assumes that the code is being compiled on a target using a + * 2's complement representation for signed integer values. + */ +#if ((SCHAR_MIN + 1) != -SCHAR_MAX) +#error "This code must be compiled using a 2's complement representation for signed integer values" +#endif + +/* + * Maximum length of a MATLAB identifier (function/variable/model) + * including the null-termination character. + */ +#define TMW_NAME_LENGTH_MAX 64 + +/* + * Maximum values for indices and dimensions + */ +#include + +#ifdef MX_COMPAT_32 +typedef int mwSize; +typedef int mwIndex; +typedef int mwSignedIndex; +#else +typedef size_t mwSize; /* unsigned pointer-width integer */ +typedef size_t mwIndex; /* unsigned pointer-width integer */ +typedef ptrdiff_t mwSignedIndex; /* a signed pointer-width integer */ +#endif + + /* for the individual dim */ +/* If updating SLSize or SLIndex, update defintions in sl_types_def.h + as well. */ +#ifndef SLSIZE_SLINDEX + #define SLSIZE_SLINDEX + #ifdef INT_TYPE_64_IS_SUPPORTED + typedef int64_T SLIndex; + typedef int64_T SLSize; + #else + typedef int SLIndex; + typedef int SLSize; + #endif +#endif + +/* for the total size */ +#define SLIndexType size_t +#define INVALID_SIZET_VALUE (std::numeric_limits::max()) +#define MAX_VALID_SIZET_VALUE (std::numeric_limits::max() -1) + + +#if (defined(_LP64) || defined(_WIN64)) && !defined(MX_COMPAT_32) +/* Currently 2^48 based on hardware limitations */ +# define MWSIZE_MAX 281474976710655UL +# define MWINDEX_MAX 281474976710655UL +# define MWSINDEX_MAX 281474976710655L +# define MWSINDEX_MIN -281474976710655L +#else +# define MWSIZE_MAX 2147483647UL +# define MWINDEX_MAX 2147483647UL +# define MWSINDEX_MAX 2147483647L +# define MWSINDEX_MIN -2147483647L +#endif +#define MWSIZE_MIN 0UL +#define MWINDEX_MIN 0UL + +/** UTF-16 character type */ + +#if (defined(__cplusplus) && (__cplusplus >= 201103L)) || (defined(_HAS_CHAR16_T_LANGUAGE_SUPPORT) && _HAS_CHAR16_T_LANGUAGE_SUPPORT) +typedef char16_t CHAR16_T; +#define U16_STRING_LITERAL_PREFIX u +#elif defined(_MSC_VER) +typedef wchar_t CHAR16_T; +#define U16_STRING_LITERAL_PREFIX L +#else +typedef UINT16_T CHAR16_T; +#endif + +#endif /* __TMWTYPES__ */ + +#endif /* tmwtypes_h */ diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt index cb102fd..03a2f57 100644 --- a/libs/CMakeLists.txt +++ b/libs/CMakeLists.txt @@ -1,11 +1,11 @@ -##### Set variables used by XAPP_SDK ##### - -## For E2AP -set(E2AP_VERSION "E2AP_V3" CACHE STRING "E2AP version") - -## For KPM -set(KPM_VERSION "KPM_V3_00" CACHE STRING "The KPM SM version to use") - -##### End set variables used by xapp_sdk ##### - +##### Set variables used by XAPP_SDK ##### + +## For E2AP +set(E2AP_VERSION "E2AP_V3" CACHE STRING "E2AP version") + +## For KPM +set(KPM_VERSION "KPM_V3_00" CACHE STRING "The KPM SM version to use") + +##### End set variables used by xapp_sdk ##### + add_subdirectory(flexric) \ No newline at end of file diff --git a/libs/tabulate/asciidoc_exporter.hpp b/libs/tabulate/asciidoc_exporter.hpp index a49a3b7..bea3d3f 100644 --- a/libs/tabulate/asciidoc_exporter.hpp +++ b/libs/tabulate/asciidoc_exporter.hpp @@ -1,140 +1,140 @@ - -/* - __ ___. .__ __ -_/ |______ \_ |__ __ __| | _____ _/ |_ ____ -\ __\__ \ | __ \| | \ | \__ \\ __\/ __ \ - | | / __ \| \_\ \ | / |__/ __ \| | \ ___/ - |__| (____ /___ /____/|____(____ /__| \___ > - \/ \/ \/ \/ -Table Maker for Modern C++ -https://github.com/p-ranav/tabulate - -Licensed under the MIT License . -SPDX-License-Identifier: MIT -Copyright (c) 2019 Pranav Srinivas Kumar . - -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. -*/ -#pragma once -#include -#include -#include -#include -#include - -namespace tabulate { - -class AsciiDocExporter : public Exporter { - - static const char new_line = '\n'; - -public: - std::string dump(Table &table) override { - std::stringstream ss; - ss << add_alignment_header(table); - ss << new_line; - - const auto rows = table.rows_; - // iterate content and put text into the table. - for (size_t row_index = 0; row_index < rows; row_index++) { - auto &row = table[row_index]; - - for (size_t cell_index = 0; cell_index < row.size(); cell_index++) { - ss << "|"; - ss << add_formatted_cell(row[cell_index]); - } - ss << new_line; - if (row_index == 0) { - ss << new_line; - } - } - - ss << "|==="; - return ss.str(); - } - - virtual ~AsciiDocExporter() {} - -private: - std::string add_formatted_cell(Cell &cell) const { - std::stringstream ss; - auto format = cell.format(); - std::string cell_string = cell.get_text(); - - auto font_style = format.font_style_.value(); - - bool format_bold = false; - bool format_italic = false; - std::for_each(font_style.begin(), font_style.end(), [&](FontStyle &style) { - if (style == FontStyle::bold) { - format_bold = true; - } else if (style == FontStyle::italic) { - format_italic = true; - } - }); - - if (format_bold) { - ss << '*'; - } - if (format_italic) { - ss << '_'; - } - - ss << cell_string; - if (format_italic) { - ss << '_'; - } - if (format_bold) { - ss << '*'; - } - return ss.str(); - } - - std::string add_alignment_header(Table &table) { - std::stringstream ss; - ss << (R"([cols=")"); - - size_t column_count = table[0].size(); - size_t column_index = 0; - for (auto &cell : table[0]) { - auto format = cell.format(); - - if (format.font_align_.value() == FontAlign::left) { - ss << '<'; - } else if (format.font_align_.value() == FontAlign::center) { - ss << '^'; - } else if (format.font_align_.value() == FontAlign::right) { - ss << '>'; - } - - ++column_index; - if (column_index != column_count) { - ss << ","; - } - } - - ss << R"("])"; - ss << new_line; - ss << "|==="; - - return ss.str(); - } -}; - -} // namespace tabulate + +/* + __ ___. .__ __ +_/ |______ \_ |__ __ __| | _____ _/ |_ ____ +\ __\__ \ | __ \| | \ | \__ \\ __\/ __ \ + | | / __ \| \_\ \ | / |__/ __ \| | \ ___/ + |__| (____ /___ /____/|____(____ /__| \___ > + \/ \/ \/ \/ +Table Maker for Modern C++ +https://github.com/p-ranav/tabulate + +Licensed under the MIT License . +SPDX-License-Identifier: MIT +Copyright (c) 2019 Pranav Srinivas Kumar . + +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. +*/ +#pragma once +#include +#include +#include +#include +#include + +namespace tabulate { + +class AsciiDocExporter : public Exporter { + + static const char new_line = '\n'; + +public: + std::string dump(Table &table) override { + std::stringstream ss; + ss << add_alignment_header(table); + ss << new_line; + + const auto rows = table.rows_; + // iterate content and put text into the table. + for (size_t row_index = 0; row_index < rows; row_index++) { + auto &row = table[row_index]; + + for (size_t cell_index = 0; cell_index < row.size(); cell_index++) { + ss << "|"; + ss << add_formatted_cell(row[cell_index]); + } + ss << new_line; + if (row_index == 0) { + ss << new_line; + } + } + + ss << "|==="; + return ss.str(); + } + + virtual ~AsciiDocExporter() {} + +private: + std::string add_formatted_cell(Cell &cell) const { + std::stringstream ss; + auto format = cell.format(); + std::string cell_string = cell.get_text(); + + auto font_style = format.font_style_.value(); + + bool format_bold = false; + bool format_italic = false; + std::for_each(font_style.begin(), font_style.end(), [&](FontStyle &style) { + if (style == FontStyle::bold) { + format_bold = true; + } else if (style == FontStyle::italic) { + format_italic = true; + } + }); + + if (format_bold) { + ss << '*'; + } + if (format_italic) { + ss << '_'; + } + + ss << cell_string; + if (format_italic) { + ss << '_'; + } + if (format_bold) { + ss << '*'; + } + return ss.str(); + } + + std::string add_alignment_header(Table &table) { + std::stringstream ss; + ss << (R"([cols=")"); + + size_t column_count = table[0].size(); + size_t column_index = 0; + for (auto &cell : table[0]) { + auto format = cell.format(); + + if (format.font_align_.value() == FontAlign::left) { + ss << '<'; + } else if (format.font_align_.value() == FontAlign::center) { + ss << '^'; + } else if (format.font_align_.value() == FontAlign::right) { + ss << '>'; + } + + ++column_index; + if (column_index != column_count) { + ss << ","; + } + } + + ss << R"("])"; + ss << new_line; + ss << "|==="; + + return ss.str(); + } +}; + +} // namespace tabulate diff --git a/libs/tabulate/cell.hpp b/libs/tabulate/cell.hpp index c4618e3..b44deea 100644 --- a/libs/tabulate/cell.hpp +++ b/libs/tabulate/cell.hpp @@ -1,77 +1,77 @@ - -/* - __ ___. .__ __ -_/ |______ \_ |__ __ __| | _____ _/ |_ ____ -\ __\__ \ | __ \| | \ | \__ \\ __\/ __ \ - | | / __ \| \_\ \ | / |__/ __ \| | \ ___/ - |__| (____ /___ /____/|____(____ /__| \___ > - \/ \/ \/ \/ -Table Maker for Modern C++ -https://github.com/p-ranav/tabulate - -Licensed under the MIT License . -SPDX-License-Identifier: MIT -Copyright (c) 2019 Pranav Srinivas Kumar . - -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. -*/ -#pragma once -#include -#include -#include -#include -#include - -#if __cplusplus >= 201703L -#include -using std::optional; -#else -#include -using nonstd::optional; -#endif - -#include - -namespace tabulate { - -class Cell { -public: - explicit Cell(std::shared_ptr parent) : parent_(parent) {} - - void set_text(const std::string &text) { data_ = text; } - - const std::string &get_text() { return data_; } - - size_t size() { - return get_sequence_length(data_, locale(), is_multi_byte_character_support_enabled()); - } - - std::string locale() { return *format().locale_; } - - Format &format(); - - bool is_multi_byte_character_support_enabled(); - -private: - std::string data_; - std::weak_ptr parent_; - optional format_; -}; - -} // namespace tabulate + +/* + __ ___. .__ __ +_/ |______ \_ |__ __ __| | _____ _/ |_ ____ +\ __\__ \ | __ \| | \ | \__ \\ __\/ __ \ + | | / __ \| \_\ \ | / |__/ __ \| | \ ___/ + |__| (____ /___ /____/|____(____ /__| \___ > + \/ \/ \/ \/ +Table Maker for Modern C++ +https://github.com/p-ranav/tabulate + +Licensed under the MIT License . +SPDX-License-Identifier: MIT +Copyright (c) 2019 Pranav Srinivas Kumar . + +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. +*/ +#pragma once +#include +#include +#include +#include +#include + +#if __cplusplus >= 201703L +#include +using std::optional; +#else +#include +using nonstd::optional; +#endif + +#include + +namespace tabulate { + +class Cell { +public: + explicit Cell(std::shared_ptr parent) : parent_(parent) {} + + void set_text(const std::string &text) { data_ = text; } + + const std::string &get_text() { return data_; } + + size_t size() { + return get_sequence_length(data_, locale(), is_multi_byte_character_support_enabled()); + } + + std::string locale() { return *format().locale_; } + + Format &format(); + + bool is_multi_byte_character_support_enabled(); + +private: + std::string data_; + std::weak_ptr parent_; + optional format_; +}; + +} // namespace tabulate diff --git a/libs/tabulate/color.hpp b/libs/tabulate/color.hpp index 621e616..5ec2f7e 100644 --- a/libs/tabulate/color.hpp +++ b/libs/tabulate/color.hpp @@ -1,40 +1,40 @@ - -/* - __ ___. .__ __ -_/ |______ \_ |__ __ __| | _____ _/ |_ ____ -\ __\__ \ | __ \| | \ | \__ \\ __\/ __ \ - | | / __ \| \_\ \ | / |__/ __ \| | \ ___/ - |__| (____ /___ /____/|____(____ /__| \___ > - \/ \/ \/ \/ -Table Maker for Modern C++ -https://github.com/p-ranav/tabulate - -Licensed under the MIT License . -SPDX-License-Identifier: MIT -Copyright (c) 2019 Pranav Srinivas Kumar . - -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. -*/ -#pragma once -#include - -namespace tabulate { - -enum class Color { none, grey, red, green, yellow, blue, magenta, cyan, white }; -} + +/* + __ ___. .__ __ +_/ |______ \_ |__ __ __| | _____ _/ |_ ____ +\ __\__ \ | __ \| | \ | \__ \\ __\/ __ \ + | | / __ \| \_\ \ | / |__/ __ \| | \ ___/ + |__| (____ /___ /____/|____(____ /__| \___ > + \/ \/ \/ \/ +Table Maker for Modern C++ +https://github.com/p-ranav/tabulate + +Licensed under the MIT License . +SPDX-License-Identifier: MIT +Copyright (c) 2019 Pranav Srinivas Kumar . + +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. +*/ +#pragma once +#include + +namespace tabulate { + +enum class Color { none, grey, red, green, yellow, blue, magenta, cyan, white }; +} diff --git a/libs/tabulate/column.hpp b/libs/tabulate/column.hpp index 4e5859c..70b3c2e 100644 --- a/libs/tabulate/column.hpp +++ b/libs/tabulate/column.hpp @@ -1,385 +1,385 @@ - -/* - __ ___. .__ __ -_/ |______ \_ |__ __ __| | _____ _/ |_ ____ -\ __\__ \ | __ \| | \ | \__ \\ __\/ __ \ - | | / __ \| \_\ \ | / |__/ __ \| | \ ___/ - |__| (____ /___ /____/|____(____ /__| \___ > - \/ \/ \/ \/ -Table Maker for Modern C++ -https://github.com/p-ranav/tabulate - -Licensed under the MIT License . -SPDX-License-Identifier: MIT -Copyright (c) 2019 Pranav Srinivas Kumar . - -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. -*/ -#pragma once -#include -#include -#include -#include - -#if __cplusplus >= 201703L -#include -using std::optional; -#else -#include -using nonstd::optional; -#endif - -#include -#include -#include -#include -#ifdef max -#undef max -#endif -#ifdef min -#undef min -#endif - -namespace tabulate { - -class Column { -public: - explicit Column(std::shared_ptr parent) : parent_(parent) {} - - void add_cell(Cell &cell) { cells_.push_back(cell); } - - Cell &operator[](size_t index) { return cells_[index]; } - - std::vector> cells() const { return cells_; } - - size_t size() const { return cells_.size(); } - - ColumnFormat format() { return ColumnFormat(*this); } - - class CellIterator { - public: - explicit CellIterator(std::vector>::iterator ptr) : ptr(ptr) {} - - CellIterator operator++() { - ++ptr; - return *this; - } - bool operator!=(const CellIterator &other) const { return ptr != other.ptr; } - Cell &operator*() { return *ptr; } - - private: - std::vector>::iterator ptr; - }; - - auto begin() -> CellIterator { return CellIterator(cells_.begin()); } - auto end() -> CellIterator { return CellIterator(cells_.end()); } - -private: - friend class ColumnFormat; - friend class Printer; - - // Returns the column width as configured - // For each cell in the column, check the cell.format.width - // property and return the largest configured column width - // This is used to ensure that all cells in a column are - // aligned when printing the column - size_t get_configured_width() { - size_t result{0}; - for (size_t i = 0; i < size(); ++i) { - auto cell = cells_[i]; - auto format = cell.get().format(); - if (format.width_.has_value()) - result = std::max(result, *format.width_); - } - return result; - } - - // Computes the width of the column based on cell contents - // and configured cell padding - // For each cell, compute padding_left + cell_contents + padding_right - // and return the largest value - // - // This is useful when no cell.format.width is configured - // Call get_configured_width() - // - If this returns 0, then use get_computed_width() - size_t get_computed_width() { - size_t result{0}; - for (size_t i = 0; i < size(); ++i) { - result = std::max(result, get_cell_width(i)); - } - return result; - } - - // Returns padding_left + cell_contents.size() + padding_right - // for a given cell in the column - size_t get_cell_width(size_t cell_index) { - size_t result{0}; - Cell &cell = cells_[cell_index].get(); - auto format = cell.format(); - if (format.padding_left_.has_value()) - result += *format.padding_left_; - - // Check if input text has newlines - auto text = cell.get_text(); - auto split_lines = Format::split_lines(text, "\n", cell.locale(), - cell.is_multi_byte_character_support_enabled()); - - // If there are no newlines in input, set column_width = text.size() - if (split_lines.size() == 1) { - result += cell.size(); - } else { - // There are newlines in input - // Find widest substring in input and use this as column_width - size_t widest_sub_string_size{0}; - for (auto &line : split_lines) - if (get_sequence_length(line, cell.locale(), - cell.is_multi_byte_character_support_enabled()) > - widest_sub_string_size) - widest_sub_string_size = get_sequence_length( - line, cell.locale(), cell.is_multi_byte_character_support_enabled()); - result += widest_sub_string_size; - } - - if (format.padding_right_.has_value()) - result += *format.padding_right_; - - return result; - } - - std::vector> cells_; - std::weak_ptr parent_; -}; - -inline ColumnFormat &ColumnFormat::width(size_t value) { - for (auto &cell : column_.get().cells_) - cell.get().format().width(value); - return *this; -} - -inline ColumnFormat &ColumnFormat::height(size_t value) { - for (auto &cell : column_.get().cells_) - cell.get().format().height(value); - return *this; -} - -inline ColumnFormat &ColumnFormat::padding(size_t value) { - for (auto &cell : column_.get().cells_) - cell.get().format().padding(value); - return *this; -} - -inline ColumnFormat &ColumnFormat::padding_left(size_t value) { - for (auto &cell : column_.get().cells_) - cell.get().format().padding_left(value); - return *this; -} - -inline ColumnFormat &ColumnFormat::padding_right(size_t value) { - for (auto &cell : column_.get().cells_) - cell.get().format().padding_right(value); - return *this; -} - -inline ColumnFormat &ColumnFormat::padding_top(size_t value) { - for (auto &cell : column_.get().cells_) - cell.get().format().padding_top(value); - return *this; -} - -inline ColumnFormat &ColumnFormat::padding_bottom(size_t value) { - for (auto &cell : column_.get().cells_) - cell.get().format().padding_bottom(value); - return *this; -} - -inline ColumnFormat &ColumnFormat::border(const std::string &value) { - for (auto &cell : column_.get().cells_) - cell.get().format().border(value); - return *this; -} - -inline ColumnFormat &ColumnFormat::border_color(Color value) { - for (auto &cell : column_.get().cells_) - cell.get().format().border_color(value); - return *this; -} - -inline ColumnFormat &ColumnFormat::border_background_color(Color value) { - for (auto &cell : column_.get().cells_) - cell.get().format().border_background_color(value); - return *this; -} - -inline ColumnFormat &ColumnFormat::border_left(const std::string &value) { - for (auto &cell : column_.get().cells_) - cell.get().format().border_left(value); - return *this; -} - -inline ColumnFormat &ColumnFormat::border_left_color(Color value) { - for (auto &cell : column_.get().cells_) - cell.get().format().border_left_color(value); - return *this; -} - -inline ColumnFormat &ColumnFormat::border_left_background_color(Color value) { - for (auto &cell : column_.get().cells_) - cell.get().format().border_left_background_color(value); - return *this; -} - -inline ColumnFormat &ColumnFormat::border_right(const std::string &value) { - for (auto &cell : column_.get().cells_) - cell.get().format().border_right(value); - return *this; -} - -inline ColumnFormat &ColumnFormat::border_right_color(Color value) { - for (auto &cell : column_.get().cells_) - cell.get().format().border_right_color(value); - return *this; -} - -inline ColumnFormat &ColumnFormat::border_right_background_color(Color value) { - for (auto &cell : column_.get().cells_) - cell.get().format().border_right_background_color(value); - return *this; -} - -inline ColumnFormat &ColumnFormat::border_top(const std::string &value) { - for (auto &cell : column_.get().cells_) - cell.get().format().border_top(value); - return *this; -} - -inline ColumnFormat &ColumnFormat::border_top_color(Color value) { - for (auto &cell : column_.get().cells_) - cell.get().format().border_top_color(value); - return *this; -} - -inline ColumnFormat &ColumnFormat::border_top_background_color(Color value) { - for (auto &cell : column_.get().cells_) - cell.get().format().border_top_background_color(value); - return *this; -} - -inline ColumnFormat &ColumnFormat::border_bottom(const std::string &value) { - for (auto &cell : column_.get().cells_) - cell.get().format().border_bottom(value); - return *this; -} - -inline ColumnFormat &ColumnFormat::border_bottom_color(Color value) { - for (auto &cell : column_.get().cells_) - cell.get().format().border_bottom_color(value); - return *this; -} - -inline ColumnFormat &ColumnFormat::border_bottom_background_color(Color value) { - for (auto &cell : column_.get().cells_) - cell.get().format().border_bottom_background_color(value); - return *this; -} - -inline ColumnFormat &ColumnFormat::corner(const std::string &value) { - for (auto &cell : column_.get().cells_) - cell.get().format().corner(value); - return *this; -} - -inline ColumnFormat &ColumnFormat::corner_color(Color value) { - for (auto &cell : column_.get().cells_) - cell.get().format().corner_color(value); - return *this; -} - -inline ColumnFormat &ColumnFormat::corner_background_color(Color value) { - for (auto &cell : column_.get().cells_) - cell.get().format().corner_background_color(value); - return *this; -} - -inline ColumnFormat &ColumnFormat::column_separator(const std::string &value) { - for (auto &cell : column_.get().cells_) - cell.get().format().column_separator(value); - return *this; -} - -inline ColumnFormat &ColumnFormat::column_separator_color(Color value) { - for (auto &cell : column_.get().cells_) - cell.get().format().column_separator_color(value); - return *this; -} - -inline ColumnFormat &ColumnFormat::column_separator_background_color(Color value) { - for (auto &cell : column_.get().cells_) - cell.get().format().column_separator_background_color(value); - return *this; -} - -inline ColumnFormat &ColumnFormat::font_align(FontAlign value) { - for (auto &cell : column_.get().cells_) - cell.get().format().font_align(value); - return *this; -} - -inline ColumnFormat &ColumnFormat::font_style(const std::vector &style) { - for (auto &cell : column_.get().cells_) - cell.get().format().font_style(style); - return *this; -} - -inline ColumnFormat &ColumnFormat::font_color(Color value) { - for (auto &cell : column_.get().cells_) - cell.get().format().font_color(value); - return *this; -} - -inline ColumnFormat &ColumnFormat::font_background_color(Color value) { - for (auto &cell : column_.get().cells_) - cell.get().format().font_background_color(value); - return *this; -} - -inline ColumnFormat &ColumnFormat::color(Color value) { - for (auto &cell : column_.get().cells_) - cell.get().format().color(value); - return *this; -} - -inline ColumnFormat &ColumnFormat::background_color(Color value) { - for (auto &cell : column_.get().cells_) - cell.get().format().background_color(value); - return *this; -} - -inline ColumnFormat &ColumnFormat::multi_byte_characters(bool value) { - for (auto &cell : column_.get().cells_) - cell.get().format().multi_byte_characters(value); - return *this; -} - -inline ColumnFormat &ColumnFormat::locale(const std::string &value) { - for (auto &cell : column_.get().cells_) - cell.get().format().locale(value); - return *this; -} - -} // namespace tabulate + +/* + __ ___. .__ __ +_/ |______ \_ |__ __ __| | _____ _/ |_ ____ +\ __\__ \ | __ \| | \ | \__ \\ __\/ __ \ + | | / __ \| \_\ \ | / |__/ __ \| | \ ___/ + |__| (____ /___ /____/|____(____ /__| \___ > + \/ \/ \/ \/ +Table Maker for Modern C++ +https://github.com/p-ranav/tabulate + +Licensed under the MIT License . +SPDX-License-Identifier: MIT +Copyright (c) 2019 Pranav Srinivas Kumar . + +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. +*/ +#pragma once +#include +#include +#include +#include + +#if __cplusplus >= 201703L +#include +using std::optional; +#else +#include +using nonstd::optional; +#endif + +#include +#include +#include +#include +#ifdef max +#undef max +#endif +#ifdef min +#undef min +#endif + +namespace tabulate { + +class Column { +public: + explicit Column(std::shared_ptr parent) : parent_(parent) {} + + void add_cell(Cell &cell) { cells_.push_back(cell); } + + Cell &operator[](size_t index) { return cells_[index]; } + + std::vector> cells() const { return cells_; } + + size_t size() const { return cells_.size(); } + + ColumnFormat format() { return ColumnFormat(*this); } + + class CellIterator { + public: + explicit CellIterator(std::vector>::iterator ptr) : ptr(ptr) {} + + CellIterator operator++() { + ++ptr; + return *this; + } + bool operator!=(const CellIterator &other) const { return ptr != other.ptr; } + Cell &operator*() { return *ptr; } + + private: + std::vector>::iterator ptr; + }; + + auto begin() -> CellIterator { return CellIterator(cells_.begin()); } + auto end() -> CellIterator { return CellIterator(cells_.end()); } + +private: + friend class ColumnFormat; + friend class Printer; + + // Returns the column width as configured + // For each cell in the column, check the cell.format.width + // property and return the largest configured column width + // This is used to ensure that all cells in a column are + // aligned when printing the column + size_t get_configured_width() { + size_t result{0}; + for (size_t i = 0; i < size(); ++i) { + auto cell = cells_[i]; + auto format = cell.get().format(); + if (format.width_.has_value()) + result = std::max(result, *format.width_); + } + return result; + } + + // Computes the width of the column based on cell contents + // and configured cell padding + // For each cell, compute padding_left + cell_contents + padding_right + // and return the largest value + // + // This is useful when no cell.format.width is configured + // Call get_configured_width() + // - If this returns 0, then use get_computed_width() + size_t get_computed_width() { + size_t result{0}; + for (size_t i = 0; i < size(); ++i) { + result = std::max(result, get_cell_width(i)); + } + return result; + } + + // Returns padding_left + cell_contents.size() + padding_right + // for a given cell in the column + size_t get_cell_width(size_t cell_index) { + size_t result{0}; + Cell &cell = cells_[cell_index].get(); + auto format = cell.format(); + if (format.padding_left_.has_value()) + result += *format.padding_left_; + + // Check if input text has newlines + auto text = cell.get_text(); + auto split_lines = Format::split_lines(text, "\n", cell.locale(), + cell.is_multi_byte_character_support_enabled()); + + // If there are no newlines in input, set column_width = text.size() + if (split_lines.size() == 1) { + result += cell.size(); + } else { + // There are newlines in input + // Find widest substring in input and use this as column_width + size_t widest_sub_string_size{0}; + for (auto &line : split_lines) + if (get_sequence_length(line, cell.locale(), + cell.is_multi_byte_character_support_enabled()) > + widest_sub_string_size) + widest_sub_string_size = get_sequence_length( + line, cell.locale(), cell.is_multi_byte_character_support_enabled()); + result += widest_sub_string_size; + } + + if (format.padding_right_.has_value()) + result += *format.padding_right_; + + return result; + } + + std::vector> cells_; + std::weak_ptr parent_; +}; + +inline ColumnFormat &ColumnFormat::width(size_t value) { + for (auto &cell : column_.get().cells_) + cell.get().format().width(value); + return *this; +} + +inline ColumnFormat &ColumnFormat::height(size_t value) { + for (auto &cell : column_.get().cells_) + cell.get().format().height(value); + return *this; +} + +inline ColumnFormat &ColumnFormat::padding(size_t value) { + for (auto &cell : column_.get().cells_) + cell.get().format().padding(value); + return *this; +} + +inline ColumnFormat &ColumnFormat::padding_left(size_t value) { + for (auto &cell : column_.get().cells_) + cell.get().format().padding_left(value); + return *this; +} + +inline ColumnFormat &ColumnFormat::padding_right(size_t value) { + for (auto &cell : column_.get().cells_) + cell.get().format().padding_right(value); + return *this; +} + +inline ColumnFormat &ColumnFormat::padding_top(size_t value) { + for (auto &cell : column_.get().cells_) + cell.get().format().padding_top(value); + return *this; +} + +inline ColumnFormat &ColumnFormat::padding_bottom(size_t value) { + for (auto &cell : column_.get().cells_) + cell.get().format().padding_bottom(value); + return *this; +} + +inline ColumnFormat &ColumnFormat::border(const std::string &value) { + for (auto &cell : column_.get().cells_) + cell.get().format().border(value); + return *this; +} + +inline ColumnFormat &ColumnFormat::border_color(Color value) { + for (auto &cell : column_.get().cells_) + cell.get().format().border_color(value); + return *this; +} + +inline ColumnFormat &ColumnFormat::border_background_color(Color value) { + for (auto &cell : column_.get().cells_) + cell.get().format().border_background_color(value); + return *this; +} + +inline ColumnFormat &ColumnFormat::border_left(const std::string &value) { + for (auto &cell : column_.get().cells_) + cell.get().format().border_left(value); + return *this; +} + +inline ColumnFormat &ColumnFormat::border_left_color(Color value) { + for (auto &cell : column_.get().cells_) + cell.get().format().border_left_color(value); + return *this; +} + +inline ColumnFormat &ColumnFormat::border_left_background_color(Color value) { + for (auto &cell : column_.get().cells_) + cell.get().format().border_left_background_color(value); + return *this; +} + +inline ColumnFormat &ColumnFormat::border_right(const std::string &value) { + for (auto &cell : column_.get().cells_) + cell.get().format().border_right(value); + return *this; +} + +inline ColumnFormat &ColumnFormat::border_right_color(Color value) { + for (auto &cell : column_.get().cells_) + cell.get().format().border_right_color(value); + return *this; +} + +inline ColumnFormat &ColumnFormat::border_right_background_color(Color value) { + for (auto &cell : column_.get().cells_) + cell.get().format().border_right_background_color(value); + return *this; +} + +inline ColumnFormat &ColumnFormat::border_top(const std::string &value) { + for (auto &cell : column_.get().cells_) + cell.get().format().border_top(value); + return *this; +} + +inline ColumnFormat &ColumnFormat::border_top_color(Color value) { + for (auto &cell : column_.get().cells_) + cell.get().format().border_top_color(value); + return *this; +} + +inline ColumnFormat &ColumnFormat::border_top_background_color(Color value) { + for (auto &cell : column_.get().cells_) + cell.get().format().border_top_background_color(value); + return *this; +} + +inline ColumnFormat &ColumnFormat::border_bottom(const std::string &value) { + for (auto &cell : column_.get().cells_) + cell.get().format().border_bottom(value); + return *this; +} + +inline ColumnFormat &ColumnFormat::border_bottom_color(Color value) { + for (auto &cell : column_.get().cells_) + cell.get().format().border_bottom_color(value); + return *this; +} + +inline ColumnFormat &ColumnFormat::border_bottom_background_color(Color value) { + for (auto &cell : column_.get().cells_) + cell.get().format().border_bottom_background_color(value); + return *this; +} + +inline ColumnFormat &ColumnFormat::corner(const std::string &value) { + for (auto &cell : column_.get().cells_) + cell.get().format().corner(value); + return *this; +} + +inline ColumnFormat &ColumnFormat::corner_color(Color value) { + for (auto &cell : column_.get().cells_) + cell.get().format().corner_color(value); + return *this; +} + +inline ColumnFormat &ColumnFormat::corner_background_color(Color value) { + for (auto &cell : column_.get().cells_) + cell.get().format().corner_background_color(value); + return *this; +} + +inline ColumnFormat &ColumnFormat::column_separator(const std::string &value) { + for (auto &cell : column_.get().cells_) + cell.get().format().column_separator(value); + return *this; +} + +inline ColumnFormat &ColumnFormat::column_separator_color(Color value) { + for (auto &cell : column_.get().cells_) + cell.get().format().column_separator_color(value); + return *this; +} + +inline ColumnFormat &ColumnFormat::column_separator_background_color(Color value) { + for (auto &cell : column_.get().cells_) + cell.get().format().column_separator_background_color(value); + return *this; +} + +inline ColumnFormat &ColumnFormat::font_align(FontAlign value) { + for (auto &cell : column_.get().cells_) + cell.get().format().font_align(value); + return *this; +} + +inline ColumnFormat &ColumnFormat::font_style(const std::vector &style) { + for (auto &cell : column_.get().cells_) + cell.get().format().font_style(style); + return *this; +} + +inline ColumnFormat &ColumnFormat::font_color(Color value) { + for (auto &cell : column_.get().cells_) + cell.get().format().font_color(value); + return *this; +} + +inline ColumnFormat &ColumnFormat::font_background_color(Color value) { + for (auto &cell : column_.get().cells_) + cell.get().format().font_background_color(value); + return *this; +} + +inline ColumnFormat &ColumnFormat::color(Color value) { + for (auto &cell : column_.get().cells_) + cell.get().format().color(value); + return *this; +} + +inline ColumnFormat &ColumnFormat::background_color(Color value) { + for (auto &cell : column_.get().cells_) + cell.get().format().background_color(value); + return *this; +} + +inline ColumnFormat &ColumnFormat::multi_byte_characters(bool value) { + for (auto &cell : column_.get().cells_) + cell.get().format().multi_byte_characters(value); + return *this; +} + +inline ColumnFormat &ColumnFormat::locale(const std::string &value) { + for (auto &cell : column_.get().cells_) + cell.get().format().locale(value); + return *this; +} + +} // namespace tabulate diff --git a/libs/tabulate/column_format.hpp b/libs/tabulate/column_format.hpp index 00e194a..7bf6c14 100644 --- a/libs/tabulate/column_format.hpp +++ b/libs/tabulate/column_format.hpp @@ -1,95 +1,95 @@ - -/* - __ ___. .__ __ -_/ |______ \_ |__ __ __| | _____ _/ |_ ____ -\ __\__ \ | __ \| | \ | \__ \\ __\/ __ \ - | | / __ \| \_\ \ | / |__/ __ \| | \ ___/ - |__| (____ /___ /____/|____(____ /__| \___ > - \/ \/ \/ \/ -Table Maker for Modern C++ -https://github.com/p-ranav/tabulate - -Licensed under the MIT License . -SPDX-License-Identifier: MIT -Copyright (c) 2019 Pranav Srinivas Kumar . - -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. -*/ -#pragma once - -namespace tabulate { - -class ColumnFormat : public Format { -public: - explicit ColumnFormat(class Column &column) : column_(column) {} - - ColumnFormat &width(size_t value); - ColumnFormat &height(size_t value); - - // Padding - ColumnFormat &padding(size_t value); - ColumnFormat &padding_left(size_t value); - ColumnFormat &padding_right(size_t value); - ColumnFormat &padding_top(size_t value); - ColumnFormat &padding_bottom(size_t value); - - // Border - ColumnFormat &border(const std::string &value); - ColumnFormat &border_color(Color value); - ColumnFormat &border_background_color(Color value); - ColumnFormat &border_left(const std::string &value); - ColumnFormat &border_left_color(Color value); - ColumnFormat &border_left_background_color(Color value); - ColumnFormat &border_right(const std::string &value); - ColumnFormat &border_right_color(Color value); - ColumnFormat &border_right_background_color(Color value); - ColumnFormat &border_top(const std::string &value); - ColumnFormat &border_top_color(Color value); - ColumnFormat &border_top_background_color(Color value); - ColumnFormat &border_bottom(const std::string &value); - ColumnFormat &border_bottom_color(Color value); - ColumnFormat &border_bottom_background_color(Color value); - - // Corner - ColumnFormat &corner(const std::string &value); - ColumnFormat &corner_color(Color value); - ColumnFormat &corner_background_color(Color value); - - // Column separator - ColumnFormat &column_separator(const std::string &value); - ColumnFormat &column_separator_color(Color value); - ColumnFormat &column_separator_background_color(Color value); - - // Font styling - ColumnFormat &font_align(FontAlign value); - ColumnFormat &font_style(const std::vector &style); - ColumnFormat &font_color(Color value); - ColumnFormat &font_background_color(Color value); - ColumnFormat &color(Color value); - ColumnFormat &background_color(Color value); - - // Locale - ColumnFormat &multi_byte_characters(bool value); - ColumnFormat &locale(const std::string &value); - -private: - std::reference_wrapper column_; -}; - -} // namespace tabulate + +/* + __ ___. .__ __ +_/ |______ \_ |__ __ __| | _____ _/ |_ ____ +\ __\__ \ | __ \| | \ | \__ \\ __\/ __ \ + | | / __ \| \_\ \ | / |__/ __ \| | \ ___/ + |__| (____ /___ /____/|____(____ /__| \___ > + \/ \/ \/ \/ +Table Maker for Modern C++ +https://github.com/p-ranav/tabulate + +Licensed under the MIT License . +SPDX-License-Identifier: MIT +Copyright (c) 2019 Pranav Srinivas Kumar . + +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. +*/ +#pragma once + +namespace tabulate { + +class ColumnFormat : public Format { +public: + explicit ColumnFormat(class Column &column) : column_(column) {} + + ColumnFormat &width(size_t value); + ColumnFormat &height(size_t value); + + // Padding + ColumnFormat &padding(size_t value); + ColumnFormat &padding_left(size_t value); + ColumnFormat &padding_right(size_t value); + ColumnFormat &padding_top(size_t value); + ColumnFormat &padding_bottom(size_t value); + + // Border + ColumnFormat &border(const std::string &value); + ColumnFormat &border_color(Color value); + ColumnFormat &border_background_color(Color value); + ColumnFormat &border_left(const std::string &value); + ColumnFormat &border_left_color(Color value); + ColumnFormat &border_left_background_color(Color value); + ColumnFormat &border_right(const std::string &value); + ColumnFormat &border_right_color(Color value); + ColumnFormat &border_right_background_color(Color value); + ColumnFormat &border_top(const std::string &value); + ColumnFormat &border_top_color(Color value); + ColumnFormat &border_top_background_color(Color value); + ColumnFormat &border_bottom(const std::string &value); + ColumnFormat &border_bottom_color(Color value); + ColumnFormat &border_bottom_background_color(Color value); + + // Corner + ColumnFormat &corner(const std::string &value); + ColumnFormat &corner_color(Color value); + ColumnFormat &corner_background_color(Color value); + + // Column separator + ColumnFormat &column_separator(const std::string &value); + ColumnFormat &column_separator_color(Color value); + ColumnFormat &column_separator_background_color(Color value); + + // Font styling + ColumnFormat &font_align(FontAlign value); + ColumnFormat &font_style(const std::vector &style); + ColumnFormat &font_color(Color value); + ColumnFormat &font_background_color(Color value); + ColumnFormat &color(Color value); + ColumnFormat &background_color(Color value); + + // Locale + ColumnFormat &multi_byte_characters(bool value); + ColumnFormat &locale(const std::string &value); + +private: + std::reference_wrapper column_; +}; + +} // namespace tabulate diff --git a/libs/tabulate/exporter.hpp b/libs/tabulate/exporter.hpp index fd10402..15f11a9 100644 --- a/libs/tabulate/exporter.hpp +++ b/libs/tabulate/exporter.hpp @@ -1,46 +1,46 @@ - -/* - __ ___. .__ __ -_/ |______ \_ |__ __ __| | _____ _/ |_ ____ -\ __\__ \ | __ \| | \ | \__ \\ __\/ __ \ - | | / __ \| \_\ \ | / |__/ __ \| | \ ___/ - |__| (____ /___ /____/|____(____ /__| \___ > - \/ \/ \/ \/ -Table Maker for Modern C++ -https://github.com/p-ranav/tabulate - -Licensed under the MIT License . -SPDX-License-Identifier: MIT -Copyright (c) 2019 Pranav Srinivas Kumar . - -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. -*/ -#pragma once -#include -#include - -namespace tabulate { - -class Exporter { -public: - virtual std::string dump(Table &table) = 0; - virtual ~Exporter() {} -}; - -} // namespace tabulate + +/* + __ ___. .__ __ +_/ |______ \_ |__ __ __| | _____ _/ |_ ____ +\ __\__ \ | __ \| | \ | \__ \\ __\/ __ \ + | | / __ \| \_\ \ | / |__/ __ \| | \ ___/ + |__| (____ /___ /____/|____(____ /__| \___ > + \/ \/ \/ \/ +Table Maker for Modern C++ +https://github.com/p-ranav/tabulate + +Licensed under the MIT License . +SPDX-License-Identifier: MIT +Copyright (c) 2019 Pranav Srinivas Kumar . + +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. +*/ +#pragma once +#include +#include + +namespace tabulate { + +class Exporter { +public: + virtual std::string dump(Table &table) = 0; + virtual ~Exporter() {} +}; + +} // namespace tabulate diff --git a/libs/tabulate/font_align.hpp b/libs/tabulate/font_align.hpp index e459f21..a0817b1 100644 --- a/libs/tabulate/font_align.hpp +++ b/libs/tabulate/font_align.hpp @@ -1,39 +1,39 @@ - -/* - __ ___. .__ __ -_/ |______ \_ |__ __ __| | _____ _/ |_ ____ -\ __\__ \ | __ \| | \ | \__ \\ __\/ __ \ - | | / __ \| \_\ \ | / |__/ __ \| | \ ___/ - |__| (____ /___ /____/|____(____ /__| \___ > - \/ \/ \/ \/ -Table Maker for Modern C++ -https://github.com/p-ranav/tabulate - -Licensed under the MIT License . -SPDX-License-Identifier: MIT -Copyright (c) 2019 Pranav Srinivas Kumar . - -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. -*/ -#pragma once - -namespace tabulate { - -enum class FontAlign { left, right, center }; -} + +/* + __ ___. .__ __ +_/ |______ \_ |__ __ __| | _____ _/ |_ ____ +\ __\__ \ | __ \| | \ | \__ \\ __\/ __ \ + | | / __ \| \_\ \ | / |__/ __ \| | \ ___/ + |__| (____ /___ /____/|____(____ /__| \___ > + \/ \/ \/ \/ +Table Maker for Modern C++ +https://github.com/p-ranav/tabulate + +Licensed under the MIT License . +SPDX-License-Identifier: MIT +Copyright (c) 2019 Pranav Srinivas Kumar . + +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. +*/ +#pragma once + +namespace tabulate { + +enum class FontAlign { left, right, center }; +} diff --git a/libs/tabulate/font_style.hpp b/libs/tabulate/font_style.hpp index 16db133..8ef81b9 100644 --- a/libs/tabulate/font_style.hpp +++ b/libs/tabulate/font_style.hpp @@ -1,39 +1,39 @@ - -/* - __ ___. .__ __ -_/ |______ \_ |__ __ __| | _____ _/ |_ ____ -\ __\__ \ | __ \| | \ | \__ \\ __\/ __ \ - | | / __ \| \_\ \ | / |__/ __ \| | \ ___/ - |__| (____ /___ /____/|____(____ /__| \___ > - \/ \/ \/ \/ -Table Maker for Modern C++ -https://github.com/p-ranav/tabulate - -Licensed under the MIT License . -SPDX-License-Identifier: MIT -Copyright (c) 2019 Pranav Srinivas Kumar . - -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. -*/ -#pragma once - -namespace tabulate { - -enum class FontStyle { bold, dark, italic, underline, blink, reverse, concealed, crossed }; -} + +/* + __ ___. .__ __ +_/ |______ \_ |__ __ __| | _____ _/ |_ ____ +\ __\__ \ | __ \| | \ | \__ \\ __\/ __ \ + | | / __ \| \_\ \ | / |__/ __ \| | \ ___/ + |__| (____ /___ /____/|____(____ /__| \___ > + \/ \/ \/ \/ +Table Maker for Modern C++ +https://github.com/p-ranav/tabulate + +Licensed under the MIT License . +SPDX-License-Identifier: MIT +Copyright (c) 2019 Pranav Srinivas Kumar . + +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. +*/ +#pragma once + +namespace tabulate { + +enum class FontStyle { bold, dark, italic, underline, blink, reverse, concealed, crossed }; +} diff --git a/libs/tabulate/format.hpp b/libs/tabulate/format.hpp index e486b6c..5fb3b2a 100644 --- a/libs/tabulate/format.hpp +++ b/libs/tabulate/format.hpp @@ -1,900 +1,900 @@ - -/* - __ ___. .__ __ -_/ |______ \_ |__ __ __| | _____ _/ |_ ____ -\ __\__ \ | __ \| | \ | \__ \\ __\/ __ \ - | | / __ \| \_\ \ | / |__/ __ \| | \ ___/ - |__| (____ /___ /____/|____(____ /__| \___ > - \/ \/ \/ \/ -Table Maker for Modern C++ -https://github.com/p-ranav/tabulate - -Licensed under the MIT License . -SPDX-License-Identifier: MIT -Copyright (c) 2019 Pranav Srinivas Kumar . - -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. -*/ -#pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if __cplusplus >= 201703L -#include -using std::optional; -#else -#include -using nonstd::optional; -#endif - -#include - -namespace tabulate { - -class Format { -public: - Format &width(size_t value) { - width_ = value; - return *this; - } - - Format &height(size_t value) { - height_ = value; - return *this; - } - - Format &padding(size_t value) { - padding_left_ = value; - padding_right_ = value; - padding_top_ = value; - padding_bottom_ = value; - return *this; - } - - Format &padding_left(size_t value) { - padding_left_ = value; - return *this; - } - - Format &padding_right(size_t value) { - padding_right_ = value; - return *this; - } - - Format &padding_top(size_t value) { - padding_top_ = value; - return *this; - } - - Format &padding_bottom(size_t value) { - padding_bottom_ = value; - return *this; - } - - Format &border(const std::string &value) { - border_left_ = value; - border_right_ = value; - border_top_ = value; - border_bottom_ = value; - return *this; - } - - Format &border_color(Color value) { - border_left_color_ = value; - border_right_color_ = value; - border_top_color_ = value; - border_bottom_color_ = value; - return *this; - } - - Format &border_background_color(Color value) { - border_left_background_color_ = value; - border_right_background_color_ = value; - border_top_background_color_ = value; - border_bottom_background_color_ = value; - return *this; - } - - Format &border_left(const std::string &value) { - border_left_ = value; - return *this; - } - - Format &border_left_color(Color value) { - border_left_color_ = value; - return *this; - } - - Format &border_left_background_color(Color value) { - border_left_background_color_ = value; - return *this; - } - - Format &border_right(const std::string &value) { - border_right_ = value; - return *this; - } - - Format &border_right_color(Color value) { - border_right_color_ = value; - return *this; - } - - Format &border_right_background_color(Color value) { - border_right_background_color_ = value; - return *this; - } - - Format &border_top(const std::string &value) { - border_top_ = value; - return *this; - } - - Format &border_top_color(Color value) { - border_top_color_ = value; - return *this; - } - - Format &border_top_background_color(Color value) { - border_top_background_color_ = value; - return *this; - } - - Format &border_bottom(const std::string &value) { - border_bottom_ = value; - return *this; - } - - Format &border_bottom_color(Color value) { - border_bottom_color_ = value; - return *this; - } - - Format &border_bottom_background_color(Color value) { - border_bottom_background_color_ = value; - return *this; - } - - Format &show_border() { - show_border_top_ = true; - show_border_bottom_ = true; - show_border_left_ = true; - show_border_right_ = true; - return *this; - } - - Format &hide_border() { - show_border_top_ = false; - show_border_bottom_ = false; - show_border_left_ = false; - show_border_right_ = false; - return *this; - } - - Format &show_border_top() { - show_border_top_ = true; - return *this; - } - - Format &hide_border_top() { - show_border_top_ = false; - return *this; - } - - Format &show_border_bottom() { - show_border_bottom_ = true; - return *this; - } - - Format &hide_border_bottom() { - show_border_bottom_ = false; - return *this; - } - - Format &show_border_left() { - show_border_left_ = true; - return *this; - } - - Format &hide_border_left() { - show_border_left_ = false; - return *this; - } - - Format &show_border_right() { - show_border_right_ = true; - return *this; - } - - Format &hide_border_right() { - show_border_right_ = false; - return *this; - } - - Format& show_column_separator() { - show_column_separator_ = true; - return *this; - } - - Format& show_row_separator() { - show_border_top_ = true; - show_row_separator_ = true; - return *this; - } - - Format &corner(const std::string &value) { - corner_top_left_ = value; - corner_top_right_ = value; - corner_bottom_left_ = value; - corner_bottom_right_ = value; - return *this; - } - - Format &corner_color(Color value) { - corner_top_left_color_ = value; - corner_top_right_color_ = value; - corner_bottom_left_color_ = value; - corner_bottom_right_color_ = value; - return *this; - } - - Format &corner_background_color(Color value) { - corner_top_left_background_color_ = value; - corner_top_right_background_color_ = value; - corner_bottom_left_background_color_ = value; - corner_bottom_right_background_color_ = value; - return *this; - } - - Format &corner_top_left(const std::string &value) { - corner_top_left_ = value; - return *this; - } - - Format &corner_top_left_color(Color value) { - corner_top_left_color_ = value; - return *this; - } - - Format &corner_top_left_background_color(Color value) { - corner_top_left_background_color_ = value; - return *this; - } - - Format &corner_top_right(const std::string &value) { - corner_top_right_ = value; - return *this; - } - - Format &corner_top_right_color(Color value) { - corner_top_right_color_ = value; - return *this; - } - - Format &corner_top_right_background_color(Color value) { - corner_top_right_background_color_ = value; - return *this; - } - - Format &corner_bottom_left(const std::string &value) { - corner_bottom_left_ = value; - return *this; - } - - Format &corner_bottom_left_color(Color value) { - corner_bottom_left_color_ = value; - return *this; - } - - Format &corner_bottom_left_background_color(Color value) { - corner_bottom_left_background_color_ = value; - return *this; - } - - Format &corner_bottom_right(const std::string &value) { - corner_bottom_right_ = value; - return *this; - } - - Format &corner_bottom_right_color(Color value) { - corner_bottom_right_color_ = value; - return *this; - } - - Format &corner_bottom_right_background_color(Color value) { - corner_bottom_right_background_color_ = value; - return *this; - } - - Format &column_separator(const std::string &value) { - column_separator_ = value; - return *this; - } - - Format &column_separator_color(Color value) { - column_separator_color_ = value; - return *this; - } - - Format &column_separator_background_color(Color value) { - column_separator_background_color_ = value; - return *this; - } - - Format &font_align(FontAlign value) { - font_align_ = value; - return *this; - } - - Format &font_style(const std::vector &style) { - if (font_style_.has_value()) { - for (auto &s : style) - font_style_->push_back(s); - } else { - font_style_ = style; - } - return *this; - } - - Format &font_color(Color value) { - font_color_ = value; - return *this; - } - - Format &font_background_color(Color value) { - font_background_color_ = value; - return *this; - } - - Format &color(Color value) { - font_color(value); - border_color(value); - corner_color(value); - return *this; - } - - Format &background_color(Color value) { - font_background_color(value); - border_background_color(value); - corner_background_color(value); - return *this; - } - - Format &multi_byte_characters(bool value) { - multi_byte_characters_ = value; - return *this; - } - - Format &locale(const std::string &value) { - locale_ = value; - return *this; - } - - enum class TrimMode { - kNone = 0, - kLeft = 1 << 0, - kRight = 1 << 1, - kBoth = kLeft | kRight, - }; - - Format &trim_mode(TrimMode trim_mode) { - trim_mode_ = trim_mode; - return *this; - } - - // Apply word wrap - // Given an input string and a line length, this will insert \n - // in strategic places in input string and apply word wrapping - static std::string word_wrap(const std::string &str, size_t width, const std::string &locale, - bool is_multi_byte_character_support_enabled) { - std::vector words = explode_string(str, {" ", "-", "\t"}); - size_t current_line_length = 0; - std::string result; - - for (size_t i = 0; i < words.size(); ++i) { - std::string word = words[i]; - // If adding the new word to the current line would be too long, - // then put it on a new line (and split it up if it's too long). - if (current_line_length + - get_sequence_length(word, locale, is_multi_byte_character_support_enabled) > - width) { - // Only move down to a new line if we have text on the current line. - // Avoids situation where wrapped whitespace causes emptylines in text. - if (current_line_length > 0) { - result += '\n'; - current_line_length = 0; - } - - // If the current word is too long to fit on a line even on it's own - // then split the word up. - while (get_sequence_length(word, locale, is_multi_byte_character_support_enabled) > width) { - result += word.substr(0, width - 1) + "-"; - word = word.substr(width - 1); - result += '\n'; - } - - // Remove leading whitespace from the word so the new line starts flush - // to the left. - word = trim_left(word); - } - result += word; - current_line_length += - get_sequence_length(word, locale, is_multi_byte_character_support_enabled); - } - return result; - } - - static std::vector split_lines(const std::string &text, const std::string &delimiter, - const std::string &locale, - bool is_multi_byte_character_support_enabled) { - std::vector result{}; - std::string input = text; - size_t pos = 0; - std::string token; - while ((pos = input.find(delimiter)) != std::string::npos) { - token = input.substr(0, pos); - result.push_back(token); - input.erase(0, pos + delimiter.length()); - } - if (get_sequence_length(input, locale, is_multi_byte_character_support_enabled)) - result.push_back(input); - return result; - }; - - // Merge two formats - // first has higher precedence - // e.g., first = cell-level formatting and - // second = row-level formatting - // Result has attributes of both with cell-level - // formatting taking precedence - static Format merge(Format first, Format second) { - Format result; - - // Width and height - if (first.width_.has_value()) - result.width_ = first.width_; - else - result.width_ = second.width_; - - if (first.height_.has_value()) - result.height_ = first.height_; - else - result.height_ = second.height_; - - // Font styling - if (first.font_align_.has_value()) - result.font_align_ = first.font_align_; - else - result.font_align_ = second.font_align_; - - if (first.font_style_.has_value()) { - // Merge font styles using std::set_union - std::vector merged_font_style(first.font_style_->size() + - second.font_style_->size()); -#if defined(_WIN32) || defined(_WIN64) - // Fixes error in Windows - Sequence not ordered - std::sort(first.font_style_->begin(), first.font_style_->end()); - std::sort(second.font_style_->begin(), second.font_style_->end()); -#endif - std::set_union(first.font_style_->begin(), first.font_style_->end(), - second.font_style_->begin(), second.font_style_->end(), - merged_font_style.begin()); - result.font_style_ = merged_font_style; - } else - result.font_style_ = second.font_style_; - - if (first.font_color_.has_value()) - result.font_color_ = first.font_color_; - else - result.font_color_ = second.font_color_; - - if (first.font_background_color_.has_value()) - result.font_background_color_ = first.font_background_color_; - else - result.font_background_color_ = second.font_background_color_; - - // Padding - if (first.padding_left_.has_value()) - result.padding_left_ = first.padding_left_; - else - result.padding_left_ = second.padding_left_; - - if (first.padding_top_.has_value()) - result.padding_top_ = first.padding_top_; - else - result.padding_top_ = second.padding_top_; - - if (first.padding_right_.has_value()) - result.padding_right_ = first.padding_right_; - else - result.padding_right_ = second.padding_right_; - - if (first.padding_bottom_.has_value()) - result.padding_bottom_ = first.padding_bottom_; - else - result.padding_bottom_ = second.padding_bottom_; - - // Border - if (first.border_left_.has_value()) - result.border_left_ = first.border_left_; - else - result.border_left_ = second.border_left_; - - if (first.border_left_color_.has_value()) - result.border_left_color_ = first.border_left_color_; - else - result.border_left_color_ = second.border_left_color_; - - if (first.border_left_background_color_.has_value()) - result.border_left_background_color_ = first.border_left_background_color_; - else - result.border_left_background_color_ = second.border_left_background_color_; - - if (first.border_top_.has_value()) - result.border_top_ = first.border_top_; - else - result.border_top_ = second.border_top_; - - if (first.border_top_color_.has_value()) - result.border_top_color_ = first.border_top_color_; - else - result.border_top_color_ = second.border_top_color_; - - if (first.border_top_background_color_.has_value()) - result.border_top_background_color_ = first.border_top_background_color_; - else - result.border_top_background_color_ = second.border_top_background_color_; - - if (first.border_bottom_.has_value()) - result.border_bottom_ = first.border_bottom_; - else - result.border_bottom_ = second.border_bottom_; - - if (first.border_bottom_color_.has_value()) - result.border_bottom_color_ = first.border_bottom_color_; - else - result.border_bottom_color_ = second.border_bottom_color_; - - if (first.border_bottom_background_color_.has_value()) - result.border_bottom_background_color_ = first.border_bottom_background_color_; - else - result.border_bottom_background_color_ = second.border_bottom_background_color_; - - if (first.border_right_.has_value()) - result.border_right_ = first.border_right_; - else - result.border_right_ = second.border_right_; - - if (first.border_right_color_.has_value()) - result.border_right_color_ = first.border_right_color_; - else - result.border_right_color_ = second.border_right_color_; - - if (first.border_right_background_color_.has_value()) - result.border_right_background_color_ = first.border_right_background_color_; - else - result.border_right_background_color_ = second.border_right_background_color_; - - if (first.show_border_top_.has_value()) - result.show_border_top_ = first.show_border_top_; - else - result.show_border_top_ = second.show_border_top_; - - if (first.show_border_bottom_.has_value()) - result.show_border_bottom_ = first.show_border_bottom_; - else - result.show_border_bottom_ = second.show_border_bottom_; - - if (first.show_border_left_.has_value()) - result.show_border_left_ = first.show_border_left_; - else - result.show_border_left_ = second.show_border_left_; - - if (first.show_border_right_.has_value()) - result.show_border_right_ = first.show_border_right_; - else - result.show_border_right_ = second.show_border_right_; - - // Corner - if (first.corner_top_left_.has_value()) - result.corner_top_left_ = first.corner_top_left_; - else - result.corner_top_left_ = second.corner_top_left_; - - if (first.corner_top_left_color_.has_value()) - result.corner_top_left_color_ = first.corner_top_left_color_; - else - result.corner_top_left_color_ = second.corner_top_left_color_; - - if (first.corner_top_left_background_color_.has_value()) - result.corner_top_left_background_color_ = first.corner_top_left_background_color_; - else - result.corner_top_left_background_color_ = second.corner_top_left_background_color_; - - if (first.corner_top_right_.has_value()) - result.corner_top_right_ = first.corner_top_right_; - else - result.corner_top_right_ = second.corner_top_right_; - - if (first.corner_top_right_color_.has_value()) - result.corner_top_right_color_ = first.corner_top_right_color_; - else - result.corner_top_right_color_ = second.corner_top_right_color_; - - if (first.corner_top_right_background_color_.has_value()) - result.corner_top_right_background_color_ = first.corner_top_right_background_color_; - else - result.corner_top_right_background_color_ = second.corner_top_right_background_color_; - - if (first.corner_bottom_left_.has_value()) - result.corner_bottom_left_ = first.corner_bottom_left_; - else - result.corner_bottom_left_ = second.corner_bottom_left_; - - if (first.corner_bottom_left_color_.has_value()) - result.corner_bottom_left_color_ = first.corner_bottom_left_color_; - else - result.corner_bottom_left_color_ = second.corner_bottom_left_color_; - - if (first.corner_bottom_left_background_color_.has_value()) - result.corner_bottom_left_background_color_ = first.corner_bottom_left_background_color_; - else - result.corner_bottom_left_background_color_ = second.corner_bottom_left_background_color_; - - if (first.corner_bottom_right_.has_value()) - result.corner_bottom_right_ = first.corner_bottom_right_; - else - result.corner_bottom_right_ = second.corner_bottom_right_; - - if (first.corner_bottom_right_color_.has_value()) - result.corner_bottom_right_color_ = first.corner_bottom_right_color_; - else - result.corner_bottom_right_color_ = second.corner_bottom_right_color_; - - if (first.corner_bottom_right_background_color_.has_value()) - result.corner_bottom_right_background_color_ = first.corner_bottom_right_background_color_; - else - result.corner_bottom_right_background_color_ = second.corner_bottom_right_background_color_; - - // Column separator - if (first.show_column_separator_.has_value()) - result.show_column_separator_ = first.show_column_separator_; - else - result.show_column_separator_ = second.show_column_separator_; - - if (first.column_separator_.has_value()) - result.column_separator_ = first.column_separator_; - else - result.column_separator_ = second.column_separator_; - - if (first.column_separator_color_.has_value()) - result.column_separator_color_ = first.column_separator_color_; - else - result.column_separator_color_ = second.column_separator_color_; - - if (first.column_separator_background_color_.has_value()) - result.column_separator_background_color_ = first.column_separator_background_color_; - else - result.column_separator_background_color_ = second.column_separator_background_color_; - - // Internationlization - if (first.multi_byte_characters_.has_value()) - result.multi_byte_characters_ = first.multi_byte_characters_; - else - result.multi_byte_characters_ = second.multi_byte_characters_; - - if (first.locale_.has_value()) - result.locale_ = first.locale_; - else - result.locale_ = second.locale_; - - if (first.trim_mode_.has_value()) - result.trim_mode_ = first.trim_mode_; - else - result.trim_mode_ = second.trim_mode_; - - if (first.show_row_separator_.has_value()) - result.show_row_separator_ = first.show_row_separator_; - else - result.show_row_separator_ = second.show_row_separator_; - - return result; - } - -private: - friend class Cell; - friend class Row; - friend class Column; - friend class TableInternal; - friend class Printer; - friend class MarkdownExporter; - friend class LatexExporter; - friend class AsciiDocExporter; - - void set_defaults() { - // NOTE: width and height are not set here - font_align_ = FontAlign::left; - font_style_ = std::vector{}; - font_color_ = font_background_color_ = Color::none; - padding_left_ = padding_right_ = 1; - padding_top_ = padding_bottom_ = 0; - border_top_ = border_bottom_ = "-"; - border_left_ = border_right_ = "|"; - show_border_left_ = show_border_right_ = show_border_top_ = show_border_bottom_ = true; - border_top_color_ = border_top_background_color_ = border_bottom_color_ = - border_bottom_background_color_ = border_left_color_ = border_left_background_color_ = - border_right_color_ = border_right_background_color_ = Color::none; - corner_top_left_ = corner_top_right_ = corner_bottom_left_ = corner_bottom_right_ = "+"; - corner_top_left_color_ = corner_top_left_background_color_ = corner_top_right_color_ = - corner_top_right_background_color_ = corner_bottom_left_color_ = - corner_bottom_left_background_color_ = corner_bottom_right_color_ = - corner_bottom_right_background_color_ = Color::none; - show_column_separator_ = true; - column_separator_ = "|"; - column_separator_color_ = column_separator_background_color_ = Color::none; - multi_byte_characters_ = false; - locale_ = ""; - trim_mode_ = TrimMode::kBoth; - show_row_separator_ = false; - } - - // Helper methods for word wrapping: - - // trim white spaces from the left end of an input string - static std::string trim_left(const std::string &input_string) { - std::string result = input_string; - result.erase(result.begin(), std::find_if(result.begin(), result.end(), - [](int ch) { return !std::isspace(ch); })); - return result; - } - - // trim white spaces from right end of an input string - static std::string trim_right(const std::string &input_string) { - std::string result = input_string; - result.erase( - std::find_if(result.rbegin(), result.rend(), [](int ch) { return !std::isspace(ch); }) - .base(), - result.end()); - return result; - } - - // trim white spaces from either end of an input string - static std::string trim(const std::string &input_string) { - return trim_left(trim_right(input_string)); - } - - static size_t index_of_any(const std::string &input, size_t start_index, - const std::vector &split_characters) { - std::vector indices{}; - for (auto &c : split_characters) { - auto index = input.find(c, start_index); - if (index != std::string::npos) - indices.push_back(index); - } - if (indices.size() > 0) - return *std::min_element(indices.begin(), indices.end()); - else - return std::string::npos; - } - - static std::vector explode_string(const std::string &input, - const std::vector &split_characters) { - std::vector result{}; - size_t start_index{0}; - while (true) { - auto index = index_of_any(input, start_index, split_characters); - - if (index == std::string::npos) { - result.push_back(input.substr(start_index)); - return result; - } - - std::string word = input.substr(start_index, index - start_index); - char next_character = input.substr(index, 1)[0]; - // Unlike whitespace, dashes and the like should stick to the word - // occurring before it. - if (isspace(next_character)) { - result.push_back(word); - result.push_back(std::string(1, next_character)); - } else { - result.push_back(word + next_character); - } - start_index = index + 1; - } - - return result; - } - - // Element width and height - optional width_{}; - optional height_{}; - - // Font styling - optional font_align_{}; - optional> font_style_{}; - optional font_color_{}; - optional font_background_color_{}; - - // Element padding - optional padding_left_{}; - optional padding_top_{}; - optional padding_right_{}; - optional padding_bottom_{}; - - // Element border - optional show_border_top_{}; - optional border_top_{}; - optional border_top_color_{}; - optional border_top_background_color_{}; - - optional show_border_bottom_{}; - optional border_bottom_{}; - optional border_bottom_color_{}; - optional border_bottom_background_color_{}; - - optional show_border_left_{}; - optional border_left_{}; - optional border_left_color_{}; - optional border_left_background_color_{}; - - optional show_border_right_{}; - optional border_right_{}; - optional border_right_color_{}; - optional border_right_background_color_{}; - - // Element corner - optional corner_top_left_{}; - optional corner_top_left_color_{}; - optional corner_top_left_background_color_{}; - - optional corner_top_right_{}; - optional corner_top_right_color_{}; - optional corner_top_right_background_color_{}; - - optional corner_bottom_left_{}; - optional corner_bottom_left_color_{}; - optional corner_bottom_left_background_color_{}; - - optional corner_bottom_right_{}; - optional corner_bottom_right_color_{}; - optional corner_bottom_right_background_color_{}; - - // Element column separator - optional show_column_separator_{}; - optional column_separator_{}; - optional column_separator_color_{}; - optional column_separator_background_color_{}; - - // Internationalization - optional multi_byte_characters_{}; - optional locale_{}; - - optional trim_mode_{}; - - optional show_row_separator_{}; -}; - -} // namespace tabulate + +/* + __ ___. .__ __ +_/ |______ \_ |__ __ __| | _____ _/ |_ ____ +\ __\__ \ | __ \| | \ | \__ \\ __\/ __ \ + | | / __ \| \_\ \ | / |__/ __ \| | \ ___/ + |__| (____ /___ /____/|____(____ /__| \___ > + \/ \/ \/ \/ +Table Maker for Modern C++ +https://github.com/p-ranav/tabulate + +Licensed under the MIT License . +SPDX-License-Identifier: MIT +Copyright (c) 2019 Pranav Srinivas Kumar . + +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. +*/ +#pragma once +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if __cplusplus >= 201703L +#include +using std::optional; +#else +#include +using nonstd::optional; +#endif + +#include + +namespace tabulate { + +class Format { +public: + Format &width(size_t value) { + width_ = value; + return *this; + } + + Format &height(size_t value) { + height_ = value; + return *this; + } + + Format &padding(size_t value) { + padding_left_ = value; + padding_right_ = value; + padding_top_ = value; + padding_bottom_ = value; + return *this; + } + + Format &padding_left(size_t value) { + padding_left_ = value; + return *this; + } + + Format &padding_right(size_t value) { + padding_right_ = value; + return *this; + } + + Format &padding_top(size_t value) { + padding_top_ = value; + return *this; + } + + Format &padding_bottom(size_t value) { + padding_bottom_ = value; + return *this; + } + + Format &border(const std::string &value) { + border_left_ = value; + border_right_ = value; + border_top_ = value; + border_bottom_ = value; + return *this; + } + + Format &border_color(Color value) { + border_left_color_ = value; + border_right_color_ = value; + border_top_color_ = value; + border_bottom_color_ = value; + return *this; + } + + Format &border_background_color(Color value) { + border_left_background_color_ = value; + border_right_background_color_ = value; + border_top_background_color_ = value; + border_bottom_background_color_ = value; + return *this; + } + + Format &border_left(const std::string &value) { + border_left_ = value; + return *this; + } + + Format &border_left_color(Color value) { + border_left_color_ = value; + return *this; + } + + Format &border_left_background_color(Color value) { + border_left_background_color_ = value; + return *this; + } + + Format &border_right(const std::string &value) { + border_right_ = value; + return *this; + } + + Format &border_right_color(Color value) { + border_right_color_ = value; + return *this; + } + + Format &border_right_background_color(Color value) { + border_right_background_color_ = value; + return *this; + } + + Format &border_top(const std::string &value) { + border_top_ = value; + return *this; + } + + Format &border_top_color(Color value) { + border_top_color_ = value; + return *this; + } + + Format &border_top_background_color(Color value) { + border_top_background_color_ = value; + return *this; + } + + Format &border_bottom(const std::string &value) { + border_bottom_ = value; + return *this; + } + + Format &border_bottom_color(Color value) { + border_bottom_color_ = value; + return *this; + } + + Format &border_bottom_background_color(Color value) { + border_bottom_background_color_ = value; + return *this; + } + + Format &show_border() { + show_border_top_ = true; + show_border_bottom_ = true; + show_border_left_ = true; + show_border_right_ = true; + return *this; + } + + Format &hide_border() { + show_border_top_ = false; + show_border_bottom_ = false; + show_border_left_ = false; + show_border_right_ = false; + return *this; + } + + Format &show_border_top() { + show_border_top_ = true; + return *this; + } + + Format &hide_border_top() { + show_border_top_ = false; + return *this; + } + + Format &show_border_bottom() { + show_border_bottom_ = true; + return *this; + } + + Format &hide_border_bottom() { + show_border_bottom_ = false; + return *this; + } + + Format &show_border_left() { + show_border_left_ = true; + return *this; + } + + Format &hide_border_left() { + show_border_left_ = false; + return *this; + } + + Format &show_border_right() { + show_border_right_ = true; + return *this; + } + + Format &hide_border_right() { + show_border_right_ = false; + return *this; + } + + Format& show_column_separator() { + show_column_separator_ = true; + return *this; + } + + Format& show_row_separator() { + show_border_top_ = true; + show_row_separator_ = true; + return *this; + } + + Format &corner(const std::string &value) { + corner_top_left_ = value; + corner_top_right_ = value; + corner_bottom_left_ = value; + corner_bottom_right_ = value; + return *this; + } + + Format &corner_color(Color value) { + corner_top_left_color_ = value; + corner_top_right_color_ = value; + corner_bottom_left_color_ = value; + corner_bottom_right_color_ = value; + return *this; + } + + Format &corner_background_color(Color value) { + corner_top_left_background_color_ = value; + corner_top_right_background_color_ = value; + corner_bottom_left_background_color_ = value; + corner_bottom_right_background_color_ = value; + return *this; + } + + Format &corner_top_left(const std::string &value) { + corner_top_left_ = value; + return *this; + } + + Format &corner_top_left_color(Color value) { + corner_top_left_color_ = value; + return *this; + } + + Format &corner_top_left_background_color(Color value) { + corner_top_left_background_color_ = value; + return *this; + } + + Format &corner_top_right(const std::string &value) { + corner_top_right_ = value; + return *this; + } + + Format &corner_top_right_color(Color value) { + corner_top_right_color_ = value; + return *this; + } + + Format &corner_top_right_background_color(Color value) { + corner_top_right_background_color_ = value; + return *this; + } + + Format &corner_bottom_left(const std::string &value) { + corner_bottom_left_ = value; + return *this; + } + + Format &corner_bottom_left_color(Color value) { + corner_bottom_left_color_ = value; + return *this; + } + + Format &corner_bottom_left_background_color(Color value) { + corner_bottom_left_background_color_ = value; + return *this; + } + + Format &corner_bottom_right(const std::string &value) { + corner_bottom_right_ = value; + return *this; + } + + Format &corner_bottom_right_color(Color value) { + corner_bottom_right_color_ = value; + return *this; + } + + Format &corner_bottom_right_background_color(Color value) { + corner_bottom_right_background_color_ = value; + return *this; + } + + Format &column_separator(const std::string &value) { + column_separator_ = value; + return *this; + } + + Format &column_separator_color(Color value) { + column_separator_color_ = value; + return *this; + } + + Format &column_separator_background_color(Color value) { + column_separator_background_color_ = value; + return *this; + } + + Format &font_align(FontAlign value) { + font_align_ = value; + return *this; + } + + Format &font_style(const std::vector &style) { + if (font_style_.has_value()) { + for (auto &s : style) + font_style_->push_back(s); + } else { + font_style_ = style; + } + return *this; + } + + Format &font_color(Color value) { + font_color_ = value; + return *this; + } + + Format &font_background_color(Color value) { + font_background_color_ = value; + return *this; + } + + Format &color(Color value) { + font_color(value); + border_color(value); + corner_color(value); + return *this; + } + + Format &background_color(Color value) { + font_background_color(value); + border_background_color(value); + corner_background_color(value); + return *this; + } + + Format &multi_byte_characters(bool value) { + multi_byte_characters_ = value; + return *this; + } + + Format &locale(const std::string &value) { + locale_ = value; + return *this; + } + + enum class TrimMode { + kNone = 0, + kLeft = 1 << 0, + kRight = 1 << 1, + kBoth = kLeft | kRight, + }; + + Format &trim_mode(TrimMode trim_mode) { + trim_mode_ = trim_mode; + return *this; + } + + // Apply word wrap + // Given an input string and a line length, this will insert \n + // in strategic places in input string and apply word wrapping + static std::string word_wrap(const std::string &str, size_t width, const std::string &locale, + bool is_multi_byte_character_support_enabled) { + std::vector words = explode_string(str, {" ", "-", "\t"}); + size_t current_line_length = 0; + std::string result; + + for (size_t i = 0; i < words.size(); ++i) { + std::string word = words[i]; + // If adding the new word to the current line would be too long, + // then put it on a new line (and split it up if it's too long). + if (current_line_length + + get_sequence_length(word, locale, is_multi_byte_character_support_enabled) > + width) { + // Only move down to a new line if we have text on the current line. + // Avoids situation where wrapped whitespace causes emptylines in text. + if (current_line_length > 0) { + result += '\n'; + current_line_length = 0; + } + + // If the current word is too long to fit on a line even on it's own + // then split the word up. + while (get_sequence_length(word, locale, is_multi_byte_character_support_enabled) > width) { + result += word.substr(0, width - 1) + "-"; + word = word.substr(width - 1); + result += '\n'; + } + + // Remove leading whitespace from the word so the new line starts flush + // to the left. + word = trim_left(word); + } + result += word; + current_line_length += + get_sequence_length(word, locale, is_multi_byte_character_support_enabled); + } + return result; + } + + static std::vector split_lines(const std::string &text, const std::string &delimiter, + const std::string &locale, + bool is_multi_byte_character_support_enabled) { + std::vector result{}; + std::string input = text; + size_t pos = 0; + std::string token; + while ((pos = input.find(delimiter)) != std::string::npos) { + token = input.substr(0, pos); + result.push_back(token); + input.erase(0, pos + delimiter.length()); + } + if (get_sequence_length(input, locale, is_multi_byte_character_support_enabled)) + result.push_back(input); + return result; + }; + + // Merge two formats + // first has higher precedence + // e.g., first = cell-level formatting and + // second = row-level formatting + // Result has attributes of both with cell-level + // formatting taking precedence + static Format merge(Format first, Format second) { + Format result; + + // Width and height + if (first.width_.has_value()) + result.width_ = first.width_; + else + result.width_ = second.width_; + + if (first.height_.has_value()) + result.height_ = first.height_; + else + result.height_ = second.height_; + + // Font styling + if (first.font_align_.has_value()) + result.font_align_ = first.font_align_; + else + result.font_align_ = second.font_align_; + + if (first.font_style_.has_value()) { + // Merge font styles using std::set_union + std::vector merged_font_style(first.font_style_->size() + + second.font_style_->size()); +#if defined(_WIN32) || defined(_WIN64) + // Fixes error in Windows - Sequence not ordered + std::sort(first.font_style_->begin(), first.font_style_->end()); + std::sort(second.font_style_->begin(), second.font_style_->end()); +#endif + std::set_union(first.font_style_->begin(), first.font_style_->end(), + second.font_style_->begin(), second.font_style_->end(), + merged_font_style.begin()); + result.font_style_ = merged_font_style; + } else + result.font_style_ = second.font_style_; + + if (first.font_color_.has_value()) + result.font_color_ = first.font_color_; + else + result.font_color_ = second.font_color_; + + if (first.font_background_color_.has_value()) + result.font_background_color_ = first.font_background_color_; + else + result.font_background_color_ = second.font_background_color_; + + // Padding + if (first.padding_left_.has_value()) + result.padding_left_ = first.padding_left_; + else + result.padding_left_ = second.padding_left_; + + if (first.padding_top_.has_value()) + result.padding_top_ = first.padding_top_; + else + result.padding_top_ = second.padding_top_; + + if (first.padding_right_.has_value()) + result.padding_right_ = first.padding_right_; + else + result.padding_right_ = second.padding_right_; + + if (first.padding_bottom_.has_value()) + result.padding_bottom_ = first.padding_bottom_; + else + result.padding_bottom_ = second.padding_bottom_; + + // Border + if (first.border_left_.has_value()) + result.border_left_ = first.border_left_; + else + result.border_left_ = second.border_left_; + + if (first.border_left_color_.has_value()) + result.border_left_color_ = first.border_left_color_; + else + result.border_left_color_ = second.border_left_color_; + + if (first.border_left_background_color_.has_value()) + result.border_left_background_color_ = first.border_left_background_color_; + else + result.border_left_background_color_ = second.border_left_background_color_; + + if (first.border_top_.has_value()) + result.border_top_ = first.border_top_; + else + result.border_top_ = second.border_top_; + + if (first.border_top_color_.has_value()) + result.border_top_color_ = first.border_top_color_; + else + result.border_top_color_ = second.border_top_color_; + + if (first.border_top_background_color_.has_value()) + result.border_top_background_color_ = first.border_top_background_color_; + else + result.border_top_background_color_ = second.border_top_background_color_; + + if (first.border_bottom_.has_value()) + result.border_bottom_ = first.border_bottom_; + else + result.border_bottom_ = second.border_bottom_; + + if (first.border_bottom_color_.has_value()) + result.border_bottom_color_ = first.border_bottom_color_; + else + result.border_bottom_color_ = second.border_bottom_color_; + + if (first.border_bottom_background_color_.has_value()) + result.border_bottom_background_color_ = first.border_bottom_background_color_; + else + result.border_bottom_background_color_ = second.border_bottom_background_color_; + + if (first.border_right_.has_value()) + result.border_right_ = first.border_right_; + else + result.border_right_ = second.border_right_; + + if (first.border_right_color_.has_value()) + result.border_right_color_ = first.border_right_color_; + else + result.border_right_color_ = second.border_right_color_; + + if (first.border_right_background_color_.has_value()) + result.border_right_background_color_ = first.border_right_background_color_; + else + result.border_right_background_color_ = second.border_right_background_color_; + + if (first.show_border_top_.has_value()) + result.show_border_top_ = first.show_border_top_; + else + result.show_border_top_ = second.show_border_top_; + + if (first.show_border_bottom_.has_value()) + result.show_border_bottom_ = first.show_border_bottom_; + else + result.show_border_bottom_ = second.show_border_bottom_; + + if (first.show_border_left_.has_value()) + result.show_border_left_ = first.show_border_left_; + else + result.show_border_left_ = second.show_border_left_; + + if (first.show_border_right_.has_value()) + result.show_border_right_ = first.show_border_right_; + else + result.show_border_right_ = second.show_border_right_; + + // Corner + if (first.corner_top_left_.has_value()) + result.corner_top_left_ = first.corner_top_left_; + else + result.corner_top_left_ = second.corner_top_left_; + + if (first.corner_top_left_color_.has_value()) + result.corner_top_left_color_ = first.corner_top_left_color_; + else + result.corner_top_left_color_ = second.corner_top_left_color_; + + if (first.corner_top_left_background_color_.has_value()) + result.corner_top_left_background_color_ = first.corner_top_left_background_color_; + else + result.corner_top_left_background_color_ = second.corner_top_left_background_color_; + + if (first.corner_top_right_.has_value()) + result.corner_top_right_ = first.corner_top_right_; + else + result.corner_top_right_ = second.corner_top_right_; + + if (first.corner_top_right_color_.has_value()) + result.corner_top_right_color_ = first.corner_top_right_color_; + else + result.corner_top_right_color_ = second.corner_top_right_color_; + + if (first.corner_top_right_background_color_.has_value()) + result.corner_top_right_background_color_ = first.corner_top_right_background_color_; + else + result.corner_top_right_background_color_ = second.corner_top_right_background_color_; + + if (first.corner_bottom_left_.has_value()) + result.corner_bottom_left_ = first.corner_bottom_left_; + else + result.corner_bottom_left_ = second.corner_bottom_left_; + + if (first.corner_bottom_left_color_.has_value()) + result.corner_bottom_left_color_ = first.corner_bottom_left_color_; + else + result.corner_bottom_left_color_ = second.corner_bottom_left_color_; + + if (first.corner_bottom_left_background_color_.has_value()) + result.corner_bottom_left_background_color_ = first.corner_bottom_left_background_color_; + else + result.corner_bottom_left_background_color_ = second.corner_bottom_left_background_color_; + + if (first.corner_bottom_right_.has_value()) + result.corner_bottom_right_ = first.corner_bottom_right_; + else + result.corner_bottom_right_ = second.corner_bottom_right_; + + if (first.corner_bottom_right_color_.has_value()) + result.corner_bottom_right_color_ = first.corner_bottom_right_color_; + else + result.corner_bottom_right_color_ = second.corner_bottom_right_color_; + + if (first.corner_bottom_right_background_color_.has_value()) + result.corner_bottom_right_background_color_ = first.corner_bottom_right_background_color_; + else + result.corner_bottom_right_background_color_ = second.corner_bottom_right_background_color_; + + // Column separator + if (first.show_column_separator_.has_value()) + result.show_column_separator_ = first.show_column_separator_; + else + result.show_column_separator_ = second.show_column_separator_; + + if (first.column_separator_.has_value()) + result.column_separator_ = first.column_separator_; + else + result.column_separator_ = second.column_separator_; + + if (first.column_separator_color_.has_value()) + result.column_separator_color_ = first.column_separator_color_; + else + result.column_separator_color_ = second.column_separator_color_; + + if (first.column_separator_background_color_.has_value()) + result.column_separator_background_color_ = first.column_separator_background_color_; + else + result.column_separator_background_color_ = second.column_separator_background_color_; + + // Internationlization + if (first.multi_byte_characters_.has_value()) + result.multi_byte_characters_ = first.multi_byte_characters_; + else + result.multi_byte_characters_ = second.multi_byte_characters_; + + if (first.locale_.has_value()) + result.locale_ = first.locale_; + else + result.locale_ = second.locale_; + + if (first.trim_mode_.has_value()) + result.trim_mode_ = first.trim_mode_; + else + result.trim_mode_ = second.trim_mode_; + + if (first.show_row_separator_.has_value()) + result.show_row_separator_ = first.show_row_separator_; + else + result.show_row_separator_ = second.show_row_separator_; + + return result; + } + +private: + friend class Cell; + friend class Row; + friend class Column; + friend class TableInternal; + friend class Printer; + friend class MarkdownExporter; + friend class LatexExporter; + friend class AsciiDocExporter; + + void set_defaults() { + // NOTE: width and height are not set here + font_align_ = FontAlign::left; + font_style_ = std::vector{}; + font_color_ = font_background_color_ = Color::none; + padding_left_ = padding_right_ = 1; + padding_top_ = padding_bottom_ = 0; + border_top_ = border_bottom_ = "-"; + border_left_ = border_right_ = "|"; + show_border_left_ = show_border_right_ = show_border_top_ = show_border_bottom_ = true; + border_top_color_ = border_top_background_color_ = border_bottom_color_ = + border_bottom_background_color_ = border_left_color_ = border_left_background_color_ = + border_right_color_ = border_right_background_color_ = Color::none; + corner_top_left_ = corner_top_right_ = corner_bottom_left_ = corner_bottom_right_ = "+"; + corner_top_left_color_ = corner_top_left_background_color_ = corner_top_right_color_ = + corner_top_right_background_color_ = corner_bottom_left_color_ = + corner_bottom_left_background_color_ = corner_bottom_right_color_ = + corner_bottom_right_background_color_ = Color::none; + show_column_separator_ = true; + column_separator_ = "|"; + column_separator_color_ = column_separator_background_color_ = Color::none; + multi_byte_characters_ = false; + locale_ = ""; + trim_mode_ = TrimMode::kBoth; + show_row_separator_ = false; + } + + // Helper methods for word wrapping: + + // trim white spaces from the left end of an input string + static std::string trim_left(const std::string &input_string) { + std::string result = input_string; + result.erase(result.begin(), std::find_if(result.begin(), result.end(), + [](int ch) { return !std::isspace(ch); })); + return result; + } + + // trim white spaces from right end of an input string + static std::string trim_right(const std::string &input_string) { + std::string result = input_string; + result.erase( + std::find_if(result.rbegin(), result.rend(), [](int ch) { return !std::isspace(ch); }) + .base(), + result.end()); + return result; + } + + // trim white spaces from either end of an input string + static std::string trim(const std::string &input_string) { + return trim_left(trim_right(input_string)); + } + + static size_t index_of_any(const std::string &input, size_t start_index, + const std::vector &split_characters) { + std::vector indices{}; + for (auto &c : split_characters) { + auto index = input.find(c, start_index); + if (index != std::string::npos) + indices.push_back(index); + } + if (indices.size() > 0) + return *std::min_element(indices.begin(), indices.end()); + else + return std::string::npos; + } + + static std::vector explode_string(const std::string &input, + const std::vector &split_characters) { + std::vector result{}; + size_t start_index{0}; + while (true) { + auto index = index_of_any(input, start_index, split_characters); + + if (index == std::string::npos) { + result.push_back(input.substr(start_index)); + return result; + } + + std::string word = input.substr(start_index, index - start_index); + char next_character = input.substr(index, 1)[0]; + // Unlike whitespace, dashes and the like should stick to the word + // occurring before it. + if (isspace(next_character)) { + result.push_back(word); + result.push_back(std::string(1, next_character)); + } else { + result.push_back(word + next_character); + } + start_index = index + 1; + } + + return result; + } + + // Element width and height + optional width_{}; + optional height_{}; + + // Font styling + optional font_align_{}; + optional> font_style_{}; + optional font_color_{}; + optional font_background_color_{}; + + // Element padding + optional padding_left_{}; + optional padding_top_{}; + optional padding_right_{}; + optional padding_bottom_{}; + + // Element border + optional show_border_top_{}; + optional border_top_{}; + optional border_top_color_{}; + optional border_top_background_color_{}; + + optional show_border_bottom_{}; + optional border_bottom_{}; + optional border_bottom_color_{}; + optional border_bottom_background_color_{}; + + optional show_border_left_{}; + optional border_left_{}; + optional border_left_color_{}; + optional border_left_background_color_{}; + + optional show_border_right_{}; + optional border_right_{}; + optional border_right_color_{}; + optional border_right_background_color_{}; + + // Element corner + optional corner_top_left_{}; + optional corner_top_left_color_{}; + optional corner_top_left_background_color_{}; + + optional corner_top_right_{}; + optional corner_top_right_color_{}; + optional corner_top_right_background_color_{}; + + optional corner_bottom_left_{}; + optional corner_bottom_left_color_{}; + optional corner_bottom_left_background_color_{}; + + optional corner_bottom_right_{}; + optional corner_bottom_right_color_{}; + optional corner_bottom_right_background_color_{}; + + // Element column separator + optional show_column_separator_{}; + optional column_separator_{}; + optional column_separator_color_{}; + optional column_separator_background_color_{}; + + // Internationalization + optional multi_byte_characters_{}; + optional locale_{}; + + optional trim_mode_{}; + + optional show_row_separator_{}; +}; + +} // namespace tabulate diff --git a/libs/tabulate/latex_exporter.hpp b/libs/tabulate/latex_exporter.hpp index d22a51e..10b323a 100644 --- a/libs/tabulate/latex_exporter.hpp +++ b/libs/tabulate/latex_exporter.hpp @@ -1,122 +1,122 @@ - -/* - __ ___. .__ __ -_/ |______ \_ |__ __ __| | _____ _/ |_ ____ -\ __\__ \ | __ \| | \ | \__ \\ __\/ __ \ - | | / __ \| \_\ \ | / |__/ __ \| | \ ___/ - |__| (____ /___ /____/|____(____ /__| \___ > - \/ \/ \/ \/ -Table Maker for Modern C++ -https://github.com/p-ranav/tabulate - -Licensed under the MIT License . -SPDX-License-Identifier: MIT -Copyright (c) 2019 Pranav Srinivas Kumar . - -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. -*/ -#pragma once -#include - -#if __cplusplus >= 201703L -#include -using std::optional; -#else -#include -using nonstd::optional; -#endif - -namespace tabulate { - -class LatexExporter : public Exporter { - - static const char new_line = '\n'; - -public: - class ExportOptions { - public: - ExportOptions &indentation(std::size_t value) { - indentation_ = value; - return *this; - } - - private: - friend class LatexExporter; - optional indentation_; - }; - - ExportOptions &configure() { return options_; } - - std::string dump(Table &table) override { - std::string result{"\\begin{tabular}"}; - result += new_line; - - result += add_alignment_header(table); - result += new_line; - const auto rows = table.rows_; - // iterate content and put text into the table. - for (size_t i = 0; i < rows; i++) { - auto &row = table[i]; - // apply row content indentation - if (options_.indentation_.has_value()) { - result += std::string(options_.indentation_.value(), ' '); - } - - for (size_t j = 0; j < row.size(); j++) { - - result += row[j].get_text(); - - // check column position, need "\\" at the end of each row - if (j < row.size() - 1) { - result += " & "; - } else { - result += " \\\\"; - } - } - result += new_line; - } - - result += "\\end{tabular}"; - return result; - } - - virtual ~LatexExporter() {} - -private: - std::string add_alignment_header(Table &table) { - std::string result{"{"}; - - for (auto &cell : table[0]) { - auto format = cell.format(); - if (format.font_align_.value() == FontAlign::left) { - result += 'l'; - } else if (format.font_align_.value() == FontAlign::center) { - result += 'c'; - } else if (format.font_align_.value() == FontAlign::right) { - result += 'r'; - } - } - - result += "}"; - return result; - } - ExportOptions options_; -}; - -} // namespace tabulate + +/* + __ ___. .__ __ +_/ |______ \_ |__ __ __| | _____ _/ |_ ____ +\ __\__ \ | __ \| | \ | \__ \\ __\/ __ \ + | | / __ \| \_\ \ | / |__/ __ \| | \ ___/ + |__| (____ /___ /____/|____(____ /__| \___ > + \/ \/ \/ \/ +Table Maker for Modern C++ +https://github.com/p-ranav/tabulate + +Licensed under the MIT License . +SPDX-License-Identifier: MIT +Copyright (c) 2019 Pranav Srinivas Kumar . + +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. +*/ +#pragma once +#include + +#if __cplusplus >= 201703L +#include +using std::optional; +#else +#include +using nonstd::optional; +#endif + +namespace tabulate { + +class LatexExporter : public Exporter { + + static const char new_line = '\n'; + +public: + class ExportOptions { + public: + ExportOptions &indentation(std::size_t value) { + indentation_ = value; + return *this; + } + + private: + friend class LatexExporter; + optional indentation_; + }; + + ExportOptions &configure() { return options_; } + + std::string dump(Table &table) override { + std::string result{"\\begin{tabular}"}; + result += new_line; + + result += add_alignment_header(table); + result += new_line; + const auto rows = table.rows_; + // iterate content and put text into the table. + for (size_t i = 0; i < rows; i++) { + auto &row = table[i]; + // apply row content indentation + if (options_.indentation_.has_value()) { + result += std::string(options_.indentation_.value(), ' '); + } + + for (size_t j = 0; j < row.size(); j++) { + + result += row[j].get_text(); + + // check column position, need "\\" at the end of each row + if (j < row.size() - 1) { + result += " & "; + } else { + result += " \\\\"; + } + } + result += new_line; + } + + result += "\\end{tabular}"; + return result; + } + + virtual ~LatexExporter() {} + +private: + std::string add_alignment_header(Table &table) { + std::string result{"{"}; + + for (auto &cell : table[0]) { + auto format = cell.format(); + if (format.font_align_.value() == FontAlign::left) { + result += 'l'; + } else if (format.font_align_.value() == FontAlign::center) { + result += 'c'; + } else if (format.font_align_.value() == FontAlign::right) { + result += 'r'; + } + } + + result += "}"; + return result; + } + ExportOptions options_; +}; + +} // namespace tabulate diff --git a/libs/tabulate/markdown_exporter.hpp b/libs/tabulate/markdown_exporter.hpp index 41bc456..76ae7bf 100644 --- a/libs/tabulate/markdown_exporter.hpp +++ b/libs/tabulate/markdown_exporter.hpp @@ -1,138 +1,138 @@ - -/* - __ ___. .__ __ -_/ |______ \_ |__ __ __| | _____ _/ |_ ____ -\ __\__ \ | __ \| | \ | \__ \\ __\/ __ \ - | | / __ \| \_\ \ | / |__/ __ \| | \ ___/ - |__| (____ /___ /____/|____(____ /__| \___ > - \/ \/ \/ \/ -Table Maker for Modern C++ -https://github.com/p-ranav/tabulate - -Licensed under the MIT License . -SPDX-License-Identifier: MIT -Copyright (c) 2019 Pranav Srinivas Kumar . - -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. -*/ -#pragma once -#include - -namespace tabulate { - -class MarkdownExporter : public Exporter { -public: - std::string dump(Table &table) override { - std::string result{""}; - apply_markdown_format(table); - result = table.str(); - restore_table_format(table); - return result; - } - - virtual ~MarkdownExporter() {} - -private: - void add_alignment_header_row(Table &table) { - auto &rows = table.table_->rows_; - - if (rows.size() >= 1) { - auto alignment_row = std::make_shared(table.table_->shared_from_this()); - - // Create alignment header cells - std::vector alignment_cells{}; - for (auto &cell : table[0]) { - auto format = cell.format(); - if (format.font_align_.value() == FontAlign::left) { - alignment_cells.push_back(":----"); - } else if (format.font_align_.value() == FontAlign::center) { - alignment_cells.push_back(":---:"); - } else if (format.font_align_.value() == FontAlign::right) { - alignment_cells.push_back("----:"); - } - } - - // Add alignment header cells to alignment row - for (auto &c : alignment_cells) { - auto cell = std::make_shared(alignment_row); - cell->format() - .hide_border_top() - .hide_border_bottom() - .border_left("|") - .border_right("|") - .column_separator("|") - .corner("|"); - cell->set_text(c); - if (c == ":---:") - cell->format().font_align(FontAlign::center); - else if (c == "----:") - cell->format().font_align(FontAlign::right); - alignment_row->add_cell(cell); - } - - // Insert alignment header row - if (rows.size() > 1) - rows.insert(rows.begin() + 1, alignment_row); - else - rows.push_back(alignment_row); - } - } - - void remove_alignment_header_row(Table &table) { - auto &rows = table.table_->rows_; - table.table_->rows_.erase(rows.begin() + 1); - } - - void apply_markdown_format(Table &table) { - // Apply markdown format to cells in each row - for (auto row : table) { - for (auto &cell : row) { - auto format = cell.format(); - formats_.push_back(format); - cell.format() - .hide_border_top() - .hide_border_bottom() - .border_left("|") - .border_right("|") - .column_separator("|") - .corner("|"); - } - } - // Add alignment header row at position 1 - add_alignment_header_row(table); - } - - void restore_table_format(Table &table) { - // Remove alignment header row at position 1 - remove_alignment_header_row(table); - - // Restore original formatting for each cell - size_t format_index{0}; - for (auto row : table) { - for (auto &cell : row) { - cell.format() = formats_[format_index]; - format_index += 1; - } - } - } - - std::vector formats_; -}; - -} // namespace tabulate + +/* + __ ___. .__ __ +_/ |______ \_ |__ __ __| | _____ _/ |_ ____ +\ __\__ \ | __ \| | \ | \__ \\ __\/ __ \ + | | / __ \| \_\ \ | / |__/ __ \| | \ ___/ + |__| (____ /___ /____/|____(____ /__| \___ > + \/ \/ \/ \/ +Table Maker for Modern C++ +https://github.com/p-ranav/tabulate + +Licensed under the MIT License . +SPDX-License-Identifier: MIT +Copyright (c) 2019 Pranav Srinivas Kumar . + +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. +*/ +#pragma once +#include + +namespace tabulate { + +class MarkdownExporter : public Exporter { +public: + std::string dump(Table &table) override { + std::string result{""}; + apply_markdown_format(table); + result = table.str(); + restore_table_format(table); + return result; + } + + virtual ~MarkdownExporter() {} + +private: + void add_alignment_header_row(Table &table) { + auto &rows = table.table_->rows_; + + if (rows.size() >= 1) { + auto alignment_row = std::make_shared(table.table_->shared_from_this()); + + // Create alignment header cells + std::vector alignment_cells{}; + for (auto &cell : table[0]) { + auto format = cell.format(); + if (format.font_align_.value() == FontAlign::left) { + alignment_cells.push_back(":----"); + } else if (format.font_align_.value() == FontAlign::center) { + alignment_cells.push_back(":---:"); + } else if (format.font_align_.value() == FontAlign::right) { + alignment_cells.push_back("----:"); + } + } + + // Add alignment header cells to alignment row + for (auto &c : alignment_cells) { + auto cell = std::make_shared(alignment_row); + cell->format() + .hide_border_top() + .hide_border_bottom() + .border_left("|") + .border_right("|") + .column_separator("|") + .corner("|"); + cell->set_text(c); + if (c == ":---:") + cell->format().font_align(FontAlign::center); + else if (c == "----:") + cell->format().font_align(FontAlign::right); + alignment_row->add_cell(cell); + } + + // Insert alignment header row + if (rows.size() > 1) + rows.insert(rows.begin() + 1, alignment_row); + else + rows.push_back(alignment_row); + } + } + + void remove_alignment_header_row(Table &table) { + auto &rows = table.table_->rows_; + table.table_->rows_.erase(rows.begin() + 1); + } + + void apply_markdown_format(Table &table) { + // Apply markdown format to cells in each row + for (auto row : table) { + for (auto &cell : row) { + auto format = cell.format(); + formats_.push_back(format); + cell.format() + .hide_border_top() + .hide_border_bottom() + .border_left("|") + .border_right("|") + .column_separator("|") + .corner("|"); + } + } + // Add alignment header row at position 1 + add_alignment_header_row(table); + } + + void restore_table_format(Table &table) { + // Remove alignment header row at position 1 + remove_alignment_header_row(table); + + // Restore original formatting for each cell + size_t format_index{0}; + for (auto row : table) { + for (auto &cell : row) { + cell.format() = formats_[format_index]; + format_index += 1; + } + } + } + + std::vector formats_; +}; + +} // namespace tabulate diff --git a/libs/tabulate/optional_lite.hpp b/libs/tabulate/optional_lite.hpp index e398b74..703455e 100644 --- a/libs/tabulate/optional_lite.hpp +++ b/libs/tabulate/optional_lite.hpp @@ -1,1501 +1,1501 @@ -// -// Copyright (c) 2014-2018 Martin Moene -// -// https://github.com/martinmoene/optional-lite -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#pragma once - -#ifndef NONSTD_OPTIONAL_LITE_HPP -#define NONSTD_OPTIONAL_LITE_HPP - -#define optional_lite_MAJOR 3 -#define optional_lite_MINOR 2 -#define optional_lite_PATCH 0 - -#define optional_lite_VERSION \ - optional_STRINGIFY(optional_lite_MAJOR) "." optional_STRINGIFY( \ - optional_lite_MINOR) "." optional_STRINGIFY(optional_lite_PATCH) - -#define optional_STRINGIFY(x) optional_STRINGIFY_(x) -#define optional_STRINGIFY_(x) #x - -// optional-lite configuration: - -#define optional_OPTIONAL_DEFAULT 0 -#define optional_OPTIONAL_NONSTD 1 -#define optional_OPTIONAL_STD 2 - -#if !defined(optional_CONFIG_SELECT_OPTIONAL) -#define optional_CONFIG_SELECT_OPTIONAL \ - (optional_HAVE_STD_OPTIONAL ? optional_OPTIONAL_STD : optional_OPTIONAL_NONSTD) -#endif - -// Control presence of exception handling (try and auto discover): - -#ifndef optional_CONFIG_NO_EXCEPTIONS -#if defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND) -#define optional_CONFIG_NO_EXCEPTIONS 0 -#else -#define optional_CONFIG_NO_EXCEPTIONS 1 -#endif -#endif - -// C++ language version detection (C++20 is speculative): -// Note: VC14.0/1900 (VS2015) lacks too much from C++14. - -#ifndef optional_CPLUSPLUS -#if defined(_MSVC_LANG) && !defined(__clang__) -#define optional_CPLUSPLUS (_MSC_VER == 1900 ? 201103L : _MSVC_LANG) -#else -#define optional_CPLUSPLUS __cplusplus -#endif -#endif - -#define optional_CPP98_OR_GREATER (optional_CPLUSPLUS >= 199711L) -#define optional_CPP11_OR_GREATER (optional_CPLUSPLUS >= 201103L) -#define optional_CPP11_OR_GREATER_ (optional_CPLUSPLUS >= 201103L) -#define optional_CPP14_OR_GREATER (optional_CPLUSPLUS >= 201402L) -#define optional_CPP17_OR_GREATER (optional_CPLUSPLUS >= 201703L) -#define optional_CPP20_OR_GREATER (optional_CPLUSPLUS >= 202000L) - -// C++ language version (represent 98 as 3): - -#define optional_CPLUSPLUS_V \ - (optional_CPLUSPLUS / 100 - (optional_CPLUSPLUS > 200000 ? 2000 : 1994)) - -// Use C++17 std::optional if available and requested: - -#if optional_CPP17_OR_GREATER && defined(__has_include) -#if __has_include( ) -#define optional_HAVE_STD_OPTIONAL 1 -#else -#define optional_HAVE_STD_OPTIONAL 0 -#endif -#else -#define optional_HAVE_STD_OPTIONAL 0 -#endif - -#define optional_USES_STD_OPTIONAL \ - ((optional_CONFIG_SELECT_OPTIONAL == optional_OPTIONAL_STD) || \ - ((optional_CONFIG_SELECT_OPTIONAL == optional_OPTIONAL_DEFAULT) && optional_HAVE_STD_OPTIONAL)) - -// -// in_place: code duplicated in any-lite, expected-lite, optional-lite, value-ptr-lite, -// variant-lite: -// - -#ifndef nonstd_lite_HAVE_IN_PLACE_TYPES -#define nonstd_lite_HAVE_IN_PLACE_TYPES 1 - -// C++17 std::in_place in : - -#if optional_CPP17_OR_GREATER - -#include - -namespace nonstd { - -using std::in_place; -using std::in_place_index; -using std::in_place_index_t; -using std::in_place_t; -using std::in_place_type; -using std::in_place_type_t; - -#define nonstd_lite_in_place_t(T) std::in_place_t -#define nonstd_lite_in_place_type_t(T) std::in_place_type_t -#define nonstd_lite_in_place_index_t(K) std::in_place_index_t - -#define nonstd_lite_in_place(T) \ - std::in_place_t {} -#define nonstd_lite_in_place_type(T) \ - std::in_place_type_t {} -#define nonstd_lite_in_place_index(K) \ - std::in_place_index_t {} - -} // namespace nonstd - -#else // optional_CPP17_OR_GREATER - -#include - -namespace nonstd { -namespace detail { - -template struct in_place_type_tag {}; - -template struct in_place_index_tag {}; - -} // namespace detail - -struct in_place_t {}; - -template -inline in_place_t -in_place(detail::in_place_type_tag /*unused*/ = detail::in_place_type_tag()) { - return in_place_t(); -} - -template -inline in_place_t -in_place(detail::in_place_index_tag /*unused*/ = detail::in_place_index_tag()) { - return in_place_t(); -} - -template -inline in_place_t -in_place_type(detail::in_place_type_tag /*unused*/ = detail::in_place_type_tag()) { - return in_place_t(); -} - -template -inline in_place_t -in_place_index(detail::in_place_index_tag /*unused*/ = detail::in_place_index_tag()) { - return in_place_t(); -} - -// mimic templated typedef: - -#define nonstd_lite_in_place_t(T) nonstd::in_place_t (&)(nonstd::detail::in_place_type_tag) -#define nonstd_lite_in_place_type_t(T) nonstd::in_place_t (&)(nonstd::detail::in_place_type_tag) -#define nonstd_lite_in_place_index_t(K) \ - nonstd::in_place_t (&)(nonstd::detail::in_place_index_tag) - -#define nonstd_lite_in_place(T) nonstd::in_place_type -#define nonstd_lite_in_place_type(T) nonstd::in_place_type -#define nonstd_lite_in_place_index(K) nonstd::in_place_index - -} // namespace nonstd - -#endif // optional_CPP17_OR_GREATER -#endif // nonstd_lite_HAVE_IN_PLACE_TYPES - -// -// Using std::optional: -// - -#if optional_USES_STD_OPTIONAL - -#include - -namespace nonstd { - -using std::bad_optional_access; -using std::hash; -using std::optional; - -using std::nullopt; -using std::nullopt_t; - -using std::operator==; -using std::operator!=; -using std::operator<; -using std::operator<=; -using std::operator>; -using std::operator>=; -using std::make_optional; -using std::swap; -} // namespace nonstd - -#else // optional_USES_STD_OPTIONAL - -#include -#include - -// optional-lite alignment configuration: - -#ifndef optional_CONFIG_MAX_ALIGN_HACK -#define optional_CONFIG_MAX_ALIGN_HACK 0 -#endif - -#ifndef optional_CONFIG_ALIGN_AS -// no default, used in #if defined() -#endif - -#ifndef optional_CONFIG_ALIGN_AS_FALLBACK -#define optional_CONFIG_ALIGN_AS_FALLBACK double -#endif - -// Compiler warning suppression: - -#if defined(__clang__) -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wundef" -#elif defined(__GNUC__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wundef" -#elif defined(_MSC_VER) -#pragma warning(push) -#endif - -// half-open range [lo..hi): -#define optional_BETWEEN(v, lo, hi) ((lo) <= (v) && (v) < (hi)) - -// Compiler versions: -// -// MSVC++ 6.0 _MSC_VER == 1200 optional_COMPILER_MSVC_VERSION == 60 (Visual Studio 6.0) -// MSVC++ 7.0 _MSC_VER == 1300 optional_COMPILER_MSVC_VERSION == 70 (Visual Studio .NET 2002) -// MSVC++ 7.1 _MSC_VER == 1310 optional_COMPILER_MSVC_VERSION == 71 (Visual Studio .NET 2003) -// MSVC++ 8.0 _MSC_VER == 1400 optional_COMPILER_MSVC_VERSION == 80 (Visual Studio 2005) -// MSVC++ 9.0 _MSC_VER == 1500 optional_COMPILER_MSVC_VERSION == 90 (Visual Studio 2008) -// MSVC++ 10.0 _MSC_VER == 1600 optional_COMPILER_MSVC_VERSION == 100 (Visual Studio 2010) -// MSVC++ 11.0 _MSC_VER == 1700 optional_COMPILER_MSVC_VERSION == 110 (Visual Studio 2012) -// MSVC++ 12.0 _MSC_VER == 1800 optional_COMPILER_MSVC_VERSION == 120 (Visual Studio 2013) -// MSVC++ 14.0 _MSC_VER == 1900 optional_COMPILER_MSVC_VERSION == 140 (Visual Studio 2015) -// MSVC++ 14.1 _MSC_VER >= 1910 optional_COMPILER_MSVC_VERSION == 141 (Visual Studio 2017) -// MSVC++ 14.2 _MSC_VER >= 1920 optional_COMPILER_MSVC_VERSION == 142 (Visual Studio 2019) - -#if defined(_MSC_VER) && !defined(__clang__) -#define optional_COMPILER_MSVC_VER (_MSC_VER) -#define optional_COMPILER_MSVC_VERSION (_MSC_VER / 10 - 10 * (5 + (_MSC_VER < 1900))) -#else -#define optional_COMPILER_MSVC_VER 0 -#define optional_COMPILER_MSVC_VERSION 0 -#endif - -#define optional_COMPILER_VERSION(major, minor, patch) (10 * (10 * (major) + (minor)) + (patch)) - -#if defined(__GNUC__) && !defined(__clang__) -#define optional_COMPILER_GNUC_VERSION \ - optional_COMPILER_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) -#else -#define optional_COMPILER_GNUC_VERSION 0 -#endif - -#if defined(__clang__) -#define optional_COMPILER_CLANG_VERSION \ - optional_COMPILER_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__) -#else -#define optional_COMPILER_CLANG_VERSION 0 -#endif - -#if optional_BETWEEN(optional_COMPILER_MSVC_VERSION, 70, 140) -#pragma warning(disable : 4345) // initialization behavior changed -#endif - -#if optional_BETWEEN(optional_COMPILER_MSVC_VERSION, 70, 150) -#pragma warning(disable : 4814) // in C++14 'constexpr' will not imply 'const' -#endif - -// Presence of language and library features: - -#define optional_HAVE(FEATURE) (optional_HAVE_##FEATURE) - -#ifdef _HAS_CPP0X -#define optional_HAS_CPP0X _HAS_CPP0X -#else -#define optional_HAS_CPP0X 0 -#endif - -// Unless defined otherwise below, consider VC14 as C++11 for optional-lite: - -#if optional_COMPILER_MSVC_VER >= 1900 -#undef optional_CPP11_OR_GREATER -#define optional_CPP11_OR_GREATER 1 -#endif - -#define optional_CPP11_90 (optional_CPP11_OR_GREATER_ || optional_COMPILER_MSVC_VER >= 1500) -#define optional_CPP11_100 (optional_CPP11_OR_GREATER_ || optional_COMPILER_MSVC_VER >= 1600) -#define optional_CPP11_110 (optional_CPP11_OR_GREATER_ || optional_COMPILER_MSVC_VER >= 1700) -#define optional_CPP11_120 (optional_CPP11_OR_GREATER_ || optional_COMPILER_MSVC_VER >= 1800) -#define optional_CPP11_140 (optional_CPP11_OR_GREATER_ || optional_COMPILER_MSVC_VER >= 1900) -#define optional_CPP11_141 (optional_CPP11_OR_GREATER_ || optional_COMPILER_MSVC_VER >= 1910) - -#define optional_CPP11_140_490 \ - ((optional_CPP11_OR_GREATER_ && optional_COMPILER_GNUC_VERSION >= 490) || \ - (optional_COMPILER_MSVC_VER >= 1910)) - -#define optional_CPP14_000 (optional_CPP14_OR_GREATER) -#define optional_CPP17_000 (optional_CPP17_OR_GREATER) - -// Presence of C++11 language features: - -#define optional_HAVE_CONSTEXPR_11 optional_CPP11_140 -#define optional_HAVE_IS_DEFAULT optional_CPP11_140 -#define optional_HAVE_NOEXCEPT optional_CPP11_140 -#define optional_HAVE_NULLPTR optional_CPP11_100 -#define optional_HAVE_REF_QUALIFIER optional_CPP11_140_490 -#define optional_HAVE_INITIALIZER_LIST optional_CPP11_140 - -// Presence of C++14 language features: - -#define optional_HAVE_CONSTEXPR_14 optional_CPP14_000 - -// Presence of C++17 language features: - -#define optional_HAVE_NODISCARD optional_CPP17_000 - -// Presence of C++ library features: - -#define optional_HAVE_CONDITIONAL optional_CPP11_120 -#define optional_HAVE_REMOVE_CV optional_CPP11_120 -#define optional_HAVE_TYPE_TRAITS optional_CPP11_90 - -#define optional_HAVE_TR1_TYPE_TRAITS (!!optional_COMPILER_GNUC_VERSION) -#define optional_HAVE_TR1_ADD_POINTER (!!optional_COMPILER_GNUC_VERSION) - -// C++ feature usage: - -#if optional_HAVE(CONSTEXPR_11) -#define optional_constexpr constexpr -#else -#define optional_constexpr /*constexpr*/ -#endif - -#if optional_HAVE(IS_DEFAULT) -#define optional_is_default = default; -#else -#define optional_is_default \ - {} -#endif - -#if optional_HAVE(CONSTEXPR_14) -#define optional_constexpr14 constexpr -#else -#define optional_constexpr14 /*constexpr*/ -#endif - -#if optional_HAVE(NODISCARD) -#define optional_nodiscard [[nodiscard]] -#else -#define optional_nodiscard /*[[nodiscard]]*/ -#endif - -#if optional_HAVE(NOEXCEPT) -#define optional_noexcept noexcept -#else -#define optional_noexcept /*noexcept*/ -#endif - -#if optional_HAVE(NULLPTR) -#define optional_nullptr nullptr -#else -#define optional_nullptr NULL -#endif - -#if optional_HAVE(REF_QUALIFIER) -// NOLINTNEXTLINE( bugprone-macro-parentheses ) -#define optional_ref_qual & -#define optional_refref_qual && -#else -#define optional_ref_qual /*&*/ -#define optional_refref_qual /*&&*/ -#endif - -// additional includes: - -#if optional_CONFIG_NO_EXCEPTIONS -// already included: -#else -#include -#endif - -#if optional_CPP11_OR_GREATER -#include -#endif - -#if optional_HAVE(INITIALIZER_LIST) -#include -#endif - -#if optional_HAVE(TYPE_TRAITS) -#include -#elif optional_HAVE(TR1_TYPE_TRAITS) -#include -#endif - -// Method enabling - -#if optional_CPP11_OR_GREATER - -#define optional_REQUIRES_0(...) \ - template ::type = 0> - -#define optional_REQUIRES_T(...) , typename std::enable_if<(__VA_ARGS__), int>::type = 0 - -#define optional_REQUIRES_R(R, ...) typename std::enable_if<(__VA_ARGS__), R>::type - -#define optional_REQUIRES_A(...) , typename std::enable_if<(__VA_ARGS__), void *>::type = nullptr - -#endif - -// -// optional: -// - -namespace nonstd { -namespace optional_lite { - -namespace std11 { - -#if optional_CPP11_OR_GREATER -using std::move; -#else -template T &move(T &t) { return t; } -#endif - -#if optional_HAVE(CONDITIONAL) -using std::conditional; -#else -template struct conditional { typedef T type; }; -template struct conditional { typedef F type; }; -#endif // optional_HAVE_CONDITIONAL - -// gcc < 5: -#if optional_CPP11_OR_GREATER -#if optional_BETWEEN(optional_COMPILER_GNUC_VERSION, 1, 500) -template struct is_trivially_copy_constructible : std::true_type {}; -template struct is_trivially_move_constructible : std::true_type {}; -#else -using std::is_trivially_copy_constructible; -using std::is_trivially_move_constructible; -#endif -#endif -} // namespace std11 - -#if optional_CPP11_OR_GREATER - -/// type traits C++17: - -namespace std17 { - -#if optional_CPP17_OR_GREATER - -using std::is_nothrow_swappable; -using std::is_swappable; - -#elif optional_CPP11_OR_GREATER - -namespace detail { - -using std::swap; - -struct is_swappable { - template (), std::declval()))> - static std::true_type test(int /*unused*/); - - template static std::false_type test(...); -}; - -struct is_nothrow_swappable { - // wrap noexcept(expr) in separate function as work-around for VC140 (VS2015): - - template static constexpr bool satisfies() { - return noexcept(swap(std::declval(), std::declval())); - } - - template - static auto test(int /*unused*/) -> std::integral_constant()> {} - - template static auto test(...) -> std::false_type; -}; - -} // namespace detail - -// is [nothow] swappable: - -template struct is_swappable : decltype(detail::is_swappable::test(0)) {}; - -template -struct is_nothrow_swappable : decltype(detail::is_nothrow_swappable::test(0)) {}; - -#endif // optional_CPP17_OR_GREATER - -} // namespace std17 - -/// type traits C++20: - -namespace std20 { - -template struct remove_cvref { - typedef typename std::remove_cv::type>::type type; -}; - -} // namespace std20 - -#endif // optional_CPP11_OR_GREATER - -/// class optional - -template class optional; - -namespace detail { - -// C++11 emulation: - -struct nulltype {}; - -template struct typelist { - typedef Head head; - typedef Tail tail; -}; - -#if optional_CONFIG_MAX_ALIGN_HACK - -// Max align, use most restricted type for alignment: - -#define optional_UNIQUE(name) optional_UNIQUE2(name, __LINE__) -#define optional_UNIQUE2(name, line) optional_UNIQUE3(name, line) -#define optional_UNIQUE3(name, line) name##line - -#define optional_ALIGN_TYPE(type) \ - type optional_UNIQUE(_t); \ - struct_t optional_UNIQUE(_st) - -template struct struct_t { T _; }; - -union max_align_t { - optional_ALIGN_TYPE(char); - optional_ALIGN_TYPE(short int); - optional_ALIGN_TYPE(int); - optional_ALIGN_TYPE(long int); - optional_ALIGN_TYPE(float); - optional_ALIGN_TYPE(double); - optional_ALIGN_TYPE(long double); - optional_ALIGN_TYPE(char *); - optional_ALIGN_TYPE(short int *); - optional_ALIGN_TYPE(int *); - optional_ALIGN_TYPE(long int *); - optional_ALIGN_TYPE(float *); - optional_ALIGN_TYPE(double *); - optional_ALIGN_TYPE(long double *); - optional_ALIGN_TYPE(void *); - -#ifdef HAVE_LONG_LONG - optional_ALIGN_TYPE(long long); -#endif - - struct Unknown; - - Unknown (*optional_UNIQUE(_))(Unknown); - Unknown *Unknown::*optional_UNIQUE(_); - Unknown (Unknown::*optional_UNIQUE(_))(Unknown); - - struct_t optional_UNIQUE(_); - struct_t optional_UNIQUE(_); - struct_t optional_UNIQUE(_); -}; - -#undef optional_UNIQUE -#undef optional_UNIQUE2 -#undef optional_UNIQUE3 - -#undef optional_ALIGN_TYPE - -#elif defined(optional_CONFIG_ALIGN_AS) // optional_CONFIG_MAX_ALIGN_HACK - -// Use user-specified type for alignment: - -#define optional_ALIGN_AS(unused) optional_CONFIG_ALIGN_AS - -#else // optional_CONFIG_MAX_ALIGN_HACK - -// Determine POD type to use for alignment: - -#define optional_ALIGN_AS(to_align) \ - typename type_of_size::value>::type - -template struct alignment_of; - -template struct alignment_of_hack { - char c; - T t; - alignment_of_hack(); -}; - -template struct alignment_logic { - enum { value = A < S ? A : S }; -}; - -template struct alignment_of { - enum { value = alignment_logic) - sizeof(T), sizeof(T)>::value }; -}; - -template struct type_of_size { - typedef - typename std11::conditional::type>::type type; -}; - -template struct type_of_size { - typedef optional_CONFIG_ALIGN_AS_FALLBACK type; -}; - -template struct struct_t { T _; }; - -#define optional_ALIGN_TYPE(type) typelist < type, typelist < struct_t - -struct Unknown; - -typedef optional_ALIGN_TYPE(char), optional_ALIGN_TYPE(short), optional_ALIGN_TYPE(int), - optional_ALIGN_TYPE(long), optional_ALIGN_TYPE(float), optional_ALIGN_TYPE(double), - optional_ALIGN_TYPE(long double), - - optional_ALIGN_TYPE(char *), optional_ALIGN_TYPE(short *), optional_ALIGN_TYPE(int *), - optional_ALIGN_TYPE(long *), optional_ALIGN_TYPE(float *), optional_ALIGN_TYPE(double *), - optional_ALIGN_TYPE(long double *), - - optional_ALIGN_TYPE(Unknown (*)(Unknown)), optional_ALIGN_TYPE(Unknown *Unknown::*), - optional_ALIGN_TYPE(Unknown (Unknown::*)(Unknown)), - - nulltype >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> alignment_types; - -#undef optional_ALIGN_TYPE - -#endif // optional_CONFIG_MAX_ALIGN_HACK - -/// C++03 constructed union to hold value. - -template union storage_t { - // private: - // template< typename > friend class optional; - - typedef T value_type; - - storage_t() optional_is_default - - explicit storage_t(value_type const &v) { - construct_value(v); - } - - void construct_value(value_type const &v) { ::new (value_ptr()) value_type(v); } - -#if optional_CPP11_OR_GREATER - - explicit storage_t(value_type &&v) { construct_value(std::move(v)); } - - void construct_value(value_type &&v) { ::new (value_ptr()) value_type(std::move(v)); } - - template void emplace(Args &&... args) { - ::new (value_ptr()) value_type(std::forward(args)...); - } - - template void emplace(std::initializer_list il, Args &&... args) { - ::new (value_ptr()) value_type(il, std::forward(args)...); - } - -#endif - - void destruct_value() { value_ptr()->~T(); } - - optional_nodiscard value_type const *value_ptr() const { return as(); } - - value_type *value_ptr() { return as(); } - - optional_nodiscard value_type const &value() const optional_ref_qual { return *value_ptr(); } - - value_type &value() optional_ref_qual { return *value_ptr(); } - -#if optional_HAVE(REF_QUALIFIER) - - optional_nodiscard value_type const &&value() const optional_refref_qual { - return std::move(value()); - } - - value_type &&value() optional_refref_qual { return std::move(value()); } - -#endif - -#if optional_CPP11_OR_GREATER - - using aligned_storage_t = - typename std::aligned_storage::type; - aligned_storage_t data; - -#elif optional_CONFIG_MAX_ALIGN_HACK - - typedef struct { - unsigned char data[sizeof(value_type)]; - } aligned_storage_t; - - max_align_t hack; - aligned_storage_t data; - -#else - typedef optional_ALIGN_AS(value_type) align_as_type; - - typedef struct { - align_as_type data[1 + (sizeof(value_type) - 1) / sizeof(align_as_type)]; - } aligned_storage_t; - aligned_storage_t data; - -#undef optional_ALIGN_AS - -#endif // optional_CONFIG_MAX_ALIGN_HACK - - optional_nodiscard void *ptr() optional_noexcept { return &data; } - - optional_nodiscard void const *ptr() const optional_noexcept { return &data; } - - template optional_nodiscard U *as() { return reinterpret_cast(ptr()); } - - template optional_nodiscard U const *as() const { - return reinterpret_cast(ptr()); - } -}; - -} // namespace detail - -/// disengaged state tag - -struct nullopt_t { - struct init {}; - explicit optional_constexpr nullopt_t(init /*unused*/) optional_noexcept {} -}; - -#if optional_HAVE(CONSTEXPR_11) -constexpr nullopt_t nullopt{nullopt_t::init{}}; -#else -// extra parenthesis to prevent the most vexing parse: -const nullopt_t nullopt((nullopt_t::init())); -#endif - -/// optional access error - -#if !optional_CONFIG_NO_EXCEPTIONS - -class bad_optional_access : public std::logic_error { -public: - explicit bad_optional_access() : logic_error("bad optional access") {} -}; - -#endif // optional_CONFIG_NO_EXCEPTIONS - -/// optional - -template class optional { -private: - template friend class optional; - - typedef void (optional::*safe_bool)() const; - -public: - typedef T value_type; - - // x.x.3.1, constructors - - // 1a - default construct - optional_constexpr optional() optional_noexcept : has_value_(false), contained() {} - - // 1b - construct explicitly empty - // NOLINTNEXTLINE( google-explicit-constructor, hicpp-explicit-conversions ) - optional_constexpr optional(nullopt_t /*unused*/) optional_noexcept : has_value_(false), - contained() {} - - // 2 - copy-construct -#if optional_CPP11_OR_GREATER - // template< typename U = T - // optional_REQUIRES_T( - // std::is_copy_constructible::value - // || std11::is_trivially_copy_constructible::value - // ) - // > -#endif - optional_constexpr14 optional(optional const &other) : has_value_(other.has_value()) { - if (other.has_value()) { - contained.construct_value(other.contained.value()); - } - } - -#if optional_CPP11_OR_GREATER - - // 3 (C++11) - move-construct from optional - template ::value || - std11::is_trivially_move_constructible::value)> - optional_constexpr14 optional(optional &&other) - // NOLINTNEXTLINE( performance-noexcept-move-constructor ) - noexcept(std::is_nothrow_move_constructible::value) - : has_value_(other.has_value()) { - if (other.has_value()) { - contained.construct_value(std::move(other.contained.value())); - } - } - - // 4a (C++11) - explicit converting copy-construct from optional - template ::value && - !std::is_constructible &>::value && - !std::is_constructible &&>::value && - !std::is_constructible const &>::value && - !std::is_constructible const &&>::value && - !std::is_convertible &, T>::value && - !std::is_convertible &&, T>::value && - !std::is_convertible const &, T>::value && - !std::is_convertible const &&, T>::value && - !std::is_convertible::value /*=> explicit - */ - )> - explicit optional(optional const &other) : has_value_(other.has_value()) { - if (other.has_value()) { - contained.construct_value(T{other.contained.value()}); - } - } -#endif // optional_CPP11_OR_GREATER - - // 4b (C++98 and later) - non-explicit converting copy-construct from optional - template ::value && - !std::is_constructible &>::value && - !std::is_constructible &&>::value && - !std::is_constructible const &>::value && - !std::is_constructible const &&>::value && - !std::is_convertible &, T>::value && - !std::is_convertible &&, T>::value && - !std::is_convertible const &, T>::value && - !std::is_convertible const &&, T>::value && - std::is_convertible::value /*=> non-explicit */ - ) -#endif // optional_CPP11_OR_GREATER - > - // NOLINTNEXTLINE( google-explicit-constructor, hicpp-explicit-conversions ) - /*non-explicit*/ optional(optional const &other) : has_value_(other.has_value()) { - if (other.has_value()) { - contained.construct_value(other.contained.value()); - } - } - -#if optional_CPP11_OR_GREATER - - // 5a (C++11) - explicit converting move-construct from optional - template ::value && - !std::is_constructible &>::value && - !std::is_constructible &&>::value && - !std::is_constructible const &>::value && - !std::is_constructible const &&>::value && - !std::is_convertible &, T>::value && - !std::is_convertible &&, T>::value && - !std::is_convertible const &, T>::value && - !std::is_convertible const &&, T>::value && - !std::is_convertible::value /*=> explicit */ - )> - explicit optional(optional &&other) : has_value_(other.has_value()) { - if (other.has_value()) { - contained.construct_value(T{std::move(other.contained.value())}); - } - } - - // 5a (C++11) - non-explicit converting move-construct from optional - template ::value && - !std::is_constructible &>::value && - !std::is_constructible &&>::value && - !std::is_constructible const &>::value && - !std::is_constructible const &&>::value && - !std::is_convertible &, T>::value && - !std::is_convertible &&, T>::value && - !std::is_convertible const &, T>::value && - !std::is_convertible const &&, T>::value && - std::is_convertible::value /*=> non-explicit */ - )> - // NOLINTNEXTLINE( google-explicit-constructor, hicpp-explicit-conversions ) - /*non-explicit*/ optional(optional &&other) : has_value_(other.has_value()) { - if (other.has_value()) { - contained.construct_value(std::move(other.contained.value())); - } - } - - // 6 (C++11) - in-place construct - template ::value)> - optional_constexpr explicit optional(nonstd_lite_in_place_t(T), Args &&... args) - : has_value_(true), contained(T(std::forward(args)...)) {} - - // 7 (C++11) - in-place construct, initializer-list - template &, Args &&...>::value)> - optional_constexpr explicit optional(nonstd_lite_in_place_t(T), std::initializer_list il, - Args &&... args) - : has_value_(true), contained(T(il, std::forward(args)...)) {} - - // 8a (C++11) - explicit move construct from value - template < - typename U = T optional_REQUIRES_T( - std::is_constructible::value && - !std::is_same::type, nonstd_lite_in_place_t(U)>::value && - !std::is_same::type, optional>::value && - !std::is_convertible::value /*=> explicit */ - )> - optional_constexpr explicit optional(U &&value) - : has_value_(true), contained(T{std::forward(value)}) {} - - // 8b (C++11) - non-explicit move construct from value - template < - typename U = T optional_REQUIRES_T( - std::is_constructible::value && - !std::is_same::type, nonstd_lite_in_place_t(U)>::value && - !std::is_same::type, optional>::value && - std::is_convertible::value /*=> non-explicit */ - )> - // NOLINTNEXTLINE( google-explicit-constructor, hicpp-explicit-conversions ) - optional_constexpr /*non-explicit*/ optional(U &&value) - : has_value_(true), contained(std::forward(value)) {} - -#else // optional_CPP11_OR_GREATER - - // 8 (C++98) - optional(value_type const &value) : has_value_(true), contained(value) {} - -#endif // optional_CPP11_OR_GREATER - - // x.x.3.2, destructor - - ~optional() { - if (has_value()) { - contained.destruct_value(); - } - } - - // x.x.3.3, assignment - - // 1 (C++98and later) - assign explicitly empty - optional &operator=(nullopt_t /*unused*/) optional_noexcept { - reset(); - return *this; - } - - // 2 (C++98and later) - copy-assign from optional -#if optional_CPP11_OR_GREATER - // NOLINTNEXTLINE( cppcoreguidelines-c-copy-assignment-signature, - // misc-unconventional-assign-operator ) - optional_REQUIRES_R(optional &, true - // std::is_copy_constructible::value - // && std::is_copy_assignable::value - ) - operator=(optional const &other) noexcept( - std::is_nothrow_move_assignable::value &&std::is_nothrow_move_constructible::value) -#else - optional &operator=(optional const &other) -#endif - { - if ((has_value() == true) && (other.has_value() == false)) { - reset(); - } else if ((has_value() == false) && (other.has_value() == true)) { - initialize(*other); - } else if ((has_value() == true) && (other.has_value() == true)) { - contained.value() = *other; - } - return *this; - } - -#if optional_CPP11_OR_GREATER - - // 3 (C++11) - move-assign from optional - // NOLINTNEXTLINE( cppcoreguidelines-c-copy-assignment-signature, - // misc-unconventional-assign-operator ) - optional_REQUIRES_R(optional &, true - // std::is_move_constructible::value - // && std::is_move_assignable::value - ) - operator=(optional &&other) noexcept { - if ((has_value() == true) && (other.has_value() == false)) { - reset(); - } else if ((has_value() == false) && (other.has_value() == true)) { - initialize(std::move(*other)); - } else if ((has_value() == true) && (other.has_value() == true)) { - contained.value() = std::move(*other); - } - return *this; - } - - // 4 (C++11) - move-assign from value - template - // NOLINTNEXTLINE( cppcoreguidelines-c-copy-assignment-signature, - // misc-unconventional-assign-operator ) - optional_REQUIRES_R( - optional &, - std::is_constructible::value &&std::is_assignable::value && - !std::is_same::type, nonstd_lite_in_place_t(U)>::value && - !std::is_same::type, optional>::value && - !(std::is_scalar::value && std::is_same::type>::value)) - operator=(U &&value) { - if (has_value()) { - contained.value() = std::forward(value); - } else { - initialize(T(std::forward(value))); - } - return *this; - } - -#else // optional_CPP11_OR_GREATER - - // 4 (C++98) - copy-assign from value - template optional &operator=(U const &value) { - if (has_value()) - contained.value() = value; - else - initialize(T(value)); - return *this; - } - -#endif // optional_CPP11_OR_GREATER - - // 5 (C++98 and later) - converting copy-assign from optional - template -#if optional_CPP11_OR_GREATER - // NOLINTNEXTLINE( cppcoreguidelines-c-copy-assignment-signature, - // misc-unconventional-assign-operator ) - optional_REQUIRES_R( - optional &, - std::is_constructible::value &&std::is_assignable::value && - !std::is_constructible &>::value && - !std::is_constructible &&>::value && - !std::is_constructible const &>::value && - !std::is_constructible const &&>::value && - !std::is_convertible &, T>::value && - !std::is_convertible &&, T>::value && - !std::is_convertible const &, T>::value && - !std::is_convertible const &&, T>::value && - !std::is_assignable &>::value && - !std::is_assignable &&>::value && - !std::is_assignable const &>::value && - !std::is_assignable const &&>::value) -#else - optional & -#endif // optional_CPP11_OR_GREATER - operator=(optional const &other) { - return *this = optional(other); - } - -#if optional_CPP11_OR_GREATER - - // 6 (C++11) - converting move-assign from optional - template - // NOLINTNEXTLINE( cppcoreguidelines-c-copy-assignment-signature, - // misc-unconventional-assign-operator ) - optional_REQUIRES_R(optional &, - std::is_constructible::value &&std::is_assignable::value && - !std::is_constructible &>::value && - !std::is_constructible &&>::value && - !std::is_constructible const &>::value && - !std::is_constructible const &&>::value && - !std::is_convertible &, T>::value && - !std::is_convertible &&, T>::value && - !std::is_convertible const &, T>::value && - !std::is_convertible const &&, T>::value && - !std::is_assignable &>::value && - !std::is_assignable &&>::value && - !std::is_assignable const &>::value && - !std::is_assignable const &&>::value) - operator=(optional &&other) { - return *this = optional(std::move(other)); - } - - // 7 (C++11) - emplace - template ::value)> - T &emplace(Args &&... args) { - *this = nullopt; - contained.emplace(std::forward(args)...); - has_value_ = true; - return contained.value(); - } - - // 8 (C++11) - emplace, initializer-list - template &, Args &&...>::value)> - T &emplace(std::initializer_list il, Args &&... args) { - *this = nullopt; - contained.emplace(il, std::forward(args)...); - has_value_ = true; - return contained.value(); - } - -#endif // optional_CPP11_OR_GREATER - - // x.x.3.4, swap - - void swap(optional &other) -#if optional_CPP11_OR_GREATER - noexcept(std::is_nothrow_move_constructible::value &&std17::is_nothrow_swappable::value) -#endif - { - using std::swap; - if ((has_value() == true) && (other.has_value() == true)) { - swap(**this, *other); - } else if ((has_value() == false) && (other.has_value() == true)) { - initialize(std11::move(*other)); - other.reset(); - } else if ((has_value() == true) && (other.has_value() == false)) { - other.initialize(std11::move(**this)); - reset(); - } - } - - // x.x.3.5, observers - - optional_constexpr value_type const *operator->() const { - return assert(has_value()), contained.value_ptr(); - } - - optional_constexpr14 value_type *operator->() { - return assert(has_value()), contained.value_ptr(); - } - - optional_constexpr value_type const &operator*() const optional_ref_qual { - return assert(has_value()), contained.value(); - } - - optional_constexpr14 value_type &operator*() optional_ref_qual { - return assert(has_value()), contained.value(); - } - -#if optional_HAVE(REF_QUALIFIER) - - optional_constexpr value_type const &&operator*() const optional_refref_qual { - return std::move(**this); - } - - optional_constexpr14 value_type &&operator*() optional_refref_qual { return std::move(**this); } - -#endif - -#if optional_CPP11_OR_GREATER - optional_constexpr explicit operator bool() const optional_noexcept { return has_value(); } -#else - optional_constexpr operator safe_bool() const optional_noexcept { - return has_value() ? &optional::this_type_does_not_support_comparisons : 0; - } -#endif - - // NOLINTNEXTLINE( modernize-use-nodiscard ) - /*optional_nodiscard*/ optional_constexpr bool has_value() const optional_noexcept { - return has_value_; - } - - // NOLINTNEXTLINE( modernize-use-nodiscard ) - /*optional_nodiscard*/ optional_constexpr14 value_type const &value() const optional_ref_qual { -#if optional_CONFIG_NO_EXCEPTIONS - assert(has_value()); -#else - if (!has_value()) { - throw bad_optional_access(); - } -#endif - return contained.value(); - } - - optional_constexpr14 value_type &value() optional_ref_qual { -#if optional_CONFIG_NO_EXCEPTIONS - assert(has_value()); -#else - if (!has_value()) { - throw bad_optional_access(); - } -#endif - return contained.value(); - } - -#if optional_HAVE(REF_QUALIFIER) && \ - (!optional_COMPILER_GNUC_VERSION || optional_COMPILER_GNUC_VERSION >= 490) - - // NOLINTNEXTLINE( modernize-use-nodiscard ) - /*optional_nodiscard*/ optional_constexpr value_type const &&value() const optional_refref_qual { - return std::move(value()); - } - - optional_constexpr14 value_type &&value() optional_refref_qual { return std::move(value()); } - -#endif - -#if optional_CPP11_OR_GREATER - - template optional_constexpr value_type value_or(U &&v) const optional_ref_qual { - return has_value() ? contained.value() : static_cast(std::forward(v)); - } - - template optional_constexpr14 value_type value_or(U &&v) optional_refref_qual { - return has_value() ? std::move(contained.value()) : static_cast(std::forward(v)); - } - -#else - - template optional_constexpr value_type value_or(U const &v) const { - return has_value() ? contained.value() : static_cast(v); - } - -#endif // optional_CPP11_OR_GREATER - - // x.x.3.6, modifiers - - void reset() optional_noexcept { - if (has_value()) { - contained.destruct_value(); - } - - has_value_ = false; - } - -private: - void this_type_does_not_support_comparisons() const {} - - template void initialize(V const &value) { - assert(!has_value()); - contained.construct_value(value); - has_value_ = true; - } - -#if optional_CPP11_OR_GREATER - template void initialize(V &&value) { - assert(!has_value()); - contained.construct_value(std::move(value)); - has_value_ = true; - } - -#endif - -private: - bool has_value_; - detail::storage_t contained; -}; - -// Relational operators - -template -inline optional_constexpr bool operator==(optional const &x, optional const &y) { - return bool(x) != bool(y) ? false : !bool(x) ? true : *x == *y; -} - -template -inline optional_constexpr bool operator!=(optional const &x, optional const &y) { - return !(x == y); -} - -template -inline optional_constexpr bool operator<(optional const &x, optional const &y) { - return (!y) ? false : (!x) ? true : *x < *y; -} - -template -inline optional_constexpr bool operator>(optional const &x, optional const &y) { - return (y < x); -} - -template -inline optional_constexpr bool operator<=(optional const &x, optional const &y) { - return !(y < x); -} - -template -inline optional_constexpr bool operator>=(optional const &x, optional const &y) { - return !(x < y); -} - -// Comparison with nullopt - -template -inline optional_constexpr bool operator==(optional const &x, - nullopt_t /*unused*/) optional_noexcept { - return (!x); -} - -template -inline optional_constexpr bool operator==(nullopt_t /*unused*/, - optional const &x) optional_noexcept { - return (!x); -} - -template -inline optional_constexpr bool operator!=(optional const &x, - nullopt_t /*unused*/) optional_noexcept { - return bool(x); -} - -template -inline optional_constexpr bool operator!=(nullopt_t /*unused*/, - optional const &x) optional_noexcept { - return bool(x); -} - -template -inline optional_constexpr bool operator<(optional const & /*unused*/, - nullopt_t /*unused*/) optional_noexcept { - return false; -} - -template -inline optional_constexpr bool operator<(nullopt_t /*unused*/, - optional const &x) optional_noexcept { - return bool(x); -} - -template -inline optional_constexpr bool operator<=(optional const &x, - nullopt_t /*unused*/) optional_noexcept { - return (!x); -} - -template -inline optional_constexpr bool operator<=(nullopt_t /*unused*/, - optional const & /*unused*/) optional_noexcept { - return true; -} - -template -inline optional_constexpr bool operator>(optional const &x, - nullopt_t /*unused*/) optional_noexcept { - return bool(x); -} - -template -inline optional_constexpr bool operator>(nullopt_t /*unused*/, - optional const & /*unused*/) optional_noexcept { - return false; -} - -template -inline optional_constexpr bool operator>=(optional const & /*unused*/, - nullopt_t /*unused*/) optional_noexcept { - return true; -} - -template -inline optional_constexpr bool operator>=(nullopt_t /*unused*/, - optional const &x) optional_noexcept { - return (!x); -} - -// Comparison with T - -template -inline optional_constexpr bool operator==(optional const &x, U const &v) { - return bool(x) ? *x == v : false; -} - -template -inline optional_constexpr bool operator==(U const &v, optional const &x) { - return bool(x) ? v == *x : false; -} - -template -inline optional_constexpr bool operator!=(optional const &x, U const &v) { - return bool(x) ? *x != v : true; -} - -template -inline optional_constexpr bool operator!=(U const &v, optional const &x) { - return bool(x) ? v != *x : true; -} - -template -inline optional_constexpr bool operator<(optional const &x, U const &v) { - return bool(x) ? *x < v : true; -} - -template -inline optional_constexpr bool operator<(U const &v, optional const &x) { - return bool(x) ? v < *x : false; -} - -template -inline optional_constexpr bool operator<=(optional const &x, U const &v) { - return bool(x) ? *x <= v : true; -} - -template -inline optional_constexpr bool operator<=(U const &v, optional const &x) { - return bool(x) ? v <= *x : false; -} - -template -inline optional_constexpr bool operator>(optional const &x, U const &v) { - return bool(x) ? *x > v : false; -} - -template -inline optional_constexpr bool operator>(U const &v, optional const &x) { - return bool(x) ? v > *x : true; -} - -template -inline optional_constexpr bool operator>=(optional const &x, U const &v) { - return bool(x) ? *x >= v : false; -} - -template -inline optional_constexpr bool operator>=(U const &v, optional const &x) { - return bool(x) ? v >= *x : true; -} - -// Specialized algorithms - -template < - typename T -#if optional_CPP11_OR_GREATER - optional_REQUIRES_T(std::is_move_constructible::value &&std17::is_swappable::value) -#endif - > -void swap(optional &x, optional &y) -#if optional_CPP11_OR_GREATER - noexcept(noexcept(x.swap(y))) -#endif -{ - x.swap(y); -} - -#if optional_CPP11_OR_GREATER - -template -optional_constexpr optional::type> make_optional(T &&value) { - return optional::type>(std::forward(value)); -} - -template -optional_constexpr optional make_optional(Args &&... args) { - return optional(nonstd_lite_in_place(T), std::forward(args)...); -} - -template -optional_constexpr optional make_optional(std::initializer_list il, Args &&... args) { - return optional(nonstd_lite_in_place(T), il, std::forward(args)...); -} - -#else - -template optional make_optional(T const &value) { return optional(value); } - -#endif // optional_CPP11_OR_GREATER - -} // namespace optional_lite - -using optional_lite::nullopt; -using optional_lite::nullopt_t; -using optional_lite::optional; - -#if !optional_CONFIG_NO_EXCEPTIONS -using optional_lite::bad_optional_access; -#endif - -using optional_lite::make_optional; - -} // namespace nonstd - -#if optional_CPP11_OR_GREATER - -// specialize the std::hash algorithm: - -namespace std { - -template struct hash> { -public: - std::size_t operator()(nonstd::optional const &v) const optional_noexcept { - return bool(v) ? std::hash{}(*v) : 0; - } -}; - -} // namespace std - -#endif // optional_CPP11_OR_GREATER - -#if defined(__clang__) -#pragma clang diagnostic pop -#elif defined(__GNUC__) -#pragma GCC diagnostic pop -#elif defined(_MSC_VER) -#pragma warning(pop) -#endif - -#endif // optional_USES_STD_OPTIONAL - -#endif // NONSTD_OPTIONAL_LITE_HPP +// +// Copyright (c) 2014-2018 Martin Moene +// +// https://github.com/martinmoene/optional-lite +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#pragma once + +#ifndef NONSTD_OPTIONAL_LITE_HPP +#define NONSTD_OPTIONAL_LITE_HPP + +#define optional_lite_MAJOR 3 +#define optional_lite_MINOR 2 +#define optional_lite_PATCH 0 + +#define optional_lite_VERSION \ + optional_STRINGIFY(optional_lite_MAJOR) "." optional_STRINGIFY( \ + optional_lite_MINOR) "." optional_STRINGIFY(optional_lite_PATCH) + +#define optional_STRINGIFY(x) optional_STRINGIFY_(x) +#define optional_STRINGIFY_(x) #x + +// optional-lite configuration: + +#define optional_OPTIONAL_DEFAULT 0 +#define optional_OPTIONAL_NONSTD 1 +#define optional_OPTIONAL_STD 2 + +#if !defined(optional_CONFIG_SELECT_OPTIONAL) +#define optional_CONFIG_SELECT_OPTIONAL \ + (optional_HAVE_STD_OPTIONAL ? optional_OPTIONAL_STD : optional_OPTIONAL_NONSTD) +#endif + +// Control presence of exception handling (try and auto discover): + +#ifndef optional_CONFIG_NO_EXCEPTIONS +#if defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND) +#define optional_CONFIG_NO_EXCEPTIONS 0 +#else +#define optional_CONFIG_NO_EXCEPTIONS 1 +#endif +#endif + +// C++ language version detection (C++20 is speculative): +// Note: VC14.0/1900 (VS2015) lacks too much from C++14. + +#ifndef optional_CPLUSPLUS +#if defined(_MSVC_LANG) && !defined(__clang__) +#define optional_CPLUSPLUS (_MSC_VER == 1900 ? 201103L : _MSVC_LANG) +#else +#define optional_CPLUSPLUS __cplusplus +#endif +#endif + +#define optional_CPP98_OR_GREATER (optional_CPLUSPLUS >= 199711L) +#define optional_CPP11_OR_GREATER (optional_CPLUSPLUS >= 201103L) +#define optional_CPP11_OR_GREATER_ (optional_CPLUSPLUS >= 201103L) +#define optional_CPP14_OR_GREATER (optional_CPLUSPLUS >= 201402L) +#define optional_CPP17_OR_GREATER (optional_CPLUSPLUS >= 201703L) +#define optional_CPP20_OR_GREATER (optional_CPLUSPLUS >= 202000L) + +// C++ language version (represent 98 as 3): + +#define optional_CPLUSPLUS_V \ + (optional_CPLUSPLUS / 100 - (optional_CPLUSPLUS > 200000 ? 2000 : 1994)) + +// Use C++17 std::optional if available and requested: + +#if optional_CPP17_OR_GREATER && defined(__has_include) +#if __has_include( ) +#define optional_HAVE_STD_OPTIONAL 1 +#else +#define optional_HAVE_STD_OPTIONAL 0 +#endif +#else +#define optional_HAVE_STD_OPTIONAL 0 +#endif + +#define optional_USES_STD_OPTIONAL \ + ((optional_CONFIG_SELECT_OPTIONAL == optional_OPTIONAL_STD) || \ + ((optional_CONFIG_SELECT_OPTIONAL == optional_OPTIONAL_DEFAULT) && optional_HAVE_STD_OPTIONAL)) + +// +// in_place: code duplicated in any-lite, expected-lite, optional-lite, value-ptr-lite, +// variant-lite: +// + +#ifndef nonstd_lite_HAVE_IN_PLACE_TYPES +#define nonstd_lite_HAVE_IN_PLACE_TYPES 1 + +// C++17 std::in_place in : + +#if optional_CPP17_OR_GREATER + +#include + +namespace nonstd { + +using std::in_place; +using std::in_place_index; +using std::in_place_index_t; +using std::in_place_t; +using std::in_place_type; +using std::in_place_type_t; + +#define nonstd_lite_in_place_t(T) std::in_place_t +#define nonstd_lite_in_place_type_t(T) std::in_place_type_t +#define nonstd_lite_in_place_index_t(K) std::in_place_index_t + +#define nonstd_lite_in_place(T) \ + std::in_place_t {} +#define nonstd_lite_in_place_type(T) \ + std::in_place_type_t {} +#define nonstd_lite_in_place_index(K) \ + std::in_place_index_t {} + +} // namespace nonstd + +#else // optional_CPP17_OR_GREATER + +#include + +namespace nonstd { +namespace detail { + +template struct in_place_type_tag {}; + +template struct in_place_index_tag {}; + +} // namespace detail + +struct in_place_t {}; + +template +inline in_place_t +in_place(detail::in_place_type_tag /*unused*/ = detail::in_place_type_tag()) { + return in_place_t(); +} + +template +inline in_place_t +in_place(detail::in_place_index_tag /*unused*/ = detail::in_place_index_tag()) { + return in_place_t(); +} + +template +inline in_place_t +in_place_type(detail::in_place_type_tag /*unused*/ = detail::in_place_type_tag()) { + return in_place_t(); +} + +template +inline in_place_t +in_place_index(detail::in_place_index_tag /*unused*/ = detail::in_place_index_tag()) { + return in_place_t(); +} + +// mimic templated typedef: + +#define nonstd_lite_in_place_t(T) nonstd::in_place_t (&)(nonstd::detail::in_place_type_tag) +#define nonstd_lite_in_place_type_t(T) nonstd::in_place_t (&)(nonstd::detail::in_place_type_tag) +#define nonstd_lite_in_place_index_t(K) \ + nonstd::in_place_t (&)(nonstd::detail::in_place_index_tag) + +#define nonstd_lite_in_place(T) nonstd::in_place_type +#define nonstd_lite_in_place_type(T) nonstd::in_place_type +#define nonstd_lite_in_place_index(K) nonstd::in_place_index + +} // namespace nonstd + +#endif // optional_CPP17_OR_GREATER +#endif // nonstd_lite_HAVE_IN_PLACE_TYPES + +// +// Using std::optional: +// + +#if optional_USES_STD_OPTIONAL + +#include + +namespace nonstd { + +using std::bad_optional_access; +using std::hash; +using std::optional; + +using std::nullopt; +using std::nullopt_t; + +using std::operator==; +using std::operator!=; +using std::operator<; +using std::operator<=; +using std::operator>; +using std::operator>=; +using std::make_optional; +using std::swap; +} // namespace nonstd + +#else // optional_USES_STD_OPTIONAL + +#include +#include + +// optional-lite alignment configuration: + +#ifndef optional_CONFIG_MAX_ALIGN_HACK +#define optional_CONFIG_MAX_ALIGN_HACK 0 +#endif + +#ifndef optional_CONFIG_ALIGN_AS +// no default, used in #if defined() +#endif + +#ifndef optional_CONFIG_ALIGN_AS_FALLBACK +#define optional_CONFIG_ALIGN_AS_FALLBACK double +#endif + +// Compiler warning suppression: + +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wundef" +#elif defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wundef" +#elif defined(_MSC_VER) +#pragma warning(push) +#endif + +// half-open range [lo..hi): +#define optional_BETWEEN(v, lo, hi) ((lo) <= (v) && (v) < (hi)) + +// Compiler versions: +// +// MSVC++ 6.0 _MSC_VER == 1200 optional_COMPILER_MSVC_VERSION == 60 (Visual Studio 6.0) +// MSVC++ 7.0 _MSC_VER == 1300 optional_COMPILER_MSVC_VERSION == 70 (Visual Studio .NET 2002) +// MSVC++ 7.1 _MSC_VER == 1310 optional_COMPILER_MSVC_VERSION == 71 (Visual Studio .NET 2003) +// MSVC++ 8.0 _MSC_VER == 1400 optional_COMPILER_MSVC_VERSION == 80 (Visual Studio 2005) +// MSVC++ 9.0 _MSC_VER == 1500 optional_COMPILER_MSVC_VERSION == 90 (Visual Studio 2008) +// MSVC++ 10.0 _MSC_VER == 1600 optional_COMPILER_MSVC_VERSION == 100 (Visual Studio 2010) +// MSVC++ 11.0 _MSC_VER == 1700 optional_COMPILER_MSVC_VERSION == 110 (Visual Studio 2012) +// MSVC++ 12.0 _MSC_VER == 1800 optional_COMPILER_MSVC_VERSION == 120 (Visual Studio 2013) +// MSVC++ 14.0 _MSC_VER == 1900 optional_COMPILER_MSVC_VERSION == 140 (Visual Studio 2015) +// MSVC++ 14.1 _MSC_VER >= 1910 optional_COMPILER_MSVC_VERSION == 141 (Visual Studio 2017) +// MSVC++ 14.2 _MSC_VER >= 1920 optional_COMPILER_MSVC_VERSION == 142 (Visual Studio 2019) + +#if defined(_MSC_VER) && !defined(__clang__) +#define optional_COMPILER_MSVC_VER (_MSC_VER) +#define optional_COMPILER_MSVC_VERSION (_MSC_VER / 10 - 10 * (5 + (_MSC_VER < 1900))) +#else +#define optional_COMPILER_MSVC_VER 0 +#define optional_COMPILER_MSVC_VERSION 0 +#endif + +#define optional_COMPILER_VERSION(major, minor, patch) (10 * (10 * (major) + (minor)) + (patch)) + +#if defined(__GNUC__) && !defined(__clang__) +#define optional_COMPILER_GNUC_VERSION \ + optional_COMPILER_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) +#else +#define optional_COMPILER_GNUC_VERSION 0 +#endif + +#if defined(__clang__) +#define optional_COMPILER_CLANG_VERSION \ + optional_COMPILER_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__) +#else +#define optional_COMPILER_CLANG_VERSION 0 +#endif + +#if optional_BETWEEN(optional_COMPILER_MSVC_VERSION, 70, 140) +#pragma warning(disable : 4345) // initialization behavior changed +#endif + +#if optional_BETWEEN(optional_COMPILER_MSVC_VERSION, 70, 150) +#pragma warning(disable : 4814) // in C++14 'constexpr' will not imply 'const' +#endif + +// Presence of language and library features: + +#define optional_HAVE(FEATURE) (optional_HAVE_##FEATURE) + +#ifdef _HAS_CPP0X +#define optional_HAS_CPP0X _HAS_CPP0X +#else +#define optional_HAS_CPP0X 0 +#endif + +// Unless defined otherwise below, consider VC14 as C++11 for optional-lite: + +#if optional_COMPILER_MSVC_VER >= 1900 +#undef optional_CPP11_OR_GREATER +#define optional_CPP11_OR_GREATER 1 +#endif + +#define optional_CPP11_90 (optional_CPP11_OR_GREATER_ || optional_COMPILER_MSVC_VER >= 1500) +#define optional_CPP11_100 (optional_CPP11_OR_GREATER_ || optional_COMPILER_MSVC_VER >= 1600) +#define optional_CPP11_110 (optional_CPP11_OR_GREATER_ || optional_COMPILER_MSVC_VER >= 1700) +#define optional_CPP11_120 (optional_CPP11_OR_GREATER_ || optional_COMPILER_MSVC_VER >= 1800) +#define optional_CPP11_140 (optional_CPP11_OR_GREATER_ || optional_COMPILER_MSVC_VER >= 1900) +#define optional_CPP11_141 (optional_CPP11_OR_GREATER_ || optional_COMPILER_MSVC_VER >= 1910) + +#define optional_CPP11_140_490 \ + ((optional_CPP11_OR_GREATER_ && optional_COMPILER_GNUC_VERSION >= 490) || \ + (optional_COMPILER_MSVC_VER >= 1910)) + +#define optional_CPP14_000 (optional_CPP14_OR_GREATER) +#define optional_CPP17_000 (optional_CPP17_OR_GREATER) + +// Presence of C++11 language features: + +#define optional_HAVE_CONSTEXPR_11 optional_CPP11_140 +#define optional_HAVE_IS_DEFAULT optional_CPP11_140 +#define optional_HAVE_NOEXCEPT optional_CPP11_140 +#define optional_HAVE_NULLPTR optional_CPP11_100 +#define optional_HAVE_REF_QUALIFIER optional_CPP11_140_490 +#define optional_HAVE_INITIALIZER_LIST optional_CPP11_140 + +// Presence of C++14 language features: + +#define optional_HAVE_CONSTEXPR_14 optional_CPP14_000 + +// Presence of C++17 language features: + +#define optional_HAVE_NODISCARD optional_CPP17_000 + +// Presence of C++ library features: + +#define optional_HAVE_CONDITIONAL optional_CPP11_120 +#define optional_HAVE_REMOVE_CV optional_CPP11_120 +#define optional_HAVE_TYPE_TRAITS optional_CPP11_90 + +#define optional_HAVE_TR1_TYPE_TRAITS (!!optional_COMPILER_GNUC_VERSION) +#define optional_HAVE_TR1_ADD_POINTER (!!optional_COMPILER_GNUC_VERSION) + +// C++ feature usage: + +#if optional_HAVE(CONSTEXPR_11) +#define optional_constexpr constexpr +#else +#define optional_constexpr /*constexpr*/ +#endif + +#if optional_HAVE(IS_DEFAULT) +#define optional_is_default = default; +#else +#define optional_is_default \ + {} +#endif + +#if optional_HAVE(CONSTEXPR_14) +#define optional_constexpr14 constexpr +#else +#define optional_constexpr14 /*constexpr*/ +#endif + +#if optional_HAVE(NODISCARD) +#define optional_nodiscard [[nodiscard]] +#else +#define optional_nodiscard /*[[nodiscard]]*/ +#endif + +#if optional_HAVE(NOEXCEPT) +#define optional_noexcept noexcept +#else +#define optional_noexcept /*noexcept*/ +#endif + +#if optional_HAVE(NULLPTR) +#define optional_nullptr nullptr +#else +#define optional_nullptr NULL +#endif + +#if optional_HAVE(REF_QUALIFIER) +// NOLINTNEXTLINE( bugprone-macro-parentheses ) +#define optional_ref_qual & +#define optional_refref_qual && +#else +#define optional_ref_qual /*&*/ +#define optional_refref_qual /*&&*/ +#endif + +// additional includes: + +#if optional_CONFIG_NO_EXCEPTIONS +// already included: +#else +#include +#endif + +#if optional_CPP11_OR_GREATER +#include +#endif + +#if optional_HAVE(INITIALIZER_LIST) +#include +#endif + +#if optional_HAVE(TYPE_TRAITS) +#include +#elif optional_HAVE(TR1_TYPE_TRAITS) +#include +#endif + +// Method enabling + +#if optional_CPP11_OR_GREATER + +#define optional_REQUIRES_0(...) \ + template ::type = 0> + +#define optional_REQUIRES_T(...) , typename std::enable_if<(__VA_ARGS__), int>::type = 0 + +#define optional_REQUIRES_R(R, ...) typename std::enable_if<(__VA_ARGS__), R>::type + +#define optional_REQUIRES_A(...) , typename std::enable_if<(__VA_ARGS__), void *>::type = nullptr + +#endif + +// +// optional: +// + +namespace nonstd { +namespace optional_lite { + +namespace std11 { + +#if optional_CPP11_OR_GREATER +using std::move; +#else +template T &move(T &t) { return t; } +#endif + +#if optional_HAVE(CONDITIONAL) +using std::conditional; +#else +template struct conditional { typedef T type; }; +template struct conditional { typedef F type; }; +#endif // optional_HAVE_CONDITIONAL + +// gcc < 5: +#if optional_CPP11_OR_GREATER +#if optional_BETWEEN(optional_COMPILER_GNUC_VERSION, 1, 500) +template struct is_trivially_copy_constructible : std::true_type {}; +template struct is_trivially_move_constructible : std::true_type {}; +#else +using std::is_trivially_copy_constructible; +using std::is_trivially_move_constructible; +#endif +#endif +} // namespace std11 + +#if optional_CPP11_OR_GREATER + +/// type traits C++17: + +namespace std17 { + +#if optional_CPP17_OR_GREATER + +using std::is_nothrow_swappable; +using std::is_swappable; + +#elif optional_CPP11_OR_GREATER + +namespace detail { + +using std::swap; + +struct is_swappable { + template (), std::declval()))> + static std::true_type test(int /*unused*/); + + template static std::false_type test(...); +}; + +struct is_nothrow_swappable { + // wrap noexcept(expr) in separate function as work-around for VC140 (VS2015): + + template static constexpr bool satisfies() { + return noexcept(swap(std::declval(), std::declval())); + } + + template + static auto test(int /*unused*/) -> std::integral_constant()> {} + + template static auto test(...) -> std::false_type; +}; + +} // namespace detail + +// is [nothow] swappable: + +template struct is_swappable : decltype(detail::is_swappable::test(0)) {}; + +template +struct is_nothrow_swappable : decltype(detail::is_nothrow_swappable::test(0)) {}; + +#endif // optional_CPP17_OR_GREATER + +} // namespace std17 + +/// type traits C++20: + +namespace std20 { + +template struct remove_cvref { + typedef typename std::remove_cv::type>::type type; +}; + +} // namespace std20 + +#endif // optional_CPP11_OR_GREATER + +/// class optional + +template class optional; + +namespace detail { + +// C++11 emulation: + +struct nulltype {}; + +template struct typelist { + typedef Head head; + typedef Tail tail; +}; + +#if optional_CONFIG_MAX_ALIGN_HACK + +// Max align, use most restricted type for alignment: + +#define optional_UNIQUE(name) optional_UNIQUE2(name, __LINE__) +#define optional_UNIQUE2(name, line) optional_UNIQUE3(name, line) +#define optional_UNIQUE3(name, line) name##line + +#define optional_ALIGN_TYPE(type) \ + type optional_UNIQUE(_t); \ + struct_t optional_UNIQUE(_st) + +template struct struct_t { T _; }; + +union max_align_t { + optional_ALIGN_TYPE(char); + optional_ALIGN_TYPE(short int); + optional_ALIGN_TYPE(int); + optional_ALIGN_TYPE(long int); + optional_ALIGN_TYPE(float); + optional_ALIGN_TYPE(double); + optional_ALIGN_TYPE(long double); + optional_ALIGN_TYPE(char *); + optional_ALIGN_TYPE(short int *); + optional_ALIGN_TYPE(int *); + optional_ALIGN_TYPE(long int *); + optional_ALIGN_TYPE(float *); + optional_ALIGN_TYPE(double *); + optional_ALIGN_TYPE(long double *); + optional_ALIGN_TYPE(void *); + +#ifdef HAVE_LONG_LONG + optional_ALIGN_TYPE(long long); +#endif + + struct Unknown; + + Unknown (*optional_UNIQUE(_))(Unknown); + Unknown *Unknown::*optional_UNIQUE(_); + Unknown (Unknown::*optional_UNIQUE(_))(Unknown); + + struct_t optional_UNIQUE(_); + struct_t optional_UNIQUE(_); + struct_t optional_UNIQUE(_); +}; + +#undef optional_UNIQUE +#undef optional_UNIQUE2 +#undef optional_UNIQUE3 + +#undef optional_ALIGN_TYPE + +#elif defined(optional_CONFIG_ALIGN_AS) // optional_CONFIG_MAX_ALIGN_HACK + +// Use user-specified type for alignment: + +#define optional_ALIGN_AS(unused) optional_CONFIG_ALIGN_AS + +#else // optional_CONFIG_MAX_ALIGN_HACK + +// Determine POD type to use for alignment: + +#define optional_ALIGN_AS(to_align) \ + typename type_of_size::value>::type + +template struct alignment_of; + +template struct alignment_of_hack { + char c; + T t; + alignment_of_hack(); +}; + +template struct alignment_logic { + enum { value = A < S ? A : S }; +}; + +template struct alignment_of { + enum { value = alignment_logic) - sizeof(T), sizeof(T)>::value }; +}; + +template struct type_of_size { + typedef + typename std11::conditional::type>::type type; +}; + +template struct type_of_size { + typedef optional_CONFIG_ALIGN_AS_FALLBACK type; +}; + +template struct struct_t { T _; }; + +#define optional_ALIGN_TYPE(type) typelist < type, typelist < struct_t + +struct Unknown; + +typedef optional_ALIGN_TYPE(char), optional_ALIGN_TYPE(short), optional_ALIGN_TYPE(int), + optional_ALIGN_TYPE(long), optional_ALIGN_TYPE(float), optional_ALIGN_TYPE(double), + optional_ALIGN_TYPE(long double), + + optional_ALIGN_TYPE(char *), optional_ALIGN_TYPE(short *), optional_ALIGN_TYPE(int *), + optional_ALIGN_TYPE(long *), optional_ALIGN_TYPE(float *), optional_ALIGN_TYPE(double *), + optional_ALIGN_TYPE(long double *), + + optional_ALIGN_TYPE(Unknown (*)(Unknown)), optional_ALIGN_TYPE(Unknown *Unknown::*), + optional_ALIGN_TYPE(Unknown (Unknown::*)(Unknown)), + + nulltype >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> alignment_types; + +#undef optional_ALIGN_TYPE + +#endif // optional_CONFIG_MAX_ALIGN_HACK + +/// C++03 constructed union to hold value. + +template union storage_t { + // private: + // template< typename > friend class optional; + + typedef T value_type; + + storage_t() optional_is_default + + explicit storage_t(value_type const &v) { + construct_value(v); + } + + void construct_value(value_type const &v) { ::new (value_ptr()) value_type(v); } + +#if optional_CPP11_OR_GREATER + + explicit storage_t(value_type &&v) { construct_value(std::move(v)); } + + void construct_value(value_type &&v) { ::new (value_ptr()) value_type(std::move(v)); } + + template void emplace(Args &&... args) { + ::new (value_ptr()) value_type(std::forward(args)...); + } + + template void emplace(std::initializer_list il, Args &&... args) { + ::new (value_ptr()) value_type(il, std::forward(args)...); + } + +#endif + + void destruct_value() { value_ptr()->~T(); } + + optional_nodiscard value_type const *value_ptr() const { return as(); } + + value_type *value_ptr() { return as(); } + + optional_nodiscard value_type const &value() const optional_ref_qual { return *value_ptr(); } + + value_type &value() optional_ref_qual { return *value_ptr(); } + +#if optional_HAVE(REF_QUALIFIER) + + optional_nodiscard value_type const &&value() const optional_refref_qual { + return std::move(value()); + } + + value_type &&value() optional_refref_qual { return std::move(value()); } + +#endif + +#if optional_CPP11_OR_GREATER + + using aligned_storage_t = + typename std::aligned_storage::type; + aligned_storage_t data; + +#elif optional_CONFIG_MAX_ALIGN_HACK + + typedef struct { + unsigned char data[sizeof(value_type)]; + } aligned_storage_t; + + max_align_t hack; + aligned_storage_t data; + +#else + typedef optional_ALIGN_AS(value_type) align_as_type; + + typedef struct { + align_as_type data[1 + (sizeof(value_type) - 1) / sizeof(align_as_type)]; + } aligned_storage_t; + aligned_storage_t data; + +#undef optional_ALIGN_AS + +#endif // optional_CONFIG_MAX_ALIGN_HACK + + optional_nodiscard void *ptr() optional_noexcept { return &data; } + + optional_nodiscard void const *ptr() const optional_noexcept { return &data; } + + template optional_nodiscard U *as() { return reinterpret_cast(ptr()); } + + template optional_nodiscard U const *as() const { + return reinterpret_cast(ptr()); + } +}; + +} // namespace detail + +/// disengaged state tag + +struct nullopt_t { + struct init {}; + explicit optional_constexpr nullopt_t(init /*unused*/) optional_noexcept {} +}; + +#if optional_HAVE(CONSTEXPR_11) +constexpr nullopt_t nullopt{nullopt_t::init{}}; +#else +// extra parenthesis to prevent the most vexing parse: +const nullopt_t nullopt((nullopt_t::init())); +#endif + +/// optional access error + +#if !optional_CONFIG_NO_EXCEPTIONS + +class bad_optional_access : public std::logic_error { +public: + explicit bad_optional_access() : logic_error("bad optional access") {} +}; + +#endif // optional_CONFIG_NO_EXCEPTIONS + +/// optional + +template class optional { +private: + template friend class optional; + + typedef void (optional::*safe_bool)() const; + +public: + typedef T value_type; + + // x.x.3.1, constructors + + // 1a - default construct + optional_constexpr optional() optional_noexcept : has_value_(false), contained() {} + + // 1b - construct explicitly empty + // NOLINTNEXTLINE( google-explicit-constructor, hicpp-explicit-conversions ) + optional_constexpr optional(nullopt_t /*unused*/) optional_noexcept : has_value_(false), + contained() {} + + // 2 - copy-construct +#if optional_CPP11_OR_GREATER + // template< typename U = T + // optional_REQUIRES_T( + // std::is_copy_constructible::value + // || std11::is_trivially_copy_constructible::value + // ) + // > +#endif + optional_constexpr14 optional(optional const &other) : has_value_(other.has_value()) { + if (other.has_value()) { + contained.construct_value(other.contained.value()); + } + } + +#if optional_CPP11_OR_GREATER + + // 3 (C++11) - move-construct from optional + template ::value || + std11::is_trivially_move_constructible::value)> + optional_constexpr14 optional(optional &&other) + // NOLINTNEXTLINE( performance-noexcept-move-constructor ) + noexcept(std::is_nothrow_move_constructible::value) + : has_value_(other.has_value()) { + if (other.has_value()) { + contained.construct_value(std::move(other.contained.value())); + } + } + + // 4a (C++11) - explicit converting copy-construct from optional + template ::value && + !std::is_constructible &>::value && + !std::is_constructible &&>::value && + !std::is_constructible const &>::value && + !std::is_constructible const &&>::value && + !std::is_convertible &, T>::value && + !std::is_convertible &&, T>::value && + !std::is_convertible const &, T>::value && + !std::is_convertible const &&, T>::value && + !std::is_convertible::value /*=> explicit + */ + )> + explicit optional(optional const &other) : has_value_(other.has_value()) { + if (other.has_value()) { + contained.construct_value(T{other.contained.value()}); + } + } +#endif // optional_CPP11_OR_GREATER + + // 4b (C++98 and later) - non-explicit converting copy-construct from optional + template ::value && + !std::is_constructible &>::value && + !std::is_constructible &&>::value && + !std::is_constructible const &>::value && + !std::is_constructible const &&>::value && + !std::is_convertible &, T>::value && + !std::is_convertible &&, T>::value && + !std::is_convertible const &, T>::value && + !std::is_convertible const &&, T>::value && + std::is_convertible::value /*=> non-explicit */ + ) +#endif // optional_CPP11_OR_GREATER + > + // NOLINTNEXTLINE( google-explicit-constructor, hicpp-explicit-conversions ) + /*non-explicit*/ optional(optional const &other) : has_value_(other.has_value()) { + if (other.has_value()) { + contained.construct_value(other.contained.value()); + } + } + +#if optional_CPP11_OR_GREATER + + // 5a (C++11) - explicit converting move-construct from optional + template ::value && + !std::is_constructible &>::value && + !std::is_constructible &&>::value && + !std::is_constructible const &>::value && + !std::is_constructible const &&>::value && + !std::is_convertible &, T>::value && + !std::is_convertible &&, T>::value && + !std::is_convertible const &, T>::value && + !std::is_convertible const &&, T>::value && + !std::is_convertible::value /*=> explicit */ + )> + explicit optional(optional &&other) : has_value_(other.has_value()) { + if (other.has_value()) { + contained.construct_value(T{std::move(other.contained.value())}); + } + } + + // 5a (C++11) - non-explicit converting move-construct from optional + template ::value && + !std::is_constructible &>::value && + !std::is_constructible &&>::value && + !std::is_constructible const &>::value && + !std::is_constructible const &&>::value && + !std::is_convertible &, T>::value && + !std::is_convertible &&, T>::value && + !std::is_convertible const &, T>::value && + !std::is_convertible const &&, T>::value && + std::is_convertible::value /*=> non-explicit */ + )> + // NOLINTNEXTLINE( google-explicit-constructor, hicpp-explicit-conversions ) + /*non-explicit*/ optional(optional &&other) : has_value_(other.has_value()) { + if (other.has_value()) { + contained.construct_value(std::move(other.contained.value())); + } + } + + // 6 (C++11) - in-place construct + template ::value)> + optional_constexpr explicit optional(nonstd_lite_in_place_t(T), Args &&... args) + : has_value_(true), contained(T(std::forward(args)...)) {} + + // 7 (C++11) - in-place construct, initializer-list + template &, Args &&...>::value)> + optional_constexpr explicit optional(nonstd_lite_in_place_t(T), std::initializer_list il, + Args &&... args) + : has_value_(true), contained(T(il, std::forward(args)...)) {} + + // 8a (C++11) - explicit move construct from value + template < + typename U = T optional_REQUIRES_T( + std::is_constructible::value && + !std::is_same::type, nonstd_lite_in_place_t(U)>::value && + !std::is_same::type, optional>::value && + !std::is_convertible::value /*=> explicit */ + )> + optional_constexpr explicit optional(U &&value) + : has_value_(true), contained(T{std::forward(value)}) {} + + // 8b (C++11) - non-explicit move construct from value + template < + typename U = T optional_REQUIRES_T( + std::is_constructible::value && + !std::is_same::type, nonstd_lite_in_place_t(U)>::value && + !std::is_same::type, optional>::value && + std::is_convertible::value /*=> non-explicit */ + )> + // NOLINTNEXTLINE( google-explicit-constructor, hicpp-explicit-conversions ) + optional_constexpr /*non-explicit*/ optional(U &&value) + : has_value_(true), contained(std::forward(value)) {} + +#else // optional_CPP11_OR_GREATER + + // 8 (C++98) + optional(value_type const &value) : has_value_(true), contained(value) {} + +#endif // optional_CPP11_OR_GREATER + + // x.x.3.2, destructor + + ~optional() { + if (has_value()) { + contained.destruct_value(); + } + } + + // x.x.3.3, assignment + + // 1 (C++98and later) - assign explicitly empty + optional &operator=(nullopt_t /*unused*/) optional_noexcept { + reset(); + return *this; + } + + // 2 (C++98and later) - copy-assign from optional +#if optional_CPP11_OR_GREATER + // NOLINTNEXTLINE( cppcoreguidelines-c-copy-assignment-signature, + // misc-unconventional-assign-operator ) + optional_REQUIRES_R(optional &, true + // std::is_copy_constructible::value + // && std::is_copy_assignable::value + ) + operator=(optional const &other) noexcept( + std::is_nothrow_move_assignable::value &&std::is_nothrow_move_constructible::value) +#else + optional &operator=(optional const &other) +#endif + { + if ((has_value() == true) && (other.has_value() == false)) { + reset(); + } else if ((has_value() == false) && (other.has_value() == true)) { + initialize(*other); + } else if ((has_value() == true) && (other.has_value() == true)) { + contained.value() = *other; + } + return *this; + } + +#if optional_CPP11_OR_GREATER + + // 3 (C++11) - move-assign from optional + // NOLINTNEXTLINE( cppcoreguidelines-c-copy-assignment-signature, + // misc-unconventional-assign-operator ) + optional_REQUIRES_R(optional &, true + // std::is_move_constructible::value + // && std::is_move_assignable::value + ) + operator=(optional &&other) noexcept { + if ((has_value() == true) && (other.has_value() == false)) { + reset(); + } else if ((has_value() == false) && (other.has_value() == true)) { + initialize(std::move(*other)); + } else if ((has_value() == true) && (other.has_value() == true)) { + contained.value() = std::move(*other); + } + return *this; + } + + // 4 (C++11) - move-assign from value + template + // NOLINTNEXTLINE( cppcoreguidelines-c-copy-assignment-signature, + // misc-unconventional-assign-operator ) + optional_REQUIRES_R( + optional &, + std::is_constructible::value &&std::is_assignable::value && + !std::is_same::type, nonstd_lite_in_place_t(U)>::value && + !std::is_same::type, optional>::value && + !(std::is_scalar::value && std::is_same::type>::value)) + operator=(U &&value) { + if (has_value()) { + contained.value() = std::forward(value); + } else { + initialize(T(std::forward(value))); + } + return *this; + } + +#else // optional_CPP11_OR_GREATER + + // 4 (C++98) - copy-assign from value + template optional &operator=(U const &value) { + if (has_value()) + contained.value() = value; + else + initialize(T(value)); + return *this; + } + +#endif // optional_CPP11_OR_GREATER + + // 5 (C++98 and later) - converting copy-assign from optional + template +#if optional_CPP11_OR_GREATER + // NOLINTNEXTLINE( cppcoreguidelines-c-copy-assignment-signature, + // misc-unconventional-assign-operator ) + optional_REQUIRES_R( + optional &, + std::is_constructible::value &&std::is_assignable::value && + !std::is_constructible &>::value && + !std::is_constructible &&>::value && + !std::is_constructible const &>::value && + !std::is_constructible const &&>::value && + !std::is_convertible &, T>::value && + !std::is_convertible &&, T>::value && + !std::is_convertible const &, T>::value && + !std::is_convertible const &&, T>::value && + !std::is_assignable &>::value && + !std::is_assignable &&>::value && + !std::is_assignable const &>::value && + !std::is_assignable const &&>::value) +#else + optional & +#endif // optional_CPP11_OR_GREATER + operator=(optional const &other) { + return *this = optional(other); + } + +#if optional_CPP11_OR_GREATER + + // 6 (C++11) - converting move-assign from optional + template + // NOLINTNEXTLINE( cppcoreguidelines-c-copy-assignment-signature, + // misc-unconventional-assign-operator ) + optional_REQUIRES_R(optional &, + std::is_constructible::value &&std::is_assignable::value && + !std::is_constructible &>::value && + !std::is_constructible &&>::value && + !std::is_constructible const &>::value && + !std::is_constructible const &&>::value && + !std::is_convertible &, T>::value && + !std::is_convertible &&, T>::value && + !std::is_convertible const &, T>::value && + !std::is_convertible const &&, T>::value && + !std::is_assignable &>::value && + !std::is_assignable &&>::value && + !std::is_assignable const &>::value && + !std::is_assignable const &&>::value) + operator=(optional &&other) { + return *this = optional(std::move(other)); + } + + // 7 (C++11) - emplace + template ::value)> + T &emplace(Args &&... args) { + *this = nullopt; + contained.emplace(std::forward(args)...); + has_value_ = true; + return contained.value(); + } + + // 8 (C++11) - emplace, initializer-list + template &, Args &&...>::value)> + T &emplace(std::initializer_list il, Args &&... args) { + *this = nullopt; + contained.emplace(il, std::forward(args)...); + has_value_ = true; + return contained.value(); + } + +#endif // optional_CPP11_OR_GREATER + + // x.x.3.4, swap + + void swap(optional &other) +#if optional_CPP11_OR_GREATER + noexcept(std::is_nothrow_move_constructible::value &&std17::is_nothrow_swappable::value) +#endif + { + using std::swap; + if ((has_value() == true) && (other.has_value() == true)) { + swap(**this, *other); + } else if ((has_value() == false) && (other.has_value() == true)) { + initialize(std11::move(*other)); + other.reset(); + } else if ((has_value() == true) && (other.has_value() == false)) { + other.initialize(std11::move(**this)); + reset(); + } + } + + // x.x.3.5, observers + + optional_constexpr value_type const *operator->() const { + return assert(has_value()), contained.value_ptr(); + } + + optional_constexpr14 value_type *operator->() { + return assert(has_value()), contained.value_ptr(); + } + + optional_constexpr value_type const &operator*() const optional_ref_qual { + return assert(has_value()), contained.value(); + } + + optional_constexpr14 value_type &operator*() optional_ref_qual { + return assert(has_value()), contained.value(); + } + +#if optional_HAVE(REF_QUALIFIER) + + optional_constexpr value_type const &&operator*() const optional_refref_qual { + return std::move(**this); + } + + optional_constexpr14 value_type &&operator*() optional_refref_qual { return std::move(**this); } + +#endif + +#if optional_CPP11_OR_GREATER + optional_constexpr explicit operator bool() const optional_noexcept { return has_value(); } +#else + optional_constexpr operator safe_bool() const optional_noexcept { + return has_value() ? &optional::this_type_does_not_support_comparisons : 0; + } +#endif + + // NOLINTNEXTLINE( modernize-use-nodiscard ) + /*optional_nodiscard*/ optional_constexpr bool has_value() const optional_noexcept { + return has_value_; + } + + // NOLINTNEXTLINE( modernize-use-nodiscard ) + /*optional_nodiscard*/ optional_constexpr14 value_type const &value() const optional_ref_qual { +#if optional_CONFIG_NO_EXCEPTIONS + assert(has_value()); +#else + if (!has_value()) { + throw bad_optional_access(); + } +#endif + return contained.value(); + } + + optional_constexpr14 value_type &value() optional_ref_qual { +#if optional_CONFIG_NO_EXCEPTIONS + assert(has_value()); +#else + if (!has_value()) { + throw bad_optional_access(); + } +#endif + return contained.value(); + } + +#if optional_HAVE(REF_QUALIFIER) && \ + (!optional_COMPILER_GNUC_VERSION || optional_COMPILER_GNUC_VERSION >= 490) + + // NOLINTNEXTLINE( modernize-use-nodiscard ) + /*optional_nodiscard*/ optional_constexpr value_type const &&value() const optional_refref_qual { + return std::move(value()); + } + + optional_constexpr14 value_type &&value() optional_refref_qual { return std::move(value()); } + +#endif + +#if optional_CPP11_OR_GREATER + + template optional_constexpr value_type value_or(U &&v) const optional_ref_qual { + return has_value() ? contained.value() : static_cast(std::forward(v)); + } + + template optional_constexpr14 value_type value_or(U &&v) optional_refref_qual { + return has_value() ? std::move(contained.value()) : static_cast(std::forward(v)); + } + +#else + + template optional_constexpr value_type value_or(U const &v) const { + return has_value() ? contained.value() : static_cast(v); + } + +#endif // optional_CPP11_OR_GREATER + + // x.x.3.6, modifiers + + void reset() optional_noexcept { + if (has_value()) { + contained.destruct_value(); + } + + has_value_ = false; + } + +private: + void this_type_does_not_support_comparisons() const {} + + template void initialize(V const &value) { + assert(!has_value()); + contained.construct_value(value); + has_value_ = true; + } + +#if optional_CPP11_OR_GREATER + template void initialize(V &&value) { + assert(!has_value()); + contained.construct_value(std::move(value)); + has_value_ = true; + } + +#endif + +private: + bool has_value_; + detail::storage_t contained; +}; + +// Relational operators + +template +inline optional_constexpr bool operator==(optional const &x, optional const &y) { + return bool(x) != bool(y) ? false : !bool(x) ? true : *x == *y; +} + +template +inline optional_constexpr bool operator!=(optional const &x, optional const &y) { + return !(x == y); +} + +template +inline optional_constexpr bool operator<(optional const &x, optional const &y) { + return (!y) ? false : (!x) ? true : *x < *y; +} + +template +inline optional_constexpr bool operator>(optional const &x, optional const &y) { + return (y < x); +} + +template +inline optional_constexpr bool operator<=(optional const &x, optional const &y) { + return !(y < x); +} + +template +inline optional_constexpr bool operator>=(optional const &x, optional const &y) { + return !(x < y); +} + +// Comparison with nullopt + +template +inline optional_constexpr bool operator==(optional const &x, + nullopt_t /*unused*/) optional_noexcept { + return (!x); +} + +template +inline optional_constexpr bool operator==(nullopt_t /*unused*/, + optional const &x) optional_noexcept { + return (!x); +} + +template +inline optional_constexpr bool operator!=(optional const &x, + nullopt_t /*unused*/) optional_noexcept { + return bool(x); +} + +template +inline optional_constexpr bool operator!=(nullopt_t /*unused*/, + optional const &x) optional_noexcept { + return bool(x); +} + +template +inline optional_constexpr bool operator<(optional const & /*unused*/, + nullopt_t /*unused*/) optional_noexcept { + return false; +} + +template +inline optional_constexpr bool operator<(nullopt_t /*unused*/, + optional const &x) optional_noexcept { + return bool(x); +} + +template +inline optional_constexpr bool operator<=(optional const &x, + nullopt_t /*unused*/) optional_noexcept { + return (!x); +} + +template +inline optional_constexpr bool operator<=(nullopt_t /*unused*/, + optional const & /*unused*/) optional_noexcept { + return true; +} + +template +inline optional_constexpr bool operator>(optional const &x, + nullopt_t /*unused*/) optional_noexcept { + return bool(x); +} + +template +inline optional_constexpr bool operator>(nullopt_t /*unused*/, + optional const & /*unused*/) optional_noexcept { + return false; +} + +template +inline optional_constexpr bool operator>=(optional const & /*unused*/, + nullopt_t /*unused*/) optional_noexcept { + return true; +} + +template +inline optional_constexpr bool operator>=(nullopt_t /*unused*/, + optional const &x) optional_noexcept { + return (!x); +} + +// Comparison with T + +template +inline optional_constexpr bool operator==(optional const &x, U const &v) { + return bool(x) ? *x == v : false; +} + +template +inline optional_constexpr bool operator==(U const &v, optional const &x) { + return bool(x) ? v == *x : false; +} + +template +inline optional_constexpr bool operator!=(optional const &x, U const &v) { + return bool(x) ? *x != v : true; +} + +template +inline optional_constexpr bool operator!=(U const &v, optional const &x) { + return bool(x) ? v != *x : true; +} + +template +inline optional_constexpr bool operator<(optional const &x, U const &v) { + return bool(x) ? *x < v : true; +} + +template +inline optional_constexpr bool operator<(U const &v, optional const &x) { + return bool(x) ? v < *x : false; +} + +template +inline optional_constexpr bool operator<=(optional const &x, U const &v) { + return bool(x) ? *x <= v : true; +} + +template +inline optional_constexpr bool operator<=(U const &v, optional const &x) { + return bool(x) ? v <= *x : false; +} + +template +inline optional_constexpr bool operator>(optional const &x, U const &v) { + return bool(x) ? *x > v : false; +} + +template +inline optional_constexpr bool operator>(U const &v, optional const &x) { + return bool(x) ? v > *x : true; +} + +template +inline optional_constexpr bool operator>=(optional const &x, U const &v) { + return bool(x) ? *x >= v : false; +} + +template +inline optional_constexpr bool operator>=(U const &v, optional const &x) { + return bool(x) ? v >= *x : true; +} + +// Specialized algorithms + +template < + typename T +#if optional_CPP11_OR_GREATER + optional_REQUIRES_T(std::is_move_constructible::value &&std17::is_swappable::value) +#endif + > +void swap(optional &x, optional &y) +#if optional_CPP11_OR_GREATER + noexcept(noexcept(x.swap(y))) +#endif +{ + x.swap(y); +} + +#if optional_CPP11_OR_GREATER + +template +optional_constexpr optional::type> make_optional(T &&value) { + return optional::type>(std::forward(value)); +} + +template +optional_constexpr optional make_optional(Args &&... args) { + return optional(nonstd_lite_in_place(T), std::forward(args)...); +} + +template +optional_constexpr optional make_optional(std::initializer_list il, Args &&... args) { + return optional(nonstd_lite_in_place(T), il, std::forward(args)...); +} + +#else + +template optional make_optional(T const &value) { return optional(value); } + +#endif // optional_CPP11_OR_GREATER + +} // namespace optional_lite + +using optional_lite::nullopt; +using optional_lite::nullopt_t; +using optional_lite::optional; + +#if !optional_CONFIG_NO_EXCEPTIONS +using optional_lite::bad_optional_access; +#endif + +using optional_lite::make_optional; + +} // namespace nonstd + +#if optional_CPP11_OR_GREATER + +// specialize the std::hash algorithm: + +namespace std { + +template struct hash> { +public: + std::size_t operator()(nonstd::optional const &v) const optional_noexcept { + return bool(v) ? std::hash{}(*v) : 0; + } +}; + +} // namespace std + +#endif // optional_CPP11_OR_GREATER + +#if defined(__clang__) +#pragma clang diagnostic pop +#elif defined(__GNUC__) +#pragma GCC diagnostic pop +#elif defined(_MSC_VER) +#pragma warning(pop) +#endif + +#endif // optional_USES_STD_OPTIONAL + +#endif // NONSTD_OPTIONAL_LITE_HPP diff --git a/libs/tabulate/printer.hpp b/libs/tabulate/printer.hpp index 178ec97..5c972c7 100644 --- a/libs/tabulate/printer.hpp +++ b/libs/tabulate/printer.hpp @@ -1,249 +1,249 @@ - -/* - __ ___. .__ __ -_/ |______ \_ |__ __ __| | _____ _/ |_ ____ -\ __\__ \ | __ \| | \ | \__ \\ __\/ __ \ - | | / __ \| \_\ \ | / |__/ __ \| | \ ___/ - |__| (____ /___ /____/|____(____ /__| \___ > - \/ \/ \/ \/ -Table Maker for Modern C++ -https://github.com/p-ranav/tabulate - -Licensed under the MIT License . -SPDX-License-Identifier: MIT -Copyright (c) 2019 Pranav Srinivas Kumar . - -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. -*/ -#pragma once -#include -#include -#include -#include - -namespace tabulate { - -class Printer { -public: - static std::pair, std::vector> - compute_cell_dimensions(TableInternal &table); - - static void print_table(std::ostream &stream, TableInternal &table); - - static void print_row_in_cell(std::ostream &stream, TableInternal &table, - const std::pair &index, - const std::pair &dimension, size_t num_columns, - size_t row_index, - const std::vector &splitted_cell_text); - - static bool print_cell_border_top(std::ostream &stream, TableInternal &table, - const std::pair &index, - const std::pair &dimension, size_t num_columns); - static bool print_cell_border_bottom(std::ostream &stream, TableInternal &table, - const std::pair &index, - const std::pair &dimension, - size_t num_columns); - - static void apply_element_style(std::ostream &stream, Color foreground_color, - Color background_color, - const std::vector &font_style) { - apply_foreground_color(stream, foreground_color); - apply_background_color(stream, background_color); - for (auto &style : font_style) - apply_font_style(stream, style); - } - - static void reset_element_style(std::ostream &stream) { stream << termcolor::reset; } - -private: - static void print_content_left_aligned(std::ostream &stream, const std::string &cell_content, - const Format &format, size_t text_with_padding_size, - size_t column_width) { - - // Apply font style - apply_element_style(stream, *format.font_color_, *format.font_background_color_, - *format.font_style_); - stream << cell_content; - // Only apply font_style to the font - // Not the padding. So calling apply_element_style with font_style = {} - reset_element_style(stream); - apply_element_style(stream, *format.font_color_, *format.font_background_color_, {}); - - if (text_with_padding_size < column_width) { - for (size_t j = 0; j < (column_width - text_with_padding_size); ++j) { - stream << " "; - } - } - } - - static void print_content_center_aligned(std::ostream &stream, const std::string &cell_content, - const Format &format, size_t text_with_padding_size, - size_t column_width) { - auto num_spaces = column_width - text_with_padding_size; - if (num_spaces % 2 == 0) { - // Even spacing on either side - for (size_t j = 0; j < num_spaces / 2; ++j) - stream << " "; - - // Apply font style - apply_element_style(stream, *format.font_color_, *format.font_background_color_, - *format.font_style_); - stream << cell_content; - // Only apply font_style to the font - // Not the padding. So calling apply_element_style with font_style = {} - reset_element_style(stream); - apply_element_style(stream, *format.font_color_, *format.font_background_color_, {}); - - for (size_t j = 0; j < num_spaces / 2; ++j) - stream << " "; - } else { - auto num_spaces_before = num_spaces / 2 + 1; - for (size_t j = 0; j < num_spaces_before; ++j) - stream << " "; - - // Apply font style - apply_element_style(stream, *format.font_color_, *format.font_background_color_, - *format.font_style_); - stream << cell_content; - // Only apply font_style to the font - // Not the padding. So calling apply_element_style with font_style = {} - reset_element_style(stream); - apply_element_style(stream, *format.font_color_, *format.font_background_color_, {}); - - for (size_t j = 0; j < num_spaces - num_spaces_before; ++j) - stream << " "; - } - } - - static void print_content_right_aligned(std::ostream &stream, const std::string &cell_content, - const Format &format, size_t text_with_padding_size, - size_t column_width) { - if (text_with_padding_size < column_width) { - for (size_t j = 0; j < (column_width - text_with_padding_size); ++j) { - stream << " "; - } - } - - // Apply font style - apply_element_style(stream, *format.font_color_, *format.font_background_color_, - *format.font_style_); - stream << cell_content; - // Only apply font_style to the font - // Not the padding. So calling apply_element_style with font_style = {} - reset_element_style(stream); - apply_element_style(stream, *format.font_color_, *format.font_background_color_, {}); - } - - static void apply_font_style(std::ostream &stream, FontStyle style) { - switch (style) { - case FontStyle::bold: - stream << termcolor::bold; - break; - case FontStyle::dark: - stream << termcolor::dark; - break; - case FontStyle::italic: - stream << termcolor::italic; - break; - case FontStyle::underline: - stream << termcolor::underline; - break; - case FontStyle::blink: - stream << termcolor::blink; - break; - case FontStyle::reverse: - stream << termcolor::reverse; - break; - case FontStyle::concealed: - stream << termcolor::concealed; - break; - case FontStyle::crossed: - stream << termcolor::crossed; - break; - default: - break; - } - } - - static void apply_foreground_color(std::ostream &stream, Color foreground_color) { - switch (foreground_color) { - case Color::grey: - stream << termcolor::grey; - break; - case Color::red: - stream << termcolor::red; - break; - case Color::green: - stream << termcolor::green; - break; - case Color::yellow: - stream << termcolor::yellow; - break; - case Color::blue: - stream << termcolor::blue; - break; - case Color::magenta: - stream << termcolor::magenta; - break; - case Color::cyan: - stream << termcolor::cyan; - break; - case Color::white: - stream << termcolor::white; - break; - case Color::none: - default: - break; - } - } - - static void apply_background_color(std::ostream &stream, Color background_color) { - switch (background_color) { - case Color::grey: - stream << termcolor::on_grey; - break; - case Color::red: - stream << termcolor::on_red; - break; - case Color::green: - stream << termcolor::on_green; - break; - case Color::yellow: - stream << termcolor::on_yellow; - break; - case Color::blue: - stream << termcolor::on_blue; - break; - case Color::magenta: - stream << termcolor::on_magenta; - break; - case Color::cyan: - stream << termcolor::on_cyan; - break; - case Color::white: - stream << termcolor::on_white; - break; - case Color::none: - default: - break; - } - } -}; - -} // namespace tabulate + +/* + __ ___. .__ __ +_/ |______ \_ |__ __ __| | _____ _/ |_ ____ +\ __\__ \ | __ \| | \ | \__ \\ __\/ __ \ + | | / __ \| \_\ \ | / |__/ __ \| | \ ___/ + |__| (____ /___ /____/|____(____ /__| \___ > + \/ \/ \/ \/ +Table Maker for Modern C++ +https://github.com/p-ranav/tabulate + +Licensed under the MIT License . +SPDX-License-Identifier: MIT +Copyright (c) 2019 Pranav Srinivas Kumar . + +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. +*/ +#pragma once +#include +#include +#include +#include + +namespace tabulate { + +class Printer { +public: + static std::pair, std::vector> + compute_cell_dimensions(TableInternal &table); + + static void print_table(std::ostream &stream, TableInternal &table); + + static void print_row_in_cell(std::ostream &stream, TableInternal &table, + const std::pair &index, + const std::pair &dimension, size_t num_columns, + size_t row_index, + const std::vector &splitted_cell_text); + + static bool print_cell_border_top(std::ostream &stream, TableInternal &table, + const std::pair &index, + const std::pair &dimension, size_t num_columns); + static bool print_cell_border_bottom(std::ostream &stream, TableInternal &table, + const std::pair &index, + const std::pair &dimension, + size_t num_columns); + + static void apply_element_style(std::ostream &stream, Color foreground_color, + Color background_color, + const std::vector &font_style) { + apply_foreground_color(stream, foreground_color); + apply_background_color(stream, background_color); + for (auto &style : font_style) + apply_font_style(stream, style); + } + + static void reset_element_style(std::ostream &stream) { stream << termcolor::reset; } + +private: + static void print_content_left_aligned(std::ostream &stream, const std::string &cell_content, + const Format &format, size_t text_with_padding_size, + size_t column_width) { + + // Apply font style + apply_element_style(stream, *format.font_color_, *format.font_background_color_, + *format.font_style_); + stream << cell_content; + // Only apply font_style to the font + // Not the padding. So calling apply_element_style with font_style = {} + reset_element_style(stream); + apply_element_style(stream, *format.font_color_, *format.font_background_color_, {}); + + if (text_with_padding_size < column_width) { + for (size_t j = 0; j < (column_width - text_with_padding_size); ++j) { + stream << " "; + } + } + } + + static void print_content_center_aligned(std::ostream &stream, const std::string &cell_content, + const Format &format, size_t text_with_padding_size, + size_t column_width) { + auto num_spaces = column_width - text_with_padding_size; + if (num_spaces % 2 == 0) { + // Even spacing on either side + for (size_t j = 0; j < num_spaces / 2; ++j) + stream << " "; + + // Apply font style + apply_element_style(stream, *format.font_color_, *format.font_background_color_, + *format.font_style_); + stream << cell_content; + // Only apply font_style to the font + // Not the padding. So calling apply_element_style with font_style = {} + reset_element_style(stream); + apply_element_style(stream, *format.font_color_, *format.font_background_color_, {}); + + for (size_t j = 0; j < num_spaces / 2; ++j) + stream << " "; + } else { + auto num_spaces_before = num_spaces / 2 + 1; + for (size_t j = 0; j < num_spaces_before; ++j) + stream << " "; + + // Apply font style + apply_element_style(stream, *format.font_color_, *format.font_background_color_, + *format.font_style_); + stream << cell_content; + // Only apply font_style to the font + // Not the padding. So calling apply_element_style with font_style = {} + reset_element_style(stream); + apply_element_style(stream, *format.font_color_, *format.font_background_color_, {}); + + for (size_t j = 0; j < num_spaces - num_spaces_before; ++j) + stream << " "; + } + } + + static void print_content_right_aligned(std::ostream &stream, const std::string &cell_content, + const Format &format, size_t text_with_padding_size, + size_t column_width) { + if (text_with_padding_size < column_width) { + for (size_t j = 0; j < (column_width - text_with_padding_size); ++j) { + stream << " "; + } + } + + // Apply font style + apply_element_style(stream, *format.font_color_, *format.font_background_color_, + *format.font_style_); + stream << cell_content; + // Only apply font_style to the font + // Not the padding. So calling apply_element_style with font_style = {} + reset_element_style(stream); + apply_element_style(stream, *format.font_color_, *format.font_background_color_, {}); + } + + static void apply_font_style(std::ostream &stream, FontStyle style) { + switch (style) { + case FontStyle::bold: + stream << termcolor::bold; + break; + case FontStyle::dark: + stream << termcolor::dark; + break; + case FontStyle::italic: + stream << termcolor::italic; + break; + case FontStyle::underline: + stream << termcolor::underline; + break; + case FontStyle::blink: + stream << termcolor::blink; + break; + case FontStyle::reverse: + stream << termcolor::reverse; + break; + case FontStyle::concealed: + stream << termcolor::concealed; + break; + case FontStyle::crossed: + stream << termcolor::crossed; + break; + default: + break; + } + } + + static void apply_foreground_color(std::ostream &stream, Color foreground_color) { + switch (foreground_color) { + case Color::grey: + stream << termcolor::grey; + break; + case Color::red: + stream << termcolor::red; + break; + case Color::green: + stream << termcolor::green; + break; + case Color::yellow: + stream << termcolor::yellow; + break; + case Color::blue: + stream << termcolor::blue; + break; + case Color::magenta: + stream << termcolor::magenta; + break; + case Color::cyan: + stream << termcolor::cyan; + break; + case Color::white: + stream << termcolor::white; + break; + case Color::none: + default: + break; + } + } + + static void apply_background_color(std::ostream &stream, Color background_color) { + switch (background_color) { + case Color::grey: + stream << termcolor::on_grey; + break; + case Color::red: + stream << termcolor::on_red; + break; + case Color::green: + stream << termcolor::on_green; + break; + case Color::yellow: + stream << termcolor::on_yellow; + break; + case Color::blue: + stream << termcolor::on_blue; + break; + case Color::magenta: + stream << termcolor::on_magenta; + break; + case Color::cyan: + stream << termcolor::on_cyan; + break; + case Color::white: + stream << termcolor::on_white; + break; + case Color::none: + default: + break; + } + } +}; + +} // namespace tabulate diff --git a/libs/tabulate/row.hpp b/libs/tabulate/row.hpp index e5cf98f..9995cc8 100644 --- a/libs/tabulate/row.hpp +++ b/libs/tabulate/row.hpp @@ -1,191 +1,191 @@ - -/* - __ ___. .__ __ -_/ |______ \_ |__ __ __| | _____ _/ |_ ____ -\ __\__ \ | __ \| | \ | \__ \\ __\/ __ \ - | | / __ \| \_\ \ | / |__/ __ \| | \ ___/ - |__| (____ /___ /____/|____(____ /__| \___ > - \/ \/ \/ \/ -Table Maker for Modern C++ -https://github.com/p-ranav/tabulate - -Licensed under the MIT License . -SPDX-License-Identifier: MIT -Copyright (c) 2019 Pranav Srinivas Kumar . - -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. -*/ -#pragma once -#include -#include -#include -#include - -#if __cplusplus >= 201703L -#include -using std::optional; -#else -#include -using nonstd::optional; -#endif - -#include -#ifdef max -#undef max -#endif -#ifdef min -#undef min -#endif - -namespace tabulate { - -class Row { -public: - explicit Row(std::shared_ptr parent) : parent_(parent) {} - - void add_cell(std::shared_ptr cell) { cells_.push_back(cell); } - - Cell &operator[](size_t index) { return cell(index); } - - Cell &cell(size_t index) { return *(cells_[index]); } - - std::vector> cells() const { return cells_; } - - size_t size() const { return cells_.size(); } - - Format &format(); - - class CellIterator { - public: - explicit CellIterator(std::vector>::iterator ptr) : ptr(ptr) {} - - CellIterator operator++() { - ++ptr; - return *this; - } - bool operator!=(const CellIterator &other) const { return ptr != other.ptr; } - Cell &operator*() { return **ptr; } - - private: - std::vector>::iterator ptr; - }; - - auto begin() -> CellIterator { return CellIterator(cells_.begin()); } - auto end() -> CellIterator { return CellIterator(cells_.end()); } - -private: - friend class Printer; - - // Returns the row height as configured - // For each cell in the row, check the cell.format.height - // property and return the largest configured row height - // This is used to ensure that all cells in a row are - // aligned when printing the column - size_t get_configured_height() { - size_t result{0}; - for (size_t i = 0; i < size(); ++i) { - auto cell = cells_[i]; - auto format = cell->format(); - if (format.height_.has_value()) - result = std::max(result, *format.height_); - } - return result; - } - - // Computes the height of the row based on cell contents - // and configured cell padding - // For each cell, compute: - // padding_top + (cell_contents / column height) + padding_bottom - // and return the largest value - // - // This is useful when no cell.format.height is configured - // Call get_configured_height() - // - If this returns 0, then use get_computed_height() - size_t get_computed_height(const std::vector &column_widths) { - size_t result{0}; - for (size_t i = 0; i < size(); ++i) { - result = std::max(result, get_cell_height(i, column_widths[i])); - } - return result; - } - - // Returns padding_top + cell_contents / column_height + padding_bottom - // for a given cell in the column - // e.g., - // column width = 5 - // cell_contents = "I love tabulate" (size/length = 15) - // padding top and padding bottom are 1 - // then, cell height = 1 + (15 / 5) + 1 = 1 + 3 + 1 = 5 - // The cell will look like this: - // - // ..... - // I lov - // e tab - // ulate - // ..... - size_t get_cell_height(size_t cell_index, size_t column_width) { - size_t result{0}; - Cell &cell = *(cells_[cell_index]); - auto format = cell.format(); - auto text = cell.get_text(); - - auto padding_left = *format.padding_left_; - auto padding_right = *format.padding_right_; - - result += *format.padding_top_; - - if (column_width > (padding_left + padding_right)) { - column_width -= (padding_left + padding_right); - } - - // Check if input text has embedded newline characters - auto newlines_in_text = std::count(text.begin(), text.end(), '\n'); - std::string word_wrapped_text; - if (newlines_in_text == 0) { - // No new lines in input - // Apply automatic word wrapping and compute row height - word_wrapped_text = Format::word_wrap(text, column_width, cell.locale(), - cell.is_multi_byte_character_support_enabled()); - } else { - // There are embedded '\n' characters - // Respect these characters - word_wrapped_text = text; - } - - auto newlines_in_wrapped_text = - std::count(word_wrapped_text.begin(), word_wrapped_text.end(), '\n'); - auto estimated_row_height = newlines_in_wrapped_text; - - if (!word_wrapped_text.empty() && - word_wrapped_text[word_wrapped_text.size() - 1] != '\n') // text doesn't end with a newline - estimated_row_height += 1; - - result += estimated_row_height; - - result += *format.padding_bottom_; - - return result; - } - - std::vector> cells_; - std::weak_ptr parent_; - optional format_; -}; - -} // namespace tabulate + +/* + __ ___. .__ __ +_/ |______ \_ |__ __ __| | _____ _/ |_ ____ +\ __\__ \ | __ \| | \ | \__ \\ __\/ __ \ + | | / __ \| \_\ \ | / |__/ __ \| | \ ___/ + |__| (____ /___ /____/|____(____ /__| \___ > + \/ \/ \/ \/ +Table Maker for Modern C++ +https://github.com/p-ranav/tabulate + +Licensed under the MIT License . +SPDX-License-Identifier: MIT +Copyright (c) 2019 Pranav Srinivas Kumar . + +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. +*/ +#pragma once +#include +#include +#include +#include + +#if __cplusplus >= 201703L +#include +using std::optional; +#else +#include +using nonstd::optional; +#endif + +#include +#ifdef max +#undef max +#endif +#ifdef min +#undef min +#endif + +namespace tabulate { + +class Row { +public: + explicit Row(std::shared_ptr parent) : parent_(parent) {} + + void add_cell(std::shared_ptr cell) { cells_.push_back(cell); } + + Cell &operator[](size_t index) { return cell(index); } + + Cell &cell(size_t index) { return *(cells_[index]); } + + std::vector> cells() const { return cells_; } + + size_t size() const { return cells_.size(); } + + Format &format(); + + class CellIterator { + public: + explicit CellIterator(std::vector>::iterator ptr) : ptr(ptr) {} + + CellIterator operator++() { + ++ptr; + return *this; + } + bool operator!=(const CellIterator &other) const { return ptr != other.ptr; } + Cell &operator*() { return **ptr; } + + private: + std::vector>::iterator ptr; + }; + + auto begin() -> CellIterator { return CellIterator(cells_.begin()); } + auto end() -> CellIterator { return CellIterator(cells_.end()); } + +private: + friend class Printer; + + // Returns the row height as configured + // For each cell in the row, check the cell.format.height + // property and return the largest configured row height + // This is used to ensure that all cells in a row are + // aligned when printing the column + size_t get_configured_height() { + size_t result{0}; + for (size_t i = 0; i < size(); ++i) { + auto cell = cells_[i]; + auto format = cell->format(); + if (format.height_.has_value()) + result = std::max(result, *format.height_); + } + return result; + } + + // Computes the height of the row based on cell contents + // and configured cell padding + // For each cell, compute: + // padding_top + (cell_contents / column height) + padding_bottom + // and return the largest value + // + // This is useful when no cell.format.height is configured + // Call get_configured_height() + // - If this returns 0, then use get_computed_height() + size_t get_computed_height(const std::vector &column_widths) { + size_t result{0}; + for (size_t i = 0; i < size(); ++i) { + result = std::max(result, get_cell_height(i, column_widths[i])); + } + return result; + } + + // Returns padding_top + cell_contents / column_height + padding_bottom + // for a given cell in the column + // e.g., + // column width = 5 + // cell_contents = "I love tabulate" (size/length = 15) + // padding top and padding bottom are 1 + // then, cell height = 1 + (15 / 5) + 1 = 1 + 3 + 1 = 5 + // The cell will look like this: + // + // ..... + // I lov + // e tab + // ulate + // ..... + size_t get_cell_height(size_t cell_index, size_t column_width) { + size_t result{0}; + Cell &cell = *(cells_[cell_index]); + auto format = cell.format(); + auto text = cell.get_text(); + + auto padding_left = *format.padding_left_; + auto padding_right = *format.padding_right_; + + result += *format.padding_top_; + + if (column_width > (padding_left + padding_right)) { + column_width -= (padding_left + padding_right); + } + + // Check if input text has embedded newline characters + auto newlines_in_text = std::count(text.begin(), text.end(), '\n'); + std::string word_wrapped_text; + if (newlines_in_text == 0) { + // No new lines in input + // Apply automatic word wrapping and compute row height + word_wrapped_text = Format::word_wrap(text, column_width, cell.locale(), + cell.is_multi_byte_character_support_enabled()); + } else { + // There are embedded '\n' characters + // Respect these characters + word_wrapped_text = text; + } + + auto newlines_in_wrapped_text = + std::count(word_wrapped_text.begin(), word_wrapped_text.end(), '\n'); + auto estimated_row_height = newlines_in_wrapped_text; + + if (!word_wrapped_text.empty() && + word_wrapped_text[word_wrapped_text.size() - 1] != '\n') // text doesn't end with a newline + estimated_row_height += 1; + + result += estimated_row_height; + + result += *format.padding_bottom_; + + return result; + } + + std::vector> cells_; + std::weak_ptr parent_; + optional format_; +}; + +} // namespace tabulate diff --git a/libs/tabulate/string_view_lite.hpp b/libs/tabulate/string_view_lite.hpp index 1a24685..f248afb 100644 --- a/libs/tabulate/string_view_lite.hpp +++ b/libs/tabulate/string_view_lite.hpp @@ -1,1638 +1,1638 @@ -// Copyright 2017-2020 by Martin Moene -// -// string-view lite, a C++17-like string_view for C++98 and later. -// For more information see https://github.com/martinmoene/string-view-lite -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#pragma once - -#ifndef NONSTD_SV_LITE_H_INCLUDED -#define NONSTD_SV_LITE_H_INCLUDED - -#define string_view_lite_MAJOR 1 -#define string_view_lite_MINOR 6 -#define string_view_lite_PATCH 0 - -#define string_view_lite_VERSION nssv_STRINGIFY(string_view_lite_MAJOR) "." nssv_STRINGIFY(string_view_lite_MINOR) "." nssv_STRINGIFY(string_view_lite_PATCH) - -#define nssv_STRINGIFY( x ) nssv_STRINGIFY_( x ) -#define nssv_STRINGIFY_( x ) #x - -// string-view lite configuration: - -#define nssv_STRING_VIEW_DEFAULT 0 -#define nssv_STRING_VIEW_NONSTD 1 -#define nssv_STRING_VIEW_STD 2 - -// tweak header support: - -#ifdef __has_include -# if __has_include() -# include -# endif -#define nssv_HAVE_TWEAK_HEADER 1 -#else -#define nssv_HAVE_TWEAK_HEADER 0 -//# pragma message("string_view.hpp: Note: Tweak header not supported.") -#endif - -// string_view selection and configuration: - -#if !defined( nssv_CONFIG_SELECT_STRING_VIEW ) -# define nssv_CONFIG_SELECT_STRING_VIEW ( nssv_HAVE_STD_STRING_VIEW ? nssv_STRING_VIEW_STD : nssv_STRING_VIEW_NONSTD ) -#endif - -#ifndef nssv_CONFIG_STD_SV_OPERATOR -# define nssv_CONFIG_STD_SV_OPERATOR 0 -#endif - -#ifndef nssv_CONFIG_USR_SV_OPERATOR -# define nssv_CONFIG_USR_SV_OPERATOR 1 -#endif - -#ifdef nssv_CONFIG_CONVERSION_STD_STRING -# define nssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS nssv_CONFIG_CONVERSION_STD_STRING -# define nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS nssv_CONFIG_CONVERSION_STD_STRING -#endif - -#ifndef nssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS -# define nssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS 1 -#endif - -#ifndef nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS -# define nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS 1 -#endif - -#ifndef nssv_CONFIG_NO_STREAM_INSERTION -# define nssv_CONFIG_NO_STREAM_INSERTION 0 -#endif - -// Control presence of exception handling (try and auto discover): - -#ifndef nssv_CONFIG_NO_EXCEPTIONS -# if defined(_MSC_VER) -# include // for _HAS_EXCEPTIONS -# endif -# if defined(__cpp_exceptions) || defined(__EXCEPTIONS) || (_HAS_EXCEPTIONS) -# define nssv_CONFIG_NO_EXCEPTIONS 0 -# else -# define nssv_CONFIG_NO_EXCEPTIONS 1 -# endif -#endif - -// C++ language version detection (C++20 is speculative): -// Note: VC14.0/1900 (VS2015) lacks too much from C++14. - -#ifndef nssv_CPLUSPLUS -# if defined(_MSVC_LANG ) && !defined(__clang__) -# define nssv_CPLUSPLUS (_MSC_VER == 1900 ? 201103L : _MSVC_LANG ) -# else -# define nssv_CPLUSPLUS __cplusplus -# endif -#endif - -#define nssv_CPP98_OR_GREATER ( nssv_CPLUSPLUS >= 199711L ) -#define nssv_CPP11_OR_GREATER ( nssv_CPLUSPLUS >= 201103L ) -#define nssv_CPP11_OR_GREATER_ ( nssv_CPLUSPLUS >= 201103L ) -#define nssv_CPP14_OR_GREATER ( nssv_CPLUSPLUS >= 201402L ) -#define nssv_CPP17_OR_GREATER ( nssv_CPLUSPLUS >= 201703L ) -#define nssv_CPP20_OR_GREATER ( nssv_CPLUSPLUS >= 202000L ) - -// use C++17 std::string_view if available and requested: - -#if nssv_CPP17_OR_GREATER && defined(__has_include ) -# if __has_include( ) -# define nssv_HAVE_STD_STRING_VIEW 1 -# else -# define nssv_HAVE_STD_STRING_VIEW 0 -# endif -#else -# define nssv_HAVE_STD_STRING_VIEW 0 -#endif - -#define nssv_USES_STD_STRING_VIEW ( (nssv_CONFIG_SELECT_STRING_VIEW == nssv_STRING_VIEW_STD) || ((nssv_CONFIG_SELECT_STRING_VIEW == nssv_STRING_VIEW_DEFAULT) && nssv_HAVE_STD_STRING_VIEW) ) - -#define nssv_HAVE_STARTS_WITH ( nssv_CPP20_OR_GREATER || !nssv_USES_STD_STRING_VIEW ) -#define nssv_HAVE_ENDS_WITH nssv_HAVE_STARTS_WITH - -// -// Use C++17 std::string_view: -// - -#if nssv_USES_STD_STRING_VIEW - -#include - -// Extensions for std::string: - -#if nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS - -namespace nonstd { - -template< class CharT, class Traits, class Allocator = std::allocator > -std::basic_string -to_string( std::basic_string_view v, Allocator const & a = Allocator() ) -{ - return std::basic_string( v.begin(), v.end(), a ); -} - -template< class CharT, class Traits, class Allocator > -std::basic_string_view -to_string_view( std::basic_string const & s ) -{ - return std::basic_string_view( s.data(), s.size() ); -} - -// Literal operators sv and _sv: - -#if nssv_CONFIG_STD_SV_OPERATOR - -using namespace std::literals::string_view_literals; - -#endif - -#if nssv_CONFIG_USR_SV_OPERATOR - -inline namespace literals { -inline namespace string_view_literals { - - -constexpr std::string_view operator "" _sv( const char* str, size_t len ) noexcept // (1) -{ - return std::string_view{ str, len }; -} - -constexpr std::u16string_view operator "" _sv( const char16_t* str, size_t len ) noexcept // (2) -{ - return std::u16string_view{ str, len }; -} - -constexpr std::u32string_view operator "" _sv( const char32_t* str, size_t len ) noexcept // (3) -{ - return std::u32string_view{ str, len }; -} - -constexpr std::wstring_view operator "" _sv( const wchar_t* str, size_t len ) noexcept // (4) -{ - return std::wstring_view{ str, len }; -} - -}} // namespace literals::string_view_literals - -#endif // nssv_CONFIG_USR_SV_OPERATOR - -} // namespace nonstd - -#endif // nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS - -namespace nonstd { - -using std::string_view; -using std::wstring_view; -using std::u16string_view; -using std::u32string_view; -using std::basic_string_view; - -// literal "sv" and "_sv", see above - -using std::operator==; -using std::operator!=; -using std::operator<; -using std::operator<=; -using std::operator>; -using std::operator>=; - -using std::operator<<; - -} // namespace nonstd - -#else // nssv_HAVE_STD_STRING_VIEW - -// -// Before C++17: use string_view lite: -// - -// Compiler versions: -// -// MSVC++ 6.0 _MSC_VER == 1200 nssv_COMPILER_MSVC_VERSION == 60 (Visual Studio 6.0) -// MSVC++ 7.0 _MSC_VER == 1300 nssv_COMPILER_MSVC_VERSION == 70 (Visual Studio .NET 2002) -// MSVC++ 7.1 _MSC_VER == 1310 nssv_COMPILER_MSVC_VERSION == 71 (Visual Studio .NET 2003) -// MSVC++ 8.0 _MSC_VER == 1400 nssv_COMPILER_MSVC_VERSION == 80 (Visual Studio 2005) -// MSVC++ 9.0 _MSC_VER == 1500 nssv_COMPILER_MSVC_VERSION == 90 (Visual Studio 2008) -// MSVC++ 10.0 _MSC_VER == 1600 nssv_COMPILER_MSVC_VERSION == 100 (Visual Studio 2010) -// MSVC++ 11.0 _MSC_VER == 1700 nssv_COMPILER_MSVC_VERSION == 110 (Visual Studio 2012) -// MSVC++ 12.0 _MSC_VER == 1800 nssv_COMPILER_MSVC_VERSION == 120 (Visual Studio 2013) -// MSVC++ 14.0 _MSC_VER == 1900 nssv_COMPILER_MSVC_VERSION == 140 (Visual Studio 2015) -// MSVC++ 14.1 _MSC_VER >= 1910 nssv_COMPILER_MSVC_VERSION == 141 (Visual Studio 2017) -// MSVC++ 14.2 _MSC_VER >= 1920 nssv_COMPILER_MSVC_VERSION == 142 (Visual Studio 2019) - -#if defined(_MSC_VER ) && !defined(__clang__) -# define nssv_COMPILER_MSVC_VER (_MSC_VER ) -# define nssv_COMPILER_MSVC_VERSION (_MSC_VER / 10 - 10 * ( 5 + (_MSC_VER < 1900 ) ) ) -#else -# define nssv_COMPILER_MSVC_VER 0 -# define nssv_COMPILER_MSVC_VERSION 0 -#endif - -#define nssv_COMPILER_VERSION( major, minor, patch ) ( 10 * ( 10 * (major) + (minor) ) + (patch) ) - -#if defined( __apple_build_version__ ) -# define nssv_COMPILER_APPLECLANG_VERSION nssv_COMPILER_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__) -# define nssv_COMPILER_CLANG_VERSION 0 -#elif defined( __clang__ ) -# define nssv_COMPILER_APPLECLANG_VERSION 0 -# define nssv_COMPILER_CLANG_VERSION nssv_COMPILER_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__) -#else -# define nssv_COMPILER_APPLECLANG_VERSION 0 -# define nssv_COMPILER_CLANG_VERSION 0 -#endif - -#if defined(__GNUC__) && !defined(__clang__) -# define nssv_COMPILER_GNUC_VERSION nssv_COMPILER_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) -#else -# define nssv_COMPILER_GNUC_VERSION 0 -#endif - -// half-open range [lo..hi): -#define nssv_BETWEEN( v, lo, hi ) ( (lo) <= (v) && (v) < (hi) ) - -// Presence of language and library features: - -#ifdef _HAS_CPP0X -# define nssv_HAS_CPP0X _HAS_CPP0X -#else -# define nssv_HAS_CPP0X 0 -#endif - -// Unless defined otherwise below, consider VC14 as C++11 for variant-lite: - -#if nssv_COMPILER_MSVC_VER >= 1900 -# undef nssv_CPP11_OR_GREATER -# define nssv_CPP11_OR_GREATER 1 -#endif - -#define nssv_CPP11_90 (nssv_CPP11_OR_GREATER_ || nssv_COMPILER_MSVC_VER >= 1500) -#define nssv_CPP11_100 (nssv_CPP11_OR_GREATER_ || nssv_COMPILER_MSVC_VER >= 1600) -#define nssv_CPP11_110 (nssv_CPP11_OR_GREATER_ || nssv_COMPILER_MSVC_VER >= 1700) -#define nssv_CPP11_120 (nssv_CPP11_OR_GREATER_ || nssv_COMPILER_MSVC_VER >= 1800) -#define nssv_CPP11_140 (nssv_CPP11_OR_GREATER_ || nssv_COMPILER_MSVC_VER >= 1900) -#define nssv_CPP11_141 (nssv_CPP11_OR_GREATER_ || nssv_COMPILER_MSVC_VER >= 1910) - -#define nssv_CPP14_000 (nssv_CPP14_OR_GREATER) -#define nssv_CPP17_000 (nssv_CPP17_OR_GREATER) - -// Presence of C++11 language features: - -#define nssv_HAVE_CONSTEXPR_11 nssv_CPP11_140 -#define nssv_HAVE_EXPLICIT_CONVERSION nssv_CPP11_140 -#define nssv_HAVE_INLINE_NAMESPACE nssv_CPP11_140 -#define nssv_HAVE_NOEXCEPT nssv_CPP11_140 -#define nssv_HAVE_NULLPTR nssv_CPP11_100 -#define nssv_HAVE_REF_QUALIFIER nssv_CPP11_140 -#define nssv_HAVE_UNICODE_LITERALS nssv_CPP11_140 -#define nssv_HAVE_USER_DEFINED_LITERALS nssv_CPP11_140 -#define nssv_HAVE_WCHAR16_T nssv_CPP11_100 -#define nssv_HAVE_WCHAR32_T nssv_CPP11_100 - -#if ! ( ( nssv_CPP11_OR_GREATER && nssv_COMPILER_CLANG_VERSION ) || nssv_BETWEEN( nssv_COMPILER_CLANG_VERSION, 300, 400 ) ) -# define nssv_HAVE_STD_DEFINED_LITERALS nssv_CPP11_140 -#else -# define nssv_HAVE_STD_DEFINED_LITERALS 0 -#endif - -// Presence of C++14 language features: - -#define nssv_HAVE_CONSTEXPR_14 nssv_CPP14_000 - -// Presence of C++17 language features: - -#define nssv_HAVE_NODISCARD nssv_CPP17_000 - -// Presence of C++ library features: - -#define nssv_HAVE_STD_HASH nssv_CPP11_120 - -// Presence of compiler intrinsics: - -// Providing char-type specializations for compare() and length() that -// use compiler intrinsics can improve compile- and run-time performance. -// -// The challenge is in using the right combinations of builtin availability -// and its constexpr-ness. -// -// | compiler | __builtin_memcmp (constexpr) | memcmp (constexpr) | -// |----------|------------------------------|---------------------| -// | clang | 4.0 (>= 4.0 ) | any (? ) | -// | clang-a | 9.0 (>= 9.0 ) | any (? ) | -// | gcc | any (constexpr) | any (? ) | -// | msvc | >= 14.2 C++17 (>= 14.2 ) | any (? ) | - -#define nssv_HAVE_BUILTIN_VER ( (nssv_CPP17_000 && nssv_COMPILER_MSVC_VERSION >= 142) || nssv_COMPILER_GNUC_VERSION > 0 || nssv_COMPILER_CLANG_VERSION >= 400 || nssv_COMPILER_APPLECLANG_VERSION >= 900 ) -#define nssv_HAVE_BUILTIN_CE ( nssv_HAVE_BUILTIN_VER ) - -#define nssv_HAVE_BUILTIN_MEMCMP ( (nssv_HAVE_CONSTEXPR_14 && nssv_HAVE_BUILTIN_CE) || !nssv_HAVE_CONSTEXPR_14 ) -#define nssv_HAVE_BUILTIN_STRLEN ( (nssv_HAVE_CONSTEXPR_11 && nssv_HAVE_BUILTIN_CE) || !nssv_HAVE_CONSTEXPR_11 ) - -#ifdef __has_builtin -# define nssv_HAVE_BUILTIN( x ) __has_builtin( x ) -#else -# define nssv_HAVE_BUILTIN( x ) 0 -#endif - -#if nssv_HAVE_BUILTIN(__builtin_memcmp) || nssv_HAVE_BUILTIN_VER -# define nssv_BUILTIN_MEMCMP __builtin_memcmp -#else -# define nssv_BUILTIN_MEMCMP memcmp -#endif - -#if nssv_HAVE_BUILTIN(__builtin_strlen) || nssv_HAVE_BUILTIN_VER -# define nssv_BUILTIN_STRLEN __builtin_strlen -#else -# define nssv_BUILTIN_STRLEN strlen -#endif - -// C++ feature usage: - -#if nssv_HAVE_CONSTEXPR_11 -# define nssv_constexpr constexpr -#else -# define nssv_constexpr /*constexpr*/ -#endif - -#if nssv_HAVE_CONSTEXPR_14 -# define nssv_constexpr14 constexpr -#else -# define nssv_constexpr14 /*constexpr*/ -#endif - -#if nssv_HAVE_EXPLICIT_CONVERSION -# define nssv_explicit explicit -#else -# define nssv_explicit /*explicit*/ -#endif - -#if nssv_HAVE_INLINE_NAMESPACE -# define nssv_inline_ns inline -#else -# define nssv_inline_ns /*inline*/ -#endif - -#if nssv_HAVE_NOEXCEPT -# define nssv_noexcept noexcept -#else -# define nssv_noexcept /*noexcept*/ -#endif - -//#if nssv_HAVE_REF_QUALIFIER -//# define nssv_ref_qual & -//# define nssv_refref_qual && -//#else -//# define nssv_ref_qual /*&*/ -//# define nssv_refref_qual /*&&*/ -//#endif - -#if nssv_HAVE_NULLPTR -# define nssv_nullptr nullptr -#else -# define nssv_nullptr NULL -#endif - -#if nssv_HAVE_NODISCARD -# define nssv_nodiscard [[nodiscard]] -#else -# define nssv_nodiscard /*[[nodiscard]]*/ -#endif - -// Additional includes: - -#include -#include -#include -#include -#include // std::char_traits<> - -#if ! nssv_CONFIG_NO_STREAM_INSERTION -# include -#endif - -#if ! nssv_CONFIG_NO_EXCEPTIONS -# include -#endif - -#if nssv_CPP11_OR_GREATER -# include -#endif - -// Clang, GNUC, MSVC warning suppression macros: - -#if defined(__clang__) -# pragma clang diagnostic ignored "-Wreserved-user-defined-literal" -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wuser-defined-literals" -#elif defined(__GNUC__) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wliteral-suffix" -#endif // __clang__ - -#if nssv_COMPILER_MSVC_VERSION >= 140 -# define nssv_SUPPRESS_MSGSL_WARNING(expr) [[gsl::suppress(expr)]] -# define nssv_SUPPRESS_MSVC_WARNING(code, descr) __pragma(warning(suppress: code) ) -# define nssv_DISABLE_MSVC_WARNINGS(codes) __pragma(warning(push)) __pragma(warning(disable: codes)) -#else -# define nssv_SUPPRESS_MSGSL_WARNING(expr) -# define nssv_SUPPRESS_MSVC_WARNING(code, descr) -# define nssv_DISABLE_MSVC_WARNINGS(codes) -#endif - -#if defined(__clang__) -# define nssv_RESTORE_WARNINGS() _Pragma("clang diagnostic pop") -#elif defined(__GNUC__) -# define nssv_RESTORE_WARNINGS() _Pragma("GCC diagnostic pop") -#elif nssv_COMPILER_MSVC_VERSION >= 140 -# define nssv_RESTORE_WARNINGS() __pragma(warning(pop )) -#else -# define nssv_RESTORE_WARNINGS() -#endif - -// Suppress the following MSVC (GSL) warnings: -// - C4455, non-gsl : 'operator ""sv': literal suffix identifiers that do not -// start with an underscore are reserved -// - C26472, gsl::t.1 : don't use a static_cast for arithmetic conversions; -// use brace initialization, gsl::narrow_cast or gsl::narow -// - C26481: gsl::b.1 : don't use pointer arithmetic. Use span instead - -nssv_DISABLE_MSVC_WARNINGS( 4455 26481 26472 ) -//nssv_DISABLE_CLANG_WARNINGS( "-Wuser-defined-literals" ) -//nssv_DISABLE_GNUC_WARNINGS( -Wliteral-suffix ) - -namespace nonstd { namespace sv_lite { - -namespace detail { - -// support constexpr comparison in C++14; -// for C++17 and later, use provided traits: - -template< typename CharT > -inline nssv_constexpr14 int compare( CharT const * s1, CharT const * s2, std::size_t count ) -{ - while ( count-- != 0 ) - { - if ( *s1 < *s2 ) return -1; - if ( *s1 > *s2 ) return +1; - ++s1; ++s2; - } - return 0; -} - -#if nssv_HAVE_BUILTIN_MEMCMP - -// specialization of compare() for char, see also generic compare() above: - -inline nssv_constexpr14 int compare( char const * s1, char const * s2, std::size_t count ) -{ - return nssv_BUILTIN_MEMCMP( s1, s2, count ); -} - -#endif - -#if nssv_HAVE_BUILTIN_STRLEN - -// specialization of length() for char, see also generic length() further below: - -inline nssv_constexpr std::size_t length( char const * s ) -{ - return nssv_BUILTIN_STRLEN( s ); -} - -#endif - -#if defined(__OPTIMIZE__) - -// gcc, clang provide __OPTIMIZE__ -// Expect tail call optimization to make length() non-recursive: - -template< typename CharT > -inline nssv_constexpr std::size_t length( CharT * s, std::size_t result = 0 ) -{ - return *s == '\0' ? result : length( s + 1, result + 1 ); -} - -#else // OPTIMIZE - -// non-recursive: - -template< typename CharT > -inline nssv_constexpr14 std::size_t length( CharT * s ) -{ - std::size_t result = 0; - while ( *s++ != '\0' ) - { - ++result; - } - return result; -} - -#endif // OPTIMIZE - -} // namespace detail - -template -< - class CharT, - class Traits = std::char_traits -> -class basic_string_view; - -// -// basic_string_view: -// - -template -< - class CharT, - class Traits /* = std::char_traits */ -> -class basic_string_view -{ -public: - // Member types: - - typedef Traits traits_type; - typedef CharT value_type; - - typedef CharT * pointer; - typedef CharT const * const_pointer; - typedef CharT & reference; - typedef CharT const & const_reference; - - typedef const_pointer iterator; - typedef const_pointer const_iterator; - typedef std::reverse_iterator< const_iterator > reverse_iterator; - typedef std::reverse_iterator< const_iterator > const_reverse_iterator; - - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - - // 24.4.2.1 Construction and assignment: - - nssv_constexpr basic_string_view() nssv_noexcept - : data_( nssv_nullptr ) - , size_( 0 ) - {} - -#if nssv_CPP11_OR_GREATER - nssv_constexpr basic_string_view( basic_string_view const & other ) nssv_noexcept = default; -#else - nssv_constexpr basic_string_view( basic_string_view const & other ) nssv_noexcept - : data_( other.data_) - , size_( other.size_) - {} -#endif - - nssv_constexpr basic_string_view( CharT const * s, size_type count ) nssv_noexcept // non-standard noexcept - : data_( s ) - , size_( count ) - {} - - nssv_constexpr basic_string_view( CharT const * s) nssv_noexcept // non-standard noexcept - : data_( s ) -#if nssv_CPP17_OR_GREATER - , size_( Traits::length(s) ) -#elif nssv_CPP11_OR_GREATER - , size_( detail::length(s) ) -#else - , size_( Traits::length(s) ) -#endif - {} - - // Assignment: - -#if nssv_CPP11_OR_GREATER - nssv_constexpr14 basic_string_view & operator=( basic_string_view const & other ) nssv_noexcept = default; -#else - nssv_constexpr14 basic_string_view & operator=( basic_string_view const & other ) nssv_noexcept - { - data_ = other.data_; - size_ = other.size_; - return *this; - } -#endif - - // 24.4.2.2 Iterator support: - - nssv_constexpr const_iterator begin() const nssv_noexcept { return data_; } - nssv_constexpr const_iterator end() const nssv_noexcept { return data_ + size_; } - - nssv_constexpr const_iterator cbegin() const nssv_noexcept { return begin(); } - nssv_constexpr const_iterator cend() const nssv_noexcept { return end(); } - - nssv_constexpr const_reverse_iterator rbegin() const nssv_noexcept { return const_reverse_iterator( end() ); } - nssv_constexpr const_reverse_iterator rend() const nssv_noexcept { return const_reverse_iterator( begin() ); } - - nssv_constexpr const_reverse_iterator crbegin() const nssv_noexcept { return rbegin(); } - nssv_constexpr const_reverse_iterator crend() const nssv_noexcept { return rend(); } - - // 24.4.2.3 Capacity: - - nssv_constexpr size_type size() const nssv_noexcept { return size_; } - nssv_constexpr size_type length() const nssv_noexcept { return size_; } - nssv_constexpr size_type max_size() const nssv_noexcept { return (std::numeric_limits< size_type >::max)(); } - - // since C++20 - nssv_nodiscard nssv_constexpr bool empty() const nssv_noexcept - { - return 0 == size_; - } - - // 24.4.2.4 Element access: - - nssv_constexpr const_reference operator[]( size_type pos ) const - { - return data_at( pos ); - } - - nssv_constexpr14 const_reference at( size_type pos ) const - { -#if nssv_CONFIG_NO_EXCEPTIONS - assert( pos < size() ); -#else - if ( pos >= size() ) - { - throw std::out_of_range("nonstd::string_view::at()"); - } -#endif - return data_at( pos ); - } - - nssv_constexpr const_reference front() const { return data_at( 0 ); } - nssv_constexpr const_reference back() const { return data_at( size() - 1 ); } - - nssv_constexpr const_pointer data() const nssv_noexcept { return data_; } - - // 24.4.2.5 Modifiers: - - nssv_constexpr14 void remove_prefix( size_type n ) - { - assert( n <= size() ); - data_ += n; - size_ -= n; - } - - nssv_constexpr14 void remove_suffix( size_type n ) - { - assert( n <= size() ); - size_ -= n; - } - - nssv_constexpr14 void swap( basic_string_view & other ) nssv_noexcept - { - const basic_string_view tmp(other); - other = *this; - *this = tmp; - } - - // 24.4.2.6 String operations: - - size_type copy( CharT * dest, size_type n, size_type pos = 0 ) const - { -#if nssv_CONFIG_NO_EXCEPTIONS - assert( pos <= size() ); -#else - if ( pos > size() ) - { - throw std::out_of_range("nonstd::string_view::copy()"); - } -#endif - const size_type rlen = (std::min)( n, size() - pos ); - - (void) Traits::copy( dest, data() + pos, rlen ); - - return rlen; - } - - nssv_constexpr14 basic_string_view substr( size_type pos = 0, size_type n = npos ) const - { -#if nssv_CONFIG_NO_EXCEPTIONS - assert( pos <= size() ); -#else - if ( pos > size() ) - { - throw std::out_of_range("nonstd::string_view::substr()"); - } -#endif - return basic_string_view( data() + pos, (std::min)( n, size() - pos ) ); - } - - // compare(), 6x: - - nssv_constexpr14 int compare( basic_string_view other ) const nssv_noexcept // (1) - { -#if nssv_CPP17_OR_GREATER - if ( const int result = Traits::compare( data(), other.data(), (std::min)( size(), other.size() ) ) ) -#else - if ( const int result = detail::compare( data(), other.data(), (std::min)( size(), other.size() ) ) ) -#endif - { - return result; - } - - return size() == other.size() ? 0 : size() < other.size() ? -1 : 1; - } - - nssv_constexpr int compare( size_type pos1, size_type n1, basic_string_view other ) const // (2) - { - return substr( pos1, n1 ).compare( other ); - } - - nssv_constexpr int compare( size_type pos1, size_type n1, basic_string_view other, size_type pos2, size_type n2 ) const // (3) - { - return substr( pos1, n1 ).compare( other.substr( pos2, n2 ) ); - } - - nssv_constexpr int compare( CharT const * s ) const // (4) - { - return compare( basic_string_view( s ) ); - } - - nssv_constexpr int compare( size_type pos1, size_type n1, CharT const * s ) const // (5) - { - return substr( pos1, n1 ).compare( basic_string_view( s ) ); - } - - nssv_constexpr int compare( size_type pos1, size_type n1, CharT const * s, size_type n2 ) const // (6) - { - return substr( pos1, n1 ).compare( basic_string_view( s, n2 ) ); - } - - // 24.4.2.7 Searching: - - // starts_with(), 3x, since C++20: - - nssv_constexpr bool starts_with( basic_string_view v ) const nssv_noexcept // (1) - { - return size() >= v.size() && compare( 0, v.size(), v ) == 0; - } - - nssv_constexpr bool starts_with( CharT c ) const nssv_noexcept // (2) - { - return starts_with( basic_string_view( &c, 1 ) ); - } - - nssv_constexpr bool starts_with( CharT const * s ) const // (3) - { - return starts_with( basic_string_view( s ) ); - } - - // ends_with(), 3x, since C++20: - - nssv_constexpr bool ends_with( basic_string_view v ) const nssv_noexcept // (1) - { - return size() >= v.size() && compare( size() - v.size(), npos, v ) == 0; - } - - nssv_constexpr bool ends_with( CharT c ) const nssv_noexcept // (2) - { - return ends_with( basic_string_view( &c, 1 ) ); - } - - nssv_constexpr bool ends_with( CharT const * s ) const // (3) - { - return ends_with( basic_string_view( s ) ); - } - - // find(), 4x: - - nssv_constexpr14 size_type find( basic_string_view v, size_type pos = 0 ) const nssv_noexcept // (1) - { - return assert( v.size() == 0 || v.data() != nssv_nullptr ) - , pos >= size() - ? npos - : to_pos( std::search( cbegin() + pos, cend(), v.cbegin(), v.cend(), Traits::eq ) ); - } - - nssv_constexpr14 size_type find( CharT c, size_type pos = 0 ) const nssv_noexcept // (2) - { - return find( basic_string_view( &c, 1 ), pos ); - } - - nssv_constexpr14 size_type find( CharT const * s, size_type pos, size_type n ) const // (3) - { - return find( basic_string_view( s, n ), pos ); - } - - nssv_constexpr14 size_type find( CharT const * s, size_type pos = 0 ) const // (4) - { - return find( basic_string_view( s ), pos ); - } - - // rfind(), 4x: - - nssv_constexpr14 size_type rfind( basic_string_view v, size_type pos = npos ) const nssv_noexcept // (1) - { - if ( size() < v.size() ) - { - return npos; - } - - if ( v.empty() ) - { - return (std::min)( size(), pos ); - } - - const_iterator last = cbegin() + (std::min)( size() - v.size(), pos ) + v.size(); - const_iterator result = std::find_end( cbegin(), last, v.cbegin(), v.cend(), Traits::eq ); - - return result != last ? size_type( result - cbegin() ) : npos; - } - - nssv_constexpr14 size_type rfind( CharT c, size_type pos = npos ) const nssv_noexcept // (2) - { - return rfind( basic_string_view( &c, 1 ), pos ); - } - - nssv_constexpr14 size_type rfind( CharT const * s, size_type pos, size_type n ) const // (3) - { - return rfind( basic_string_view( s, n ), pos ); - } - - nssv_constexpr14 size_type rfind( CharT const * s, size_type pos = npos ) const // (4) - { - return rfind( basic_string_view( s ), pos ); - } - - // find_first_of(), 4x: - - nssv_constexpr size_type find_first_of( basic_string_view v, size_type pos = 0 ) const nssv_noexcept // (1) - { - return pos >= size() - ? npos - : to_pos( std::find_first_of( cbegin() + pos, cend(), v.cbegin(), v.cend(), Traits::eq ) ); - } - - nssv_constexpr size_type find_first_of( CharT c, size_type pos = 0 ) const nssv_noexcept // (2) - { - return find_first_of( basic_string_view( &c, 1 ), pos ); - } - - nssv_constexpr size_type find_first_of( CharT const * s, size_type pos, size_type n ) const // (3) - { - return find_first_of( basic_string_view( s, n ), pos ); - } - - nssv_constexpr size_type find_first_of( CharT const * s, size_type pos = 0 ) const // (4) - { - return find_first_of( basic_string_view( s ), pos ); - } - - // find_last_of(), 4x: - - nssv_constexpr size_type find_last_of( basic_string_view v, size_type pos = npos ) const nssv_noexcept // (1) - { - return empty() - ? npos - : pos >= size() - ? find_last_of( v, size() - 1 ) - : to_pos( std::find_first_of( const_reverse_iterator( cbegin() + pos + 1 ), crend(), v.cbegin(), v.cend(), Traits::eq ) ); - } - - nssv_constexpr size_type find_last_of( CharT c, size_type pos = npos ) const nssv_noexcept // (2) - { - return find_last_of( basic_string_view( &c, 1 ), pos ); - } - - nssv_constexpr size_type find_last_of( CharT const * s, size_type pos, size_type count ) const // (3) - { - return find_last_of( basic_string_view( s, count ), pos ); - } - - nssv_constexpr size_type find_last_of( CharT const * s, size_type pos = npos ) const // (4) - { - return find_last_of( basic_string_view( s ), pos ); - } - - // find_first_not_of(), 4x: - - nssv_constexpr size_type find_first_not_of( basic_string_view v, size_type pos = 0 ) const nssv_noexcept // (1) - { - return pos >= size() - ? npos - : to_pos( std::find_if( cbegin() + pos, cend(), not_in_view( v ) ) ); - } - - nssv_constexpr size_type find_first_not_of( CharT c, size_type pos = 0 ) const nssv_noexcept // (2) - { - return find_first_not_of( basic_string_view( &c, 1 ), pos ); - } - - nssv_constexpr size_type find_first_not_of( CharT const * s, size_type pos, size_type count ) const // (3) - { - return find_first_not_of( basic_string_view( s, count ), pos ); - } - - nssv_constexpr size_type find_first_not_of( CharT const * s, size_type pos = 0 ) const // (4) - { - return find_first_not_of( basic_string_view( s ), pos ); - } - - // find_last_not_of(), 4x: - - nssv_constexpr size_type find_last_not_of( basic_string_view v, size_type pos = npos ) const nssv_noexcept // (1) - { - return empty() - ? npos - : pos >= size() - ? find_last_not_of( v, size() - 1 ) - : to_pos( std::find_if( const_reverse_iterator( cbegin() + pos + 1 ), crend(), not_in_view( v ) ) ); - } - - nssv_constexpr size_type find_last_not_of( CharT c, size_type pos = npos ) const nssv_noexcept // (2) - { - return find_last_not_of( basic_string_view( &c, 1 ), pos ); - } - - nssv_constexpr size_type find_last_not_of( CharT const * s, size_type pos, size_type count ) const // (3) - { - return find_last_not_of( basic_string_view( s, count ), pos ); - } - - nssv_constexpr size_type find_last_not_of( CharT const * s, size_type pos = npos ) const // (4) - { - return find_last_not_of( basic_string_view( s ), pos ); - } - - // Constants: - -#if nssv_CPP17_OR_GREATER - static nssv_constexpr size_type npos = size_type(-1); -#elif nssv_CPP11_OR_GREATER - enum : size_type { npos = size_type(-1) }; -#else - enum { npos = size_type(-1) }; -#endif - -private: - struct not_in_view - { - const basic_string_view v; - - nssv_constexpr explicit not_in_view( basic_string_view v_ ) : v( v_ ) {} - - nssv_constexpr bool operator()( CharT c ) const - { - return npos == v.find_first_of( c ); - } - }; - - nssv_constexpr size_type to_pos( const_iterator it ) const - { - return it == cend() ? npos : size_type( it - cbegin() ); - } - - nssv_constexpr size_type to_pos( const_reverse_iterator it ) const - { - return it == crend() ? npos : size_type( crend() - it - 1 ); - } - - nssv_constexpr const_reference data_at( size_type pos ) const - { -#if nssv_BETWEEN( nssv_COMPILER_GNUC_VERSION, 1, 500 ) - return data_[pos]; -#else - return assert( pos < size() ), data_[pos]; -#endif - } - -private: - const_pointer data_; - size_type size_; - -public: -#if nssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS - - template< class Allocator > - basic_string_view( std::basic_string const & s ) nssv_noexcept - : data_( s.data() ) - , size_( s.size() ) - {} - -#if nssv_HAVE_EXPLICIT_CONVERSION - - template< class Allocator > - explicit operator std::basic_string() const - { - return to_string( Allocator() ); - } - -#endif // nssv_HAVE_EXPLICIT_CONVERSION - -#if nssv_CPP11_OR_GREATER - - template< class Allocator = std::allocator > - std::basic_string - to_string( Allocator const & a = Allocator() ) const - { - return std::basic_string( begin(), end(), a ); - } - -#else - - std::basic_string - to_string() const - { - return std::basic_string( begin(), end() ); - } - - template< class Allocator > - std::basic_string - to_string( Allocator const & a ) const - { - return std::basic_string( begin(), end(), a ); - } - -#endif // nssv_CPP11_OR_GREATER - -#endif // nssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS -}; - -// -// Non-member functions: -// - -// 24.4.3 Non-member comparison functions: -// lexicographically compare two string views (function template): - -template< class CharT, class Traits > -nssv_constexpr bool operator== ( - basic_string_view lhs, - basic_string_view rhs ) nssv_noexcept -{ return lhs.size() == rhs.size() && lhs.compare( rhs ) == 0; } - -template< class CharT, class Traits > -nssv_constexpr bool operator!= ( - basic_string_view lhs, - basic_string_view rhs ) nssv_noexcept -{ return !( lhs == rhs ); } - -template< class CharT, class Traits > -nssv_constexpr bool operator< ( - basic_string_view lhs, - basic_string_view rhs ) nssv_noexcept -{ return lhs.compare( rhs ) < 0; } - -template< class CharT, class Traits > -nssv_constexpr bool operator<= ( - basic_string_view lhs, - basic_string_view rhs ) nssv_noexcept -{ return lhs.compare( rhs ) <= 0; } - -template< class CharT, class Traits > -nssv_constexpr bool operator> ( - basic_string_view lhs, - basic_string_view rhs ) nssv_noexcept -{ return lhs.compare( rhs ) > 0; } - -template< class CharT, class Traits > -nssv_constexpr bool operator>= ( - basic_string_view lhs, - basic_string_view rhs ) nssv_noexcept -{ return lhs.compare( rhs ) >= 0; } - -// Let S be basic_string_view, and sv be an instance of S. -// Implementations shall provide sufficient additional overloads marked -// constexpr and noexcept so that an object t with an implicit conversion -// to S can be compared according to Table 67. - -#if ! nssv_CPP11_OR_GREATER || nssv_BETWEEN( nssv_COMPILER_MSVC_VERSION, 100, 141 ) - -// accommodate for older compilers: - -// == - -template< class CharT, class Traits> -nssv_constexpr bool operator==( - basic_string_view lhs, - CharT const * rhs ) nssv_noexcept -{ return lhs.size() == detail::length( rhs ) && lhs.compare( rhs ) == 0; } - -template< class CharT, class Traits> -nssv_constexpr bool operator==( - CharT const * lhs, - basic_string_view rhs ) nssv_noexcept -{ return detail::length( lhs ) == rhs.size() && rhs.compare( lhs ) == 0; } - -template< class CharT, class Traits> -nssv_constexpr bool operator==( - basic_string_view lhs, - std::basic_string rhs ) nssv_noexcept -{ return lhs.size() == rhs.size() && lhs.compare( rhs ) == 0; } - -template< class CharT, class Traits> -nssv_constexpr bool operator==( - std::basic_string rhs, - basic_string_view lhs ) nssv_noexcept -{ return lhs.size() == rhs.size() && lhs.compare( rhs ) == 0; } - -// != - -template< class CharT, class Traits> -nssv_constexpr bool operator!=( - basic_string_view lhs, - CharT const * rhs ) nssv_noexcept -{ return !( lhs == rhs ); } - -template< class CharT, class Traits> -nssv_constexpr bool operator!=( - CharT const * lhs, - basic_string_view rhs ) nssv_noexcept -{ return !( lhs == rhs ); } - -template< class CharT, class Traits> -nssv_constexpr bool operator!=( - basic_string_view lhs, - std::basic_string rhs ) nssv_noexcept -{ return !( lhs == rhs ); } - -template< class CharT, class Traits> -nssv_constexpr bool operator!=( - std::basic_string rhs, - basic_string_view lhs ) nssv_noexcept -{ return !( lhs == rhs ); } - -// < - -template< class CharT, class Traits> -nssv_constexpr bool operator<( - basic_string_view lhs, - CharT const * rhs ) nssv_noexcept -{ return lhs.compare( rhs ) < 0; } - -template< class CharT, class Traits> -nssv_constexpr bool operator<( - CharT const * lhs, - basic_string_view rhs ) nssv_noexcept -{ return rhs.compare( lhs ) > 0; } - -template< class CharT, class Traits> -nssv_constexpr bool operator<( - basic_string_view lhs, - std::basic_string rhs ) nssv_noexcept -{ return lhs.compare( rhs ) < 0; } - -template< class CharT, class Traits> -nssv_constexpr bool operator<( - std::basic_string rhs, - basic_string_view lhs ) nssv_noexcept -{ return rhs.compare( lhs ) > 0; } - -// <= - -template< class CharT, class Traits> -nssv_constexpr bool operator<=( - basic_string_view lhs, - CharT const * rhs ) nssv_noexcept -{ return lhs.compare( rhs ) <= 0; } - -template< class CharT, class Traits> -nssv_constexpr bool operator<=( - CharT const * lhs, - basic_string_view rhs ) nssv_noexcept -{ return rhs.compare( lhs ) >= 0; } - -template< class CharT, class Traits> -nssv_constexpr bool operator<=( - basic_string_view lhs, - std::basic_string rhs ) nssv_noexcept -{ return lhs.compare( rhs ) <= 0; } - -template< class CharT, class Traits> -nssv_constexpr bool operator<=( - std::basic_string rhs, - basic_string_view lhs ) nssv_noexcept -{ return rhs.compare( lhs ) >= 0; } - -// > - -template< class CharT, class Traits> -nssv_constexpr bool operator>( - basic_string_view lhs, - CharT const * rhs ) nssv_noexcept -{ return lhs.compare( rhs ) > 0; } - -template< class CharT, class Traits> -nssv_constexpr bool operator>( - CharT const * lhs, - basic_string_view rhs ) nssv_noexcept -{ return rhs.compare( lhs ) < 0; } - -template< class CharT, class Traits> -nssv_constexpr bool operator>( - basic_string_view lhs, - std::basic_string rhs ) nssv_noexcept -{ return lhs.compare( rhs ) > 0; } - -template< class CharT, class Traits> -nssv_constexpr bool operator>( - std::basic_string rhs, - basic_string_view lhs ) nssv_noexcept -{ return rhs.compare( lhs ) < 0; } - -// >= - -template< class CharT, class Traits> -nssv_constexpr bool operator>=( - basic_string_view lhs, - CharT const * rhs ) nssv_noexcept -{ return lhs.compare( rhs ) >= 0; } - -template< class CharT, class Traits> -nssv_constexpr bool operator>=( - CharT const * lhs, - basic_string_view rhs ) nssv_noexcept -{ return rhs.compare( lhs ) <= 0; } - -template< class CharT, class Traits> -nssv_constexpr bool operator>=( - basic_string_view lhs, - std::basic_string rhs ) nssv_noexcept -{ return lhs.compare( rhs ) >= 0; } - -template< class CharT, class Traits> -nssv_constexpr bool operator>=( - std::basic_string rhs, - basic_string_view lhs ) nssv_noexcept -{ return rhs.compare( lhs ) <= 0; } - -#else // newer compilers: - -#define nssv_BASIC_STRING_VIEW_I(T,U) typename std::decay< basic_string_view >::type - -#if defined(_MSC_VER) // issue 40 -# define nssv_MSVC_ORDER(x) , int=x -#else -# define nssv_MSVC_ORDER(x) /*, int=x*/ -#endif - -// == - -template< class CharT, class Traits nssv_MSVC_ORDER(1) > -nssv_constexpr bool operator==( - basic_string_view lhs, - nssv_BASIC_STRING_VIEW_I(CharT, Traits) rhs ) nssv_noexcept -{ return lhs.size() == rhs.size() && lhs.compare( rhs ) == 0; } - -template< class CharT, class Traits nssv_MSVC_ORDER(2) > -nssv_constexpr bool operator==( - nssv_BASIC_STRING_VIEW_I(CharT, Traits) lhs, - basic_string_view rhs ) nssv_noexcept -{ return lhs.size() == rhs.size() && lhs.compare( rhs ) == 0; } - -// != - -template< class CharT, class Traits nssv_MSVC_ORDER(1) > -nssv_constexpr bool operator!= ( - basic_string_view < CharT, Traits > lhs, - nssv_BASIC_STRING_VIEW_I( CharT, Traits ) rhs ) nssv_noexcept -{ return !( lhs == rhs ); } - -template< class CharT, class Traits nssv_MSVC_ORDER(2) > -nssv_constexpr bool operator!= ( - nssv_BASIC_STRING_VIEW_I( CharT, Traits ) lhs, - basic_string_view < CharT, Traits > rhs ) nssv_noexcept -{ return !( lhs == rhs ); } - -// < - -template< class CharT, class Traits nssv_MSVC_ORDER(1) > -nssv_constexpr bool operator< ( - basic_string_view < CharT, Traits > lhs, - nssv_BASIC_STRING_VIEW_I( CharT, Traits ) rhs ) nssv_noexcept -{ return lhs.compare( rhs ) < 0; } - -template< class CharT, class Traits nssv_MSVC_ORDER(2) > -nssv_constexpr bool operator< ( - nssv_BASIC_STRING_VIEW_I( CharT, Traits ) lhs, - basic_string_view < CharT, Traits > rhs ) nssv_noexcept -{ return lhs.compare( rhs ) < 0; } - -// <= - -template< class CharT, class Traits nssv_MSVC_ORDER(1) > -nssv_constexpr bool operator<= ( - basic_string_view < CharT, Traits > lhs, - nssv_BASIC_STRING_VIEW_I( CharT, Traits ) rhs ) nssv_noexcept -{ return lhs.compare( rhs ) <= 0; } - -template< class CharT, class Traits nssv_MSVC_ORDER(2) > -nssv_constexpr bool operator<= ( - nssv_BASIC_STRING_VIEW_I( CharT, Traits ) lhs, - basic_string_view < CharT, Traits > rhs ) nssv_noexcept -{ return lhs.compare( rhs ) <= 0; } - -// > - -template< class CharT, class Traits nssv_MSVC_ORDER(1) > -nssv_constexpr bool operator> ( - basic_string_view < CharT, Traits > lhs, - nssv_BASIC_STRING_VIEW_I( CharT, Traits ) rhs ) nssv_noexcept -{ return lhs.compare( rhs ) > 0; } - -template< class CharT, class Traits nssv_MSVC_ORDER(2) > -nssv_constexpr bool operator> ( - nssv_BASIC_STRING_VIEW_I( CharT, Traits ) lhs, - basic_string_view < CharT, Traits > rhs ) nssv_noexcept -{ return lhs.compare( rhs ) > 0; } - -// >= - -template< class CharT, class Traits nssv_MSVC_ORDER(1) > -nssv_constexpr bool operator>= ( - basic_string_view < CharT, Traits > lhs, - nssv_BASIC_STRING_VIEW_I( CharT, Traits ) rhs ) nssv_noexcept -{ return lhs.compare( rhs ) >= 0; } - -template< class CharT, class Traits nssv_MSVC_ORDER(2) > -nssv_constexpr bool operator>= ( - nssv_BASIC_STRING_VIEW_I( CharT, Traits ) lhs, - basic_string_view < CharT, Traits > rhs ) nssv_noexcept -{ return lhs.compare( rhs ) >= 0; } - -#undef nssv_MSVC_ORDER -#undef nssv_BASIC_STRING_VIEW_I - -#endif // compiler-dependent approach to comparisons - -// 24.4.4 Inserters and extractors: - -#if ! nssv_CONFIG_NO_STREAM_INSERTION - -namespace detail { - -template< class Stream > -void write_padding( Stream & os, std::streamsize n ) -{ - for ( std::streamsize i = 0; i < n; ++i ) - os.rdbuf()->sputc( os.fill() ); -} - -template< class Stream, class View > -Stream & write_to_stream( Stream & os, View const & sv ) -{ - typename Stream::sentry sentry( os ); - - if ( !os ) - return os; - - const std::streamsize length = static_cast( sv.length() ); - - // Whether, and how, to pad: - const bool pad = ( length < os.width() ); - const bool left_pad = pad && ( os.flags() & std::ios_base::adjustfield ) == std::ios_base::right; - - if ( left_pad ) - write_padding( os, os.width() - length ); - - // Write span characters: - os.rdbuf()->sputn( sv.begin(), length ); - - if ( pad && !left_pad ) - write_padding( os, os.width() - length ); - - // Reset output stream width: - os.width( 0 ); - - return os; -} - -} // namespace detail - -template< class CharT, class Traits > -std::basic_ostream & -operator<<( - std::basic_ostream& os, - basic_string_view sv ) -{ - return detail::write_to_stream( os, sv ); -} - -#endif // nssv_CONFIG_NO_STREAM_INSERTION - -// Several typedefs for common character types are provided: - -typedef basic_string_view string_view; -typedef basic_string_view wstring_view; -#if nssv_HAVE_WCHAR16_T -typedef basic_string_view u16string_view; -typedef basic_string_view u32string_view; -#endif - -}} // namespace nonstd::sv_lite - -// -// 24.4.6 Suffix for basic_string_view literals: -// - -#if nssv_HAVE_USER_DEFINED_LITERALS - -namespace nonstd { -nssv_inline_ns namespace literals { -nssv_inline_ns namespace string_view_literals { - -#if nssv_CONFIG_STD_SV_OPERATOR && nssv_HAVE_STD_DEFINED_LITERALS - -nssv_constexpr nonstd::sv_lite::string_view operator "" sv( const char* str, size_t len ) nssv_noexcept // (1) -{ - return nonstd::sv_lite::string_view{ str, len }; -} - -nssv_constexpr nonstd::sv_lite::u16string_view operator "" sv( const char16_t* str, size_t len ) nssv_noexcept // (2) -{ - return nonstd::sv_lite::u16string_view{ str, len }; -} - -nssv_constexpr nonstd::sv_lite::u32string_view operator "" sv( const char32_t* str, size_t len ) nssv_noexcept // (3) -{ - return nonstd::sv_lite::u32string_view{ str, len }; -} - -nssv_constexpr nonstd::sv_lite::wstring_view operator "" sv( const wchar_t* str, size_t len ) nssv_noexcept // (4) -{ - return nonstd::sv_lite::wstring_view{ str, len }; -} - -#endif // nssv_CONFIG_STD_SV_OPERATOR && nssv_HAVE_STD_DEFINED_LITERALS - -#if nssv_CONFIG_USR_SV_OPERATOR - -nssv_constexpr nonstd::sv_lite::string_view operator "" _sv( const char* str, size_t len ) nssv_noexcept // (1) -{ - return nonstd::sv_lite::string_view{ str, len }; -} - -nssv_constexpr nonstd::sv_lite::u16string_view operator "" _sv( const char16_t* str, size_t len ) nssv_noexcept // (2) -{ - return nonstd::sv_lite::u16string_view{ str, len }; -} - -nssv_constexpr nonstd::sv_lite::u32string_view operator "" _sv( const char32_t* str, size_t len ) nssv_noexcept // (3) -{ - return nonstd::sv_lite::u32string_view{ str, len }; -} - -nssv_constexpr nonstd::sv_lite::wstring_view operator "" _sv( const wchar_t* str, size_t len ) nssv_noexcept // (4) -{ - return nonstd::sv_lite::wstring_view{ str, len }; -} - -#endif // nssv_CONFIG_USR_SV_OPERATOR - -}}} // namespace nonstd::literals::string_view_literals - -#endif - -// -// Extensions for std::string: -// - -#if nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS - -namespace nonstd { -namespace sv_lite { - -// Exclude MSVC 14 (19.00): it yields ambiguous to_string(): - -#if nssv_CPP11_OR_GREATER && nssv_COMPILER_MSVC_VERSION != 140 - -template< class CharT, class Traits, class Allocator = std::allocator > -std::basic_string -to_string( basic_string_view v, Allocator const & a = Allocator() ) -{ - return std::basic_string( v.begin(), v.end(), a ); -} - -#else - -template< class CharT, class Traits > -std::basic_string -to_string( basic_string_view v ) -{ - return std::basic_string( v.begin(), v.end() ); -} - -template< class CharT, class Traits, class Allocator > -std::basic_string -to_string( basic_string_view v, Allocator const & a ) -{ - return std::basic_string( v.begin(), v.end(), a ); -} - -#endif // nssv_CPP11_OR_GREATER - -template< class CharT, class Traits, class Allocator > -basic_string_view -to_string_view( std::basic_string const & s ) -{ - return basic_string_view( s.data(), s.size() ); -} - -}} // namespace nonstd::sv_lite - -#endif // nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS - -// -// make types and algorithms available in namespace nonstd: -// - -namespace nonstd { - -using sv_lite::basic_string_view; -using sv_lite::string_view; -using sv_lite::wstring_view; - -#if nssv_HAVE_WCHAR16_T -using sv_lite::u16string_view; -#endif -#if nssv_HAVE_WCHAR32_T -using sv_lite::u32string_view; -#endif - -// literal "sv" - -using sv_lite::operator==; -using sv_lite::operator!=; -using sv_lite::operator<; -using sv_lite::operator<=; -using sv_lite::operator>; -using sv_lite::operator>=; - -#if ! nssv_CONFIG_NO_STREAM_INSERTION -using sv_lite::operator<<; -#endif - -#if nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS -using sv_lite::to_string; -using sv_lite::to_string_view; -#endif - -} // namespace nonstd - -// 24.4.5 Hash support (C++11): - -// Note: The hash value of a string view object is equal to the hash value of -// the corresponding string object. - -#if nssv_HAVE_STD_HASH - -#include - -namespace std { - -template<> -struct hash< nonstd::string_view > -{ -public: - std::size_t operator()( nonstd::string_view v ) const nssv_noexcept - { - return std::hash()( std::string( v.data(), v.size() ) ); - } -}; - -template<> -struct hash< nonstd::wstring_view > -{ -public: - std::size_t operator()( nonstd::wstring_view v ) const nssv_noexcept - { - return std::hash()( std::wstring( v.data(), v.size() ) ); - } -}; - -template<> -struct hash< nonstd::u16string_view > -{ -public: - std::size_t operator()( nonstd::u16string_view v ) const nssv_noexcept - { - return std::hash()( std::u16string( v.data(), v.size() ) ); - } -}; - -template<> -struct hash< nonstd::u32string_view > -{ -public: - std::size_t operator()( nonstd::u32string_view v ) const nssv_noexcept - { - return std::hash()( std::u32string( v.data(), v.size() ) ); - } -}; - -} // namespace std - -#endif // nssv_HAVE_STD_HASH - -nssv_RESTORE_WARNINGS() - -#endif // nssv_HAVE_STD_STRING_VIEW -#endif // NONSTD_SV_LITE_H_INCLUDED +// Copyright 2017-2020 by Martin Moene +// +// string-view lite, a C++17-like string_view for C++98 and later. +// For more information see https://github.com/martinmoene/string-view-lite +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#pragma once + +#ifndef NONSTD_SV_LITE_H_INCLUDED +#define NONSTD_SV_LITE_H_INCLUDED + +#define string_view_lite_MAJOR 1 +#define string_view_lite_MINOR 6 +#define string_view_lite_PATCH 0 + +#define string_view_lite_VERSION nssv_STRINGIFY(string_view_lite_MAJOR) "." nssv_STRINGIFY(string_view_lite_MINOR) "." nssv_STRINGIFY(string_view_lite_PATCH) + +#define nssv_STRINGIFY( x ) nssv_STRINGIFY_( x ) +#define nssv_STRINGIFY_( x ) #x + +// string-view lite configuration: + +#define nssv_STRING_VIEW_DEFAULT 0 +#define nssv_STRING_VIEW_NONSTD 1 +#define nssv_STRING_VIEW_STD 2 + +// tweak header support: + +#ifdef __has_include +# if __has_include() +# include +# endif +#define nssv_HAVE_TWEAK_HEADER 1 +#else +#define nssv_HAVE_TWEAK_HEADER 0 +//# pragma message("string_view.hpp: Note: Tweak header not supported.") +#endif + +// string_view selection and configuration: + +#if !defined( nssv_CONFIG_SELECT_STRING_VIEW ) +# define nssv_CONFIG_SELECT_STRING_VIEW ( nssv_HAVE_STD_STRING_VIEW ? nssv_STRING_VIEW_STD : nssv_STRING_VIEW_NONSTD ) +#endif + +#ifndef nssv_CONFIG_STD_SV_OPERATOR +# define nssv_CONFIG_STD_SV_OPERATOR 0 +#endif + +#ifndef nssv_CONFIG_USR_SV_OPERATOR +# define nssv_CONFIG_USR_SV_OPERATOR 1 +#endif + +#ifdef nssv_CONFIG_CONVERSION_STD_STRING +# define nssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS nssv_CONFIG_CONVERSION_STD_STRING +# define nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS nssv_CONFIG_CONVERSION_STD_STRING +#endif + +#ifndef nssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS +# define nssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS 1 +#endif + +#ifndef nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS +# define nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS 1 +#endif + +#ifndef nssv_CONFIG_NO_STREAM_INSERTION +# define nssv_CONFIG_NO_STREAM_INSERTION 0 +#endif + +// Control presence of exception handling (try and auto discover): + +#ifndef nssv_CONFIG_NO_EXCEPTIONS +# if defined(_MSC_VER) +# include // for _HAS_EXCEPTIONS +# endif +# if defined(__cpp_exceptions) || defined(__EXCEPTIONS) || (_HAS_EXCEPTIONS) +# define nssv_CONFIG_NO_EXCEPTIONS 0 +# else +# define nssv_CONFIG_NO_EXCEPTIONS 1 +# endif +#endif + +// C++ language version detection (C++20 is speculative): +// Note: VC14.0/1900 (VS2015) lacks too much from C++14. + +#ifndef nssv_CPLUSPLUS +# if defined(_MSVC_LANG ) && !defined(__clang__) +# define nssv_CPLUSPLUS (_MSC_VER == 1900 ? 201103L : _MSVC_LANG ) +# else +# define nssv_CPLUSPLUS __cplusplus +# endif +#endif + +#define nssv_CPP98_OR_GREATER ( nssv_CPLUSPLUS >= 199711L ) +#define nssv_CPP11_OR_GREATER ( nssv_CPLUSPLUS >= 201103L ) +#define nssv_CPP11_OR_GREATER_ ( nssv_CPLUSPLUS >= 201103L ) +#define nssv_CPP14_OR_GREATER ( nssv_CPLUSPLUS >= 201402L ) +#define nssv_CPP17_OR_GREATER ( nssv_CPLUSPLUS >= 201703L ) +#define nssv_CPP20_OR_GREATER ( nssv_CPLUSPLUS >= 202000L ) + +// use C++17 std::string_view if available and requested: + +#if nssv_CPP17_OR_GREATER && defined(__has_include ) +# if __has_include( ) +# define nssv_HAVE_STD_STRING_VIEW 1 +# else +# define nssv_HAVE_STD_STRING_VIEW 0 +# endif +#else +# define nssv_HAVE_STD_STRING_VIEW 0 +#endif + +#define nssv_USES_STD_STRING_VIEW ( (nssv_CONFIG_SELECT_STRING_VIEW == nssv_STRING_VIEW_STD) || ((nssv_CONFIG_SELECT_STRING_VIEW == nssv_STRING_VIEW_DEFAULT) && nssv_HAVE_STD_STRING_VIEW) ) + +#define nssv_HAVE_STARTS_WITH ( nssv_CPP20_OR_GREATER || !nssv_USES_STD_STRING_VIEW ) +#define nssv_HAVE_ENDS_WITH nssv_HAVE_STARTS_WITH + +// +// Use C++17 std::string_view: +// + +#if nssv_USES_STD_STRING_VIEW + +#include + +// Extensions for std::string: + +#if nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS + +namespace nonstd { + +template< class CharT, class Traits, class Allocator = std::allocator > +std::basic_string +to_string( std::basic_string_view v, Allocator const & a = Allocator() ) +{ + return std::basic_string( v.begin(), v.end(), a ); +} + +template< class CharT, class Traits, class Allocator > +std::basic_string_view +to_string_view( std::basic_string const & s ) +{ + return std::basic_string_view( s.data(), s.size() ); +} + +// Literal operators sv and _sv: + +#if nssv_CONFIG_STD_SV_OPERATOR + +using namespace std::literals::string_view_literals; + +#endif + +#if nssv_CONFIG_USR_SV_OPERATOR + +inline namespace literals { +inline namespace string_view_literals { + + +constexpr std::string_view operator "" _sv( const char* str, size_t len ) noexcept // (1) +{ + return std::string_view{ str, len }; +} + +constexpr std::u16string_view operator "" _sv( const char16_t* str, size_t len ) noexcept // (2) +{ + return std::u16string_view{ str, len }; +} + +constexpr std::u32string_view operator "" _sv( const char32_t* str, size_t len ) noexcept // (3) +{ + return std::u32string_view{ str, len }; +} + +constexpr std::wstring_view operator "" _sv( const wchar_t* str, size_t len ) noexcept // (4) +{ + return std::wstring_view{ str, len }; +} + +}} // namespace literals::string_view_literals + +#endif // nssv_CONFIG_USR_SV_OPERATOR + +} // namespace nonstd + +#endif // nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS + +namespace nonstd { + +using std::string_view; +using std::wstring_view; +using std::u16string_view; +using std::u32string_view; +using std::basic_string_view; + +// literal "sv" and "_sv", see above + +using std::operator==; +using std::operator!=; +using std::operator<; +using std::operator<=; +using std::operator>; +using std::operator>=; + +using std::operator<<; + +} // namespace nonstd + +#else // nssv_HAVE_STD_STRING_VIEW + +// +// Before C++17: use string_view lite: +// + +// Compiler versions: +// +// MSVC++ 6.0 _MSC_VER == 1200 nssv_COMPILER_MSVC_VERSION == 60 (Visual Studio 6.0) +// MSVC++ 7.0 _MSC_VER == 1300 nssv_COMPILER_MSVC_VERSION == 70 (Visual Studio .NET 2002) +// MSVC++ 7.1 _MSC_VER == 1310 nssv_COMPILER_MSVC_VERSION == 71 (Visual Studio .NET 2003) +// MSVC++ 8.0 _MSC_VER == 1400 nssv_COMPILER_MSVC_VERSION == 80 (Visual Studio 2005) +// MSVC++ 9.0 _MSC_VER == 1500 nssv_COMPILER_MSVC_VERSION == 90 (Visual Studio 2008) +// MSVC++ 10.0 _MSC_VER == 1600 nssv_COMPILER_MSVC_VERSION == 100 (Visual Studio 2010) +// MSVC++ 11.0 _MSC_VER == 1700 nssv_COMPILER_MSVC_VERSION == 110 (Visual Studio 2012) +// MSVC++ 12.0 _MSC_VER == 1800 nssv_COMPILER_MSVC_VERSION == 120 (Visual Studio 2013) +// MSVC++ 14.0 _MSC_VER == 1900 nssv_COMPILER_MSVC_VERSION == 140 (Visual Studio 2015) +// MSVC++ 14.1 _MSC_VER >= 1910 nssv_COMPILER_MSVC_VERSION == 141 (Visual Studio 2017) +// MSVC++ 14.2 _MSC_VER >= 1920 nssv_COMPILER_MSVC_VERSION == 142 (Visual Studio 2019) + +#if defined(_MSC_VER ) && !defined(__clang__) +# define nssv_COMPILER_MSVC_VER (_MSC_VER ) +# define nssv_COMPILER_MSVC_VERSION (_MSC_VER / 10 - 10 * ( 5 + (_MSC_VER < 1900 ) ) ) +#else +# define nssv_COMPILER_MSVC_VER 0 +# define nssv_COMPILER_MSVC_VERSION 0 +#endif + +#define nssv_COMPILER_VERSION( major, minor, patch ) ( 10 * ( 10 * (major) + (minor) ) + (patch) ) + +#if defined( __apple_build_version__ ) +# define nssv_COMPILER_APPLECLANG_VERSION nssv_COMPILER_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__) +# define nssv_COMPILER_CLANG_VERSION 0 +#elif defined( __clang__ ) +# define nssv_COMPILER_APPLECLANG_VERSION 0 +# define nssv_COMPILER_CLANG_VERSION nssv_COMPILER_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__) +#else +# define nssv_COMPILER_APPLECLANG_VERSION 0 +# define nssv_COMPILER_CLANG_VERSION 0 +#endif + +#if defined(__GNUC__) && !defined(__clang__) +# define nssv_COMPILER_GNUC_VERSION nssv_COMPILER_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) +#else +# define nssv_COMPILER_GNUC_VERSION 0 +#endif + +// half-open range [lo..hi): +#define nssv_BETWEEN( v, lo, hi ) ( (lo) <= (v) && (v) < (hi) ) + +// Presence of language and library features: + +#ifdef _HAS_CPP0X +# define nssv_HAS_CPP0X _HAS_CPP0X +#else +# define nssv_HAS_CPP0X 0 +#endif + +// Unless defined otherwise below, consider VC14 as C++11 for variant-lite: + +#if nssv_COMPILER_MSVC_VER >= 1900 +# undef nssv_CPP11_OR_GREATER +# define nssv_CPP11_OR_GREATER 1 +#endif + +#define nssv_CPP11_90 (nssv_CPP11_OR_GREATER_ || nssv_COMPILER_MSVC_VER >= 1500) +#define nssv_CPP11_100 (nssv_CPP11_OR_GREATER_ || nssv_COMPILER_MSVC_VER >= 1600) +#define nssv_CPP11_110 (nssv_CPP11_OR_GREATER_ || nssv_COMPILER_MSVC_VER >= 1700) +#define nssv_CPP11_120 (nssv_CPP11_OR_GREATER_ || nssv_COMPILER_MSVC_VER >= 1800) +#define nssv_CPP11_140 (nssv_CPP11_OR_GREATER_ || nssv_COMPILER_MSVC_VER >= 1900) +#define nssv_CPP11_141 (nssv_CPP11_OR_GREATER_ || nssv_COMPILER_MSVC_VER >= 1910) + +#define nssv_CPP14_000 (nssv_CPP14_OR_GREATER) +#define nssv_CPP17_000 (nssv_CPP17_OR_GREATER) + +// Presence of C++11 language features: + +#define nssv_HAVE_CONSTEXPR_11 nssv_CPP11_140 +#define nssv_HAVE_EXPLICIT_CONVERSION nssv_CPP11_140 +#define nssv_HAVE_INLINE_NAMESPACE nssv_CPP11_140 +#define nssv_HAVE_NOEXCEPT nssv_CPP11_140 +#define nssv_HAVE_NULLPTR nssv_CPP11_100 +#define nssv_HAVE_REF_QUALIFIER nssv_CPP11_140 +#define nssv_HAVE_UNICODE_LITERALS nssv_CPP11_140 +#define nssv_HAVE_USER_DEFINED_LITERALS nssv_CPP11_140 +#define nssv_HAVE_WCHAR16_T nssv_CPP11_100 +#define nssv_HAVE_WCHAR32_T nssv_CPP11_100 + +#if ! ( ( nssv_CPP11_OR_GREATER && nssv_COMPILER_CLANG_VERSION ) || nssv_BETWEEN( nssv_COMPILER_CLANG_VERSION, 300, 400 ) ) +# define nssv_HAVE_STD_DEFINED_LITERALS nssv_CPP11_140 +#else +# define nssv_HAVE_STD_DEFINED_LITERALS 0 +#endif + +// Presence of C++14 language features: + +#define nssv_HAVE_CONSTEXPR_14 nssv_CPP14_000 + +// Presence of C++17 language features: + +#define nssv_HAVE_NODISCARD nssv_CPP17_000 + +// Presence of C++ library features: + +#define nssv_HAVE_STD_HASH nssv_CPP11_120 + +// Presence of compiler intrinsics: + +// Providing char-type specializations for compare() and length() that +// use compiler intrinsics can improve compile- and run-time performance. +// +// The challenge is in using the right combinations of builtin availability +// and its constexpr-ness. +// +// | compiler | __builtin_memcmp (constexpr) | memcmp (constexpr) | +// |----------|------------------------------|---------------------| +// | clang | 4.0 (>= 4.0 ) | any (? ) | +// | clang-a | 9.0 (>= 9.0 ) | any (? ) | +// | gcc | any (constexpr) | any (? ) | +// | msvc | >= 14.2 C++17 (>= 14.2 ) | any (? ) | + +#define nssv_HAVE_BUILTIN_VER ( (nssv_CPP17_000 && nssv_COMPILER_MSVC_VERSION >= 142) || nssv_COMPILER_GNUC_VERSION > 0 || nssv_COMPILER_CLANG_VERSION >= 400 || nssv_COMPILER_APPLECLANG_VERSION >= 900 ) +#define nssv_HAVE_BUILTIN_CE ( nssv_HAVE_BUILTIN_VER ) + +#define nssv_HAVE_BUILTIN_MEMCMP ( (nssv_HAVE_CONSTEXPR_14 && nssv_HAVE_BUILTIN_CE) || !nssv_HAVE_CONSTEXPR_14 ) +#define nssv_HAVE_BUILTIN_STRLEN ( (nssv_HAVE_CONSTEXPR_11 && nssv_HAVE_BUILTIN_CE) || !nssv_HAVE_CONSTEXPR_11 ) + +#ifdef __has_builtin +# define nssv_HAVE_BUILTIN( x ) __has_builtin( x ) +#else +# define nssv_HAVE_BUILTIN( x ) 0 +#endif + +#if nssv_HAVE_BUILTIN(__builtin_memcmp) || nssv_HAVE_BUILTIN_VER +# define nssv_BUILTIN_MEMCMP __builtin_memcmp +#else +# define nssv_BUILTIN_MEMCMP memcmp +#endif + +#if nssv_HAVE_BUILTIN(__builtin_strlen) || nssv_HAVE_BUILTIN_VER +# define nssv_BUILTIN_STRLEN __builtin_strlen +#else +# define nssv_BUILTIN_STRLEN strlen +#endif + +// C++ feature usage: + +#if nssv_HAVE_CONSTEXPR_11 +# define nssv_constexpr constexpr +#else +# define nssv_constexpr /*constexpr*/ +#endif + +#if nssv_HAVE_CONSTEXPR_14 +# define nssv_constexpr14 constexpr +#else +# define nssv_constexpr14 /*constexpr*/ +#endif + +#if nssv_HAVE_EXPLICIT_CONVERSION +# define nssv_explicit explicit +#else +# define nssv_explicit /*explicit*/ +#endif + +#if nssv_HAVE_INLINE_NAMESPACE +# define nssv_inline_ns inline +#else +# define nssv_inline_ns /*inline*/ +#endif + +#if nssv_HAVE_NOEXCEPT +# define nssv_noexcept noexcept +#else +# define nssv_noexcept /*noexcept*/ +#endif + +//#if nssv_HAVE_REF_QUALIFIER +//# define nssv_ref_qual & +//# define nssv_refref_qual && +//#else +//# define nssv_ref_qual /*&*/ +//# define nssv_refref_qual /*&&*/ +//#endif + +#if nssv_HAVE_NULLPTR +# define nssv_nullptr nullptr +#else +# define nssv_nullptr NULL +#endif + +#if nssv_HAVE_NODISCARD +# define nssv_nodiscard [[nodiscard]] +#else +# define nssv_nodiscard /*[[nodiscard]]*/ +#endif + +// Additional includes: + +#include +#include +#include +#include +#include // std::char_traits<> + +#if ! nssv_CONFIG_NO_STREAM_INSERTION +# include +#endif + +#if ! nssv_CONFIG_NO_EXCEPTIONS +# include +#endif + +#if nssv_CPP11_OR_GREATER +# include +#endif + +// Clang, GNUC, MSVC warning suppression macros: + +#if defined(__clang__) +# pragma clang diagnostic ignored "-Wreserved-user-defined-literal" +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wuser-defined-literals" +#elif defined(__GNUC__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wliteral-suffix" +#endif // __clang__ + +#if nssv_COMPILER_MSVC_VERSION >= 140 +# define nssv_SUPPRESS_MSGSL_WARNING(expr) [[gsl::suppress(expr)]] +# define nssv_SUPPRESS_MSVC_WARNING(code, descr) __pragma(warning(suppress: code) ) +# define nssv_DISABLE_MSVC_WARNINGS(codes) __pragma(warning(push)) __pragma(warning(disable: codes)) +#else +# define nssv_SUPPRESS_MSGSL_WARNING(expr) +# define nssv_SUPPRESS_MSVC_WARNING(code, descr) +# define nssv_DISABLE_MSVC_WARNINGS(codes) +#endif + +#if defined(__clang__) +# define nssv_RESTORE_WARNINGS() _Pragma("clang diagnostic pop") +#elif defined(__GNUC__) +# define nssv_RESTORE_WARNINGS() _Pragma("GCC diagnostic pop") +#elif nssv_COMPILER_MSVC_VERSION >= 140 +# define nssv_RESTORE_WARNINGS() __pragma(warning(pop )) +#else +# define nssv_RESTORE_WARNINGS() +#endif + +// Suppress the following MSVC (GSL) warnings: +// - C4455, non-gsl : 'operator ""sv': literal suffix identifiers that do not +// start with an underscore are reserved +// - C26472, gsl::t.1 : don't use a static_cast for arithmetic conversions; +// use brace initialization, gsl::narrow_cast or gsl::narow +// - C26481: gsl::b.1 : don't use pointer arithmetic. Use span instead + +nssv_DISABLE_MSVC_WARNINGS( 4455 26481 26472 ) +//nssv_DISABLE_CLANG_WARNINGS( "-Wuser-defined-literals" ) +//nssv_DISABLE_GNUC_WARNINGS( -Wliteral-suffix ) + +namespace nonstd { namespace sv_lite { + +namespace detail { + +// support constexpr comparison in C++14; +// for C++17 and later, use provided traits: + +template< typename CharT > +inline nssv_constexpr14 int compare( CharT const * s1, CharT const * s2, std::size_t count ) +{ + while ( count-- != 0 ) + { + if ( *s1 < *s2 ) return -1; + if ( *s1 > *s2 ) return +1; + ++s1; ++s2; + } + return 0; +} + +#if nssv_HAVE_BUILTIN_MEMCMP + +// specialization of compare() for char, see also generic compare() above: + +inline nssv_constexpr14 int compare( char const * s1, char const * s2, std::size_t count ) +{ + return nssv_BUILTIN_MEMCMP( s1, s2, count ); +} + +#endif + +#if nssv_HAVE_BUILTIN_STRLEN + +// specialization of length() for char, see also generic length() further below: + +inline nssv_constexpr std::size_t length( char const * s ) +{ + return nssv_BUILTIN_STRLEN( s ); +} + +#endif + +#if defined(__OPTIMIZE__) + +// gcc, clang provide __OPTIMIZE__ +// Expect tail call optimization to make length() non-recursive: + +template< typename CharT > +inline nssv_constexpr std::size_t length( CharT * s, std::size_t result = 0 ) +{ + return *s == '\0' ? result : length( s + 1, result + 1 ); +} + +#else // OPTIMIZE + +// non-recursive: + +template< typename CharT > +inline nssv_constexpr14 std::size_t length( CharT * s ) +{ + std::size_t result = 0; + while ( *s++ != '\0' ) + { + ++result; + } + return result; +} + +#endif // OPTIMIZE + +} // namespace detail + +template +< + class CharT, + class Traits = std::char_traits +> +class basic_string_view; + +// +// basic_string_view: +// + +template +< + class CharT, + class Traits /* = std::char_traits */ +> +class basic_string_view +{ +public: + // Member types: + + typedef Traits traits_type; + typedef CharT value_type; + + typedef CharT * pointer; + typedef CharT const * const_pointer; + typedef CharT & reference; + typedef CharT const & const_reference; + + typedef const_pointer iterator; + typedef const_pointer const_iterator; + typedef std::reverse_iterator< const_iterator > reverse_iterator; + typedef std::reverse_iterator< const_iterator > const_reverse_iterator; + + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + + // 24.4.2.1 Construction and assignment: + + nssv_constexpr basic_string_view() nssv_noexcept + : data_( nssv_nullptr ) + , size_( 0 ) + {} + +#if nssv_CPP11_OR_GREATER + nssv_constexpr basic_string_view( basic_string_view const & other ) nssv_noexcept = default; +#else + nssv_constexpr basic_string_view( basic_string_view const & other ) nssv_noexcept + : data_( other.data_) + , size_( other.size_) + {} +#endif + + nssv_constexpr basic_string_view( CharT const * s, size_type count ) nssv_noexcept // non-standard noexcept + : data_( s ) + , size_( count ) + {} + + nssv_constexpr basic_string_view( CharT const * s) nssv_noexcept // non-standard noexcept + : data_( s ) +#if nssv_CPP17_OR_GREATER + , size_( Traits::length(s) ) +#elif nssv_CPP11_OR_GREATER + , size_( detail::length(s) ) +#else + , size_( Traits::length(s) ) +#endif + {} + + // Assignment: + +#if nssv_CPP11_OR_GREATER + nssv_constexpr14 basic_string_view & operator=( basic_string_view const & other ) nssv_noexcept = default; +#else + nssv_constexpr14 basic_string_view & operator=( basic_string_view const & other ) nssv_noexcept + { + data_ = other.data_; + size_ = other.size_; + return *this; + } +#endif + + // 24.4.2.2 Iterator support: + + nssv_constexpr const_iterator begin() const nssv_noexcept { return data_; } + nssv_constexpr const_iterator end() const nssv_noexcept { return data_ + size_; } + + nssv_constexpr const_iterator cbegin() const nssv_noexcept { return begin(); } + nssv_constexpr const_iterator cend() const nssv_noexcept { return end(); } + + nssv_constexpr const_reverse_iterator rbegin() const nssv_noexcept { return const_reverse_iterator( end() ); } + nssv_constexpr const_reverse_iterator rend() const nssv_noexcept { return const_reverse_iterator( begin() ); } + + nssv_constexpr const_reverse_iterator crbegin() const nssv_noexcept { return rbegin(); } + nssv_constexpr const_reverse_iterator crend() const nssv_noexcept { return rend(); } + + // 24.4.2.3 Capacity: + + nssv_constexpr size_type size() const nssv_noexcept { return size_; } + nssv_constexpr size_type length() const nssv_noexcept { return size_; } + nssv_constexpr size_type max_size() const nssv_noexcept { return (std::numeric_limits< size_type >::max)(); } + + // since C++20 + nssv_nodiscard nssv_constexpr bool empty() const nssv_noexcept + { + return 0 == size_; + } + + // 24.4.2.4 Element access: + + nssv_constexpr const_reference operator[]( size_type pos ) const + { + return data_at( pos ); + } + + nssv_constexpr14 const_reference at( size_type pos ) const + { +#if nssv_CONFIG_NO_EXCEPTIONS + assert( pos < size() ); +#else + if ( pos >= size() ) + { + throw std::out_of_range("nonstd::string_view::at()"); + } +#endif + return data_at( pos ); + } + + nssv_constexpr const_reference front() const { return data_at( 0 ); } + nssv_constexpr const_reference back() const { return data_at( size() - 1 ); } + + nssv_constexpr const_pointer data() const nssv_noexcept { return data_; } + + // 24.4.2.5 Modifiers: + + nssv_constexpr14 void remove_prefix( size_type n ) + { + assert( n <= size() ); + data_ += n; + size_ -= n; + } + + nssv_constexpr14 void remove_suffix( size_type n ) + { + assert( n <= size() ); + size_ -= n; + } + + nssv_constexpr14 void swap( basic_string_view & other ) nssv_noexcept + { + const basic_string_view tmp(other); + other = *this; + *this = tmp; + } + + // 24.4.2.6 String operations: + + size_type copy( CharT * dest, size_type n, size_type pos = 0 ) const + { +#if nssv_CONFIG_NO_EXCEPTIONS + assert( pos <= size() ); +#else + if ( pos > size() ) + { + throw std::out_of_range("nonstd::string_view::copy()"); + } +#endif + const size_type rlen = (std::min)( n, size() - pos ); + + (void) Traits::copy( dest, data() + pos, rlen ); + + return rlen; + } + + nssv_constexpr14 basic_string_view substr( size_type pos = 0, size_type n = npos ) const + { +#if nssv_CONFIG_NO_EXCEPTIONS + assert( pos <= size() ); +#else + if ( pos > size() ) + { + throw std::out_of_range("nonstd::string_view::substr()"); + } +#endif + return basic_string_view( data() + pos, (std::min)( n, size() - pos ) ); + } + + // compare(), 6x: + + nssv_constexpr14 int compare( basic_string_view other ) const nssv_noexcept // (1) + { +#if nssv_CPP17_OR_GREATER + if ( const int result = Traits::compare( data(), other.data(), (std::min)( size(), other.size() ) ) ) +#else + if ( const int result = detail::compare( data(), other.data(), (std::min)( size(), other.size() ) ) ) +#endif + { + return result; + } + + return size() == other.size() ? 0 : size() < other.size() ? -1 : 1; + } + + nssv_constexpr int compare( size_type pos1, size_type n1, basic_string_view other ) const // (2) + { + return substr( pos1, n1 ).compare( other ); + } + + nssv_constexpr int compare( size_type pos1, size_type n1, basic_string_view other, size_type pos2, size_type n2 ) const // (3) + { + return substr( pos1, n1 ).compare( other.substr( pos2, n2 ) ); + } + + nssv_constexpr int compare( CharT const * s ) const // (4) + { + return compare( basic_string_view( s ) ); + } + + nssv_constexpr int compare( size_type pos1, size_type n1, CharT const * s ) const // (5) + { + return substr( pos1, n1 ).compare( basic_string_view( s ) ); + } + + nssv_constexpr int compare( size_type pos1, size_type n1, CharT const * s, size_type n2 ) const // (6) + { + return substr( pos1, n1 ).compare( basic_string_view( s, n2 ) ); + } + + // 24.4.2.7 Searching: + + // starts_with(), 3x, since C++20: + + nssv_constexpr bool starts_with( basic_string_view v ) const nssv_noexcept // (1) + { + return size() >= v.size() && compare( 0, v.size(), v ) == 0; + } + + nssv_constexpr bool starts_with( CharT c ) const nssv_noexcept // (2) + { + return starts_with( basic_string_view( &c, 1 ) ); + } + + nssv_constexpr bool starts_with( CharT const * s ) const // (3) + { + return starts_with( basic_string_view( s ) ); + } + + // ends_with(), 3x, since C++20: + + nssv_constexpr bool ends_with( basic_string_view v ) const nssv_noexcept // (1) + { + return size() >= v.size() && compare( size() - v.size(), npos, v ) == 0; + } + + nssv_constexpr bool ends_with( CharT c ) const nssv_noexcept // (2) + { + return ends_with( basic_string_view( &c, 1 ) ); + } + + nssv_constexpr bool ends_with( CharT const * s ) const // (3) + { + return ends_with( basic_string_view( s ) ); + } + + // find(), 4x: + + nssv_constexpr14 size_type find( basic_string_view v, size_type pos = 0 ) const nssv_noexcept // (1) + { + return assert( v.size() == 0 || v.data() != nssv_nullptr ) + , pos >= size() + ? npos + : to_pos( std::search( cbegin() + pos, cend(), v.cbegin(), v.cend(), Traits::eq ) ); + } + + nssv_constexpr14 size_type find( CharT c, size_type pos = 0 ) const nssv_noexcept // (2) + { + return find( basic_string_view( &c, 1 ), pos ); + } + + nssv_constexpr14 size_type find( CharT const * s, size_type pos, size_type n ) const // (3) + { + return find( basic_string_view( s, n ), pos ); + } + + nssv_constexpr14 size_type find( CharT const * s, size_type pos = 0 ) const // (4) + { + return find( basic_string_view( s ), pos ); + } + + // rfind(), 4x: + + nssv_constexpr14 size_type rfind( basic_string_view v, size_type pos = npos ) const nssv_noexcept // (1) + { + if ( size() < v.size() ) + { + return npos; + } + + if ( v.empty() ) + { + return (std::min)( size(), pos ); + } + + const_iterator last = cbegin() + (std::min)( size() - v.size(), pos ) + v.size(); + const_iterator result = std::find_end( cbegin(), last, v.cbegin(), v.cend(), Traits::eq ); + + return result != last ? size_type( result - cbegin() ) : npos; + } + + nssv_constexpr14 size_type rfind( CharT c, size_type pos = npos ) const nssv_noexcept // (2) + { + return rfind( basic_string_view( &c, 1 ), pos ); + } + + nssv_constexpr14 size_type rfind( CharT const * s, size_type pos, size_type n ) const // (3) + { + return rfind( basic_string_view( s, n ), pos ); + } + + nssv_constexpr14 size_type rfind( CharT const * s, size_type pos = npos ) const // (4) + { + return rfind( basic_string_view( s ), pos ); + } + + // find_first_of(), 4x: + + nssv_constexpr size_type find_first_of( basic_string_view v, size_type pos = 0 ) const nssv_noexcept // (1) + { + return pos >= size() + ? npos + : to_pos( std::find_first_of( cbegin() + pos, cend(), v.cbegin(), v.cend(), Traits::eq ) ); + } + + nssv_constexpr size_type find_first_of( CharT c, size_type pos = 0 ) const nssv_noexcept // (2) + { + return find_first_of( basic_string_view( &c, 1 ), pos ); + } + + nssv_constexpr size_type find_first_of( CharT const * s, size_type pos, size_type n ) const // (3) + { + return find_first_of( basic_string_view( s, n ), pos ); + } + + nssv_constexpr size_type find_first_of( CharT const * s, size_type pos = 0 ) const // (4) + { + return find_first_of( basic_string_view( s ), pos ); + } + + // find_last_of(), 4x: + + nssv_constexpr size_type find_last_of( basic_string_view v, size_type pos = npos ) const nssv_noexcept // (1) + { + return empty() + ? npos + : pos >= size() + ? find_last_of( v, size() - 1 ) + : to_pos( std::find_first_of( const_reverse_iterator( cbegin() + pos + 1 ), crend(), v.cbegin(), v.cend(), Traits::eq ) ); + } + + nssv_constexpr size_type find_last_of( CharT c, size_type pos = npos ) const nssv_noexcept // (2) + { + return find_last_of( basic_string_view( &c, 1 ), pos ); + } + + nssv_constexpr size_type find_last_of( CharT const * s, size_type pos, size_type count ) const // (3) + { + return find_last_of( basic_string_view( s, count ), pos ); + } + + nssv_constexpr size_type find_last_of( CharT const * s, size_type pos = npos ) const // (4) + { + return find_last_of( basic_string_view( s ), pos ); + } + + // find_first_not_of(), 4x: + + nssv_constexpr size_type find_first_not_of( basic_string_view v, size_type pos = 0 ) const nssv_noexcept // (1) + { + return pos >= size() + ? npos + : to_pos( std::find_if( cbegin() + pos, cend(), not_in_view( v ) ) ); + } + + nssv_constexpr size_type find_first_not_of( CharT c, size_type pos = 0 ) const nssv_noexcept // (2) + { + return find_first_not_of( basic_string_view( &c, 1 ), pos ); + } + + nssv_constexpr size_type find_first_not_of( CharT const * s, size_type pos, size_type count ) const // (3) + { + return find_first_not_of( basic_string_view( s, count ), pos ); + } + + nssv_constexpr size_type find_first_not_of( CharT const * s, size_type pos = 0 ) const // (4) + { + return find_first_not_of( basic_string_view( s ), pos ); + } + + // find_last_not_of(), 4x: + + nssv_constexpr size_type find_last_not_of( basic_string_view v, size_type pos = npos ) const nssv_noexcept // (1) + { + return empty() + ? npos + : pos >= size() + ? find_last_not_of( v, size() - 1 ) + : to_pos( std::find_if( const_reverse_iterator( cbegin() + pos + 1 ), crend(), not_in_view( v ) ) ); + } + + nssv_constexpr size_type find_last_not_of( CharT c, size_type pos = npos ) const nssv_noexcept // (2) + { + return find_last_not_of( basic_string_view( &c, 1 ), pos ); + } + + nssv_constexpr size_type find_last_not_of( CharT const * s, size_type pos, size_type count ) const // (3) + { + return find_last_not_of( basic_string_view( s, count ), pos ); + } + + nssv_constexpr size_type find_last_not_of( CharT const * s, size_type pos = npos ) const // (4) + { + return find_last_not_of( basic_string_view( s ), pos ); + } + + // Constants: + +#if nssv_CPP17_OR_GREATER + static nssv_constexpr size_type npos = size_type(-1); +#elif nssv_CPP11_OR_GREATER + enum : size_type { npos = size_type(-1) }; +#else + enum { npos = size_type(-1) }; +#endif + +private: + struct not_in_view + { + const basic_string_view v; + + nssv_constexpr explicit not_in_view( basic_string_view v_ ) : v( v_ ) {} + + nssv_constexpr bool operator()( CharT c ) const + { + return npos == v.find_first_of( c ); + } + }; + + nssv_constexpr size_type to_pos( const_iterator it ) const + { + return it == cend() ? npos : size_type( it - cbegin() ); + } + + nssv_constexpr size_type to_pos( const_reverse_iterator it ) const + { + return it == crend() ? npos : size_type( crend() - it - 1 ); + } + + nssv_constexpr const_reference data_at( size_type pos ) const + { +#if nssv_BETWEEN( nssv_COMPILER_GNUC_VERSION, 1, 500 ) + return data_[pos]; +#else + return assert( pos < size() ), data_[pos]; +#endif + } + +private: + const_pointer data_; + size_type size_; + +public: +#if nssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS + + template< class Allocator > + basic_string_view( std::basic_string const & s ) nssv_noexcept + : data_( s.data() ) + , size_( s.size() ) + {} + +#if nssv_HAVE_EXPLICIT_CONVERSION + + template< class Allocator > + explicit operator std::basic_string() const + { + return to_string( Allocator() ); + } + +#endif // nssv_HAVE_EXPLICIT_CONVERSION + +#if nssv_CPP11_OR_GREATER + + template< class Allocator = std::allocator > + std::basic_string + to_string( Allocator const & a = Allocator() ) const + { + return std::basic_string( begin(), end(), a ); + } + +#else + + std::basic_string + to_string() const + { + return std::basic_string( begin(), end() ); + } + + template< class Allocator > + std::basic_string + to_string( Allocator const & a ) const + { + return std::basic_string( begin(), end(), a ); + } + +#endif // nssv_CPP11_OR_GREATER + +#endif // nssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS +}; + +// +// Non-member functions: +// + +// 24.4.3 Non-member comparison functions: +// lexicographically compare two string views (function template): + +template< class CharT, class Traits > +nssv_constexpr bool operator== ( + basic_string_view lhs, + basic_string_view rhs ) nssv_noexcept +{ return lhs.size() == rhs.size() && lhs.compare( rhs ) == 0; } + +template< class CharT, class Traits > +nssv_constexpr bool operator!= ( + basic_string_view lhs, + basic_string_view rhs ) nssv_noexcept +{ return !( lhs == rhs ); } + +template< class CharT, class Traits > +nssv_constexpr bool operator< ( + basic_string_view lhs, + basic_string_view rhs ) nssv_noexcept +{ return lhs.compare( rhs ) < 0; } + +template< class CharT, class Traits > +nssv_constexpr bool operator<= ( + basic_string_view lhs, + basic_string_view rhs ) nssv_noexcept +{ return lhs.compare( rhs ) <= 0; } + +template< class CharT, class Traits > +nssv_constexpr bool operator> ( + basic_string_view lhs, + basic_string_view rhs ) nssv_noexcept +{ return lhs.compare( rhs ) > 0; } + +template< class CharT, class Traits > +nssv_constexpr bool operator>= ( + basic_string_view lhs, + basic_string_view rhs ) nssv_noexcept +{ return lhs.compare( rhs ) >= 0; } + +// Let S be basic_string_view, and sv be an instance of S. +// Implementations shall provide sufficient additional overloads marked +// constexpr and noexcept so that an object t with an implicit conversion +// to S can be compared according to Table 67. + +#if ! nssv_CPP11_OR_GREATER || nssv_BETWEEN( nssv_COMPILER_MSVC_VERSION, 100, 141 ) + +// accommodate for older compilers: + +// == + +template< class CharT, class Traits> +nssv_constexpr bool operator==( + basic_string_view lhs, + CharT const * rhs ) nssv_noexcept +{ return lhs.size() == detail::length( rhs ) && lhs.compare( rhs ) == 0; } + +template< class CharT, class Traits> +nssv_constexpr bool operator==( + CharT const * lhs, + basic_string_view rhs ) nssv_noexcept +{ return detail::length( lhs ) == rhs.size() && rhs.compare( lhs ) == 0; } + +template< class CharT, class Traits> +nssv_constexpr bool operator==( + basic_string_view lhs, + std::basic_string rhs ) nssv_noexcept +{ return lhs.size() == rhs.size() && lhs.compare( rhs ) == 0; } + +template< class CharT, class Traits> +nssv_constexpr bool operator==( + std::basic_string rhs, + basic_string_view lhs ) nssv_noexcept +{ return lhs.size() == rhs.size() && lhs.compare( rhs ) == 0; } + +// != + +template< class CharT, class Traits> +nssv_constexpr bool operator!=( + basic_string_view lhs, + CharT const * rhs ) nssv_noexcept +{ return !( lhs == rhs ); } + +template< class CharT, class Traits> +nssv_constexpr bool operator!=( + CharT const * lhs, + basic_string_view rhs ) nssv_noexcept +{ return !( lhs == rhs ); } + +template< class CharT, class Traits> +nssv_constexpr bool operator!=( + basic_string_view lhs, + std::basic_string rhs ) nssv_noexcept +{ return !( lhs == rhs ); } + +template< class CharT, class Traits> +nssv_constexpr bool operator!=( + std::basic_string rhs, + basic_string_view lhs ) nssv_noexcept +{ return !( lhs == rhs ); } + +// < + +template< class CharT, class Traits> +nssv_constexpr bool operator<( + basic_string_view lhs, + CharT const * rhs ) nssv_noexcept +{ return lhs.compare( rhs ) < 0; } + +template< class CharT, class Traits> +nssv_constexpr bool operator<( + CharT const * lhs, + basic_string_view rhs ) nssv_noexcept +{ return rhs.compare( lhs ) > 0; } + +template< class CharT, class Traits> +nssv_constexpr bool operator<( + basic_string_view lhs, + std::basic_string rhs ) nssv_noexcept +{ return lhs.compare( rhs ) < 0; } + +template< class CharT, class Traits> +nssv_constexpr bool operator<( + std::basic_string rhs, + basic_string_view lhs ) nssv_noexcept +{ return rhs.compare( lhs ) > 0; } + +// <= + +template< class CharT, class Traits> +nssv_constexpr bool operator<=( + basic_string_view lhs, + CharT const * rhs ) nssv_noexcept +{ return lhs.compare( rhs ) <= 0; } + +template< class CharT, class Traits> +nssv_constexpr bool operator<=( + CharT const * lhs, + basic_string_view rhs ) nssv_noexcept +{ return rhs.compare( lhs ) >= 0; } + +template< class CharT, class Traits> +nssv_constexpr bool operator<=( + basic_string_view lhs, + std::basic_string rhs ) nssv_noexcept +{ return lhs.compare( rhs ) <= 0; } + +template< class CharT, class Traits> +nssv_constexpr bool operator<=( + std::basic_string rhs, + basic_string_view lhs ) nssv_noexcept +{ return rhs.compare( lhs ) >= 0; } + +// > + +template< class CharT, class Traits> +nssv_constexpr bool operator>( + basic_string_view lhs, + CharT const * rhs ) nssv_noexcept +{ return lhs.compare( rhs ) > 0; } + +template< class CharT, class Traits> +nssv_constexpr bool operator>( + CharT const * lhs, + basic_string_view rhs ) nssv_noexcept +{ return rhs.compare( lhs ) < 0; } + +template< class CharT, class Traits> +nssv_constexpr bool operator>( + basic_string_view lhs, + std::basic_string rhs ) nssv_noexcept +{ return lhs.compare( rhs ) > 0; } + +template< class CharT, class Traits> +nssv_constexpr bool operator>( + std::basic_string rhs, + basic_string_view lhs ) nssv_noexcept +{ return rhs.compare( lhs ) < 0; } + +// >= + +template< class CharT, class Traits> +nssv_constexpr bool operator>=( + basic_string_view lhs, + CharT const * rhs ) nssv_noexcept +{ return lhs.compare( rhs ) >= 0; } + +template< class CharT, class Traits> +nssv_constexpr bool operator>=( + CharT const * lhs, + basic_string_view rhs ) nssv_noexcept +{ return rhs.compare( lhs ) <= 0; } + +template< class CharT, class Traits> +nssv_constexpr bool operator>=( + basic_string_view lhs, + std::basic_string rhs ) nssv_noexcept +{ return lhs.compare( rhs ) >= 0; } + +template< class CharT, class Traits> +nssv_constexpr bool operator>=( + std::basic_string rhs, + basic_string_view lhs ) nssv_noexcept +{ return rhs.compare( lhs ) <= 0; } + +#else // newer compilers: + +#define nssv_BASIC_STRING_VIEW_I(T,U) typename std::decay< basic_string_view >::type + +#if defined(_MSC_VER) // issue 40 +# define nssv_MSVC_ORDER(x) , int=x +#else +# define nssv_MSVC_ORDER(x) /*, int=x*/ +#endif + +// == + +template< class CharT, class Traits nssv_MSVC_ORDER(1) > +nssv_constexpr bool operator==( + basic_string_view lhs, + nssv_BASIC_STRING_VIEW_I(CharT, Traits) rhs ) nssv_noexcept +{ return lhs.size() == rhs.size() && lhs.compare( rhs ) == 0; } + +template< class CharT, class Traits nssv_MSVC_ORDER(2) > +nssv_constexpr bool operator==( + nssv_BASIC_STRING_VIEW_I(CharT, Traits) lhs, + basic_string_view rhs ) nssv_noexcept +{ return lhs.size() == rhs.size() && lhs.compare( rhs ) == 0; } + +// != + +template< class CharT, class Traits nssv_MSVC_ORDER(1) > +nssv_constexpr bool operator!= ( + basic_string_view < CharT, Traits > lhs, + nssv_BASIC_STRING_VIEW_I( CharT, Traits ) rhs ) nssv_noexcept +{ return !( lhs == rhs ); } + +template< class CharT, class Traits nssv_MSVC_ORDER(2) > +nssv_constexpr bool operator!= ( + nssv_BASIC_STRING_VIEW_I( CharT, Traits ) lhs, + basic_string_view < CharT, Traits > rhs ) nssv_noexcept +{ return !( lhs == rhs ); } + +// < + +template< class CharT, class Traits nssv_MSVC_ORDER(1) > +nssv_constexpr bool operator< ( + basic_string_view < CharT, Traits > lhs, + nssv_BASIC_STRING_VIEW_I( CharT, Traits ) rhs ) nssv_noexcept +{ return lhs.compare( rhs ) < 0; } + +template< class CharT, class Traits nssv_MSVC_ORDER(2) > +nssv_constexpr bool operator< ( + nssv_BASIC_STRING_VIEW_I( CharT, Traits ) lhs, + basic_string_view < CharT, Traits > rhs ) nssv_noexcept +{ return lhs.compare( rhs ) < 0; } + +// <= + +template< class CharT, class Traits nssv_MSVC_ORDER(1) > +nssv_constexpr bool operator<= ( + basic_string_view < CharT, Traits > lhs, + nssv_BASIC_STRING_VIEW_I( CharT, Traits ) rhs ) nssv_noexcept +{ return lhs.compare( rhs ) <= 0; } + +template< class CharT, class Traits nssv_MSVC_ORDER(2) > +nssv_constexpr bool operator<= ( + nssv_BASIC_STRING_VIEW_I( CharT, Traits ) lhs, + basic_string_view < CharT, Traits > rhs ) nssv_noexcept +{ return lhs.compare( rhs ) <= 0; } + +// > + +template< class CharT, class Traits nssv_MSVC_ORDER(1) > +nssv_constexpr bool operator> ( + basic_string_view < CharT, Traits > lhs, + nssv_BASIC_STRING_VIEW_I( CharT, Traits ) rhs ) nssv_noexcept +{ return lhs.compare( rhs ) > 0; } + +template< class CharT, class Traits nssv_MSVC_ORDER(2) > +nssv_constexpr bool operator> ( + nssv_BASIC_STRING_VIEW_I( CharT, Traits ) lhs, + basic_string_view < CharT, Traits > rhs ) nssv_noexcept +{ return lhs.compare( rhs ) > 0; } + +// >= + +template< class CharT, class Traits nssv_MSVC_ORDER(1) > +nssv_constexpr bool operator>= ( + basic_string_view < CharT, Traits > lhs, + nssv_BASIC_STRING_VIEW_I( CharT, Traits ) rhs ) nssv_noexcept +{ return lhs.compare( rhs ) >= 0; } + +template< class CharT, class Traits nssv_MSVC_ORDER(2) > +nssv_constexpr bool operator>= ( + nssv_BASIC_STRING_VIEW_I( CharT, Traits ) lhs, + basic_string_view < CharT, Traits > rhs ) nssv_noexcept +{ return lhs.compare( rhs ) >= 0; } + +#undef nssv_MSVC_ORDER +#undef nssv_BASIC_STRING_VIEW_I + +#endif // compiler-dependent approach to comparisons + +// 24.4.4 Inserters and extractors: + +#if ! nssv_CONFIG_NO_STREAM_INSERTION + +namespace detail { + +template< class Stream > +void write_padding( Stream & os, std::streamsize n ) +{ + for ( std::streamsize i = 0; i < n; ++i ) + os.rdbuf()->sputc( os.fill() ); +} + +template< class Stream, class View > +Stream & write_to_stream( Stream & os, View const & sv ) +{ + typename Stream::sentry sentry( os ); + + if ( !os ) + return os; + + const std::streamsize length = static_cast( sv.length() ); + + // Whether, and how, to pad: + const bool pad = ( length < os.width() ); + const bool left_pad = pad && ( os.flags() & std::ios_base::adjustfield ) == std::ios_base::right; + + if ( left_pad ) + write_padding( os, os.width() - length ); + + // Write span characters: + os.rdbuf()->sputn( sv.begin(), length ); + + if ( pad && !left_pad ) + write_padding( os, os.width() - length ); + + // Reset output stream width: + os.width( 0 ); + + return os; +} + +} // namespace detail + +template< class CharT, class Traits > +std::basic_ostream & +operator<<( + std::basic_ostream& os, + basic_string_view sv ) +{ + return detail::write_to_stream( os, sv ); +} + +#endif // nssv_CONFIG_NO_STREAM_INSERTION + +// Several typedefs for common character types are provided: + +typedef basic_string_view string_view; +typedef basic_string_view wstring_view; +#if nssv_HAVE_WCHAR16_T +typedef basic_string_view u16string_view; +typedef basic_string_view u32string_view; +#endif + +}} // namespace nonstd::sv_lite + +// +// 24.4.6 Suffix for basic_string_view literals: +// + +#if nssv_HAVE_USER_DEFINED_LITERALS + +namespace nonstd { +nssv_inline_ns namespace literals { +nssv_inline_ns namespace string_view_literals { + +#if nssv_CONFIG_STD_SV_OPERATOR && nssv_HAVE_STD_DEFINED_LITERALS + +nssv_constexpr nonstd::sv_lite::string_view operator "" sv( const char* str, size_t len ) nssv_noexcept // (1) +{ + return nonstd::sv_lite::string_view{ str, len }; +} + +nssv_constexpr nonstd::sv_lite::u16string_view operator "" sv( const char16_t* str, size_t len ) nssv_noexcept // (2) +{ + return nonstd::sv_lite::u16string_view{ str, len }; +} + +nssv_constexpr nonstd::sv_lite::u32string_view operator "" sv( const char32_t* str, size_t len ) nssv_noexcept // (3) +{ + return nonstd::sv_lite::u32string_view{ str, len }; +} + +nssv_constexpr nonstd::sv_lite::wstring_view operator "" sv( const wchar_t* str, size_t len ) nssv_noexcept // (4) +{ + return nonstd::sv_lite::wstring_view{ str, len }; +} + +#endif // nssv_CONFIG_STD_SV_OPERATOR && nssv_HAVE_STD_DEFINED_LITERALS + +#if nssv_CONFIG_USR_SV_OPERATOR + +nssv_constexpr nonstd::sv_lite::string_view operator "" _sv( const char* str, size_t len ) nssv_noexcept // (1) +{ + return nonstd::sv_lite::string_view{ str, len }; +} + +nssv_constexpr nonstd::sv_lite::u16string_view operator "" _sv( const char16_t* str, size_t len ) nssv_noexcept // (2) +{ + return nonstd::sv_lite::u16string_view{ str, len }; +} + +nssv_constexpr nonstd::sv_lite::u32string_view operator "" _sv( const char32_t* str, size_t len ) nssv_noexcept // (3) +{ + return nonstd::sv_lite::u32string_view{ str, len }; +} + +nssv_constexpr nonstd::sv_lite::wstring_view operator "" _sv( const wchar_t* str, size_t len ) nssv_noexcept // (4) +{ + return nonstd::sv_lite::wstring_view{ str, len }; +} + +#endif // nssv_CONFIG_USR_SV_OPERATOR + +}}} // namespace nonstd::literals::string_view_literals + +#endif + +// +// Extensions for std::string: +// + +#if nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS + +namespace nonstd { +namespace sv_lite { + +// Exclude MSVC 14 (19.00): it yields ambiguous to_string(): + +#if nssv_CPP11_OR_GREATER && nssv_COMPILER_MSVC_VERSION != 140 + +template< class CharT, class Traits, class Allocator = std::allocator > +std::basic_string +to_string( basic_string_view v, Allocator const & a = Allocator() ) +{ + return std::basic_string( v.begin(), v.end(), a ); +} + +#else + +template< class CharT, class Traits > +std::basic_string +to_string( basic_string_view v ) +{ + return std::basic_string( v.begin(), v.end() ); +} + +template< class CharT, class Traits, class Allocator > +std::basic_string +to_string( basic_string_view v, Allocator const & a ) +{ + return std::basic_string( v.begin(), v.end(), a ); +} + +#endif // nssv_CPP11_OR_GREATER + +template< class CharT, class Traits, class Allocator > +basic_string_view +to_string_view( std::basic_string const & s ) +{ + return basic_string_view( s.data(), s.size() ); +} + +}} // namespace nonstd::sv_lite + +#endif // nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS + +// +// make types and algorithms available in namespace nonstd: +// + +namespace nonstd { + +using sv_lite::basic_string_view; +using sv_lite::string_view; +using sv_lite::wstring_view; + +#if nssv_HAVE_WCHAR16_T +using sv_lite::u16string_view; +#endif +#if nssv_HAVE_WCHAR32_T +using sv_lite::u32string_view; +#endif + +// literal "sv" + +using sv_lite::operator==; +using sv_lite::operator!=; +using sv_lite::operator<; +using sv_lite::operator<=; +using sv_lite::operator>; +using sv_lite::operator>=; + +#if ! nssv_CONFIG_NO_STREAM_INSERTION +using sv_lite::operator<<; +#endif + +#if nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS +using sv_lite::to_string; +using sv_lite::to_string_view; +#endif + +} // namespace nonstd + +// 24.4.5 Hash support (C++11): + +// Note: The hash value of a string view object is equal to the hash value of +// the corresponding string object. + +#if nssv_HAVE_STD_HASH + +#include + +namespace std { + +template<> +struct hash< nonstd::string_view > +{ +public: + std::size_t operator()( nonstd::string_view v ) const nssv_noexcept + { + return std::hash()( std::string( v.data(), v.size() ) ); + } +}; + +template<> +struct hash< nonstd::wstring_view > +{ +public: + std::size_t operator()( nonstd::wstring_view v ) const nssv_noexcept + { + return std::hash()( std::wstring( v.data(), v.size() ) ); + } +}; + +template<> +struct hash< nonstd::u16string_view > +{ +public: + std::size_t operator()( nonstd::u16string_view v ) const nssv_noexcept + { + return std::hash()( std::u16string( v.data(), v.size() ) ); + } +}; + +template<> +struct hash< nonstd::u32string_view > +{ +public: + std::size_t operator()( nonstd::u32string_view v ) const nssv_noexcept + { + return std::hash()( std::u32string( v.data(), v.size() ) ); + } +}; + +} // namespace std + +#endif // nssv_HAVE_STD_HASH + +nssv_RESTORE_WARNINGS() + +#endif // nssv_HAVE_STD_STRING_VIEW +#endif // NONSTD_SV_LITE_H_INCLUDED diff --git a/libs/tabulate/table.hpp b/libs/tabulate/table.hpp index 4f9a2b7..6a62d75 100644 --- a/libs/tabulate/table.hpp +++ b/libs/tabulate/table.hpp @@ -1,221 +1,221 @@ - -/* - __ ___. .__ __ -_/ |______ \_ |__ __ __| | _____ _/ |_ ____ -\ __\__ \ | __ \| | \ | \__ \\ __\/ __ \ - | | / __ \| \_\ \ | / |__/ __ \| | \ ___/ - |__| (____ /___ /____/|____(____ /__| \___ > - \/ \/ \/ \/ -Table Maker for Modern C++ -https://github.com/p-ranav/tabulate - -Licensed under the MIT License . -SPDX-License-Identifier: MIT -Copyright (c) 2019 Pranav Srinivas Kumar . - -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. -*/ -#pragma once -#include - -#if __cplusplus >= 201703L -#include -#include -using std::get_if; -using std::holds_alternative; -using std::string_view; -using std::variant; -using std::visit; -#else -#include -#include -using nonstd::get_if; -using nonstd::holds_alternative; -using nonstd::string_view; -using nonstd::variant; -using nonstd::visit; -#endif - -#include - -namespace tabulate { - -class Table { -public: - Table() : table_(TableInternal::create()) {} - - using Row_t = std::vector>; - - Table &add_row(const Row_t &cells) { - - if (rows_ == 0) { - // This is the first row added - // cells.size() is the number of columns - cols_ = cells.size(); - } - - std::vector cell_strings; - if (cells.size() < cols_) { - cell_strings.resize(cols_); - std::fill(cell_strings.begin(), cell_strings.end(), ""); - } else { - cell_strings.resize(cells.size()); - std::fill(cell_strings.begin(), cell_strings.end(), ""); - } - - for (size_t i = 0; i < cells.size(); ++i) { - auto cell = cells[i]; - if (holds_alternative(cell)) { - cell_strings[i] = *get_if(&cell); - } else if (holds_alternative(cell)) { - cell_strings[i] = *get_if(&cell); - } else if (holds_alternative(cell)) { - cell_strings[i] = std::string{*get_if(&cell)}; - } else { - auto table = *get_if(&cell); - std::stringstream stream; - table.print(stream); - cell_strings[i] = stream.str(); - } - } - - table_->add_row(cell_strings); - rows_ += 1; - return *this; - } - - Row &operator[](size_t index) { return row(index); } - - Row &row(size_t index) { return (*table_)[index]; } - - Column column(size_t index) { return table_->column(index); } - - Format &format() { return table_->format(); } - - void print(std::ostream &stream) { table_->print(stream); } - - std::string str() { - std::stringstream stream; - print(stream); - return stream.str(); - } - - size_t size() const { return table_->size(); } - - std::pair shape() { return table_->shape(); } - - class RowIterator { - public: - explicit RowIterator(std::vector>::iterator ptr) : ptr(ptr) {} - - RowIterator operator++() { - ++ptr; - return *this; - } - bool operator!=(const RowIterator &other) const { return ptr != other.ptr; } - Row &operator*() { return **ptr; } - - private: - std::vector>::iterator ptr; - }; - - auto begin() -> RowIterator { return RowIterator(table_->rows_.begin()); } - auto end() -> RowIterator { return RowIterator(table_->rows_.end()); } - -private: - friend class MarkdownExporter; - friend class LatexExporter; - friend class AsciiDocExporter; - - friend std::ostream &operator<<(std::ostream &stream, const Table &table); - size_t rows_{0}; - size_t cols_{0}; - std::shared_ptr table_; -}; - -inline std::ostream &operator<<(std::ostream &stream, const Table &table) { - const_cast
(table).print(stream); - return stream; -} - -class RowStream { -public: - operator const Table::Row_t &() const { return row_; } - - template ::value>::type> - RowStream &operator<<(const T &obj) { - oss_ << obj; - std::string cell{oss_.str()}; - oss_.str(""); - if (!cell.empty()) { - row_.push_back(cell); - } - return *this; - } - - RowStream &operator<<(const Table::Row_t::value_type &cell) { - row_.push_back(cell); - return *this; - } - - RowStream ©fmt(const RowStream &other) { - oss_.copyfmt(other.oss_); - return *this; - } - - RowStream ©fmt(const std::ios &other) { - oss_.copyfmt(other); - return *this; - } - - std::ostringstream::char_type fill() const { return oss_.fill(); } - std::ostringstream::char_type fill(std::ostringstream::char_type ch) { return oss_.fill(ch); } - - std::ios_base::iostate exceptions() const { return oss_.exceptions(); } - void exceptions(std::ios_base::iostate except) { oss_.exceptions(except); } - - std::locale imbue(const std::locale &loc) { return oss_.imbue(loc); } - std::locale getloc() const { return oss_.getloc(); } - - char narrow(std::ostringstream::char_type c, char dfault) const { return oss_.narrow(c, dfault); } - std::ostringstream::char_type widen(char c) const { return oss_.widen(c); } - - std::ios::fmtflags flags() const { return oss_.flags(); } - std::ios::fmtflags flags(std::ios::fmtflags flags) { return oss_.flags(flags); } - - std::ios::fmtflags setf(std::ios::fmtflags flags) { return oss_.setf(flags); } - std::ios::fmtflags setf(std::ios::fmtflags flags, std::ios::fmtflags mask) { - return oss_.setf(flags, mask); - } - - void unsetf(std::ios::fmtflags flags) { oss_.unsetf(flags); } - - std::streamsize precision() const { return oss_.precision(); } - std::streamsize precision(std::streamsize new_precision) { return oss_.precision(new_precision); } - - std::streamsize width() const { return oss_.width(); } - std::streamsize width(std::streamsize new_width) { return oss_.width(new_width); } - -private: - Table::Row_t row_; - std::ostringstream oss_; -}; - -} // namespace tabulate + +/* + __ ___. .__ __ +_/ |______ \_ |__ __ __| | _____ _/ |_ ____ +\ __\__ \ | __ \| | \ | \__ \\ __\/ __ \ + | | / __ \| \_\ \ | / |__/ __ \| | \ ___/ + |__| (____ /___ /____/|____(____ /__| \___ > + \/ \/ \/ \/ +Table Maker for Modern C++ +https://github.com/p-ranav/tabulate + +Licensed under the MIT License . +SPDX-License-Identifier: MIT +Copyright (c) 2019 Pranav Srinivas Kumar . + +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. +*/ +#pragma once +#include + +#if __cplusplus >= 201703L +#include +#include +using std::get_if; +using std::holds_alternative; +using std::string_view; +using std::variant; +using std::visit; +#else +#include +#include +using nonstd::get_if; +using nonstd::holds_alternative; +using nonstd::string_view; +using nonstd::variant; +using nonstd::visit; +#endif + +#include + +namespace tabulate { + +class Table { +public: + Table() : table_(TableInternal::create()) {} + + using Row_t = std::vector>; + + Table &add_row(const Row_t &cells) { + + if (rows_ == 0) { + // This is the first row added + // cells.size() is the number of columns + cols_ = cells.size(); + } + + std::vector cell_strings; + if (cells.size() < cols_) { + cell_strings.resize(cols_); + std::fill(cell_strings.begin(), cell_strings.end(), ""); + } else { + cell_strings.resize(cells.size()); + std::fill(cell_strings.begin(), cell_strings.end(), ""); + } + + for (size_t i = 0; i < cells.size(); ++i) { + auto cell = cells[i]; + if (holds_alternative(cell)) { + cell_strings[i] = *get_if(&cell); + } else if (holds_alternative(cell)) { + cell_strings[i] = *get_if(&cell); + } else if (holds_alternative(cell)) { + cell_strings[i] = std::string{*get_if(&cell)}; + } else { + auto table = *get_if
(&cell); + std::stringstream stream; + table.print(stream); + cell_strings[i] = stream.str(); + } + } + + table_->add_row(cell_strings); + rows_ += 1; + return *this; + } + + Row &operator[](size_t index) { return row(index); } + + Row &row(size_t index) { return (*table_)[index]; } + + Column column(size_t index) { return table_->column(index); } + + Format &format() { return table_->format(); } + + void print(std::ostream &stream) { table_->print(stream); } + + std::string str() { + std::stringstream stream; + print(stream); + return stream.str(); + } + + size_t size() const { return table_->size(); } + + std::pair shape() { return table_->shape(); } + + class RowIterator { + public: + explicit RowIterator(std::vector>::iterator ptr) : ptr(ptr) {} + + RowIterator operator++() { + ++ptr; + return *this; + } + bool operator!=(const RowIterator &other) const { return ptr != other.ptr; } + Row &operator*() { return **ptr; } + + private: + std::vector>::iterator ptr; + }; + + auto begin() -> RowIterator { return RowIterator(table_->rows_.begin()); } + auto end() -> RowIterator { return RowIterator(table_->rows_.end()); } + +private: + friend class MarkdownExporter; + friend class LatexExporter; + friend class AsciiDocExporter; + + friend std::ostream &operator<<(std::ostream &stream, const Table &table); + size_t rows_{0}; + size_t cols_{0}; + std::shared_ptr table_; +}; + +inline std::ostream &operator<<(std::ostream &stream, const Table &table) { + const_cast
(table).print(stream); + return stream; +} + +class RowStream { +public: + operator const Table::Row_t &() const { return row_; } + + template ::value>::type> + RowStream &operator<<(const T &obj) { + oss_ << obj; + std::string cell{oss_.str()}; + oss_.str(""); + if (!cell.empty()) { + row_.push_back(cell); + } + return *this; + } + + RowStream &operator<<(const Table::Row_t::value_type &cell) { + row_.push_back(cell); + return *this; + } + + RowStream ©fmt(const RowStream &other) { + oss_.copyfmt(other.oss_); + return *this; + } + + RowStream ©fmt(const std::ios &other) { + oss_.copyfmt(other); + return *this; + } + + std::ostringstream::char_type fill() const { return oss_.fill(); } + std::ostringstream::char_type fill(std::ostringstream::char_type ch) { return oss_.fill(ch); } + + std::ios_base::iostate exceptions() const { return oss_.exceptions(); } + void exceptions(std::ios_base::iostate except) { oss_.exceptions(except); } + + std::locale imbue(const std::locale &loc) { return oss_.imbue(loc); } + std::locale getloc() const { return oss_.getloc(); } + + char narrow(std::ostringstream::char_type c, char dfault) const { return oss_.narrow(c, dfault); } + std::ostringstream::char_type widen(char c) const { return oss_.widen(c); } + + std::ios::fmtflags flags() const { return oss_.flags(); } + std::ios::fmtflags flags(std::ios::fmtflags flags) { return oss_.flags(flags); } + + std::ios::fmtflags setf(std::ios::fmtflags flags) { return oss_.setf(flags); } + std::ios::fmtflags setf(std::ios::fmtflags flags, std::ios::fmtflags mask) { + return oss_.setf(flags, mask); + } + + void unsetf(std::ios::fmtflags flags) { oss_.unsetf(flags); } + + std::streamsize precision() const { return oss_.precision(); } + std::streamsize precision(std::streamsize new_precision) { return oss_.precision(new_precision); } + + std::streamsize width() const { return oss_.width(); } + std::streamsize width(std::streamsize new_width) { return oss_.width(new_width); } + +private: + Table::Row_t row_; + std::ostringstream oss_; +}; + +} // namespace tabulate diff --git a/libs/tabulate/table_internal.hpp b/libs/tabulate/table_internal.hpp index 1b94c6b..e4a6dad 100644 --- a/libs/tabulate/table_internal.hpp +++ b/libs/tabulate/table_internal.hpp @@ -1,497 +1,497 @@ - -/* - __ ___. .__ __ -_/ |______ \_ |__ __ __| | _____ _/ |_ ____ -\ __\__ \ | __ \| | \ | \__ \\ __\/ __ \ - | | / __ \| \_\ \ | / |__/ __ \| | \ ___/ - |__| (____ /___ /____/|____(____ /__| \___ > - \/ \/ \/ \/ -Table Maker for Modern C++ -https://github.com/p-ranav/tabulate - -Licensed under the MIT License . -SPDX-License-Identifier: MIT -Copyright (c) 2019 Pranav Srinivas Kumar . - -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. -*/ -#pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef max -#undef max -#endif -#ifdef min -#undef min -#endif - -namespace tabulate { - -class TableInternal : public std::enable_shared_from_this { -public: - static std::shared_ptr create() { - auto result = std::shared_ptr(new TableInternal()); - result->format_.set_defaults(); - return result; - } - - void add_row(const std::vector &cells) { - auto row = std::make_shared(shared_from_this()); - for (auto &c : cells) { - auto cell = std::make_shared(row); - cell->set_text(c); - row->add_cell(cell); - } - rows_.push_back(row); - } - - Row &operator[](size_t index) { return *(rows_[index]); } - - const Row &operator[](size_t index) const { return *(rows_[index]); } - - Column column(size_t index) { - Column column(shared_from_this()); - for (size_t i = 0; i < rows_.size(); ++i) { - auto row = rows_[i]; - auto &cell = row->cell(index); - column.add_cell(cell); - } - return column; - } - - size_t size() const { return rows_.size(); } - - std::pair shape() { - std::pair result{0, 0}; - std::stringstream stream; - print(stream); - auto buffer = stream.str(); - auto lines = Format::split_lines(buffer, "\n", "", true); - if (lines.size()) { - result = {get_sequence_length(lines[0], "", true), lines.size()}; - } - return result; - } - - Format &format() { return format_; } - - void print(std::ostream &stream) { Printer::print_table(stream, *this); } - - size_t estimate_num_columns() const { - size_t result{0}; - if (size()) { - auto first_row = operator[](size_t(0)); - result = first_row.size(); - } - return result; - } - -private: - friend class Table; - friend class MarkdownExporter; - - TableInternal() {} - TableInternal &operator=(const TableInternal &); - TableInternal(const TableInternal &); - - std::vector> rows_; - Format format_; -}; - -inline Format &Cell::format() { - std::shared_ptr parent = parent_.lock(); - if (!format_.has_value()) { // no cell format - format_ = parent->format(); // Use parent row format - } else { - // Cell has formatting - // Merge cell formatting with parent row formatting - format_ = Format::merge(*format_, parent->format()); - } - return *format_; -} - -inline bool Cell::is_multi_byte_character_support_enabled() { - return (*format().multi_byte_characters_); -} - -inline Format &Row::format() { - std::shared_ptr parent = parent_.lock(); - if (!format_.has_value()) { // no row format - format_ = parent->format(); // Use parent table format - } else { - // Row has formatting rules - // Merge with parent table format - format_ = Format::merge(*format_, parent->format()); - } - return *format_; -} - -inline std::pair, std::vector> -Printer::compute_cell_dimensions(TableInternal &table) { - std::pair, std::vector> result; - size_t num_rows = table.size(); - size_t num_columns = table.estimate_num_columns(); - - std::vector row_heights, column_widths{}; - - for (size_t i = 0; i < num_columns; ++i) { - Column column = table.column(i); - size_t configured_width = column.get_configured_width(); - size_t computed_width = column.get_computed_width(); - if (configured_width != 0) - column_widths.push_back(configured_width); - else - column_widths.push_back(computed_width); - } - - for (size_t i = 0; i < num_rows; ++i) { - Row row = table[i]; - size_t configured_height = row.get_configured_height(); - size_t computed_height = row.get_computed_height(column_widths); - - // NOTE: Unlike column width, row height is calculated as the max - // b/w configured height and computed height - // which means that .width() has higher precedence than .height() - // when both are configured by the user - // - // TODO: Maybe this can be configured? - // If such a configuration is exposed, i.e., prefer height over width - // then the logic will be reversed, i.e., - // column_widths.push_back(std::max(configured_width, computed_width)) - // and - // row_height = configured_height if != 0 else computed_height - - row_heights.push_back(std::max(configured_height, computed_height)); - } - - result.first = row_heights; - result.second = column_widths; - - return result; -} - -inline void Printer::print_table(std::ostream &stream, TableInternal &table) { - size_t num_rows = table.size(); - size_t num_columns = table.estimate_num_columns(); - auto dimensions = compute_cell_dimensions(table); - auto row_heights = dimensions.first; - auto column_widths = dimensions.second; - auto splitted_cells_text = std::vector>>( - num_rows, std::vector>(num_columns, std::vector{})); - - // Pre-compute the cells' content and split them into lines before actually - // iterating the cells. - for (size_t i = 0; i < num_rows; ++i) { - Row row = table[i]; - for (size_t j = 0; j < num_columns; ++j) { - Cell cell = row.cell(j); - const std::string &text = cell.get_text(); - auto padding_left = *cell.format().padding_left_; - auto padding_right = *cell.format().padding_right_; - - // Check if input text has embedded \n that are to be respected - bool has_new_line = text.find_first_of('\n') != std::string::npos; - - if (has_new_line) { - // Respect to the embedded '\n' characters - splitted_cells_text[i][j] = Format::split_lines( - text, "\n", cell.locale(), cell.is_multi_byte_character_support_enabled()); - } else { - // If there are no embedded \n characters, then apply word wrap. - // - // Configured column width cannot be lower than (padding_left + - // padding_right) This is a bad configuration E.g., the user is trying - // to force the column width to be 5 when padding_left and padding_right - // are each configured to 3 (padding_left + padding_right) = 6 > - // column_width - auto content_width = column_widths[j] > padding_left + padding_right - ? column_widths[j] - padding_left - padding_right - : column_widths[j]; - auto word_wrapped_text = Format::word_wrap(text, content_width, cell.locale(), - cell.is_multi_byte_character_support_enabled()); - splitted_cells_text[i][j] = Format::split_lines( - word_wrapped_text, "\n", cell.locale(), cell.is_multi_byte_character_support_enabled()); - } - } - } - - // For each row, - for (size_t i = 0; i < num_rows; ++i) { - - // Print top border - bool border_top_printed{true}; - for (size_t j = 0; j < num_columns; ++j) { - border_top_printed &= print_cell_border_top(stream, table, {i, j}, - {row_heights[i], column_widths[j]}, num_columns); - } - if (border_top_printed) - stream << termcolor::reset << "\n"; - - // Print row contents with word wrapping - for (size_t k = 0; k < row_heights[i]; ++k) { - for (size_t j = 0; j < num_columns; ++j) { - print_row_in_cell(stream, table, {i, j}, {row_heights[i], column_widths[j]}, num_columns, k, - splitted_cells_text[i][j]); - } - if (k + 1 < row_heights[i]) - stream << termcolor::reset << "\n"; - } - - if (i + 1 == num_rows) { - - // Check if there is bottom border to print: - auto bottom_border_needed{true}; - for (size_t j = 0; j < num_columns; ++j) { - auto cell = table[i][j]; - auto format = cell.format(); - auto corner = *format.corner_bottom_left_; - auto border_bottom = *format.border_bottom_; - if (corner == "" && border_bottom == "") { - bottom_border_needed = false; - break; - } - } - - if (bottom_border_needed) - stream << termcolor::reset << "\n"; - // Print bottom border for table - for (size_t j = 0; j < num_columns; ++j) { - print_cell_border_bottom(stream, table, {i, j}, {row_heights[i], column_widths[j]}, - num_columns); - } - } - if (i + 1 < num_rows) - stream << termcolor::reset << "\n"; // Don't add newline after last row - } -} - -inline void Printer::print_row_in_cell(std::ostream &stream, TableInternal &table, - const std::pair &index, - const std::pair &dimension, - size_t num_columns, size_t row_index, - const std::vector &splitted_cell_text) { - auto column_width = dimension.second; - auto cell = table[index.first][index.second]; - auto locale = cell.locale(); - auto is_multi_byte_character_support_enabled = cell.is_multi_byte_character_support_enabled(); - auto old_locale = std::locale::global(std::locale(locale)); - auto format = cell.format(); - auto text_height = splitted_cell_text.size(); - auto padding_top = *format.padding_top_; - - if (*format.show_border_left_) { - apply_element_style(stream, *format.border_left_color_, *format.border_left_background_color_, - {}); - stream << *format.border_left_; - reset_element_style(stream); - } - - if (*format.show_column_separator_) { - apply_element_style(stream, *format.column_separator_color_, *format.column_separator_background_color_, - {}); - if (index.second != 0) - stream << *format.column_separator_; - reset_element_style(stream); - } - - apply_element_style(stream, *format.font_color_, *format.font_background_color_, {}); - if (row_index < padding_top) { - // Padding top - stream << std::string(column_width, ' '); - } else if (row_index >= padding_top && (row_index <= (padding_top + text_height))) { - // Retrieve padding left and right - // (column_width - padding_left - padding_right) is the amount of space - // available for cell text - Use this to word wrap cell contents - auto padding_left = *format.padding_left_; - auto padding_right = *format.padding_right_; - - if (row_index - padding_top < text_height) { - auto line = splitted_cell_text[row_index - padding_top]; - - // Print left padding characters - stream << std::string(padding_left, ' '); - - // Print word-wrapped line - switch (*format.trim_mode_) { - case Format::TrimMode::kBoth: - line = Format::trim(line); - break; - case Format::TrimMode::kLeft: - line = Format::trim_left(line); - break; - case Format::TrimMode::kRight: - line = Format::trim_right(line); - break; - case Format::TrimMode::kNone: - break; - } - - auto line_with_padding_size = - get_sequence_length(line, cell.locale(), is_multi_byte_character_support_enabled) + - padding_left + padding_right; - switch (*format.font_align_) { - case FontAlign::left: - print_content_left_aligned(stream, line, format, line_with_padding_size, column_width); - break; - case FontAlign::center: - print_content_center_aligned(stream, line, format, line_with_padding_size, column_width); - break; - case FontAlign::right: - print_content_right_aligned(stream, line, format, line_with_padding_size, column_width); - break; - } - - // Print right padding characters - stream << std::string(padding_right, ' '); - } else - stream << std::string(column_width, ' '); - - } else { - // Padding bottom - stream << std::string(column_width, ' '); - } - - reset_element_style(stream); - - if (index.second + 1 == num_columns) { - // Print right border after last column - if (*format.show_border_right_) { - apply_element_style(stream, *format.border_right_color_, - *format.border_right_background_color_, {}); - stream << *format.border_right_; - reset_element_style(stream); - } - } - std::locale::global(old_locale); -} - -inline bool Printer::print_cell_border_top(std::ostream &stream, TableInternal &table, - const std::pair &index, - const std::pair &dimension, - size_t num_columns) { - auto cell = table[index.first][index.second]; - auto locale = cell.locale(); - auto old_locale = std::locale::global(std::locale(locale)); - auto format = cell.format(); - auto column_width = dimension.second; - - auto corner = *format.corner_top_left_; - auto corner_color = *format.corner_top_left_color_; - auto corner_background_color = *format.corner_top_left_background_color_; - auto border_top = *format.border_top_; - - if ((corner == "" && border_top == "") || !*format.show_border_top_) - return false; - - apply_element_style(stream, corner_color, corner_background_color, {}); - if (*format.show_row_separator_) { - if (index.first != 0) - stream << corner; - else - stream << " "; - } - else - stream << corner; - reset_element_style(stream); - - for (size_t i = 0; i < column_width; ++i) { - apply_element_style(stream, *format.border_top_color_, *format.border_top_background_color_, - {}); - if (*format.show_row_separator_) { - if (index.first != 0) - stream << border_top; - else - stream << " "; - } else - stream << border_top; - reset_element_style(stream); - } - - if (index.second + 1 == num_columns) { - // Print corner after last column - corner = *format.corner_top_right_; - corner_color = *format.corner_top_right_color_; - corner_background_color = *format.corner_top_right_background_color_; - - apply_element_style(stream, corner_color, corner_background_color, {}); - if (*format.show_row_separator_) { - if (index.first != 0) - stream << corner; - else - stream << " "; - } - else - stream << corner; - reset_element_style(stream); - } - std::locale::global(old_locale); - return true; -} - -inline bool Printer::print_cell_border_bottom(std::ostream &stream, TableInternal &table, - const std::pair &index, - const std::pair &dimension, - size_t num_columns) { - auto cell = table[index.first][index.second]; - auto locale = cell.locale(); - auto old_locale = std::locale::global(std::locale(locale)); - auto format = cell.format(); - auto column_width = dimension.second; - - auto corner = *format.corner_bottom_left_; - auto corner_color = *format.corner_bottom_left_color_; - auto corner_background_color = *format.corner_bottom_left_background_color_; - auto border_bottom = *format.border_bottom_; - - if ((corner == "" && border_bottom == "") || !*format.show_border_bottom_) - return false; - - apply_element_style(stream, corner_color, corner_background_color, {}); - stream << corner; - reset_element_style(stream); - - for (size_t i = 0; i < column_width; ++i) { - apply_element_style(stream, *format.border_bottom_color_, - *format.border_bottom_background_color_, {}); - stream << border_bottom; - reset_element_style(stream); - } - - if (index.second + 1 == num_columns) { - // Print corner after last column - corner = *format.corner_bottom_right_; - corner_color = *format.corner_bottom_right_color_; - corner_background_color = *format.corner_bottom_right_background_color_; - - apply_element_style(stream, corner_color, corner_background_color, {}); - stream << corner; - reset_element_style(stream); - } - std::locale::global(old_locale); - return true; -} - -} // namespace tabulate + +/* + __ ___. .__ __ +_/ |______ \_ |__ __ __| | _____ _/ |_ ____ +\ __\__ \ | __ \| | \ | \__ \\ __\/ __ \ + | | / __ \| \_\ \ | / |__/ __ \| | \ ___/ + |__| (____ /___ /____/|____(____ /__| \___ > + \/ \/ \/ \/ +Table Maker for Modern C++ +https://github.com/p-ranav/tabulate + +Licensed under the MIT License . +SPDX-License-Identifier: MIT +Copyright (c) 2019 Pranav Srinivas Kumar . + +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. +*/ +#pragma once +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef max +#undef max +#endif +#ifdef min +#undef min +#endif + +namespace tabulate { + +class TableInternal : public std::enable_shared_from_this { +public: + static std::shared_ptr create() { + auto result = std::shared_ptr(new TableInternal()); + result->format_.set_defaults(); + return result; + } + + void add_row(const std::vector &cells) { + auto row = std::make_shared(shared_from_this()); + for (auto &c : cells) { + auto cell = std::make_shared(row); + cell->set_text(c); + row->add_cell(cell); + } + rows_.push_back(row); + } + + Row &operator[](size_t index) { return *(rows_[index]); } + + const Row &operator[](size_t index) const { return *(rows_[index]); } + + Column column(size_t index) { + Column column(shared_from_this()); + for (size_t i = 0; i < rows_.size(); ++i) { + auto row = rows_[i]; + auto &cell = row->cell(index); + column.add_cell(cell); + } + return column; + } + + size_t size() const { return rows_.size(); } + + std::pair shape() { + std::pair result{0, 0}; + std::stringstream stream; + print(stream); + auto buffer = stream.str(); + auto lines = Format::split_lines(buffer, "\n", "", true); + if (lines.size()) { + result = {get_sequence_length(lines[0], "", true), lines.size()}; + } + return result; + } + + Format &format() { return format_; } + + void print(std::ostream &stream) { Printer::print_table(stream, *this); } + + size_t estimate_num_columns() const { + size_t result{0}; + if (size()) { + auto first_row = operator[](size_t(0)); + result = first_row.size(); + } + return result; + } + +private: + friend class Table; + friend class MarkdownExporter; + + TableInternal() {} + TableInternal &operator=(const TableInternal &); + TableInternal(const TableInternal &); + + std::vector> rows_; + Format format_; +}; + +inline Format &Cell::format() { + std::shared_ptr parent = parent_.lock(); + if (!format_.has_value()) { // no cell format + format_ = parent->format(); // Use parent row format + } else { + // Cell has formatting + // Merge cell formatting with parent row formatting + format_ = Format::merge(*format_, parent->format()); + } + return *format_; +} + +inline bool Cell::is_multi_byte_character_support_enabled() { + return (*format().multi_byte_characters_); +} + +inline Format &Row::format() { + std::shared_ptr parent = parent_.lock(); + if (!format_.has_value()) { // no row format + format_ = parent->format(); // Use parent table format + } else { + // Row has formatting rules + // Merge with parent table format + format_ = Format::merge(*format_, parent->format()); + } + return *format_; +} + +inline std::pair, std::vector> +Printer::compute_cell_dimensions(TableInternal &table) { + std::pair, std::vector> result; + size_t num_rows = table.size(); + size_t num_columns = table.estimate_num_columns(); + + std::vector row_heights, column_widths{}; + + for (size_t i = 0; i < num_columns; ++i) { + Column column = table.column(i); + size_t configured_width = column.get_configured_width(); + size_t computed_width = column.get_computed_width(); + if (configured_width != 0) + column_widths.push_back(configured_width); + else + column_widths.push_back(computed_width); + } + + for (size_t i = 0; i < num_rows; ++i) { + Row row = table[i]; + size_t configured_height = row.get_configured_height(); + size_t computed_height = row.get_computed_height(column_widths); + + // NOTE: Unlike column width, row height is calculated as the max + // b/w configured height and computed height + // which means that .width() has higher precedence than .height() + // when both are configured by the user + // + // TODO: Maybe this can be configured? + // If such a configuration is exposed, i.e., prefer height over width + // then the logic will be reversed, i.e., + // column_widths.push_back(std::max(configured_width, computed_width)) + // and + // row_height = configured_height if != 0 else computed_height + + row_heights.push_back(std::max(configured_height, computed_height)); + } + + result.first = row_heights; + result.second = column_widths; + + return result; +} + +inline void Printer::print_table(std::ostream &stream, TableInternal &table) { + size_t num_rows = table.size(); + size_t num_columns = table.estimate_num_columns(); + auto dimensions = compute_cell_dimensions(table); + auto row_heights = dimensions.first; + auto column_widths = dimensions.second; + auto splitted_cells_text = std::vector>>( + num_rows, std::vector>(num_columns, std::vector{})); + + // Pre-compute the cells' content and split them into lines before actually + // iterating the cells. + for (size_t i = 0; i < num_rows; ++i) { + Row row = table[i]; + for (size_t j = 0; j < num_columns; ++j) { + Cell cell = row.cell(j); + const std::string &text = cell.get_text(); + auto padding_left = *cell.format().padding_left_; + auto padding_right = *cell.format().padding_right_; + + // Check if input text has embedded \n that are to be respected + bool has_new_line = text.find_first_of('\n') != std::string::npos; + + if (has_new_line) { + // Respect to the embedded '\n' characters + splitted_cells_text[i][j] = Format::split_lines( + text, "\n", cell.locale(), cell.is_multi_byte_character_support_enabled()); + } else { + // If there are no embedded \n characters, then apply word wrap. + // + // Configured column width cannot be lower than (padding_left + + // padding_right) This is a bad configuration E.g., the user is trying + // to force the column width to be 5 when padding_left and padding_right + // are each configured to 3 (padding_left + padding_right) = 6 > + // column_width + auto content_width = column_widths[j] > padding_left + padding_right + ? column_widths[j] - padding_left - padding_right + : column_widths[j]; + auto word_wrapped_text = Format::word_wrap(text, content_width, cell.locale(), + cell.is_multi_byte_character_support_enabled()); + splitted_cells_text[i][j] = Format::split_lines( + word_wrapped_text, "\n", cell.locale(), cell.is_multi_byte_character_support_enabled()); + } + } + } + + // For each row, + for (size_t i = 0; i < num_rows; ++i) { + + // Print top border + bool border_top_printed{true}; + for (size_t j = 0; j < num_columns; ++j) { + border_top_printed &= print_cell_border_top(stream, table, {i, j}, + {row_heights[i], column_widths[j]}, num_columns); + } + if (border_top_printed) + stream << termcolor::reset << "\n"; + + // Print row contents with word wrapping + for (size_t k = 0; k < row_heights[i]; ++k) { + for (size_t j = 0; j < num_columns; ++j) { + print_row_in_cell(stream, table, {i, j}, {row_heights[i], column_widths[j]}, num_columns, k, + splitted_cells_text[i][j]); + } + if (k + 1 < row_heights[i]) + stream << termcolor::reset << "\n"; + } + + if (i + 1 == num_rows) { + + // Check if there is bottom border to print: + auto bottom_border_needed{true}; + for (size_t j = 0; j < num_columns; ++j) { + auto cell = table[i][j]; + auto format = cell.format(); + auto corner = *format.corner_bottom_left_; + auto border_bottom = *format.border_bottom_; + if (corner == "" && border_bottom == "") { + bottom_border_needed = false; + break; + } + } + + if (bottom_border_needed) + stream << termcolor::reset << "\n"; + // Print bottom border for table + for (size_t j = 0; j < num_columns; ++j) { + print_cell_border_bottom(stream, table, {i, j}, {row_heights[i], column_widths[j]}, + num_columns); + } + } + if (i + 1 < num_rows) + stream << termcolor::reset << "\n"; // Don't add newline after last row + } +} + +inline void Printer::print_row_in_cell(std::ostream &stream, TableInternal &table, + const std::pair &index, + const std::pair &dimension, + size_t num_columns, size_t row_index, + const std::vector &splitted_cell_text) { + auto column_width = dimension.second; + auto cell = table[index.first][index.second]; + auto locale = cell.locale(); + auto is_multi_byte_character_support_enabled = cell.is_multi_byte_character_support_enabled(); + auto old_locale = std::locale::global(std::locale(locale)); + auto format = cell.format(); + auto text_height = splitted_cell_text.size(); + auto padding_top = *format.padding_top_; + + if (*format.show_border_left_) { + apply_element_style(stream, *format.border_left_color_, *format.border_left_background_color_, + {}); + stream << *format.border_left_; + reset_element_style(stream); + } + + if (*format.show_column_separator_) { + apply_element_style(stream, *format.column_separator_color_, *format.column_separator_background_color_, + {}); + if (index.second != 0) + stream << *format.column_separator_; + reset_element_style(stream); + } + + apply_element_style(stream, *format.font_color_, *format.font_background_color_, {}); + if (row_index < padding_top) { + // Padding top + stream << std::string(column_width, ' '); + } else if (row_index >= padding_top && (row_index <= (padding_top + text_height))) { + // Retrieve padding left and right + // (column_width - padding_left - padding_right) is the amount of space + // available for cell text - Use this to word wrap cell contents + auto padding_left = *format.padding_left_; + auto padding_right = *format.padding_right_; + + if (row_index - padding_top < text_height) { + auto line = splitted_cell_text[row_index - padding_top]; + + // Print left padding characters + stream << std::string(padding_left, ' '); + + // Print word-wrapped line + switch (*format.trim_mode_) { + case Format::TrimMode::kBoth: + line = Format::trim(line); + break; + case Format::TrimMode::kLeft: + line = Format::trim_left(line); + break; + case Format::TrimMode::kRight: + line = Format::trim_right(line); + break; + case Format::TrimMode::kNone: + break; + } + + auto line_with_padding_size = + get_sequence_length(line, cell.locale(), is_multi_byte_character_support_enabled) + + padding_left + padding_right; + switch (*format.font_align_) { + case FontAlign::left: + print_content_left_aligned(stream, line, format, line_with_padding_size, column_width); + break; + case FontAlign::center: + print_content_center_aligned(stream, line, format, line_with_padding_size, column_width); + break; + case FontAlign::right: + print_content_right_aligned(stream, line, format, line_with_padding_size, column_width); + break; + } + + // Print right padding characters + stream << std::string(padding_right, ' '); + } else + stream << std::string(column_width, ' '); + + } else { + // Padding bottom + stream << std::string(column_width, ' '); + } + + reset_element_style(stream); + + if (index.second + 1 == num_columns) { + // Print right border after last column + if (*format.show_border_right_) { + apply_element_style(stream, *format.border_right_color_, + *format.border_right_background_color_, {}); + stream << *format.border_right_; + reset_element_style(stream); + } + } + std::locale::global(old_locale); +} + +inline bool Printer::print_cell_border_top(std::ostream &stream, TableInternal &table, + const std::pair &index, + const std::pair &dimension, + size_t num_columns) { + auto cell = table[index.first][index.second]; + auto locale = cell.locale(); + auto old_locale = std::locale::global(std::locale(locale)); + auto format = cell.format(); + auto column_width = dimension.second; + + auto corner = *format.corner_top_left_; + auto corner_color = *format.corner_top_left_color_; + auto corner_background_color = *format.corner_top_left_background_color_; + auto border_top = *format.border_top_; + + if ((corner == "" && border_top == "") || !*format.show_border_top_) + return false; + + apply_element_style(stream, corner_color, corner_background_color, {}); + if (*format.show_row_separator_) { + if (index.first != 0) + stream << corner; + else + stream << " "; + } + else + stream << corner; + reset_element_style(stream); + + for (size_t i = 0; i < column_width; ++i) { + apply_element_style(stream, *format.border_top_color_, *format.border_top_background_color_, + {}); + if (*format.show_row_separator_) { + if (index.first != 0) + stream << border_top; + else + stream << " "; + } else + stream << border_top; + reset_element_style(stream); + } + + if (index.second + 1 == num_columns) { + // Print corner after last column + corner = *format.corner_top_right_; + corner_color = *format.corner_top_right_color_; + corner_background_color = *format.corner_top_right_background_color_; + + apply_element_style(stream, corner_color, corner_background_color, {}); + if (*format.show_row_separator_) { + if (index.first != 0) + stream << corner; + else + stream << " "; + } + else + stream << corner; + reset_element_style(stream); + } + std::locale::global(old_locale); + return true; +} + +inline bool Printer::print_cell_border_bottom(std::ostream &stream, TableInternal &table, + const std::pair &index, + const std::pair &dimension, + size_t num_columns) { + auto cell = table[index.first][index.second]; + auto locale = cell.locale(); + auto old_locale = std::locale::global(std::locale(locale)); + auto format = cell.format(); + auto column_width = dimension.second; + + auto corner = *format.corner_bottom_left_; + auto corner_color = *format.corner_bottom_left_color_; + auto corner_background_color = *format.corner_bottom_left_background_color_; + auto border_bottom = *format.border_bottom_; + + if ((corner == "" && border_bottom == "") || !*format.show_border_bottom_) + return false; + + apply_element_style(stream, corner_color, corner_background_color, {}); + stream << corner; + reset_element_style(stream); + + for (size_t i = 0; i < column_width; ++i) { + apply_element_style(stream, *format.border_bottom_color_, + *format.border_bottom_background_color_, {}); + stream << border_bottom; + reset_element_style(stream); + } + + if (index.second + 1 == num_columns) { + // Print corner after last column + corner = *format.corner_bottom_right_; + corner_color = *format.corner_bottom_right_color_; + corner_background_color = *format.corner_bottom_right_background_color_; + + apply_element_style(stream, corner_color, corner_background_color, {}); + stream << corner; + reset_element_style(stream); + } + std::locale::global(old_locale); + return true; +} + +} // namespace tabulate diff --git a/libs/tabulate/tabulate.hpp b/libs/tabulate/tabulate.hpp index 37a771e..eeaba30 100644 --- a/libs/tabulate/tabulate.hpp +++ b/libs/tabulate/tabulate.hpp @@ -1,63 +1,63 @@ - -/* - __ ___. .__ __ -_/ |______ \_ |__ __ __| | _____ _/ |_ ____ -\ __\__ \ | __ \| | \ | \__ \\ __\/ __ \ - | | / __ \| \_\ \ | / |__/ __ \| | \ ___/ - |__| (____ /___ /____/|____(____ /__| \___ > - \/ \/ \/ \/ -Table Maker for Modern C++ -https://github.com/p-ranav/tabulate - -Licensed under the MIT License . -SPDX-License-Identifier: MIT -Copyright (c) 2019 Pranav Srinivas Kumar . - -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. -*/ - -#ifndef TABULATE_EXPORT_HPP -#define TABULATE_EXPORT_HPP - -// #ifdef _WIN32 -// #ifdef TABULATE_STATIC_LIB -// #define TABULATE_API -// #else -// #ifdef TABULATE_EXPORTS -// #define TABULATE_API __declspec(dllexport) -// #else -// #define TABULATE_API __declspec(dllimport) -// #endif -// #endif -// #else -// #define TABULATE_API -// #endif - -// Project version -#define TABULATE_VERSION_MAJOR 1 -#define TABULATE_VERSION_MINOR 5 -#define TABULATE_VERSION_PATCH 0 - -// Composing the protocol version string from major, and minor -#define TABULATE_CONCATENATE(A, B) TABULATE_CONCATENATE_IMPL(A, B) -#define TABULATE_CONCATENATE_IMPL(A, B) A##B -#define TABULATE_STRINGIFY(a) TABULATE_STRINGIFY_IMPL(a) -#define TABULATE_STRINGIFY_IMPL(a) #a - -#endif + +/* + __ ___. .__ __ +_/ |______ \_ |__ __ __| | _____ _/ |_ ____ +\ __\__ \ | __ \| | \ | \__ \\ __\/ __ \ + | | / __ \| \_\ \ | / |__/ __ \| | \ ___/ + |__| (____ /___ /____/|____(____ /__| \___ > + \/ \/ \/ \/ +Table Maker for Modern C++ +https://github.com/p-ranav/tabulate + +Licensed under the MIT License . +SPDX-License-Identifier: MIT +Copyright (c) 2019 Pranav Srinivas Kumar . + +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. +*/ + +#ifndef TABULATE_EXPORT_HPP +#define TABULATE_EXPORT_HPP + +// #ifdef _WIN32 +// #ifdef TABULATE_STATIC_LIB +// #define TABULATE_API +// #else +// #ifdef TABULATE_EXPORTS +// #define TABULATE_API __declspec(dllexport) +// #else +// #define TABULATE_API __declspec(dllimport) +// #endif +// #endif +// #else +// #define TABULATE_API +// #endif + +// Project version +#define TABULATE_VERSION_MAJOR 1 +#define TABULATE_VERSION_MINOR 5 +#define TABULATE_VERSION_PATCH 0 + +// Composing the protocol version string from major, and minor +#define TABULATE_CONCATENATE(A, B) TABULATE_CONCATENATE_IMPL(A, B) +#define TABULATE_CONCATENATE_IMPL(A, B) A##B +#define TABULATE_STRINGIFY(a) TABULATE_STRINGIFY_IMPL(a) +#define TABULATE_STRINGIFY_IMPL(a) #a + +#endif diff --git a/libs/tabulate/termcolor.hpp b/libs/tabulate/termcolor.hpp index c2eda0d..cdf9ccf 100644 --- a/libs/tabulate/termcolor.hpp +++ b/libs/tabulate/termcolor.hpp @@ -1,447 +1,447 @@ -//! -//! termcolor -//! ~~~~~~~~~ -//! -//! termcolor is a header-only c++ library for printing colored messages -//! to the terminal. Written just for fun with a help of the Force. -//! -//! :copyright: (c) 2013 by Ihor Kalnytskyi -//! :license: BSD, see LICENSE for details -//! - -#ifndef TERMCOLOR_HPP_ -#define TERMCOLOR_HPP_ - -// the following snippet of code detects the current OS and -// defines the appropriate macro that is used to wrap some -// platform specific things -#if defined(_WIN32) || defined(_WIN64) -#define TERMCOLOR_OS_WINDOWS -#elif defined(__APPLE__) -#define TERMCOLOR_OS_MACOS -#elif defined(__unix__) || defined(__unix) -#define TERMCOLOR_OS_LINUX -#else -#error unsupported platform -#endif - -// This headers provides the `isatty()`/`fileno()` functions, -// which are used for testing whether a standart stream refers -// to the terminal. As for Windows, we also need WinApi funcs -// for changing colors attributes of the terminal. -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) -#include -#elif defined(TERMCOLOR_OS_WINDOWS) -#include -#include -#endif - -#include -#include - -namespace termcolor { -// Forward declaration of the `_internal` namespace. -// All comments are below. -namespace _internal { -// An index to be used to access a private storage of I/O streams. See -// colorize / nocolorize I/O manipulators for details. -static int colorize_index = std::ios_base::xalloc(); - -inline FILE *get_standard_stream(const std::ostream &stream); -inline bool is_colorized(std::ostream &stream); -inline bool is_atty(const std::ostream &stream); - -#if defined(TERMCOLOR_OS_WINDOWS) -inline void win_change_attributes(std::ostream &stream, int foreground, int background = -1); -#endif -} // namespace _internal - -inline std::ostream &colorize(std::ostream &stream) { - stream.iword(_internal::colorize_index) = 1L; - return stream; -} - -inline std::ostream &nocolorize(std::ostream &stream) { - stream.iword(_internal::colorize_index) = 0L; - return stream; -} - -inline std::ostream &reset(std::ostream &stream) { - if (_internal::is_colorized(stream)) { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[00m"; -#elif defined(TERMCOLOR_OS_WINDOWS) - _internal::win_change_attributes(stream, -1, -1); -#endif - } - return stream; -} - -inline std::ostream &bold(std::ostream &stream) { - if (_internal::is_colorized(stream)) { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[1m"; -#elif defined(TERMCOLOR_OS_WINDOWS) -#endif - } - return stream; -} - -inline std::ostream &dark(std::ostream &stream) { - if (_internal::is_colorized(stream)) { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[2m"; -#elif defined(TERMCOLOR_OS_WINDOWS) -#endif - } - return stream; -} - -inline std::ostream &italic(std::ostream &stream) { - if (_internal::is_colorized(stream)) { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[3m"; -#elif defined(TERMCOLOR_OS_WINDOWS) -#endif - } - return stream; -} - -inline std::ostream &underline(std::ostream &stream) { - if (_internal::is_colorized(stream)) { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[4m"; -#elif defined(TERMCOLOR_OS_WINDOWS) -#endif - } - return stream; -} - -inline std::ostream &blink(std::ostream &stream) { - if (_internal::is_colorized(stream)) { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[5m"; -#elif defined(TERMCOLOR_OS_WINDOWS) -#endif - } - return stream; -} - -inline std::ostream &reverse(std::ostream &stream) { - if (_internal::is_colorized(stream)) { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[7m"; -#elif defined(TERMCOLOR_OS_WINDOWS) -#endif - } - return stream; -} - -inline std::ostream &concealed(std::ostream &stream) { - if (_internal::is_colorized(stream)) { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[8m"; -#elif defined(TERMCOLOR_OS_WINDOWS) -#endif - } - return stream; -} - -inline std::ostream &crossed(std::ostream &stream) { - if (_internal::is_colorized(stream)) { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[9m"; -#elif defined(TERMCOLOR_OS_WINDOWS) -#endif - } - return stream; -} - -inline std::ostream &grey(std::ostream &stream) { - if (_internal::is_colorized(stream)) { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[30m"; -#elif defined(TERMCOLOR_OS_WINDOWS) - _internal::win_change_attributes(stream, - 0 // grey (black) - ); -#endif - } - return stream; -} - -inline std::ostream &red(std::ostream &stream) { - if (_internal::is_colorized(stream)) { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[31m"; -#elif defined(TERMCOLOR_OS_WINDOWS) - _internal::win_change_attributes(stream, FOREGROUND_RED); -#endif - } - return stream; -} - -inline std::ostream &green(std::ostream &stream) { - if (_internal::is_colorized(stream)) { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[32m"; -#elif defined(TERMCOLOR_OS_WINDOWS) - _internal::win_change_attributes(stream, FOREGROUND_GREEN); -#endif - } - return stream; -} - -inline std::ostream &yellow(std::ostream &stream) { - if (_internal::is_colorized(stream)) { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[33m"; -#elif defined(TERMCOLOR_OS_WINDOWS) - _internal::win_change_attributes(stream, FOREGROUND_GREEN | FOREGROUND_RED); -#endif - } - return stream; -} - -inline std::ostream &blue(std::ostream &stream) { - if (_internal::is_colorized(stream)) { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[34m"; -#elif defined(TERMCOLOR_OS_WINDOWS) - _internal::win_change_attributes(stream, FOREGROUND_BLUE); -#endif - } - return stream; -} - -inline std::ostream &magenta(std::ostream &stream) { - if (_internal::is_colorized(stream)) { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[35m"; -#elif defined(TERMCOLOR_OS_WINDOWS) - _internal::win_change_attributes(stream, FOREGROUND_BLUE | FOREGROUND_RED); -#endif - } - return stream; -} - -inline std::ostream &cyan(std::ostream &stream) { - if (_internal::is_colorized(stream)) { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[36m"; -#elif defined(TERMCOLOR_OS_WINDOWS) - _internal::win_change_attributes(stream, FOREGROUND_BLUE | FOREGROUND_GREEN); -#endif - } - return stream; -} - -inline std::ostream &white(std::ostream &stream) { - if (_internal::is_colorized(stream)) { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[37m"; -#elif defined(TERMCOLOR_OS_WINDOWS) - _internal::win_change_attributes(stream, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED); -#endif - } - return stream; -} - -inline std::ostream &on_grey(std::ostream &stream) { - if (_internal::is_colorized(stream)) { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[40m"; -#elif defined(TERMCOLOR_OS_WINDOWS) - _internal::win_change_attributes(stream, -1, - 0 // grey (black) - ); -#endif - } - return stream; -} - -inline std::ostream &on_red(std::ostream &stream) { - if (_internal::is_colorized(stream)) { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[41m"; -#elif defined(TERMCOLOR_OS_WINDOWS) - _internal::win_change_attributes(stream, -1, BACKGROUND_RED); -#endif - } - return stream; -} - -inline std::ostream &on_green(std::ostream &stream) { - if (_internal::is_colorized(stream)) { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[42m"; -#elif defined(TERMCOLOR_OS_WINDOWS) - _internal::win_change_attributes(stream, -1, BACKGROUND_GREEN); -#endif - } - return stream; -} - -inline std::ostream &on_yellow(std::ostream &stream) { - if (_internal::is_colorized(stream)) { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[43m"; -#elif defined(TERMCOLOR_OS_WINDOWS) - _internal::win_change_attributes(stream, -1, BACKGROUND_GREEN | BACKGROUND_RED); -#endif - } - return stream; -} - -inline std::ostream &on_blue(std::ostream &stream) { - if (_internal::is_colorized(stream)) { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[44m"; -#elif defined(TERMCOLOR_OS_WINDOWS) - _internal::win_change_attributes(stream, -1, BACKGROUND_BLUE); -#endif - } - return stream; -} - -inline std::ostream &on_magenta(std::ostream &stream) { - if (_internal::is_colorized(stream)) { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[45m"; -#elif defined(TERMCOLOR_OS_WINDOWS) - _internal::win_change_attributes(stream, -1, BACKGROUND_BLUE | BACKGROUND_RED); -#endif - } - return stream; -} - -inline std::ostream &on_cyan(std::ostream &stream) { - if (_internal::is_colorized(stream)) { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[46m"; -#elif defined(TERMCOLOR_OS_WINDOWS) - _internal::win_change_attributes(stream, -1, BACKGROUND_GREEN | BACKGROUND_BLUE); -#endif - } - return stream; -} - -inline std::ostream &on_white(std::ostream &stream) { - if (_internal::is_colorized(stream)) { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[47m"; -#elif defined(TERMCOLOR_OS_WINDOWS) - _internal::win_change_attributes(stream, -1, - BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_RED); -#endif - } - - return stream; -} - -//! Since C++ hasn't a way to hide something in the header from -//! the outer access, I have to introduce this namespace which -//! is used for internal purpose and should't be access from -//! the user code. -namespace _internal { -//! Since C++ hasn't a true way to extract stream handler -//! from the a given `std::ostream` object, I have to write -//! this kind of hack. -inline FILE *get_standard_stream(const std::ostream &stream) { - if (&stream == &std::cout) - return stdout; - else if ((&stream == &std::cerr) || (&stream == &std::clog)) - return stderr; - - return 0; -} - -// Say whether a given stream should be colorized or not. It's always -// true for ATTY streams and may be true for streams marked with -// colorize flag. -inline bool is_colorized(std::ostream &stream) { - return is_atty(stream) || static_cast(stream.iword(colorize_index)); -} - -//! Test whether a given `std::ostream` object refers to -//! a terminal. -inline bool is_atty(const std::ostream &stream) { - FILE *std_stream = get_standard_stream(stream); - - // Unfortunately, fileno() ends with segmentation fault - // if invalid file descriptor is passed. So we need to - // handle this case gracefully and assume it's not a tty - // if standard stream is not detected, and 0 is returned. - if (!std_stream) - return false; - -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - return ::isatty(fileno(std_stream)); -#elif defined(TERMCOLOR_OS_WINDOWS) - return ::_isatty(_fileno(std_stream)); -#endif -} - -#if defined(TERMCOLOR_OS_WINDOWS) -//! Change Windows Terminal colors attribute. If some -//! parameter is `-1` then attribute won't changed. -inline void win_change_attributes(std::ostream &stream, int foreground, int background) { - // yeah, i know.. it's ugly, it's windows. - static WORD defaultAttributes = 0; - - // Windows doesn't have ANSI escape sequences and so we use special - // API to change Terminal output color. That means we can't - // manipulate colors by means of "std::stringstream" and hence - // should do nothing in this case. - if (!_internal::is_atty(stream)) - return; - - // get terminal handle - HANDLE hTerminal = INVALID_HANDLE_VALUE; - if (&stream == &std::cout) - hTerminal = GetStdHandle(STD_OUTPUT_HANDLE); - else if (&stream == &std::cerr) - hTerminal = GetStdHandle(STD_ERROR_HANDLE); - - // save default terminal attributes if it unsaved - if (!defaultAttributes) { - CONSOLE_SCREEN_BUFFER_INFO info; - if (!GetConsoleScreenBufferInfo(hTerminal, &info)) - return; - defaultAttributes = info.wAttributes; - } - - // restore all default settings - if (foreground == -1 && background == -1) { - SetConsoleTextAttribute(hTerminal, defaultAttributes); - return; - } - - // get current settings - CONSOLE_SCREEN_BUFFER_INFO info; - if (!GetConsoleScreenBufferInfo(hTerminal, &info)) - return; - - if (foreground != -1) { - info.wAttributes &= ~(info.wAttributes & 0x0F); - info.wAttributes |= static_cast(foreground); - } - - if (background != -1) { - info.wAttributes &= ~(info.wAttributes & 0xF0); - info.wAttributes |= static_cast(background); - } - - SetConsoleTextAttribute(hTerminal, info.wAttributes); -} -#endif // TERMCOLOR_OS_WINDOWS - -} // namespace _internal - -} // namespace termcolor - -#undef TERMCOLOR_OS_WINDOWS -#undef TERMCOLOR_OS_MACOS -#undef TERMCOLOR_OS_LINUX - -#endif // TERMCOLOR_HPP_ +//! +//! termcolor +//! ~~~~~~~~~ +//! +//! termcolor is a header-only c++ library for printing colored messages +//! to the terminal. Written just for fun with a help of the Force. +//! +//! :copyright: (c) 2013 by Ihor Kalnytskyi +//! :license: BSD, see LICENSE for details +//! + +#ifndef TERMCOLOR_HPP_ +#define TERMCOLOR_HPP_ + +// the following snippet of code detects the current OS and +// defines the appropriate macro that is used to wrap some +// platform specific things +#if defined(_WIN32) || defined(_WIN64) +#define TERMCOLOR_OS_WINDOWS +#elif defined(__APPLE__) +#define TERMCOLOR_OS_MACOS +#elif defined(__unix__) || defined(__unix) +#define TERMCOLOR_OS_LINUX +#else +#error unsupported platform +#endif + +// This headers provides the `isatty()`/`fileno()` functions, +// which are used for testing whether a standart stream refers +// to the terminal. As for Windows, we also need WinApi funcs +// for changing colors attributes of the terminal. +#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) +#include +#elif defined(TERMCOLOR_OS_WINDOWS) +#include +#include +#endif + +#include +#include + +namespace termcolor { +// Forward declaration of the `_internal` namespace. +// All comments are below. +namespace _internal { +// An index to be used to access a private storage of I/O streams. See +// colorize / nocolorize I/O manipulators for details. +static int colorize_index = std::ios_base::xalloc(); + +inline FILE *get_standard_stream(const std::ostream &stream); +inline bool is_colorized(std::ostream &stream); +inline bool is_atty(const std::ostream &stream); + +#if defined(TERMCOLOR_OS_WINDOWS) +inline void win_change_attributes(std::ostream &stream, int foreground, int background = -1); +#endif +} // namespace _internal + +inline std::ostream &colorize(std::ostream &stream) { + stream.iword(_internal::colorize_index) = 1L; + return stream; +} + +inline std::ostream &nocolorize(std::ostream &stream) { + stream.iword(_internal::colorize_index) = 0L; + return stream; +} + +inline std::ostream &reset(std::ostream &stream) { + if (_internal::is_colorized(stream)) { +#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) + stream << "\033[00m"; +#elif defined(TERMCOLOR_OS_WINDOWS) + _internal::win_change_attributes(stream, -1, -1); +#endif + } + return stream; +} + +inline std::ostream &bold(std::ostream &stream) { + if (_internal::is_colorized(stream)) { +#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) + stream << "\033[1m"; +#elif defined(TERMCOLOR_OS_WINDOWS) +#endif + } + return stream; +} + +inline std::ostream &dark(std::ostream &stream) { + if (_internal::is_colorized(stream)) { +#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) + stream << "\033[2m"; +#elif defined(TERMCOLOR_OS_WINDOWS) +#endif + } + return stream; +} + +inline std::ostream &italic(std::ostream &stream) { + if (_internal::is_colorized(stream)) { +#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) + stream << "\033[3m"; +#elif defined(TERMCOLOR_OS_WINDOWS) +#endif + } + return stream; +} + +inline std::ostream &underline(std::ostream &stream) { + if (_internal::is_colorized(stream)) { +#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) + stream << "\033[4m"; +#elif defined(TERMCOLOR_OS_WINDOWS) +#endif + } + return stream; +} + +inline std::ostream &blink(std::ostream &stream) { + if (_internal::is_colorized(stream)) { +#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) + stream << "\033[5m"; +#elif defined(TERMCOLOR_OS_WINDOWS) +#endif + } + return stream; +} + +inline std::ostream &reverse(std::ostream &stream) { + if (_internal::is_colorized(stream)) { +#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) + stream << "\033[7m"; +#elif defined(TERMCOLOR_OS_WINDOWS) +#endif + } + return stream; +} + +inline std::ostream &concealed(std::ostream &stream) { + if (_internal::is_colorized(stream)) { +#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) + stream << "\033[8m"; +#elif defined(TERMCOLOR_OS_WINDOWS) +#endif + } + return stream; +} + +inline std::ostream &crossed(std::ostream &stream) { + if (_internal::is_colorized(stream)) { +#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) + stream << "\033[9m"; +#elif defined(TERMCOLOR_OS_WINDOWS) +#endif + } + return stream; +} + +inline std::ostream &grey(std::ostream &stream) { + if (_internal::is_colorized(stream)) { +#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) + stream << "\033[30m"; +#elif defined(TERMCOLOR_OS_WINDOWS) + _internal::win_change_attributes(stream, + 0 // grey (black) + ); +#endif + } + return stream; +} + +inline std::ostream &red(std::ostream &stream) { + if (_internal::is_colorized(stream)) { +#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) + stream << "\033[31m"; +#elif defined(TERMCOLOR_OS_WINDOWS) + _internal::win_change_attributes(stream, FOREGROUND_RED); +#endif + } + return stream; +} + +inline std::ostream &green(std::ostream &stream) { + if (_internal::is_colorized(stream)) { +#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) + stream << "\033[32m"; +#elif defined(TERMCOLOR_OS_WINDOWS) + _internal::win_change_attributes(stream, FOREGROUND_GREEN); +#endif + } + return stream; +} + +inline std::ostream &yellow(std::ostream &stream) { + if (_internal::is_colorized(stream)) { +#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) + stream << "\033[33m"; +#elif defined(TERMCOLOR_OS_WINDOWS) + _internal::win_change_attributes(stream, FOREGROUND_GREEN | FOREGROUND_RED); +#endif + } + return stream; +} + +inline std::ostream &blue(std::ostream &stream) { + if (_internal::is_colorized(stream)) { +#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) + stream << "\033[34m"; +#elif defined(TERMCOLOR_OS_WINDOWS) + _internal::win_change_attributes(stream, FOREGROUND_BLUE); +#endif + } + return stream; +} + +inline std::ostream &magenta(std::ostream &stream) { + if (_internal::is_colorized(stream)) { +#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) + stream << "\033[35m"; +#elif defined(TERMCOLOR_OS_WINDOWS) + _internal::win_change_attributes(stream, FOREGROUND_BLUE | FOREGROUND_RED); +#endif + } + return stream; +} + +inline std::ostream &cyan(std::ostream &stream) { + if (_internal::is_colorized(stream)) { +#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) + stream << "\033[36m"; +#elif defined(TERMCOLOR_OS_WINDOWS) + _internal::win_change_attributes(stream, FOREGROUND_BLUE | FOREGROUND_GREEN); +#endif + } + return stream; +} + +inline std::ostream &white(std::ostream &stream) { + if (_internal::is_colorized(stream)) { +#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) + stream << "\033[37m"; +#elif defined(TERMCOLOR_OS_WINDOWS) + _internal::win_change_attributes(stream, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED); +#endif + } + return stream; +} + +inline std::ostream &on_grey(std::ostream &stream) { + if (_internal::is_colorized(stream)) { +#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) + stream << "\033[40m"; +#elif defined(TERMCOLOR_OS_WINDOWS) + _internal::win_change_attributes(stream, -1, + 0 // grey (black) + ); +#endif + } + return stream; +} + +inline std::ostream &on_red(std::ostream &stream) { + if (_internal::is_colorized(stream)) { +#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) + stream << "\033[41m"; +#elif defined(TERMCOLOR_OS_WINDOWS) + _internal::win_change_attributes(stream, -1, BACKGROUND_RED); +#endif + } + return stream; +} + +inline std::ostream &on_green(std::ostream &stream) { + if (_internal::is_colorized(stream)) { +#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) + stream << "\033[42m"; +#elif defined(TERMCOLOR_OS_WINDOWS) + _internal::win_change_attributes(stream, -1, BACKGROUND_GREEN); +#endif + } + return stream; +} + +inline std::ostream &on_yellow(std::ostream &stream) { + if (_internal::is_colorized(stream)) { +#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) + stream << "\033[43m"; +#elif defined(TERMCOLOR_OS_WINDOWS) + _internal::win_change_attributes(stream, -1, BACKGROUND_GREEN | BACKGROUND_RED); +#endif + } + return stream; +} + +inline std::ostream &on_blue(std::ostream &stream) { + if (_internal::is_colorized(stream)) { +#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) + stream << "\033[44m"; +#elif defined(TERMCOLOR_OS_WINDOWS) + _internal::win_change_attributes(stream, -1, BACKGROUND_BLUE); +#endif + } + return stream; +} + +inline std::ostream &on_magenta(std::ostream &stream) { + if (_internal::is_colorized(stream)) { +#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) + stream << "\033[45m"; +#elif defined(TERMCOLOR_OS_WINDOWS) + _internal::win_change_attributes(stream, -1, BACKGROUND_BLUE | BACKGROUND_RED); +#endif + } + return stream; +} + +inline std::ostream &on_cyan(std::ostream &stream) { + if (_internal::is_colorized(stream)) { +#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) + stream << "\033[46m"; +#elif defined(TERMCOLOR_OS_WINDOWS) + _internal::win_change_attributes(stream, -1, BACKGROUND_GREEN | BACKGROUND_BLUE); +#endif + } + return stream; +} + +inline std::ostream &on_white(std::ostream &stream) { + if (_internal::is_colorized(stream)) { +#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) + stream << "\033[47m"; +#elif defined(TERMCOLOR_OS_WINDOWS) + _internal::win_change_attributes(stream, -1, + BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_RED); +#endif + } + + return stream; +} + +//! Since C++ hasn't a way to hide something in the header from +//! the outer access, I have to introduce this namespace which +//! is used for internal purpose and should't be access from +//! the user code. +namespace _internal { +//! Since C++ hasn't a true way to extract stream handler +//! from the a given `std::ostream` object, I have to write +//! this kind of hack. +inline FILE *get_standard_stream(const std::ostream &stream) { + if (&stream == &std::cout) + return stdout; + else if ((&stream == &std::cerr) || (&stream == &std::clog)) + return stderr; + + return 0; +} + +// Say whether a given stream should be colorized or not. It's always +// true for ATTY streams and may be true for streams marked with +// colorize flag. +inline bool is_colorized(std::ostream &stream) { + return is_atty(stream) || static_cast(stream.iword(colorize_index)); +} + +//! Test whether a given `std::ostream` object refers to +//! a terminal. +inline bool is_atty(const std::ostream &stream) { + FILE *std_stream = get_standard_stream(stream); + + // Unfortunately, fileno() ends with segmentation fault + // if invalid file descriptor is passed. So we need to + // handle this case gracefully and assume it's not a tty + // if standard stream is not detected, and 0 is returned. + if (!std_stream) + return false; + +#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) + return ::isatty(fileno(std_stream)); +#elif defined(TERMCOLOR_OS_WINDOWS) + return ::_isatty(_fileno(std_stream)); +#endif +} + +#if defined(TERMCOLOR_OS_WINDOWS) +//! Change Windows Terminal colors attribute. If some +//! parameter is `-1` then attribute won't changed. +inline void win_change_attributes(std::ostream &stream, int foreground, int background) { + // yeah, i know.. it's ugly, it's windows. + static WORD defaultAttributes = 0; + + // Windows doesn't have ANSI escape sequences and so we use special + // API to change Terminal output color. That means we can't + // manipulate colors by means of "std::stringstream" and hence + // should do nothing in this case. + if (!_internal::is_atty(stream)) + return; + + // get terminal handle + HANDLE hTerminal = INVALID_HANDLE_VALUE; + if (&stream == &std::cout) + hTerminal = GetStdHandle(STD_OUTPUT_HANDLE); + else if (&stream == &std::cerr) + hTerminal = GetStdHandle(STD_ERROR_HANDLE); + + // save default terminal attributes if it unsaved + if (!defaultAttributes) { + CONSOLE_SCREEN_BUFFER_INFO info; + if (!GetConsoleScreenBufferInfo(hTerminal, &info)) + return; + defaultAttributes = info.wAttributes; + } + + // restore all default settings + if (foreground == -1 && background == -1) { + SetConsoleTextAttribute(hTerminal, defaultAttributes); + return; + } + + // get current settings + CONSOLE_SCREEN_BUFFER_INFO info; + if (!GetConsoleScreenBufferInfo(hTerminal, &info)) + return; + + if (foreground != -1) { + info.wAttributes &= ~(info.wAttributes & 0x0F); + info.wAttributes |= static_cast(foreground); + } + + if (background != -1) { + info.wAttributes &= ~(info.wAttributes & 0xF0); + info.wAttributes |= static_cast(background); + } + + SetConsoleTextAttribute(hTerminal, info.wAttributes); +} +#endif // TERMCOLOR_OS_WINDOWS + +} // namespace _internal + +} // namespace termcolor + +#undef TERMCOLOR_OS_WINDOWS +#undef TERMCOLOR_OS_MACOS +#undef TERMCOLOR_OS_LINUX + +#endif // TERMCOLOR_HPP_ diff --git a/libs/tabulate/utf8.hpp b/libs/tabulate/utf8.hpp index 622e931..cb198e8 100644 --- a/libs/tabulate/utf8.hpp +++ b/libs/tabulate/utf8.hpp @@ -1,93 +1,93 @@ - -/* - __ ___. .__ __ -_/ |______ \_ |__ __ __| | _____ _/ |_ ____ -\ __\__ \ | __ \| | \ | \__ \\ __\/ __ \ - | | / __ \| \_\ \ | / |__/ __ \| | \ ___/ - |__| (____ /___ /____/|____(____ /__| \___ > - \/ \/ \/ \/ -Table Maker for Modern C++ -https://github.com/p-ranav/tabulate - -Licensed under the MIT License . -SPDX-License-Identifier: MIT -Copyright (c) 2019 Pranav Srinivas Kumar . - -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. -*/ -#pragma once -#include -#include -#include - -#include -#include - -#include -#include -#include - -namespace tabulate { - -#if defined(__unix__) || defined(__unix) || defined(__APPLE__) -inline int get_wcswidth(const std::string &string, const std::string &locale, - size_t max_column_width) { - if (string.size() == 0) - return 0; - - // The behavior of wcswidth() depends on the LC_CTYPE category of the current - // locale. Set the current locale based on cell properties before computing - // width - auto old_locale = std::locale::global(std::locale(locale)); - - // Convert from narrow std::string to wide string - wchar_t *wide_string = new wchar_t[string.size()]; - std::mbstowcs(wide_string, string.c_str(), string.size()); - - // Compute display width of wide string - int result = wcswidth(wide_string, max_column_width); - delete[] wide_string; - - // Restore old locale - std::locale::global(old_locale); - - return result; -} -#endif - -inline size_t get_sequence_length(const std::string &text, const std::string &locale, - bool is_multi_byte_character_support_enabled) { - if (!is_multi_byte_character_support_enabled) - return text.length(); - -#if defined(_WIN32) || defined(_WIN64) - (void)locale; // unused parameter - return (text.length() - std::count_if(text.begin(), text.end(), - [](char c) -> bool { return (c & 0xC0) == 0x80; })); -#elif defined(__unix__) || defined(__unix) || defined(__APPLE__) - auto result = get_wcswidth(text, locale, text.size()); - if (result >= 0) - return result; - else - return (text.length() - std::count_if(text.begin(), text.end(), - [](char c) -> bool { return (c & 0xC0) == 0x80; })); -#endif -} - -} // namespace tabulate + +/* + __ ___. .__ __ +_/ |______ \_ |__ __ __| | _____ _/ |_ ____ +\ __\__ \ | __ \| | \ | \__ \\ __\/ __ \ + | | / __ \| \_\ \ | / |__/ __ \| | \ ___/ + |__| (____ /___ /____/|____(____ /__| \___ > + \/ \/ \/ \/ +Table Maker for Modern C++ +https://github.com/p-ranav/tabulate + +Licensed under the MIT License . +SPDX-License-Identifier: MIT +Copyright (c) 2019 Pranav Srinivas Kumar . + +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. +*/ +#pragma once +#include +#include +#include + +#include +#include + +#include +#include +#include + +namespace tabulate { + +#if defined(__unix__) || defined(__unix) || defined(__APPLE__) +inline int get_wcswidth(const std::string &string, const std::string &locale, + size_t max_column_width) { + if (string.size() == 0) + return 0; + + // The behavior of wcswidth() depends on the LC_CTYPE category of the current + // locale. Set the current locale based on cell properties before computing + // width + auto old_locale = std::locale::global(std::locale(locale)); + + // Convert from narrow std::string to wide string + wchar_t *wide_string = new wchar_t[string.size()]; + std::mbstowcs(wide_string, string.c_str(), string.size()); + + // Compute display width of wide string + int result = wcswidth(wide_string, max_column_width); + delete[] wide_string; + + // Restore old locale + std::locale::global(old_locale); + + return result; +} +#endif + +inline size_t get_sequence_length(const std::string &text, const std::string &locale, + bool is_multi_byte_character_support_enabled) { + if (!is_multi_byte_character_support_enabled) + return text.length(); + +#if defined(_WIN32) || defined(_WIN64) + (void)locale; // unused parameter + return (text.length() - std::count_if(text.begin(), text.end(), + [](char c) -> bool { return (c & 0xC0) == 0x80; })); +#elif defined(__unix__) || defined(__unix) || defined(__APPLE__) + auto result = get_wcswidth(text, locale, text.size()); + if (result >= 0) + return result; + else + return (text.length() - std::count_if(text.begin(), text.end(), + [](char c) -> bool { return (c & 0xC0) == 0x80; })); +#endif +} + +} // namespace tabulate diff --git a/libs/tabulate/variant_lite.hpp b/libs/tabulate/variant_lite.hpp index b0c147d..0f8b2d2 100644 --- a/libs/tabulate/variant_lite.hpp +++ b/libs/tabulate/variant_lite.hpp @@ -1,2485 +1,2485 @@ -// Copyright 2016-2018 by Martin Moene -// -// https://github.com/martinmoene/variant-lite -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#pragma once - -#ifndef NONSTD_VARIANT_LITE_HPP -#define NONSTD_VARIANT_LITE_HPP - -#define variant_lite_MAJOR 1 -#define variant_lite_MINOR 2 -#define variant_lite_PATCH 2 - -#define variant_lite_VERSION \ - variant_STRINGIFY(variant_lite_MAJOR) "." variant_STRINGIFY( \ - variant_lite_MINOR) "." variant_STRINGIFY(variant_lite_PATCH) - -#define variant_STRINGIFY(x) variant_STRINGIFY_(x) -#define variant_STRINGIFY_(x) #x - -// variant-lite configuration: - -#define variant_VARIANT_DEFAULT 0 -#define variant_VARIANT_NONSTD 1 -#define variant_VARIANT_STD 2 - -#if !defined(variant_CONFIG_SELECT_VARIANT) -#define variant_CONFIG_SELECT_VARIANT \ - (variant_HAVE_STD_VARIANT ? variant_VARIANT_STD : variant_VARIANT_NONSTD) -#endif - -#ifndef variant_CONFIG_OMIT_VARIANT_SIZE_V_MACRO -#define variant_CONFIG_OMIT_VARIANT_SIZE_V_MACRO 0 -#endif - -#ifndef variant_CONFIG_OMIT_VARIANT_ALTERNATIVE_T_MACRO -#define variant_CONFIG_OMIT_VARIANT_ALTERNATIVE_T_MACRO 0 -#endif - -// Control presence of exception handling (try and auto discover): - -#ifndef variant_CONFIG_NO_EXCEPTIONS -#if defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND) -#define variant_CONFIG_NO_EXCEPTIONS 0 -#else -#define variant_CONFIG_NO_EXCEPTIONS 1 -#endif -#endif - -// C++ language version detection (C++20 is speculative): -// Note: VC14.0/1900 (VS2015) lacks too much from C++14. - -#ifndef variant_CPLUSPLUS -#if defined(_MSVC_LANG) && !defined(__clang__) -#define variant_CPLUSPLUS (_MSC_VER == 1900 ? 201103L : _MSVC_LANG) -#else -#define variant_CPLUSPLUS __cplusplus -#endif -#endif - -#define variant_CPP98_OR_GREATER (variant_CPLUSPLUS >= 199711L) -#define variant_CPP11_OR_GREATER (variant_CPLUSPLUS >= 201103L) -#define variant_CPP11_OR_GREATER_ (variant_CPLUSPLUS >= 201103L) -#define variant_CPP14_OR_GREATER (variant_CPLUSPLUS >= 201402L) -#define variant_CPP17_OR_GREATER (variant_CPLUSPLUS >= 201703L) -#define variant_CPP20_OR_GREATER (variant_CPLUSPLUS >= 202000L) - -// Use C++17 std::variant if available and requested: - -#if variant_CPP17_OR_GREATER && defined(__has_include) -#if __has_include( ) -#define variant_HAVE_STD_VARIANT 1 -#else -#define variant_HAVE_STD_VARIANT 0 -#endif -#else -#define variant_HAVE_STD_VARIANT 0 -#endif - -#define variant_USES_STD_VARIANT \ - ((variant_CONFIG_SELECT_VARIANT == variant_VARIANT_STD) || \ - ((variant_CONFIG_SELECT_VARIANT == variant_VARIANT_DEFAULT) && variant_HAVE_STD_VARIANT)) - -// -// in_place: code duplicated in any-lite, expected-lite, optional-lite, value-ptr-lite, -// variant-lite: -// - -#ifndef nonstd_lite_HAVE_IN_PLACE_TYPES -#define nonstd_lite_HAVE_IN_PLACE_TYPES 1 - -// C++17 std::in_place in : - -#if variant_CPP17_OR_GREATER - -#include - -namespace nonstd { - -using std::in_place; -using std::in_place_index; -using std::in_place_index_t; -using std::in_place_t; -using std::in_place_type; -using std::in_place_type_t; - -#define nonstd_lite_in_place_t(T) std::in_place_t -#define nonstd_lite_in_place_type_t(T) std::in_place_type_t -#define nonstd_lite_in_place_index_t(K) std::in_place_index_t - -#define nonstd_lite_in_place(T) \ - std::in_place_t {} -#define nonstd_lite_in_place_type(T) \ - std::in_place_type_t {} -#define nonstd_lite_in_place_index(K) \ - std::in_place_index_t {} - -} // namespace nonstd - -#else // variant_CPP17_OR_GREATER - -#include - -namespace nonstd { -namespace detail { - -template struct in_place_type_tag {}; - -template struct in_place_index_tag {}; - -} // namespace detail - -struct in_place_t {}; - -template -inline in_place_t in_place(detail::in_place_type_tag = detail::in_place_type_tag()) { - return in_place_t(); -} - -template -inline in_place_t in_place(detail::in_place_index_tag = detail::in_place_index_tag()) { - return in_place_t(); -} - -template -inline in_place_t in_place_type(detail::in_place_type_tag = detail::in_place_type_tag()) { - return in_place_t(); -} - -template -inline in_place_t in_place_index(detail::in_place_index_tag = detail::in_place_index_tag()) { - return in_place_t(); -} - -// mimic templated typedef: - -#define nonstd_lite_in_place_t(T) nonstd::in_place_t (&)(nonstd::detail::in_place_type_tag) -#define nonstd_lite_in_place_type_t(T) nonstd::in_place_t (&)(nonstd::detail::in_place_type_tag) -#define nonstd_lite_in_place_index_t(K) \ - nonstd::in_place_t (&)(nonstd::detail::in_place_index_tag) - -#define nonstd_lite_in_place(T) nonstd::in_place_type -#define nonstd_lite_in_place_type(T) nonstd::in_place_type -#define nonstd_lite_in_place_index(K) nonstd::in_place_index - -} // namespace nonstd - -#endif // variant_CPP17_OR_GREATER -#endif // nonstd_lite_HAVE_IN_PLACE_TYPES - -// -// Use C++17 std::variant: -// - -#if variant_USES_STD_VARIANT - -#include // std::hash<> -#include - -#if !variant_CONFIG_OMIT_VARIANT_SIZE_V_MACRO -#define variant_size_V(T) nonstd::variant_size::value -#endif - -#if !variant_CONFIG_OMIT_VARIANT_ALTERNATIVE_T_MACRO -#define variant_alternative_T(K, T) typename nonstd::variant_alternative::type -#endif - -namespace nonstd { - -using std::bad_variant_access; -using std::hash; -using std::monostate; -using std::variant; -using std::variant_alternative; -using std::variant_alternative_t; -using std::variant_size; -using std::variant_size_v; - -using std::get; -using std::get_if; -using std::holds_alternative; -using std::visit; -using std::operator==; -using std::operator!=; -using std::operator<; -using std::operator<=; -using std::operator>; -using std::operator>=; -using std::swap; - -constexpr auto variant_npos = std::variant_npos; -} // namespace nonstd - -#else // variant_USES_STD_VARIANT - -#include -#include -#include -#include - -#if variant_CONFIG_NO_EXCEPTIONS -#include -#else -#include -#endif - -// variant-lite type and visitor argument count configuration (script/generate_header.py): - -#define variant_CONFIG_MAX_TYPE_COUNT 16 -#define variant_CONFIG_MAX_VISITOR_ARG_COUNT 5 - -// variant-lite alignment configuration: - -#ifndef variant_CONFIG_MAX_ALIGN_HACK -#define variant_CONFIG_MAX_ALIGN_HACK 0 -#endif - -#ifndef variant_CONFIG_ALIGN_AS -// no default, used in #if defined() -#endif - -#ifndef variant_CONFIG_ALIGN_AS_FALLBACK -#define variant_CONFIG_ALIGN_AS_FALLBACK double -#endif - -// half-open range [lo..hi): -#define variant_BETWEEN(v, lo, hi) ((lo) <= (v) && (v) < (hi)) - -// Compiler versions: -// -// MSVC++ 6.0 _MSC_VER == 1200 variant_COMPILER_MSVC_VERSION == 60 (Visual Studio 6.0) -// MSVC++ 7.0 _MSC_VER == 1300 variant_COMPILER_MSVC_VERSION == 70 (Visual Studio .NET 2002) -// MSVC++ 7.1 _MSC_VER == 1310 variant_COMPILER_MSVC_VERSION == 71 (Visual Studio .NET 2003) -// MSVC++ 8.0 _MSC_VER == 1400 variant_COMPILER_MSVC_VERSION == 80 (Visual Studio 2005) -// MSVC++ 9.0 _MSC_VER == 1500 variant_COMPILER_MSVC_VERSION == 90 (Visual Studio 2008) -// MSVC++ 10.0 _MSC_VER == 1600 variant_COMPILER_MSVC_VERSION == 100 (Visual Studio 2010) -// MSVC++ 11.0 _MSC_VER == 1700 variant_COMPILER_MSVC_VERSION == 110 (Visual Studio 2012) -// MSVC++ 12.0 _MSC_VER == 1800 variant_COMPILER_MSVC_VERSION == 120 (Visual Studio 2013) -// MSVC++ 14.0 _MSC_VER == 1900 variant_COMPILER_MSVC_VERSION == 140 (Visual Studio 2015) -// MSVC++ 14.1 _MSC_VER >= 1910 variant_COMPILER_MSVC_VERSION == 141 (Visual Studio 2017) -// MSVC++ 14.2 _MSC_VER >= 1920 variant_COMPILER_MSVC_VERSION == 142 (Visual Studio 2019) - -#if defined(_MSC_VER) && !defined(__clang__) -#define variant_COMPILER_MSVC_VER (_MSC_VER) -#define variant_COMPILER_MSVC_VERSION (_MSC_VER / 10 - 10 * (5 + (_MSC_VER < 1900))) -#else -#define variant_COMPILER_MSVC_VER 0 -#define variant_COMPILER_MSVC_VERSION 0 -#endif - -#define variant_COMPILER_VERSION(major, minor, patch) (10 * (10 * (major) + (minor)) + (patch)) - -#if defined(__clang__) -#define variant_COMPILER_CLANG_VERSION \ - variant_COMPILER_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__) -#else -#define variant_COMPILER_CLANG_VERSION 0 -#endif - -#if defined(__GNUC__) && !defined(__clang__) -#define variant_COMPILER_GNUC_VERSION \ - variant_COMPILER_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) -#else -#define variant_COMPILER_GNUC_VERSION 0 -#endif - -#if variant_BETWEEN(variant_COMPILER_MSVC_VER, 1300, 1900) -#pragma warning(push) -#pragma warning(disable : 4345) // initialization behavior changed -#endif - -// Presence of language and library features: - -#define variant_HAVE(feature) (variant_HAVE_##feature) - -#ifdef _HAS_CPP0X -#define variant_HAS_CPP0X _HAS_CPP0X -#else -#define variant_HAS_CPP0X 0 -#endif - -// Unless defined otherwise below, consider VC14 as C++11 for variant-lite: - -#if variant_COMPILER_MSVC_VER >= 1900 -#undef variant_CPP11_OR_GREATER -#define variant_CPP11_OR_GREATER 1 -#endif - -#define variant_CPP11_90 (variant_CPP11_OR_GREATER_ || variant_COMPILER_MSVC_VER >= 1500) -#define variant_CPP11_100 (variant_CPP11_OR_GREATER_ || variant_COMPILER_MSVC_VER >= 1600) -#define variant_CPP11_110 (variant_CPP11_OR_GREATER_ || variant_COMPILER_MSVC_VER >= 1700) -#define variant_CPP11_120 (variant_CPP11_OR_GREATER_ || variant_COMPILER_MSVC_VER >= 1800) -#define variant_CPP11_140 (variant_CPP11_OR_GREATER_ || variant_COMPILER_MSVC_VER >= 1900) -#define variant_CPP11_141 (variant_CPP11_OR_GREATER_ || variant_COMPILER_MSVC_VER >= 1910) - -#define variant_CPP14_000 (variant_CPP14_OR_GREATER) -#define variant_CPP17_000 (variant_CPP17_OR_GREATER) - -// Presence of C++11 language features: - -#define variant_HAVE_CONSTEXPR_11 variant_CPP11_140 -#define variant_HAVE_INITIALIZER_LIST variant_CPP11_120 -#define variant_HAVE_NOEXCEPT variant_CPP11_140 -#define variant_HAVE_NULLPTR variant_CPP11_100 -#define variant_HAVE_OVERRIDE variant_CPP11_140 - -// Presence of C++14 language features: - -#define variant_HAVE_CONSTEXPR_14 variant_CPP14_000 - -// Presence of C++17 language features: - -// no flag - -// Presence of C++ library features: - -#define variant_HAVE_CONDITIONAL variant_CPP11_120 -#define variant_HAVE_REMOVE_CV variant_CPP11_120 -#define variant_HAVE_STD_ADD_POINTER variant_CPP11_90 -#define variant_HAVE_TYPE_TRAITS variant_CPP11_90 - -#define variant_HAVE_TR1_TYPE_TRAITS (!!variant_COMPILER_GNUC_VERSION) -#define variant_HAVE_TR1_ADD_POINTER (!!variant_COMPILER_GNUC_VERSION) - -// C++ feature usage: - -#if variant_HAVE_CONSTEXPR_11 -#define variant_constexpr constexpr -#else -#define variant_constexpr /*constexpr*/ -#endif - -#if variant_HAVE_CONSTEXPR_14 -#define variant_constexpr14 constexpr -#else -#define variant_constexpr14 /*constexpr*/ -#endif - -#if variant_HAVE_NOEXCEPT -#define variant_noexcept noexcept -#else -#define variant_noexcept /*noexcept*/ -#endif - -#if variant_HAVE_NULLPTR -#define variant_nullptr nullptr -#else -#define variant_nullptr NULL -#endif - -#if variant_HAVE_OVERRIDE -#define variant_override override -#else -#define variant_override /*override*/ -#endif - -// additional includes: - -#if variant_CPP11_OR_GREATER -#include // std::hash -#endif - -#if variant_HAVE_INITIALIZER_LIST -#include -#endif - -#if variant_HAVE_TYPE_TRAITS -#include -#elif variant_HAVE_TR1_TYPE_TRAITS -#include -#endif - -// Method enabling - -#if variant_CPP11_OR_GREATER - -#define variant_REQUIRES_0(...) \ - template ::type = 0> - -#define variant_REQUIRES_T(...) , typename std::enable_if<(__VA_ARGS__), int>::type = 0 - -#define variant_REQUIRES_R(R, ...) typename std::enable_if<(__VA_ARGS__), R>::type - -#define variant_REQUIRES_A(...) , typename std::enable_if<(__VA_ARGS__), void *>::type = nullptr - -#endif - -// -// variant: -// - -namespace nonstd { -namespace variants { - -// C++11 emulation: - -namespace std11 { - -#if variant_HAVE_STD_ADD_POINTER - -using std::add_pointer; - -#elif variant_HAVE_TR1_ADD_POINTER - -using std::tr1::add_pointer; - -#else - -template struct remove_reference { typedef T type; }; -template struct remove_reference { typedef T type; }; - -template struct add_pointer { typedef typename remove_reference::type *type; }; - -#endif // variant_HAVE_STD_ADD_POINTER - -#if variant_HAVE_REMOVE_CV - -using std::remove_cv; - -#else - -template struct remove_const { typedef T type; }; -template struct remove_const { typedef T type; }; - -template struct remove_volatile { typedef T type; }; -template struct remove_volatile { typedef T type; }; - -template struct remove_cv { - typedef typename remove_volatile::type>::type type; -}; - -#endif // variant_HAVE_REMOVE_CV - -#if variant_HAVE_CONDITIONAL - -using std::conditional; - -#else - -template struct conditional; - -template struct conditional { typedef Then type; }; - -template struct conditional { typedef Else type; }; - -#endif // variant_HAVE_CONDITIONAL - -} // namespace std11 - -/// type traits C++17: - -namespace std17 { - -#if variant_CPP17_OR_GREATER - -using std::is_nothrow_swappable; -using std::is_swappable; - -#elif variant_CPP11_OR_GREATER - -namespace detail { - -using std::swap; - -struct is_swappable { - template (), std::declval()))> - static std::true_type test(int); - - template static std::false_type test(...); -}; - -struct is_nothrow_swappable { - // wrap noexcept(epr) in separate function as work-around for VC140 (VS2015): - - template static constexpr bool test() { - return noexcept(swap(std::declval(), std::declval())); - } - - template static auto test(int) -> std::integral_constant()> {} - - template static std::false_type test(...); -}; - -} // namespace detail - -// is [nothow] swappable: - -template struct is_swappable : decltype(detail::is_swappable::test(0)) {}; - -template -struct is_nothrow_swappable : decltype(detail::is_nothrow_swappable::test(0)) {}; - -#endif // variant_CPP17_OR_GREATER - -} // namespace std17 - -// detail: - -namespace detail { - -// typelist: - -#define variant_TL1(T1) detail::typelist -#define variant_TL2(T1, T2) detail::typelist -#define variant_TL3(T1, T2, T3) detail::typelist -#define variant_TL4(T1, T2, T3, T4) detail::typelist -#define variant_TL5(T1, T2, T3, T4, T5) detail::typelist -#define variant_TL6(T1, T2, T3, T4, T5, T6) detail::typelist -#define variant_TL7(T1, T2, T3, T4, T5, T6, T7) \ - detail::typelist -#define variant_TL8(T1, T2, T3, T4, T5, T6, T7, T8) \ - detail::typelist -#define variant_TL9(T1, T2, T3, T4, T5, T6, T7, T8, T9) \ - detail::typelist -#define variant_TL10(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) \ - detail::typelist -#define variant_TL11(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) \ - detail::typelist -#define variant_TL12(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) \ - detail::typelist -#define variant_TL13(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) \ - detail::typelist -#define variant_TL14(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) \ - detail::typelist -#define variant_TL15(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) \ - detail::typelist -#define variant_TL16(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16) \ - detail::typelist - -// variant parameter unused type tags: - -template struct TX : T { - inline TX operator+() const { return TX(); } - inline TX operator-() const { return TX(); } - - inline TX operator!() const { return TX(); } - inline TX operator~() const { return TX(); } - - inline TX *operator&() const { return variant_nullptr; } - - template inline TX operator*(U const &)const { return TX(); } - template inline TX operator/(U const &) const { return TX(); } - - template inline TX operator%(U const &) const { return TX(); } - template inline TX operator+(U const &) const { return TX(); } - template inline TX operator-(U const &) const { return TX(); } - - template inline TX operator<<(U const &) const { return TX(); } - template inline TX operator>>(U const &) const { return TX(); } - - inline bool operator==(T const &) const { return false; } - inline bool operator<(T const &) const { return false; } - - template inline TX operator&(U const &)const { return TX(); } - template inline TX operator|(U const &) const { return TX(); } - template inline TX operator^(U const &) const { return TX(); } - - template inline TX operator&&(U const &) const { return TX(); } - template inline TX operator||(U const &) const { return TX(); } -}; - -struct S0 {}; -typedef TX T0; -struct S1 {}; -typedef TX T1; -struct S2 {}; -typedef TX T2; -struct S3 {}; -typedef TX T3; -struct S4 {}; -typedef TX T4; -struct S5 {}; -typedef TX T5; -struct S6 {}; -typedef TX T6; -struct S7 {}; -typedef TX T7; -struct S8 {}; -typedef TX T8; -struct S9 {}; -typedef TX T9; -struct S10 {}; -typedef TX T10; -struct S11 {}; -typedef TX T11; -struct S12 {}; -typedef TX T12; -struct S13 {}; -typedef TX T13; -struct S14 {}; -typedef TX T14; -struct S15 {}; -typedef TX T15; - -struct nulltype {}; - -template struct typelist { - typedef Head head; - typedef Tail tail; -}; - -// typelist max element size: - -template struct typelist_max; - -template <> struct typelist_max { - enum V { value = 0 }; - typedef void type; -}; - -template struct typelist_max> { -private: - enum TV { tail_value = size_t(typelist_max::value) }; - - typedef typename typelist_max::type tail_type; - -public: - enum V { value = (sizeof(Head) > tail_value) ? sizeof(Head) : std::size_t(tail_value) }; - - typedef typename std11::conditional<(sizeof(Head) > tail_value), Head, tail_type>::type type; -}; - -#if variant_CPP11_OR_GREATER - -// typelist max alignof element type: - -template struct typelist_max_alignof; - -template <> struct typelist_max_alignof { - enum V { value = 0 }; -}; - -template struct typelist_max_alignof> { -private: - enum TV { tail_value = size_t(typelist_max_alignof::value) }; - -public: - enum V { value = (alignof(Head) > tail_value) ? alignof(Head) : std::size_t(tail_value) }; -}; - -#endif - -// typelist size (length): - -template struct typelist_size { - enum V { value = 1 }; -}; - -template <> struct typelist_size { - enum V { value = 0 }; -}; -template <> struct typelist_size { - enum V { value = 0 }; -}; -template <> struct typelist_size { - enum V { value = 0 }; -}; -template <> struct typelist_size { - enum V { value = 0 }; -}; -template <> struct typelist_size { - enum V { value = 0 }; -}; -template <> struct typelist_size { - enum V { value = 0 }; -}; -template <> struct typelist_size { - enum V { value = 0 }; -}; -template <> struct typelist_size { - enum V { value = 0 }; -}; -template <> struct typelist_size { - enum V { value = 0 }; -}; -template <> struct typelist_size { - enum V { value = 0 }; -}; -template <> struct typelist_size { - enum V { value = 0 }; -}; -template <> struct typelist_size { - enum V { value = 0 }; -}; -template <> struct typelist_size { - enum V { value = 0 }; -}; -template <> struct typelist_size { - enum V { value = 0 }; -}; -template <> struct typelist_size { - enum V { value = 0 }; -}; -template <> struct typelist_size { - enum V { value = 0 }; -}; - -template <> struct typelist_size { - enum V { value = 0 }; -}; - -template struct typelist_size> { - enum V { value = typelist_size::value + typelist_size::value }; -}; - -// typelist index of type: - -template struct typelist_index_of; - -template struct typelist_index_of { - enum V { value = -1 }; -}; - -template struct typelist_index_of, T> { - enum V { value = 0 }; -}; - -template struct typelist_index_of, T> { -private: - enum TV { nextVal = typelist_index_of::value }; - -public: - enum V { value = nextVal == -1 ? -1 : 1 + nextVal }; -}; - -// typelist type at index: - -template struct typelist_type_at; - -template struct typelist_type_at, 0> { - typedef Head type; -}; - -template struct typelist_type_at, i> { - typedef typename typelist_type_at::type type; -}; - -#if variant_CONFIG_MAX_ALIGN_HACK - -// Max align, use most restricted type for alignment: - -#define variant_UNIQUE(name) variant_UNIQUE2(name, __LINE__) -#define variant_UNIQUE2(name, line) variant_UNIQUE3(name, line) -#define variant_UNIQUE3(name, line) name##line - -#define variant_ALIGN_TYPE(type) \ - type variant_UNIQUE(_t); \ - struct_t variant_UNIQUE(_st) - -template struct struct_t { T _; }; - -union max_align_t { - variant_ALIGN_TYPE(char); - variant_ALIGN_TYPE(short int); - variant_ALIGN_TYPE(int); - variant_ALIGN_TYPE(long int); - variant_ALIGN_TYPE(float); - variant_ALIGN_TYPE(double); - variant_ALIGN_TYPE(long double); - variant_ALIGN_TYPE(char *); - variant_ALIGN_TYPE(short int *); - variant_ALIGN_TYPE(int *); - variant_ALIGN_TYPE(long int *); - variant_ALIGN_TYPE(float *); - variant_ALIGN_TYPE(double *); - variant_ALIGN_TYPE(long double *); - variant_ALIGN_TYPE(void *); - -#ifdef HAVE_LONG_LONG - variant_ALIGN_TYPE(long long); -#endif - - struct Unknown; - - Unknown (*variant_UNIQUE(_))(Unknown); - Unknown *Unknown::*variant_UNIQUE(_); - Unknown (Unknown::*variant_UNIQUE(_))(Unknown); - - struct_t variant_UNIQUE(_); - struct_t variant_UNIQUE(_); - struct_t variant_UNIQUE(_); -}; - -#undef variant_UNIQUE -#undef variant_UNIQUE2 -#undef variant_UNIQUE3 - -#undef variant_ALIGN_TYPE - -#elif defined(variant_CONFIG_ALIGN_AS) // variant_CONFIG_MAX_ALIGN_HACK - -// Use user-specified type for alignment: - -#define variant_ALIGN_AS(unused) variant_CONFIG_ALIGN_AS - -#else // variant_CONFIG_MAX_ALIGN_HACK - -// Determine POD type to use for alignment: - -#define variant_ALIGN_AS(to_align) \ - typename detail::type_of_size::value>::type - -template struct alignment_of; - -template struct alignment_of_hack { - char c; - T t; - alignment_of_hack(); -}; - -template struct alignment_logic { - enum V { value = A < S ? A : S }; -}; - -template struct alignment_of { - enum V { value = alignment_logic) - sizeof(T), sizeof(T)>::value }; -}; - -template struct type_of_size { - typedef - typename std11::conditional::type>::type type; -}; - -template struct type_of_size { - typedef variant_CONFIG_ALIGN_AS_FALLBACK type; -}; - -template struct struct_t { T _; }; - -#define variant_ALIGN_TYPE(type) typelist < type, typelist < struct_t - -struct Unknown; - -typedef variant_ALIGN_TYPE(char), variant_ALIGN_TYPE(short), variant_ALIGN_TYPE(int), - variant_ALIGN_TYPE(long), variant_ALIGN_TYPE(float), variant_ALIGN_TYPE(double), - variant_ALIGN_TYPE(long double), - - variant_ALIGN_TYPE(char *), variant_ALIGN_TYPE(short *), variant_ALIGN_TYPE(int *), - variant_ALIGN_TYPE(long *), variant_ALIGN_TYPE(float *), variant_ALIGN_TYPE(double *), - variant_ALIGN_TYPE(long double *), - - variant_ALIGN_TYPE(Unknown (*)(Unknown)), variant_ALIGN_TYPE(Unknown *Unknown::*), - variant_ALIGN_TYPE(Unknown (Unknown::*)(Unknown)), - - nulltype >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> alignment_types; - -#undef variant_ALIGN_TYPE - -#endif // variant_CONFIG_MAX_ALIGN_HACK - -#if variant_CPP11_OR_GREATER - -template inline std::size_t hash(T const &v) { return std::hash()(v); } - -inline std::size_t hash(T0 const &) { return 0; } -inline std::size_t hash(T1 const &) { return 0; } -inline std::size_t hash(T2 const &) { return 0; } -inline std::size_t hash(T3 const &) { return 0; } -inline std::size_t hash(T4 const &) { return 0; } -inline std::size_t hash(T5 const &) { return 0; } -inline std::size_t hash(T6 const &) { return 0; } -inline std::size_t hash(T7 const &) { return 0; } -inline std::size_t hash(T8 const &) { return 0; } -inline std::size_t hash(T9 const &) { return 0; } -inline std::size_t hash(T10 const &) { return 0; } -inline std::size_t hash(T11 const &) { return 0; } -inline std::size_t hash(T12 const &) { return 0; } -inline std::size_t hash(T13 const &) { return 0; } -inline std::size_t hash(T14 const &) { return 0; } -inline std::size_t hash(T15 const &) { return 0; } - -#endif // variant_CPP11_OR_GREATER - -template -struct helper { - typedef signed char type_index_t; - typedef variant_TL16(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, - T15) variant_types; - - template static U *as(void *data) { return reinterpret_cast(data); } - - template static U const *as(void const *data) { - return reinterpret_cast(data); - } - - static type_index_t to_index_t(std::size_t index) { return static_cast(index); } - - static void destroy(type_index_t index, void *data) { - switch (index) { - case 0: - as(data)->~T0(); - break; - case 1: - as(data)->~T1(); - break; - case 2: - as(data)->~T2(); - break; - case 3: - as(data)->~T3(); - break; - case 4: - as(data)->~T4(); - break; - case 5: - as(data)->~T5(); - break; - case 6: - as(data)->~T6(); - break; - case 7: - as(data)->~T7(); - break; - case 8: - as(data)->~T8(); - break; - case 9: - as(data)->~T9(); - break; - case 10: - as(data)->~T10(); - break; - case 11: - as(data)->~T11(); - break; - case 12: - as(data)->~T12(); - break; - case 13: - as(data)->~T13(); - break; - case 14: - as(data)->~T14(); - break; - case 15: - as(data)->~T15(); - break; - } - } - -#if variant_CPP11_OR_GREATER - template static type_index_t construct_t(void *data, Args &&... args) { - new (data) T(std::forward(args)...); - - return to_index_t(detail::typelist_index_of::value); - } - - template - static type_index_t construct_i(void *data, Args &&... args) { - using type = typename detail::typelist_type_at::type; - - construct_t(data, std::forward(args)...); - - return to_index_t(K); - } - - static type_index_t move_construct(type_index_t const from_index, void *from_value, - void *to_value) { - switch (from_index) { - case 0: - new (to_value) T0(std::move(*as(from_value))); - break; - case 1: - new (to_value) T1(std::move(*as(from_value))); - break; - case 2: - new (to_value) T2(std::move(*as(from_value))); - break; - case 3: - new (to_value) T3(std::move(*as(from_value))); - break; - case 4: - new (to_value) T4(std::move(*as(from_value))); - break; - case 5: - new (to_value) T5(std::move(*as(from_value))); - break; - case 6: - new (to_value) T6(std::move(*as(from_value))); - break; - case 7: - new (to_value) T7(std::move(*as(from_value))); - break; - case 8: - new (to_value) T8(std::move(*as(from_value))); - break; - case 9: - new (to_value) T9(std::move(*as(from_value))); - break; - case 10: - new (to_value) T10(std::move(*as(from_value))); - break; - case 11: - new (to_value) T11(std::move(*as(from_value))); - break; - case 12: - new (to_value) T12(std::move(*as(from_value))); - break; - case 13: - new (to_value) T13(std::move(*as(from_value))); - break; - case 14: - new (to_value) T14(std::move(*as(from_value))); - break; - case 15: - new (to_value) T15(std::move(*as(from_value))); - break; - } - return from_index; - } - - static type_index_t move_assign(type_index_t const from_index, void *from_value, void *to_value) { - switch (from_index) { - case 0: - *as(to_value) = std::move(*as(from_value)); - break; - case 1: - *as(to_value) = std::move(*as(from_value)); - break; - case 2: - *as(to_value) = std::move(*as(from_value)); - break; - case 3: - *as(to_value) = std::move(*as(from_value)); - break; - case 4: - *as(to_value) = std::move(*as(from_value)); - break; - case 5: - *as(to_value) = std::move(*as(from_value)); - break; - case 6: - *as(to_value) = std::move(*as(from_value)); - break; - case 7: - *as(to_value) = std::move(*as(from_value)); - break; - case 8: - *as(to_value) = std::move(*as(from_value)); - break; - case 9: - *as(to_value) = std::move(*as(from_value)); - break; - case 10: - *as(to_value) = std::move(*as(from_value)); - break; - case 11: - *as(to_value) = std::move(*as(from_value)); - break; - case 12: - *as(to_value) = std::move(*as(from_value)); - break; - case 13: - *as(to_value) = std::move(*as(from_value)); - break; - case 14: - *as(to_value) = std::move(*as(from_value)); - break; - case 15: - *as(to_value) = std::move(*as(from_value)); - break; - } - return from_index; - } -#endif - - static type_index_t copy_construct(type_index_t const from_index, const void *from_value, - void *to_value) { - switch (from_index) { - case 0: - new (to_value) T0(*as(from_value)); - break; - case 1: - new (to_value) T1(*as(from_value)); - break; - case 2: - new (to_value) T2(*as(from_value)); - break; - case 3: - new (to_value) T3(*as(from_value)); - break; - case 4: - new (to_value) T4(*as(from_value)); - break; - case 5: - new (to_value) T5(*as(from_value)); - break; - case 6: - new (to_value) T6(*as(from_value)); - break; - case 7: - new (to_value) T7(*as(from_value)); - break; - case 8: - new (to_value) T8(*as(from_value)); - break; - case 9: - new (to_value) T9(*as(from_value)); - break; - case 10: - new (to_value) T10(*as(from_value)); - break; - case 11: - new (to_value) T11(*as(from_value)); - break; - case 12: - new (to_value) T12(*as(from_value)); - break; - case 13: - new (to_value) T13(*as(from_value)); - break; - case 14: - new (to_value) T14(*as(from_value)); - break; - case 15: - new (to_value) T15(*as(from_value)); - break; - } - return from_index; - } - - static type_index_t copy_assign(type_index_t const from_index, const void *from_value, - void *to_value) { - switch (from_index) { - case 0: - *as(to_value) = *as(from_value); - break; - case 1: - *as(to_value) = *as(from_value); - break; - case 2: - *as(to_value) = *as(from_value); - break; - case 3: - *as(to_value) = *as(from_value); - break; - case 4: - *as(to_value) = *as(from_value); - break; - case 5: - *as(to_value) = *as(from_value); - break; - case 6: - *as(to_value) = *as(from_value); - break; - case 7: - *as(to_value) = *as(from_value); - break; - case 8: - *as(to_value) = *as(from_value); - break; - case 9: - *as(to_value) = *as(from_value); - break; - case 10: - *as(to_value) = *as(from_value); - break; - case 11: - *as(to_value) = *as(from_value); - break; - case 12: - *as(to_value) = *as(from_value); - break; - case 13: - *as(to_value) = *as(from_value); - break; - case 14: - *as(to_value) = *as(from_value); - break; - case 15: - *as(to_value) = *as(from_value); - break; - } - return from_index; - } -}; - -} // namespace detail - -// -// Variant: -// - -template -class variant; - -// 19.7.8 Class monostate - -class monostate {}; - -// 19.7.9 monostate relational operators - -inline variant_constexpr bool operator<(monostate, monostate) variant_noexcept { return false; } -inline variant_constexpr bool operator>(monostate, monostate) variant_noexcept { return false; } -inline variant_constexpr bool operator<=(monostate, monostate) variant_noexcept { return true; } -inline variant_constexpr bool operator>=(monostate, monostate) variant_noexcept { return true; } -inline variant_constexpr bool operator==(monostate, monostate) variant_noexcept { return true; } -inline variant_constexpr bool operator!=(monostate, monostate) variant_noexcept { return false; } - -// 19.7.4 variant helper classes - -// obtain the size of the variant's list of alternatives at compile time - -template struct variant_size; /* undefined */ - -template -struct variant_size> { - enum _ { - value = detail::typelist_size::value - }; -}; - -#if variant_CPP14_OR_GREATER -template constexpr std::size_t variant_size_v = variant_size::value; -#endif - -#if !variant_CONFIG_OMIT_VARIANT_SIZE_V_MACRO -#define variant_size_V(T) nonstd::variant_size::value -#endif - -// obtain the type of the alternative specified by its index, at compile time: - -template struct variant_alternative; /* undefined */ - -template -struct variant_alternative< - K, variant> { - typedef typename detail::typelist_type_at::type type; -}; - -#if variant_CPP11_OR_GREATER -template -using variant_alternative_t = typename variant_alternative::type; -#endif - -#if !variant_CONFIG_OMIT_VARIANT_ALTERNATIVE_T_MACRO -#define variant_alternative_T(K, T) typename nonstd::variant_alternative::type -#endif - -// NTS:implement specializes the std::uses_allocator type trait -// std::uses_allocator - -// index of the variant in the invalid state (constant) - -#if variant_CPP11_OR_GREATER -variant_constexpr std::size_t variant_npos = static_cast(-1); -#else -static const std::size_t variant_npos = static_cast(-1); -#endif - -#if !variant_CONFIG_NO_EXCEPTIONS - -// 19.7.11 Class bad_variant_access - -class bad_variant_access : public std::exception { -public: -#if variant_CPP11_OR_GREATER - virtual const char *what() const variant_noexcept variant_override -#else - virtual const char *what() const throw() -#endif - { - return "bad variant access"; - } -}; - -#endif // variant_CONFIG_NO_EXCEPTIONS - -// 19.7.3 Class template variant - -template -class variant { - typedef detail::helper - helper_type; - typedef variant_TL16(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, - T15) variant_types; - -public: - // 19.7.3.1 Constructors - - variant() : type_index(0) { new (ptr()) T0(); } - - variant(T0 const &t0) : type_index(0) { new (ptr()) T0(t0); } - variant(T1 const &t1) : type_index(1) { new (ptr()) T1(t1); } - variant(T2 const &t2) : type_index(2) { new (ptr()) T2(t2); } - variant(T3 const &t3) : type_index(3) { new (ptr()) T3(t3); } - variant(T4 const &t4) : type_index(4) { new (ptr()) T4(t4); } - variant(T5 const &t5) : type_index(5) { new (ptr()) T5(t5); } - variant(T6 const &t6) : type_index(6) { new (ptr()) T6(t6); } - variant(T7 const &t7) : type_index(7) { new (ptr()) T7(t7); } - variant(T8 const &t8) : type_index(8) { new (ptr()) T8(t8); } - variant(T9 const &t9) : type_index(9) { new (ptr()) T9(t9); } - variant(T10 const &t10) : type_index(10) { new (ptr()) T10(t10); } - variant(T11 const &t11) : type_index(11) { new (ptr()) T11(t11); } - variant(T12 const &t12) : type_index(12) { new (ptr()) T12(t12); } - variant(T13 const &t13) : type_index(13) { new (ptr()) T13(t13); } - variant(T14 const &t14) : type_index(14) { new (ptr()) T14(t14); } - variant(T15 const &t15) : type_index(15) { new (ptr()) T15(t15); } - -#if variant_CPP11_OR_GREATER - variant(T0 &&t0) : type_index(0) { new (ptr()) T0(std::move(t0)); } - variant(T1 &&t1) : type_index(1) { new (ptr()) T1(std::move(t1)); } - variant(T2 &&t2) : type_index(2) { new (ptr()) T2(std::move(t2)); } - variant(T3 &&t3) : type_index(3) { new (ptr()) T3(std::move(t3)); } - variant(T4 &&t4) : type_index(4) { new (ptr()) T4(std::move(t4)); } - variant(T5 &&t5) : type_index(5) { new (ptr()) T5(std::move(t5)); } - variant(T6 &&t6) : type_index(6) { new (ptr()) T6(std::move(t6)); } - variant(T7 &&t7) : type_index(7) { new (ptr()) T7(std::move(t7)); } - variant(T8 &&t8) : type_index(8) { new (ptr()) T8(std::move(t8)); } - variant(T9 &&t9) : type_index(9) { new (ptr()) T9(std::move(t9)); } - variant(T10 &&t10) : type_index(10) { new (ptr()) T10(std::move(t10)); } - variant(T11 &&t11) : type_index(11) { new (ptr()) T11(std::move(t11)); } - variant(T12 &&t12) : type_index(12) { new (ptr()) T12(std::move(t12)); } - variant(T13 &&t13) : type_index(13) { new (ptr()) T13(std::move(t13)); } - variant(T14 &&t14) : type_index(14) { new (ptr()) T14(std::move(t14)); } - variant(T15 &&t15) : type_index(15) { new (ptr()) T15(std::move(t15)); } - -#endif - - variant(variant const &other) : type_index(other.type_index) { - (void)helper_type::copy_construct(other.type_index, other.ptr(), ptr()); - } - -#if variant_CPP11_OR_GREATER - - variant(variant &&other) noexcept( - std::is_nothrow_move_constructible::value &&std::is_nothrow_move_constructible::value - &&std::is_nothrow_move_constructible::value &&std::is_nothrow_move_constructible< - T3>::value &&std::is_nothrow_move_constructible::value - &&std::is_nothrow_move_constructible::value &&std::is_nothrow_move_constructible< - T6>::value &&std::is_nothrow_move_constructible::value - &&std::is_nothrow_move_constructible::value - &&std::is_nothrow_move_constructible::value - &&std::is_nothrow_move_constructible::value - &&std::is_nothrow_move_constructible::value - &&std::is_nothrow_move_constructible::value - &&std::is_nothrow_move_constructible::value - &&std::is_nothrow_move_constructible::value - &&std::is_nothrow_move_constructible::value) - : type_index(other.type_index) { - (void)helper_type::move_construct(other.type_index, other.ptr(), ptr()); - } - - template - using type_at_t = typename detail::typelist_type_at::type; - - template ::value)> - explicit variant(nonstd_lite_in_place_type_t(T), Args &&... args) { - type_index = variant_npos_internal(); - type_index = helper_type::template construct_t(ptr(), std::forward(args)...); - } - - template &, Args...>::value)> - explicit variant(nonstd_lite_in_place_type_t(T), std::initializer_list il, Args &&... args) { - type_index = variant_npos_internal(); - type_index = helper_type::template construct_t(ptr(), il, std::forward(args)...); - } - - template , Args...>::value)> - explicit variant(nonstd_lite_in_place_index_t(K), Args &&... args) { - type_index = variant_npos_internal(); - type_index = helper_type::template construct_i(ptr(), std::forward(args)...); - } - - template , std::initializer_list &, Args...>::value)> - explicit variant(nonstd_lite_in_place_index_t(K), std::initializer_list il, Args &&... args) { - type_index = variant_npos_internal(); - type_index = helper_type::template construct_i(ptr(), il, std::forward(args)...); - } - -#endif // variant_CPP11_OR_GREATER - - // 19.7.3.2 Destructor - - ~variant() { - if (!valueless_by_exception()) { - helper_type::destroy(type_index, ptr()); - } - } - - // 19.7.3.3 Assignment - - variant &operator=(variant const &other) { return copy_assign(other); } - -#if variant_CPP11_OR_GREATER - - variant &operator=(variant &&other) noexcept( - std::is_nothrow_move_assignable::value &&std::is_nothrow_move_assignable::value - &&std::is_nothrow_move_assignable::value &&std::is_nothrow_move_assignable::value - &&std::is_nothrow_move_assignable::value &&std::is_nothrow_move_assignable< - T5>::value &&std::is_nothrow_move_assignable::value - &&std::is_nothrow_move_assignable::value &&std::is_nothrow_move_assignable< - T8>::value &&std::is_nothrow_move_assignable::value && - std::is_nothrow_move_assignable::value &&std::is_nothrow_move_assignable< - T11>::value &&std::is_nothrow_move_assignable::value - &&std::is_nothrow_move_assignable::value - &&std::is_nothrow_move_assignable::value - &&std::is_nothrow_move_assignable::value) { - return move_assign(std::move(other)); - } - - variant &operator=(T0 &&t0) { return assign_value<0>(std::move(t0)); } - variant &operator=(T1 &&t1) { return assign_value<1>(std::move(t1)); } - variant &operator=(T2 &&t2) { return assign_value<2>(std::move(t2)); } - variant &operator=(T3 &&t3) { return assign_value<3>(std::move(t3)); } - variant &operator=(T4 &&t4) { return assign_value<4>(std::move(t4)); } - variant &operator=(T5 &&t5) { return assign_value<5>(std::move(t5)); } - variant &operator=(T6 &&t6) { return assign_value<6>(std::move(t6)); } - variant &operator=(T7 &&t7) { return assign_value<7>(std::move(t7)); } - variant &operator=(T8 &&t8) { return assign_value<8>(std::move(t8)); } - variant &operator=(T9 &&t9) { return assign_value<9>(std::move(t9)); } - variant &operator=(T10 &&t10) { return assign_value<10>(std::move(t10)); } - variant &operator=(T11 &&t11) { return assign_value<11>(std::move(t11)); } - variant &operator=(T12 &&t12) { return assign_value<12>(std::move(t12)); } - variant &operator=(T13 &&t13) { return assign_value<13>(std::move(t13)); } - variant &operator=(T14 &&t14) { return assign_value<14>(std::move(t14)); } - variant &operator=(T15 &&t15) { return assign_value<15>(std::move(t15)); } - -#endif - - variant &operator=(T0 const &t0) { return assign_value<0>(t0); } - variant &operator=(T1 const &t1) { return assign_value<1>(t1); } - variant &operator=(T2 const &t2) { return assign_value<2>(t2); } - variant &operator=(T3 const &t3) { return assign_value<3>(t3); } - variant &operator=(T4 const &t4) { return assign_value<4>(t4); } - variant &operator=(T5 const &t5) { return assign_value<5>(t5); } - variant &operator=(T6 const &t6) { return assign_value<6>(t6); } - variant &operator=(T7 const &t7) { return assign_value<7>(t7); } - variant &operator=(T8 const &t8) { return assign_value<8>(t8); } - variant &operator=(T9 const &t9) { return assign_value<9>(t9); } - variant &operator=(T10 const &t10) { return assign_value<10>(t10); } - variant &operator=(T11 const &t11) { return assign_value<11>(t11); } - variant &operator=(T12 const &t12) { return assign_value<12>(t12); } - variant &operator=(T13 const &t13) { return assign_value<13>(t13); } - variant &operator=(T14 const &t14) { return assign_value<14>(t14); } - variant &operator=(T15 const &t15) { return assign_value<15>(t15); } - - std::size_t index() const { - return variant_npos_internal() == type_index ? variant_npos - : static_cast(type_index); - } - - // 19.7.3.4 Modifiers - -#if variant_CPP11_OR_GREATER - template ::value)> - T &emplace(Args &&... args) { - helper_type::destroy(type_index, ptr()); - type_index = variant_npos_internal(); - type_index = helper_type::template construct_t(ptr(), std::forward(args)...); - - return *as(); - } - - template &, Args...>::value)> - T &emplace(std::initializer_list il, Args &&... args) { - helper_type::destroy(type_index, ptr()); - type_index = variant_npos_internal(); - type_index = helper_type::template construct_t(ptr(), il, std::forward(args)...); - - return *as(); - } - - template , Args...>::value)> - variant_alternative_t &emplace(Args &&... args) { - return this->template emplace>(std::forward(args)...); - } - - template , std::initializer_list &, Args...>::value)> - variant_alternative_t &emplace(std::initializer_list il, Args &&... args) { - return this->template emplace>(il, std::forward(args)...); - } - -#endif // variant_CPP11_OR_GREATER - - // 19.7.3.5 Value status - - bool valueless_by_exception() const { return type_index == variant_npos_internal(); } - - // 19.7.3.6 Swap - - void swap(variant &other) -#if variant_CPP11_OR_GREATER - noexcept( - std::is_nothrow_move_constructible::value &&std17::is_nothrow_swappable< - T0>::value &&std::is_nothrow_move_constructible::value - &&std17::is_nothrow_swappable::value &&std::is_nothrow_move_constructible< - T2>::value &&std17::is_nothrow_swappable::value - &&std::is_nothrow_move_constructible::value &&std17::is_nothrow_swappable< - T3>::value &&std::is_nothrow_move_constructible::value - &&std17::is_nothrow_swappable::value &&std::is_nothrow_move_constructible< - T5>::value &&std17::is_nothrow_swappable::value &&std:: - is_nothrow_move_constructible::value &&std17::is_nothrow_swappable< - T6>::value &&std::is_nothrow_move_constructible::value &&std17:: - is_nothrow_swappable::value &&std::is_nothrow_move_constructible< - T8>::value &&std17::is_nothrow_swappable::value - &&std::is_nothrow_move_constructible< - T9>::value &&std17::is_nothrow_swappable::value - &&std::is_nothrow_move_constructible< - T10>::value &&std17::is_nothrow_swappable::value - &&std::is_nothrow_move_constructible< - T11>::value &&std17::is_nothrow_swappable::value - &&std::is_nothrow_move_constructible::value - &&std17::is_nothrow_swappable::value && - std::is_nothrow_move_constructible::value - &&std17::is_nothrow_swappable::value - &&std::is_nothrow_move_constructible< - T14>::value - &&std17::is_nothrow_swappable< - T14>::value &&std:: - is_nothrow_move_constructible< - T15>::value &&std17:: - is_nothrow_swappable< - T15>::value - - ) -#endif - { - if (valueless_by_exception() && other.valueless_by_exception()) { - // no effect - } else if (type_index == other.type_index) { - this->swap_value(type_index, other); - } else { -#if variant_CPP11_OR_GREATER - variant tmp(std::move(*this)); - *this = std::move(other); - other = std::move(tmp); -#else - variant tmp(*this); - *this = other; - other = tmp; -#endif - } - } - - // - // non-standard: - // - - template static variant_constexpr std::size_t index_of() variant_noexcept { - return to_size_t( - detail::typelist_index_of::type>::value); - } - - template T &get() { -#if variant_CONFIG_NO_EXCEPTIONS - assert(index_of() == index()); -#else - if (index_of() != index()) { - throw bad_variant_access(); - } -#endif - return *as(); - } - - template T const &get() const { -#if variant_CONFIG_NO_EXCEPTIONS - assert(index_of() == index()); -#else - if (index_of() != index()) { - throw bad_variant_access(); - } -#endif - return *as(); - } - - template typename variant_alternative::type &get() { - return this->template get::type>(); - } - - template typename variant_alternative::type const &get() const { - return this->template get::type>(); - } - -private: - typedef typename helper_type::type_index_t type_index_t; - - void *ptr() variant_noexcept { return &data; } - - void const *ptr() const variant_noexcept { return &data; } - - template U *as() { return reinterpret_cast(ptr()); } - - template U const *as() const { return reinterpret_cast(ptr()); } - - template static variant_constexpr std::size_t to_size_t(U index) { - return static_cast(index); - } - - variant_constexpr type_index_t variant_npos_internal() const variant_noexcept { - return static_cast(-1); - } - - variant ©_assign(variant const &other) { - if (valueless_by_exception() && other.valueless_by_exception()) { - // no effect - } else if (!valueless_by_exception() && other.valueless_by_exception()) { - helper_type::destroy(type_index, ptr()); - type_index = variant_npos_internal(); - } else if (index() == other.index()) { - type_index = helper_type::copy_assign(other.type_index, other.ptr(), ptr()); - } else { - helper_type::destroy(type_index, ptr()); - type_index = variant_npos_internal(); - type_index = helper_type::copy_construct(other.type_index, other.ptr(), ptr()); - } - return *this; - } - -#if variant_CPP11_OR_GREATER - - variant &move_assign(variant &&other) { - if (valueless_by_exception() && other.valueless_by_exception()) { - // no effect - } else if (!valueless_by_exception() && other.valueless_by_exception()) { - helper_type::destroy(type_index, ptr()); - type_index = variant_npos_internal(); - } else if (index() == other.index()) { - type_index = helper_type::move_assign(other.type_index, other.ptr(), ptr()); - } else { - helper_type::destroy(type_index, ptr()); - type_index = variant_npos_internal(); - type_index = helper_type::move_construct(other.type_index, other.ptr(), ptr()); - } - return *this; - } - - template variant &assign_value(T &&value) { - if (index() == K) { - *as() = std::forward(value); - } else { - helper_type::destroy(type_index, ptr()); - type_index = variant_npos_internal(); - new (ptr()) T(std::forward(value)); - type_index = K; - } - return *this; - } - -#endif // variant_CPP11_OR_GREATER - - template variant &assign_value(T const &value) { - if (index() == K) { - *as() = value; - } else { - helper_type::destroy(type_index, ptr()); - type_index = variant_npos_internal(); - new (ptr()) T(value); - type_index = K; - } - return *this; - } - - void swap_value(type_index_t index, variant &other) { - using std::swap; - switch (index) { - case 0: - swap(this->get<0>(), other.get<0>()); - break; - case 1: - swap(this->get<1>(), other.get<1>()); - break; - case 2: - swap(this->get<2>(), other.get<2>()); - break; - case 3: - swap(this->get<3>(), other.get<3>()); - break; - case 4: - swap(this->get<4>(), other.get<4>()); - break; - case 5: - swap(this->get<5>(), other.get<5>()); - break; - case 6: - swap(this->get<6>(), other.get<6>()); - break; - case 7: - swap(this->get<7>(), other.get<7>()); - break; - case 8: - swap(this->get<8>(), other.get<8>()); - break; - case 9: - swap(this->get<9>(), other.get<9>()); - break; - case 10: - swap(this->get<10>(), other.get<10>()); - break; - case 11: - swap(this->get<11>(), other.get<11>()); - break; - case 12: - swap(this->get<12>(), other.get<12>()); - break; - case 13: - swap(this->get<13>(), other.get<13>()); - break; - case 14: - swap(this->get<14>(), other.get<14>()); - break; - case 15: - swap(this->get<15>(), other.get<15>()); - break; - } - } - -private: - enum { data_size = detail::typelist_max::value }; - -#if variant_CPP11_OR_GREATER - - enum { data_align = detail::typelist_max_alignof::value }; - - using aligned_storage_t = typename std::aligned_storage::type; - aligned_storage_t data; - -#elif variant_CONFIG_MAX_ALIGN_HACK - - typedef union { - unsigned char data[data_size]; - } aligned_storage_t; - - detail::max_align_t hack; - aligned_storage_t data; - -#else - typedef typename detail::typelist_max::type max_type; - - typedef variant_ALIGN_AS(max_type) align_as_type; - - typedef union { - align_as_type data[1 + (data_size - 1) / sizeof(align_as_type)]; - } aligned_storage_t; - aligned_storage_t data; - - // # undef variant_ALIGN_AS - -#endif // variant_CONFIG_MAX_ALIGN_HACK - - type_index_t type_index; -}; - -// 19.7.5 Value access - -template -inline bool holds_alternative( - variant const &v) - variant_noexcept { - return v.index() == variant::template index_of(); -} - -template -inline R &get(variant &v, - nonstd_lite_in_place_type_t(R) = nonstd_lite_in_place_type(R)) { - return v.template get(); -} - -template -inline R const & -get(variant const &v, - nonstd_lite_in_place_type_t(R) = nonstd_lite_in_place_type(R)) { - return v.template get(); -} - -template -inline typename variant_alternative< - K, variant>::type & -get(variant &v, - nonstd_lite_in_place_index_t(K) = nonstd_lite_in_place_index(K)) { -#if variant_CONFIG_NO_EXCEPTIONS - assert(K == v.index()); -#else - if (K != v.index()) { - throw bad_variant_access(); - } -#endif - return v.template get(); -} - -template -inline typename variant_alternative< - K, variant>::type const & -get(variant const &v, - nonstd_lite_in_place_index_t(K) = nonstd_lite_in_place_index(K)) { -#if variant_CONFIG_NO_EXCEPTIONS - assert(K == v.index()); -#else - if (K != v.index()) { - throw bad_variant_access(); - } -#endif - return v.template get(); -} - -#if variant_CPP11_OR_GREATER - -template -inline R &&get(variant &&v, - nonstd_lite_in_place_type_t(R) = nonstd_lite_in_place_type(R)) { - return std::move(v.template get()); -} - -template -inline R const && -get(variant const &&v, - nonstd_lite_in_place_type_t(R) = nonstd_lite_in_place_type(R)) { - return std::move(v.template get()); -} - -template -inline typename variant_alternative< - K, variant>::type && -get(variant &&v, - nonstd_lite_in_place_index_t(K) = nonstd_lite_in_place_index(K)) { -#if variant_CONFIG_NO_EXCEPTIONS - assert(K == v.index()); -#else - if (K != v.index()) { - throw bad_variant_access(); - } -#endif - return std::move(v.template get()); -} - -template -inline typename variant_alternative< - K, variant>::type const && -get(variant const &&v, - nonstd_lite_in_place_index_t(K) = nonstd_lite_in_place_index(K)) { -#if variant_CONFIG_NO_EXCEPTIONS - assert(K == v.index()); -#else - if (K != v.index()) { - throw bad_variant_access(); - } -#endif - return std::move(v.template get()); -} - -#endif // variant_CPP11_OR_GREATER - -template -inline typename std11::add_pointer::type -get_if(variant *pv, - nonstd_lite_in_place_type_t(T) = nonstd_lite_in_place_type(T)) { - return (pv->index() == variant::template index_of()) - ? &get(*pv) - : variant_nullptr; -} - -template -inline typename std11::add_pointer::type -get_if(variant const *pv, - nonstd_lite_in_place_type_t(T) = nonstd_lite_in_place_type(T)) { - return (pv->index() == variant::template index_of()) - ? &get(*pv) - : variant_nullptr; -} - -template -inline typename std11::add_pointer>::type>::type -get_if(variant *pv, - nonstd_lite_in_place_index_t(K) = nonstd_lite_in_place_index(K)) { - return (pv->index() == K) ? &get(*pv) : variant_nullptr; -} - -template -inline typename std11::add_pointer>::type>::type -get_if(variant const *pv, - nonstd_lite_in_place_index_t(K) = nonstd_lite_in_place_index(K)) { - return (pv->index() == K) ? &get(*pv) : variant_nullptr; -} - -// 19.7.10 Specialized algorithms - -template < - class T0, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, - class T9, class T10, class T11, class T12, class T13, class T14, - class T15 -#if variant_CPP11_OR_GREATER - variant_REQUIRES_T( - std::is_move_constructible::value &&std17::is_swappable< - T0>::value &&std::is_move_constructible::value &&std17::is_swappable::value - &&std::is_move_constructible::value &&std17::is_swappable< - T2>::value &&std::is_move_constructible::value &&std17::is_swappable:: - value &&std::is_move_constructible::value &&std17::is_swappable::value - &&std::is_move_constructible::value &&std17::is_swappable< - T5>::value &&std::is_move_constructible::value - &&std17::is_swappable::value &&std::is_move_constructible< - T7>::value &&std17::is_swappable::value - &&std::is_move_constructible::value &&std17::is_swappable< - T8>::value &&std::is_move_constructible::value - &&std17::is_swappable::value &&std::is_move_constructible< - T10>::value &&std17::is_swappable::value &&std:: - is_move_constructible::value &&std17::is_swappable< - T11>::value &&std::is_move_constructible::value - &&std17::is_swappable< - T12>::value &&std::is_move_constructible::value - &&std17::is_swappable::value - &&std::is_move_constructible::value - &&std17::is_swappable::value - &&std::is_move_constructible::value - &&std17::is_swappable::value) -#endif - > -inline void swap(variant &a, - variant &b) -#if variant_CPP11_OR_GREATER - noexcept(noexcept(a.swap(b))) -#endif -{ - a.swap(b); -} - -// 19.7.7 Visitation - -// Variant 'visitor' implementation - -namespace detail { - -template struct VisitorApplicatorImpl { - template static R apply(Visitor const &v, T const &arg) { - return v(arg); - } -}; - -template struct VisitorApplicatorImpl> { - template static R apply(Visitor const &, T) { - // prevent default construction of a const reference, see issue #39: - std::terminate(); - } -}; - -template struct VisitorApplicator; - -template struct VisitorUnwrapper; - -#if variant_CPP11_OR_GREATER -template -#else -template -#endif -struct TypedVisitorUnwrapper; - -template -struct TypedVisitorUnwrapper<2, R, Visitor, T2> { - const Visitor &visitor; - T2 const &val2; - - TypedVisitorUnwrapper(const Visitor &visitor_, T2 const &val2_) - : visitor(visitor_), val2(val2_) - - {} - - template R operator()(const T &val1) const { return visitor(val1, val2); } -}; - -template -struct TypedVisitorUnwrapper<3, R, Visitor, T2, T3> { - const Visitor &visitor; - T2 const &val2; - T3 const &val3; - - TypedVisitorUnwrapper(const Visitor &visitor_, T2 const &val2_, T3 const &val3_) - : visitor(visitor_), val2(val2_), val3(val3_) - - {} - - template R operator()(const T &val1) const { return visitor(val1, val2, val3); } -}; - -template -struct TypedVisitorUnwrapper<4, R, Visitor, T2, T3, T4> { - const Visitor &visitor; - T2 const &val2; - T3 const &val3; - T4 const &val4; - - TypedVisitorUnwrapper(const Visitor &visitor_, T2 const &val2_, T3 const &val3_, T4 const &val4_) - : visitor(visitor_), val2(val2_), val3(val3_), val4(val4_) - - {} - - template R operator()(const T &val1) const { - return visitor(val1, val2, val3, val4); - } -}; - -template -struct TypedVisitorUnwrapper<5, R, Visitor, T2, T3, T4, T5> { - const Visitor &visitor; - T2 const &val2; - T3 const &val3; - T4 const &val4; - T5 const &val5; - - TypedVisitorUnwrapper(const Visitor &visitor_, T2 const &val2_, T3 const &val3_, T4 const &val4_, - T5 const &val5_) - : visitor(visitor_), val2(val2_), val3(val3_), val4(val4_), val5(val5_) - - {} - - template R operator()(const T &val1) const { - return visitor(val1, val2, val3, val4, val5); - } -}; - -template struct VisitorUnwrapper { - const Visitor &visitor; - const V2 &r; - - VisitorUnwrapper(const Visitor &visitor_, const V2 &r_) : visitor(visitor_), r(r_) {} - - template R operator()(T1 const &val1) const { - typedef TypedVisitorUnwrapper<2, R, Visitor, T1> visitor_type; - return VisitorApplicator::apply(visitor_type(visitor, val1), r); - } - - template R operator()(T1 const &val1, T2 const &val2) const { - typedef TypedVisitorUnwrapper<3, R, Visitor, T1, T2> visitor_type; - return VisitorApplicator::apply(visitor_type(visitor, val1, val2), r); - } - - template - R operator()(T1 const &val1, T2 const &val2, T3 const &val3) const { - typedef TypedVisitorUnwrapper<4, R, Visitor, T1, T2, T3> visitor_type; - return VisitorApplicator::apply(visitor_type(visitor, val1, val2, val3), r); - } - - template - R operator()(T1 const &val1, T2 const &val2, T3 const &val3, T4 const &val4) const { - typedef TypedVisitorUnwrapper<5, R, Visitor, T1, T2, T3, T4> visitor_type; - return VisitorApplicator::apply(visitor_type(visitor, val1, val2, val3, val4), r); - } - - template - R operator()(T1 const &val1, T2 const &val2, T3 const &val3, T4 const &val4, - T5 const &val5) const { - typedef TypedVisitorUnwrapper<6, R, Visitor, T1, T2, T3, T4, T5> visitor_type; - return VisitorApplicator::apply(visitor_type(visitor, val1, val2, val3, val4, val5), r); - } -}; - -template struct VisitorApplicator { - template static R apply(const Visitor &v, const V1 &arg) { - switch (arg.index()) { - case 0: - return apply_visitor<0>(v, arg); - case 1: - return apply_visitor<1>(v, arg); - case 2: - return apply_visitor<2>(v, arg); - case 3: - return apply_visitor<3>(v, arg); - case 4: - return apply_visitor<4>(v, arg); - case 5: - return apply_visitor<5>(v, arg); - case 6: - return apply_visitor<6>(v, arg); - case 7: - return apply_visitor<7>(v, arg); - case 8: - return apply_visitor<8>(v, arg); - case 9: - return apply_visitor<9>(v, arg); - case 10: - return apply_visitor<10>(v, arg); - case 11: - return apply_visitor<11>(v, arg); - case 12: - return apply_visitor<12>(v, arg); - case 13: - return apply_visitor<13>(v, arg); - case 14: - return apply_visitor<14>(v, arg); - case 15: - return apply_visitor<15>(v, arg); - - // prevent default construction of a const reference, see issue #39: - default: - std::terminate(); - } - } - - template - static R apply_visitor(const Visitor &v, const V1 &arg) { - -#if variant_CPP11_OR_GREATER - typedef typename variant_alternative::type>::type value_type; -#else - typedef typename variant_alternative::type value_type; -#endif - return VisitorApplicatorImpl::apply(v, get(arg)); - } - -#if variant_CPP11_OR_GREATER - template - static R apply(const Visitor &v, const V1 &arg1, const V2 &arg2, const V... args) { - typedef VisitorUnwrapper Unwrapper; - Unwrapper unwrapper(v, arg1); - return apply(unwrapper, arg2, args...); - } -#else - - template - static R apply(const Visitor &v, V1 const &arg1, V2 const &arg2) { - typedef VisitorUnwrapper Unwrapper; - Unwrapper unwrapper(v, arg1); - return apply(unwrapper, arg2); - } - - template - static R apply(const Visitor &v, V1 const &arg1, V2 const &arg2, V3 const &arg3) { - typedef VisitorUnwrapper Unwrapper; - Unwrapper unwrapper(v, arg1); - return apply(unwrapper, arg2, arg3); - } - - template - static R apply(const Visitor &v, V1 const &arg1, V2 const &arg2, V3 const &arg3, V4 const &arg4) { - typedef VisitorUnwrapper Unwrapper; - Unwrapper unwrapper(v, arg1); - return apply(unwrapper, arg2, arg3, arg4); - } - - template - static R apply(const Visitor &v, V1 const &arg1, V2 const &arg2, V3 const &arg3, V4 const &arg4, - V5 const &arg5) { - typedef VisitorUnwrapper Unwrapper; - Unwrapper unwrapper(v, arg1); - return apply(unwrapper, arg2, arg3, arg4, arg5); - } - -#endif -}; - -#if variant_CPP11_OR_GREATER -template struct VisitorImpl { - typedef decltype( - std::declval()(get<0>(static_cast(std::declval()))...)) result_type; - typedef VisitorApplicator applicator_type; -}; -#endif -} // namespace detail - -#if variant_CPP11_OR_GREATER -// No perfect forwarding here in order to simplify code -template -inline auto visit(Visitor const &v, V const &... vars) -> - typename detail::VisitorImpl::result_type { - typedef detail::VisitorImpl impl_type; - return impl_type::applicator_type::apply(v, vars...); -} -#else - -template -inline R visit(const Visitor &v, V1 const &arg1) { - return detail::VisitorApplicator::apply(v, arg1); -} - -template -inline R visit(const Visitor &v, V1 const &arg1, V2 const &arg2) { - return detail::VisitorApplicator::apply(v, arg1, arg2); -} - -template -inline R visit(const Visitor &v, V1 const &arg1, V2 const &arg2, V3 const &arg3) { - return detail::VisitorApplicator::apply(v, arg1, arg2, arg3); -} - -template -inline R visit(const Visitor &v, V1 const &arg1, V2 const &arg2, V3 const &arg3, V4 const &arg4) { - return detail::VisitorApplicator::apply(v, arg1, arg2, arg3, arg4); -} - -template -inline R visit(const Visitor &v, V1 const &arg1, V2 const &arg2, V3 const &arg3, V4 const &arg4, - V5 const &arg5) { - return detail::VisitorApplicator::apply(v, arg1, arg2, arg3, arg4, arg5); -} - -#endif - -// 19.7.6 Relational operators - -namespace detail { - -template struct Comparator { - static inline bool equal(Variant const &v, Variant const &w) { - switch (v.index()) { - case 0: - return get<0>(v) == get<0>(w); - case 1: - return get<1>(v) == get<1>(w); - case 2: - return get<2>(v) == get<2>(w); - case 3: - return get<3>(v) == get<3>(w); - case 4: - return get<4>(v) == get<4>(w); - case 5: - return get<5>(v) == get<5>(w); - case 6: - return get<6>(v) == get<6>(w); - case 7: - return get<7>(v) == get<7>(w); - case 8: - return get<8>(v) == get<8>(w); - case 9: - return get<9>(v) == get<9>(w); - case 10: - return get<10>(v) == get<10>(w); - case 11: - return get<11>(v) == get<11>(w); - case 12: - return get<12>(v) == get<12>(w); - case 13: - return get<13>(v) == get<13>(w); - case 14: - return get<14>(v) == get<14>(w); - case 15: - return get<15>(v) == get<15>(w); - - default: - return false; - } - } - - static inline bool less_than(Variant const &v, Variant const &w) { - switch (v.index()) { - case 0: - return get<0>(v) < get<0>(w); - case 1: - return get<1>(v) < get<1>(w); - case 2: - return get<2>(v) < get<2>(w); - case 3: - return get<3>(v) < get<3>(w); - case 4: - return get<4>(v) < get<4>(w); - case 5: - return get<5>(v) < get<5>(w); - case 6: - return get<6>(v) < get<6>(w); - case 7: - return get<7>(v) < get<7>(w); - case 8: - return get<8>(v) < get<8>(w); - case 9: - return get<9>(v) < get<9>(w); - case 10: - return get<10>(v) < get<10>(w); - case 11: - return get<11>(v) < get<11>(w); - case 12: - return get<12>(v) < get<12>(w); - case 13: - return get<13>(v) < get<13>(w); - case 14: - return get<14>(v) < get<14>(w); - case 15: - return get<15>(v) < get<15>(w); - - default: - return false; - } - } -}; - -} // namespace detail - -template -inline bool -operator==(variant const &v, - variant const &w) { - if (v.index() != w.index()) - return false; - else if (v.valueless_by_exception()) - return true; - else - return detail::Comparator< - variant>::equal(v, w); -} - -template -inline bool -operator!=(variant const &v, - variant const &w) { - return !(v == w); -} - -template -inline bool -operator<(variant const &v, - variant const &w) { - if (w.valueless_by_exception()) - return false; - else if (v.valueless_by_exception()) - return true; - else if (v.index() < w.index()) - return true; - else if (v.index() > w.index()) - return false; - else - return detail::Comparator>::less_than(v, w); -} - -template -inline bool -operator>(variant const &v, - variant const &w) { - return w < v; -} - -template -inline bool -operator<=(variant const &v, - variant const &w) { - return !(v > w); -} - -template -inline bool -operator>=(variant const &v, - variant const &w) { - return !(v < w); -} - -} // namespace variants - -using namespace variants; - -} // namespace nonstd - -#if variant_CPP11_OR_GREATER - -// 19.7.12 Hash support - -namespace std { - -template <> struct hash { - std::size_t operator()(nonstd::monostate) const variant_noexcept { return 42; } -}; - -template -struct hash> { - std::size_t operator()(nonstd::variant const &v) const variant_noexcept { - namespace nvd = nonstd::variants::detail; - - switch (v.index()) { - case 0: - return nvd::hash(0) ^ nvd::hash(get<0>(v)); - case 1: - return nvd::hash(1) ^ nvd::hash(get<1>(v)); - case 2: - return nvd::hash(2) ^ nvd::hash(get<2>(v)); - case 3: - return nvd::hash(3) ^ nvd::hash(get<3>(v)); - case 4: - return nvd::hash(4) ^ nvd::hash(get<4>(v)); - case 5: - return nvd::hash(5) ^ nvd::hash(get<5>(v)); - case 6: - return nvd::hash(6) ^ nvd::hash(get<6>(v)); - case 7: - return nvd::hash(7) ^ nvd::hash(get<7>(v)); - case 8: - return nvd::hash(8) ^ nvd::hash(get<8>(v)); - case 9: - return nvd::hash(9) ^ nvd::hash(get<9>(v)); - case 10: - return nvd::hash(10) ^ nvd::hash(get<10>(v)); - case 11: - return nvd::hash(11) ^ nvd::hash(get<11>(v)); - case 12: - return nvd::hash(12) ^ nvd::hash(get<12>(v)); - case 13: - return nvd::hash(13) ^ nvd::hash(get<13>(v)); - case 14: - return nvd::hash(14) ^ nvd::hash(get<14>(v)); - case 15: - return nvd::hash(15) ^ nvd::hash(get<15>(v)); - - default: - return 0; - } - } -}; - -} // namespace std - -#endif // variant_CPP11_OR_GREATER - -#if variant_BETWEEN(variant_COMPILER_MSVC_VER, 1300, 1900) -#pragma warning(pop) -#endif - -#endif // variant_USES_STD_VARIANT - -#endif // NONSTD_VARIANT_LITE_HPP +// Copyright 2016-2018 by Martin Moene +// +// https://github.com/martinmoene/variant-lite +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#pragma once + +#ifndef NONSTD_VARIANT_LITE_HPP +#define NONSTD_VARIANT_LITE_HPP + +#define variant_lite_MAJOR 1 +#define variant_lite_MINOR 2 +#define variant_lite_PATCH 2 + +#define variant_lite_VERSION \ + variant_STRINGIFY(variant_lite_MAJOR) "." variant_STRINGIFY( \ + variant_lite_MINOR) "." variant_STRINGIFY(variant_lite_PATCH) + +#define variant_STRINGIFY(x) variant_STRINGIFY_(x) +#define variant_STRINGIFY_(x) #x + +// variant-lite configuration: + +#define variant_VARIANT_DEFAULT 0 +#define variant_VARIANT_NONSTD 1 +#define variant_VARIANT_STD 2 + +#if !defined(variant_CONFIG_SELECT_VARIANT) +#define variant_CONFIG_SELECT_VARIANT \ + (variant_HAVE_STD_VARIANT ? variant_VARIANT_STD : variant_VARIANT_NONSTD) +#endif + +#ifndef variant_CONFIG_OMIT_VARIANT_SIZE_V_MACRO +#define variant_CONFIG_OMIT_VARIANT_SIZE_V_MACRO 0 +#endif + +#ifndef variant_CONFIG_OMIT_VARIANT_ALTERNATIVE_T_MACRO +#define variant_CONFIG_OMIT_VARIANT_ALTERNATIVE_T_MACRO 0 +#endif + +// Control presence of exception handling (try and auto discover): + +#ifndef variant_CONFIG_NO_EXCEPTIONS +#if defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND) +#define variant_CONFIG_NO_EXCEPTIONS 0 +#else +#define variant_CONFIG_NO_EXCEPTIONS 1 +#endif +#endif + +// C++ language version detection (C++20 is speculative): +// Note: VC14.0/1900 (VS2015) lacks too much from C++14. + +#ifndef variant_CPLUSPLUS +#if defined(_MSVC_LANG) && !defined(__clang__) +#define variant_CPLUSPLUS (_MSC_VER == 1900 ? 201103L : _MSVC_LANG) +#else +#define variant_CPLUSPLUS __cplusplus +#endif +#endif + +#define variant_CPP98_OR_GREATER (variant_CPLUSPLUS >= 199711L) +#define variant_CPP11_OR_GREATER (variant_CPLUSPLUS >= 201103L) +#define variant_CPP11_OR_GREATER_ (variant_CPLUSPLUS >= 201103L) +#define variant_CPP14_OR_GREATER (variant_CPLUSPLUS >= 201402L) +#define variant_CPP17_OR_GREATER (variant_CPLUSPLUS >= 201703L) +#define variant_CPP20_OR_GREATER (variant_CPLUSPLUS >= 202000L) + +// Use C++17 std::variant if available and requested: + +#if variant_CPP17_OR_GREATER && defined(__has_include) +#if __has_include( ) +#define variant_HAVE_STD_VARIANT 1 +#else +#define variant_HAVE_STD_VARIANT 0 +#endif +#else +#define variant_HAVE_STD_VARIANT 0 +#endif + +#define variant_USES_STD_VARIANT \ + ((variant_CONFIG_SELECT_VARIANT == variant_VARIANT_STD) || \ + ((variant_CONFIG_SELECT_VARIANT == variant_VARIANT_DEFAULT) && variant_HAVE_STD_VARIANT)) + +// +// in_place: code duplicated in any-lite, expected-lite, optional-lite, value-ptr-lite, +// variant-lite: +// + +#ifndef nonstd_lite_HAVE_IN_PLACE_TYPES +#define nonstd_lite_HAVE_IN_PLACE_TYPES 1 + +// C++17 std::in_place in : + +#if variant_CPP17_OR_GREATER + +#include + +namespace nonstd { + +using std::in_place; +using std::in_place_index; +using std::in_place_index_t; +using std::in_place_t; +using std::in_place_type; +using std::in_place_type_t; + +#define nonstd_lite_in_place_t(T) std::in_place_t +#define nonstd_lite_in_place_type_t(T) std::in_place_type_t +#define nonstd_lite_in_place_index_t(K) std::in_place_index_t + +#define nonstd_lite_in_place(T) \ + std::in_place_t {} +#define nonstd_lite_in_place_type(T) \ + std::in_place_type_t {} +#define nonstd_lite_in_place_index(K) \ + std::in_place_index_t {} + +} // namespace nonstd + +#else // variant_CPP17_OR_GREATER + +#include + +namespace nonstd { +namespace detail { + +template struct in_place_type_tag {}; + +template struct in_place_index_tag {}; + +} // namespace detail + +struct in_place_t {}; + +template +inline in_place_t in_place(detail::in_place_type_tag = detail::in_place_type_tag()) { + return in_place_t(); +} + +template +inline in_place_t in_place(detail::in_place_index_tag = detail::in_place_index_tag()) { + return in_place_t(); +} + +template +inline in_place_t in_place_type(detail::in_place_type_tag = detail::in_place_type_tag()) { + return in_place_t(); +} + +template +inline in_place_t in_place_index(detail::in_place_index_tag = detail::in_place_index_tag()) { + return in_place_t(); +} + +// mimic templated typedef: + +#define nonstd_lite_in_place_t(T) nonstd::in_place_t (&)(nonstd::detail::in_place_type_tag) +#define nonstd_lite_in_place_type_t(T) nonstd::in_place_t (&)(nonstd::detail::in_place_type_tag) +#define nonstd_lite_in_place_index_t(K) \ + nonstd::in_place_t (&)(nonstd::detail::in_place_index_tag) + +#define nonstd_lite_in_place(T) nonstd::in_place_type +#define nonstd_lite_in_place_type(T) nonstd::in_place_type +#define nonstd_lite_in_place_index(K) nonstd::in_place_index + +} // namespace nonstd + +#endif // variant_CPP17_OR_GREATER +#endif // nonstd_lite_HAVE_IN_PLACE_TYPES + +// +// Use C++17 std::variant: +// + +#if variant_USES_STD_VARIANT + +#include // std::hash<> +#include + +#if !variant_CONFIG_OMIT_VARIANT_SIZE_V_MACRO +#define variant_size_V(T) nonstd::variant_size::value +#endif + +#if !variant_CONFIG_OMIT_VARIANT_ALTERNATIVE_T_MACRO +#define variant_alternative_T(K, T) typename nonstd::variant_alternative::type +#endif + +namespace nonstd { + +using std::bad_variant_access; +using std::hash; +using std::monostate; +using std::variant; +using std::variant_alternative; +using std::variant_alternative_t; +using std::variant_size; +using std::variant_size_v; + +using std::get; +using std::get_if; +using std::holds_alternative; +using std::visit; +using std::operator==; +using std::operator!=; +using std::operator<; +using std::operator<=; +using std::operator>; +using std::operator>=; +using std::swap; + +constexpr auto variant_npos = std::variant_npos; +} // namespace nonstd + +#else // variant_USES_STD_VARIANT + +#include +#include +#include +#include + +#if variant_CONFIG_NO_EXCEPTIONS +#include +#else +#include +#endif + +// variant-lite type and visitor argument count configuration (script/generate_header.py): + +#define variant_CONFIG_MAX_TYPE_COUNT 16 +#define variant_CONFIG_MAX_VISITOR_ARG_COUNT 5 + +// variant-lite alignment configuration: + +#ifndef variant_CONFIG_MAX_ALIGN_HACK +#define variant_CONFIG_MAX_ALIGN_HACK 0 +#endif + +#ifndef variant_CONFIG_ALIGN_AS +// no default, used in #if defined() +#endif + +#ifndef variant_CONFIG_ALIGN_AS_FALLBACK +#define variant_CONFIG_ALIGN_AS_FALLBACK double +#endif + +// half-open range [lo..hi): +#define variant_BETWEEN(v, lo, hi) ((lo) <= (v) && (v) < (hi)) + +// Compiler versions: +// +// MSVC++ 6.0 _MSC_VER == 1200 variant_COMPILER_MSVC_VERSION == 60 (Visual Studio 6.0) +// MSVC++ 7.0 _MSC_VER == 1300 variant_COMPILER_MSVC_VERSION == 70 (Visual Studio .NET 2002) +// MSVC++ 7.1 _MSC_VER == 1310 variant_COMPILER_MSVC_VERSION == 71 (Visual Studio .NET 2003) +// MSVC++ 8.0 _MSC_VER == 1400 variant_COMPILER_MSVC_VERSION == 80 (Visual Studio 2005) +// MSVC++ 9.0 _MSC_VER == 1500 variant_COMPILER_MSVC_VERSION == 90 (Visual Studio 2008) +// MSVC++ 10.0 _MSC_VER == 1600 variant_COMPILER_MSVC_VERSION == 100 (Visual Studio 2010) +// MSVC++ 11.0 _MSC_VER == 1700 variant_COMPILER_MSVC_VERSION == 110 (Visual Studio 2012) +// MSVC++ 12.0 _MSC_VER == 1800 variant_COMPILER_MSVC_VERSION == 120 (Visual Studio 2013) +// MSVC++ 14.0 _MSC_VER == 1900 variant_COMPILER_MSVC_VERSION == 140 (Visual Studio 2015) +// MSVC++ 14.1 _MSC_VER >= 1910 variant_COMPILER_MSVC_VERSION == 141 (Visual Studio 2017) +// MSVC++ 14.2 _MSC_VER >= 1920 variant_COMPILER_MSVC_VERSION == 142 (Visual Studio 2019) + +#if defined(_MSC_VER) && !defined(__clang__) +#define variant_COMPILER_MSVC_VER (_MSC_VER) +#define variant_COMPILER_MSVC_VERSION (_MSC_VER / 10 - 10 * (5 + (_MSC_VER < 1900))) +#else +#define variant_COMPILER_MSVC_VER 0 +#define variant_COMPILER_MSVC_VERSION 0 +#endif + +#define variant_COMPILER_VERSION(major, minor, patch) (10 * (10 * (major) + (minor)) + (patch)) + +#if defined(__clang__) +#define variant_COMPILER_CLANG_VERSION \ + variant_COMPILER_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__) +#else +#define variant_COMPILER_CLANG_VERSION 0 +#endif + +#if defined(__GNUC__) && !defined(__clang__) +#define variant_COMPILER_GNUC_VERSION \ + variant_COMPILER_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) +#else +#define variant_COMPILER_GNUC_VERSION 0 +#endif + +#if variant_BETWEEN(variant_COMPILER_MSVC_VER, 1300, 1900) +#pragma warning(push) +#pragma warning(disable : 4345) // initialization behavior changed +#endif + +// Presence of language and library features: + +#define variant_HAVE(feature) (variant_HAVE_##feature) + +#ifdef _HAS_CPP0X +#define variant_HAS_CPP0X _HAS_CPP0X +#else +#define variant_HAS_CPP0X 0 +#endif + +// Unless defined otherwise below, consider VC14 as C++11 for variant-lite: + +#if variant_COMPILER_MSVC_VER >= 1900 +#undef variant_CPP11_OR_GREATER +#define variant_CPP11_OR_GREATER 1 +#endif + +#define variant_CPP11_90 (variant_CPP11_OR_GREATER_ || variant_COMPILER_MSVC_VER >= 1500) +#define variant_CPP11_100 (variant_CPP11_OR_GREATER_ || variant_COMPILER_MSVC_VER >= 1600) +#define variant_CPP11_110 (variant_CPP11_OR_GREATER_ || variant_COMPILER_MSVC_VER >= 1700) +#define variant_CPP11_120 (variant_CPP11_OR_GREATER_ || variant_COMPILER_MSVC_VER >= 1800) +#define variant_CPP11_140 (variant_CPP11_OR_GREATER_ || variant_COMPILER_MSVC_VER >= 1900) +#define variant_CPP11_141 (variant_CPP11_OR_GREATER_ || variant_COMPILER_MSVC_VER >= 1910) + +#define variant_CPP14_000 (variant_CPP14_OR_GREATER) +#define variant_CPP17_000 (variant_CPP17_OR_GREATER) + +// Presence of C++11 language features: + +#define variant_HAVE_CONSTEXPR_11 variant_CPP11_140 +#define variant_HAVE_INITIALIZER_LIST variant_CPP11_120 +#define variant_HAVE_NOEXCEPT variant_CPP11_140 +#define variant_HAVE_NULLPTR variant_CPP11_100 +#define variant_HAVE_OVERRIDE variant_CPP11_140 + +// Presence of C++14 language features: + +#define variant_HAVE_CONSTEXPR_14 variant_CPP14_000 + +// Presence of C++17 language features: + +// no flag + +// Presence of C++ library features: + +#define variant_HAVE_CONDITIONAL variant_CPP11_120 +#define variant_HAVE_REMOVE_CV variant_CPP11_120 +#define variant_HAVE_STD_ADD_POINTER variant_CPP11_90 +#define variant_HAVE_TYPE_TRAITS variant_CPP11_90 + +#define variant_HAVE_TR1_TYPE_TRAITS (!!variant_COMPILER_GNUC_VERSION) +#define variant_HAVE_TR1_ADD_POINTER (!!variant_COMPILER_GNUC_VERSION) + +// C++ feature usage: + +#if variant_HAVE_CONSTEXPR_11 +#define variant_constexpr constexpr +#else +#define variant_constexpr /*constexpr*/ +#endif + +#if variant_HAVE_CONSTEXPR_14 +#define variant_constexpr14 constexpr +#else +#define variant_constexpr14 /*constexpr*/ +#endif + +#if variant_HAVE_NOEXCEPT +#define variant_noexcept noexcept +#else +#define variant_noexcept /*noexcept*/ +#endif + +#if variant_HAVE_NULLPTR +#define variant_nullptr nullptr +#else +#define variant_nullptr NULL +#endif + +#if variant_HAVE_OVERRIDE +#define variant_override override +#else +#define variant_override /*override*/ +#endif + +// additional includes: + +#if variant_CPP11_OR_GREATER +#include // std::hash +#endif + +#if variant_HAVE_INITIALIZER_LIST +#include +#endif + +#if variant_HAVE_TYPE_TRAITS +#include +#elif variant_HAVE_TR1_TYPE_TRAITS +#include +#endif + +// Method enabling + +#if variant_CPP11_OR_GREATER + +#define variant_REQUIRES_0(...) \ + template ::type = 0> + +#define variant_REQUIRES_T(...) , typename std::enable_if<(__VA_ARGS__), int>::type = 0 + +#define variant_REQUIRES_R(R, ...) typename std::enable_if<(__VA_ARGS__), R>::type + +#define variant_REQUIRES_A(...) , typename std::enable_if<(__VA_ARGS__), void *>::type = nullptr + +#endif + +// +// variant: +// + +namespace nonstd { +namespace variants { + +// C++11 emulation: + +namespace std11 { + +#if variant_HAVE_STD_ADD_POINTER + +using std::add_pointer; + +#elif variant_HAVE_TR1_ADD_POINTER + +using std::tr1::add_pointer; + +#else + +template struct remove_reference { typedef T type; }; +template struct remove_reference { typedef T type; }; + +template struct add_pointer { typedef typename remove_reference::type *type; }; + +#endif // variant_HAVE_STD_ADD_POINTER + +#if variant_HAVE_REMOVE_CV + +using std::remove_cv; + +#else + +template struct remove_const { typedef T type; }; +template struct remove_const { typedef T type; }; + +template struct remove_volatile { typedef T type; }; +template struct remove_volatile { typedef T type; }; + +template struct remove_cv { + typedef typename remove_volatile::type>::type type; +}; + +#endif // variant_HAVE_REMOVE_CV + +#if variant_HAVE_CONDITIONAL + +using std::conditional; + +#else + +template struct conditional; + +template struct conditional { typedef Then type; }; + +template struct conditional { typedef Else type; }; + +#endif // variant_HAVE_CONDITIONAL + +} // namespace std11 + +/// type traits C++17: + +namespace std17 { + +#if variant_CPP17_OR_GREATER + +using std::is_nothrow_swappable; +using std::is_swappable; + +#elif variant_CPP11_OR_GREATER + +namespace detail { + +using std::swap; + +struct is_swappable { + template (), std::declval()))> + static std::true_type test(int); + + template static std::false_type test(...); +}; + +struct is_nothrow_swappable { + // wrap noexcept(epr) in separate function as work-around for VC140 (VS2015): + + template static constexpr bool test() { + return noexcept(swap(std::declval(), std::declval())); + } + + template static auto test(int) -> std::integral_constant()> {} + + template static std::false_type test(...); +}; + +} // namespace detail + +// is [nothow] swappable: + +template struct is_swappable : decltype(detail::is_swappable::test(0)) {}; + +template +struct is_nothrow_swappable : decltype(detail::is_nothrow_swappable::test(0)) {}; + +#endif // variant_CPP17_OR_GREATER + +} // namespace std17 + +// detail: + +namespace detail { + +// typelist: + +#define variant_TL1(T1) detail::typelist +#define variant_TL2(T1, T2) detail::typelist +#define variant_TL3(T1, T2, T3) detail::typelist +#define variant_TL4(T1, T2, T3, T4) detail::typelist +#define variant_TL5(T1, T2, T3, T4, T5) detail::typelist +#define variant_TL6(T1, T2, T3, T4, T5, T6) detail::typelist +#define variant_TL7(T1, T2, T3, T4, T5, T6, T7) \ + detail::typelist +#define variant_TL8(T1, T2, T3, T4, T5, T6, T7, T8) \ + detail::typelist +#define variant_TL9(T1, T2, T3, T4, T5, T6, T7, T8, T9) \ + detail::typelist +#define variant_TL10(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) \ + detail::typelist +#define variant_TL11(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) \ + detail::typelist +#define variant_TL12(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) \ + detail::typelist +#define variant_TL13(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) \ + detail::typelist +#define variant_TL14(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) \ + detail::typelist +#define variant_TL15(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) \ + detail::typelist +#define variant_TL16(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16) \ + detail::typelist + +// variant parameter unused type tags: + +template struct TX : T { + inline TX operator+() const { return TX(); } + inline TX operator-() const { return TX(); } + + inline TX operator!() const { return TX(); } + inline TX operator~() const { return TX(); } + + inline TX *operator&() const { return variant_nullptr; } + + template inline TX operator*(U const &)const { return TX(); } + template inline TX operator/(U const &) const { return TX(); } + + template inline TX operator%(U const &) const { return TX(); } + template inline TX operator+(U const &) const { return TX(); } + template inline TX operator-(U const &) const { return TX(); } + + template inline TX operator<<(U const &) const { return TX(); } + template inline TX operator>>(U const &) const { return TX(); } + + inline bool operator==(T const &) const { return false; } + inline bool operator<(T const &) const { return false; } + + template inline TX operator&(U const &)const { return TX(); } + template inline TX operator|(U const &) const { return TX(); } + template inline TX operator^(U const &) const { return TX(); } + + template inline TX operator&&(U const &) const { return TX(); } + template inline TX operator||(U const &) const { return TX(); } +}; + +struct S0 {}; +typedef TX T0; +struct S1 {}; +typedef TX T1; +struct S2 {}; +typedef TX T2; +struct S3 {}; +typedef TX T3; +struct S4 {}; +typedef TX T4; +struct S5 {}; +typedef TX T5; +struct S6 {}; +typedef TX T6; +struct S7 {}; +typedef TX T7; +struct S8 {}; +typedef TX T8; +struct S9 {}; +typedef TX T9; +struct S10 {}; +typedef TX T10; +struct S11 {}; +typedef TX T11; +struct S12 {}; +typedef TX T12; +struct S13 {}; +typedef TX T13; +struct S14 {}; +typedef TX T14; +struct S15 {}; +typedef TX T15; + +struct nulltype {}; + +template struct typelist { + typedef Head head; + typedef Tail tail; +}; + +// typelist max element size: + +template struct typelist_max; + +template <> struct typelist_max { + enum V { value = 0 }; + typedef void type; +}; + +template struct typelist_max> { +private: + enum TV { tail_value = size_t(typelist_max::value) }; + + typedef typename typelist_max::type tail_type; + +public: + enum V { value = (sizeof(Head) > tail_value) ? sizeof(Head) : std::size_t(tail_value) }; + + typedef typename std11::conditional<(sizeof(Head) > tail_value), Head, tail_type>::type type; +}; + +#if variant_CPP11_OR_GREATER + +// typelist max alignof element type: + +template struct typelist_max_alignof; + +template <> struct typelist_max_alignof { + enum V { value = 0 }; +}; + +template struct typelist_max_alignof> { +private: + enum TV { tail_value = size_t(typelist_max_alignof::value) }; + +public: + enum V { value = (alignof(Head) > tail_value) ? alignof(Head) : std::size_t(tail_value) }; +}; + +#endif + +// typelist size (length): + +template struct typelist_size { + enum V { value = 1 }; +}; + +template <> struct typelist_size { + enum V { value = 0 }; +}; +template <> struct typelist_size { + enum V { value = 0 }; +}; +template <> struct typelist_size { + enum V { value = 0 }; +}; +template <> struct typelist_size { + enum V { value = 0 }; +}; +template <> struct typelist_size { + enum V { value = 0 }; +}; +template <> struct typelist_size { + enum V { value = 0 }; +}; +template <> struct typelist_size { + enum V { value = 0 }; +}; +template <> struct typelist_size { + enum V { value = 0 }; +}; +template <> struct typelist_size { + enum V { value = 0 }; +}; +template <> struct typelist_size { + enum V { value = 0 }; +}; +template <> struct typelist_size { + enum V { value = 0 }; +}; +template <> struct typelist_size { + enum V { value = 0 }; +}; +template <> struct typelist_size { + enum V { value = 0 }; +}; +template <> struct typelist_size { + enum V { value = 0 }; +}; +template <> struct typelist_size { + enum V { value = 0 }; +}; +template <> struct typelist_size { + enum V { value = 0 }; +}; + +template <> struct typelist_size { + enum V { value = 0 }; +}; + +template struct typelist_size> { + enum V { value = typelist_size::value + typelist_size::value }; +}; + +// typelist index of type: + +template struct typelist_index_of; + +template struct typelist_index_of { + enum V { value = -1 }; +}; + +template struct typelist_index_of, T> { + enum V { value = 0 }; +}; + +template struct typelist_index_of, T> { +private: + enum TV { nextVal = typelist_index_of::value }; + +public: + enum V { value = nextVal == -1 ? -1 : 1 + nextVal }; +}; + +// typelist type at index: + +template struct typelist_type_at; + +template struct typelist_type_at, 0> { + typedef Head type; +}; + +template struct typelist_type_at, i> { + typedef typename typelist_type_at::type type; +}; + +#if variant_CONFIG_MAX_ALIGN_HACK + +// Max align, use most restricted type for alignment: + +#define variant_UNIQUE(name) variant_UNIQUE2(name, __LINE__) +#define variant_UNIQUE2(name, line) variant_UNIQUE3(name, line) +#define variant_UNIQUE3(name, line) name##line + +#define variant_ALIGN_TYPE(type) \ + type variant_UNIQUE(_t); \ + struct_t variant_UNIQUE(_st) + +template struct struct_t { T _; }; + +union max_align_t { + variant_ALIGN_TYPE(char); + variant_ALIGN_TYPE(short int); + variant_ALIGN_TYPE(int); + variant_ALIGN_TYPE(long int); + variant_ALIGN_TYPE(float); + variant_ALIGN_TYPE(double); + variant_ALIGN_TYPE(long double); + variant_ALIGN_TYPE(char *); + variant_ALIGN_TYPE(short int *); + variant_ALIGN_TYPE(int *); + variant_ALIGN_TYPE(long int *); + variant_ALIGN_TYPE(float *); + variant_ALIGN_TYPE(double *); + variant_ALIGN_TYPE(long double *); + variant_ALIGN_TYPE(void *); + +#ifdef HAVE_LONG_LONG + variant_ALIGN_TYPE(long long); +#endif + + struct Unknown; + + Unknown (*variant_UNIQUE(_))(Unknown); + Unknown *Unknown::*variant_UNIQUE(_); + Unknown (Unknown::*variant_UNIQUE(_))(Unknown); + + struct_t variant_UNIQUE(_); + struct_t variant_UNIQUE(_); + struct_t variant_UNIQUE(_); +}; + +#undef variant_UNIQUE +#undef variant_UNIQUE2 +#undef variant_UNIQUE3 + +#undef variant_ALIGN_TYPE + +#elif defined(variant_CONFIG_ALIGN_AS) // variant_CONFIG_MAX_ALIGN_HACK + +// Use user-specified type for alignment: + +#define variant_ALIGN_AS(unused) variant_CONFIG_ALIGN_AS + +#else // variant_CONFIG_MAX_ALIGN_HACK + +// Determine POD type to use for alignment: + +#define variant_ALIGN_AS(to_align) \ + typename detail::type_of_size::value>::type + +template struct alignment_of; + +template struct alignment_of_hack { + char c; + T t; + alignment_of_hack(); +}; + +template struct alignment_logic { + enum V { value = A < S ? A : S }; +}; + +template struct alignment_of { + enum V { value = alignment_logic) - sizeof(T), sizeof(T)>::value }; +}; + +template struct type_of_size { + typedef + typename std11::conditional::type>::type type; +}; + +template struct type_of_size { + typedef variant_CONFIG_ALIGN_AS_FALLBACK type; +}; + +template struct struct_t { T _; }; + +#define variant_ALIGN_TYPE(type) typelist < type, typelist < struct_t + +struct Unknown; + +typedef variant_ALIGN_TYPE(char), variant_ALIGN_TYPE(short), variant_ALIGN_TYPE(int), + variant_ALIGN_TYPE(long), variant_ALIGN_TYPE(float), variant_ALIGN_TYPE(double), + variant_ALIGN_TYPE(long double), + + variant_ALIGN_TYPE(char *), variant_ALIGN_TYPE(short *), variant_ALIGN_TYPE(int *), + variant_ALIGN_TYPE(long *), variant_ALIGN_TYPE(float *), variant_ALIGN_TYPE(double *), + variant_ALIGN_TYPE(long double *), + + variant_ALIGN_TYPE(Unknown (*)(Unknown)), variant_ALIGN_TYPE(Unknown *Unknown::*), + variant_ALIGN_TYPE(Unknown (Unknown::*)(Unknown)), + + nulltype >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> alignment_types; + +#undef variant_ALIGN_TYPE + +#endif // variant_CONFIG_MAX_ALIGN_HACK + +#if variant_CPP11_OR_GREATER + +template inline std::size_t hash(T const &v) { return std::hash()(v); } + +inline std::size_t hash(T0 const &) { return 0; } +inline std::size_t hash(T1 const &) { return 0; } +inline std::size_t hash(T2 const &) { return 0; } +inline std::size_t hash(T3 const &) { return 0; } +inline std::size_t hash(T4 const &) { return 0; } +inline std::size_t hash(T5 const &) { return 0; } +inline std::size_t hash(T6 const &) { return 0; } +inline std::size_t hash(T7 const &) { return 0; } +inline std::size_t hash(T8 const &) { return 0; } +inline std::size_t hash(T9 const &) { return 0; } +inline std::size_t hash(T10 const &) { return 0; } +inline std::size_t hash(T11 const &) { return 0; } +inline std::size_t hash(T12 const &) { return 0; } +inline std::size_t hash(T13 const &) { return 0; } +inline std::size_t hash(T14 const &) { return 0; } +inline std::size_t hash(T15 const &) { return 0; } + +#endif // variant_CPP11_OR_GREATER + +template +struct helper { + typedef signed char type_index_t; + typedef variant_TL16(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, + T15) variant_types; + + template static U *as(void *data) { return reinterpret_cast(data); } + + template static U const *as(void const *data) { + return reinterpret_cast(data); + } + + static type_index_t to_index_t(std::size_t index) { return static_cast(index); } + + static void destroy(type_index_t index, void *data) { + switch (index) { + case 0: + as(data)->~T0(); + break; + case 1: + as(data)->~T1(); + break; + case 2: + as(data)->~T2(); + break; + case 3: + as(data)->~T3(); + break; + case 4: + as(data)->~T4(); + break; + case 5: + as(data)->~T5(); + break; + case 6: + as(data)->~T6(); + break; + case 7: + as(data)->~T7(); + break; + case 8: + as(data)->~T8(); + break; + case 9: + as(data)->~T9(); + break; + case 10: + as(data)->~T10(); + break; + case 11: + as(data)->~T11(); + break; + case 12: + as(data)->~T12(); + break; + case 13: + as(data)->~T13(); + break; + case 14: + as(data)->~T14(); + break; + case 15: + as(data)->~T15(); + break; + } + } + +#if variant_CPP11_OR_GREATER + template static type_index_t construct_t(void *data, Args &&... args) { + new (data) T(std::forward(args)...); + + return to_index_t(detail::typelist_index_of::value); + } + + template + static type_index_t construct_i(void *data, Args &&... args) { + using type = typename detail::typelist_type_at::type; + + construct_t(data, std::forward(args)...); + + return to_index_t(K); + } + + static type_index_t move_construct(type_index_t const from_index, void *from_value, + void *to_value) { + switch (from_index) { + case 0: + new (to_value) T0(std::move(*as(from_value))); + break; + case 1: + new (to_value) T1(std::move(*as(from_value))); + break; + case 2: + new (to_value) T2(std::move(*as(from_value))); + break; + case 3: + new (to_value) T3(std::move(*as(from_value))); + break; + case 4: + new (to_value) T4(std::move(*as(from_value))); + break; + case 5: + new (to_value) T5(std::move(*as(from_value))); + break; + case 6: + new (to_value) T6(std::move(*as(from_value))); + break; + case 7: + new (to_value) T7(std::move(*as(from_value))); + break; + case 8: + new (to_value) T8(std::move(*as(from_value))); + break; + case 9: + new (to_value) T9(std::move(*as(from_value))); + break; + case 10: + new (to_value) T10(std::move(*as(from_value))); + break; + case 11: + new (to_value) T11(std::move(*as(from_value))); + break; + case 12: + new (to_value) T12(std::move(*as(from_value))); + break; + case 13: + new (to_value) T13(std::move(*as(from_value))); + break; + case 14: + new (to_value) T14(std::move(*as(from_value))); + break; + case 15: + new (to_value) T15(std::move(*as(from_value))); + break; + } + return from_index; + } + + static type_index_t move_assign(type_index_t const from_index, void *from_value, void *to_value) { + switch (from_index) { + case 0: + *as(to_value) = std::move(*as(from_value)); + break; + case 1: + *as(to_value) = std::move(*as(from_value)); + break; + case 2: + *as(to_value) = std::move(*as(from_value)); + break; + case 3: + *as(to_value) = std::move(*as(from_value)); + break; + case 4: + *as(to_value) = std::move(*as(from_value)); + break; + case 5: + *as(to_value) = std::move(*as(from_value)); + break; + case 6: + *as(to_value) = std::move(*as(from_value)); + break; + case 7: + *as(to_value) = std::move(*as(from_value)); + break; + case 8: + *as(to_value) = std::move(*as(from_value)); + break; + case 9: + *as(to_value) = std::move(*as(from_value)); + break; + case 10: + *as(to_value) = std::move(*as(from_value)); + break; + case 11: + *as(to_value) = std::move(*as(from_value)); + break; + case 12: + *as(to_value) = std::move(*as(from_value)); + break; + case 13: + *as(to_value) = std::move(*as(from_value)); + break; + case 14: + *as(to_value) = std::move(*as(from_value)); + break; + case 15: + *as(to_value) = std::move(*as(from_value)); + break; + } + return from_index; + } +#endif + + static type_index_t copy_construct(type_index_t const from_index, const void *from_value, + void *to_value) { + switch (from_index) { + case 0: + new (to_value) T0(*as(from_value)); + break; + case 1: + new (to_value) T1(*as(from_value)); + break; + case 2: + new (to_value) T2(*as(from_value)); + break; + case 3: + new (to_value) T3(*as(from_value)); + break; + case 4: + new (to_value) T4(*as(from_value)); + break; + case 5: + new (to_value) T5(*as(from_value)); + break; + case 6: + new (to_value) T6(*as(from_value)); + break; + case 7: + new (to_value) T7(*as(from_value)); + break; + case 8: + new (to_value) T8(*as(from_value)); + break; + case 9: + new (to_value) T9(*as(from_value)); + break; + case 10: + new (to_value) T10(*as(from_value)); + break; + case 11: + new (to_value) T11(*as(from_value)); + break; + case 12: + new (to_value) T12(*as(from_value)); + break; + case 13: + new (to_value) T13(*as(from_value)); + break; + case 14: + new (to_value) T14(*as(from_value)); + break; + case 15: + new (to_value) T15(*as(from_value)); + break; + } + return from_index; + } + + static type_index_t copy_assign(type_index_t const from_index, const void *from_value, + void *to_value) { + switch (from_index) { + case 0: + *as(to_value) = *as(from_value); + break; + case 1: + *as(to_value) = *as(from_value); + break; + case 2: + *as(to_value) = *as(from_value); + break; + case 3: + *as(to_value) = *as(from_value); + break; + case 4: + *as(to_value) = *as(from_value); + break; + case 5: + *as(to_value) = *as(from_value); + break; + case 6: + *as(to_value) = *as(from_value); + break; + case 7: + *as(to_value) = *as(from_value); + break; + case 8: + *as(to_value) = *as(from_value); + break; + case 9: + *as(to_value) = *as(from_value); + break; + case 10: + *as(to_value) = *as(from_value); + break; + case 11: + *as(to_value) = *as(from_value); + break; + case 12: + *as(to_value) = *as(from_value); + break; + case 13: + *as(to_value) = *as(from_value); + break; + case 14: + *as(to_value) = *as(from_value); + break; + case 15: + *as(to_value) = *as(from_value); + break; + } + return from_index; + } +}; + +} // namespace detail + +// +// Variant: +// + +template +class variant; + +// 19.7.8 Class monostate + +class monostate {}; + +// 19.7.9 monostate relational operators + +inline variant_constexpr bool operator<(monostate, monostate) variant_noexcept { return false; } +inline variant_constexpr bool operator>(monostate, monostate) variant_noexcept { return false; } +inline variant_constexpr bool operator<=(monostate, monostate) variant_noexcept { return true; } +inline variant_constexpr bool operator>=(monostate, monostate) variant_noexcept { return true; } +inline variant_constexpr bool operator==(monostate, monostate) variant_noexcept { return true; } +inline variant_constexpr bool operator!=(monostate, monostate) variant_noexcept { return false; } + +// 19.7.4 variant helper classes + +// obtain the size of the variant's list of alternatives at compile time + +template struct variant_size; /* undefined */ + +template +struct variant_size> { + enum _ { + value = detail::typelist_size::value + }; +}; + +#if variant_CPP14_OR_GREATER +template constexpr std::size_t variant_size_v = variant_size::value; +#endif + +#if !variant_CONFIG_OMIT_VARIANT_SIZE_V_MACRO +#define variant_size_V(T) nonstd::variant_size::value +#endif + +// obtain the type of the alternative specified by its index, at compile time: + +template struct variant_alternative; /* undefined */ + +template +struct variant_alternative< + K, variant> { + typedef typename detail::typelist_type_at::type type; +}; + +#if variant_CPP11_OR_GREATER +template +using variant_alternative_t = typename variant_alternative::type; +#endif + +#if !variant_CONFIG_OMIT_VARIANT_ALTERNATIVE_T_MACRO +#define variant_alternative_T(K, T) typename nonstd::variant_alternative::type +#endif + +// NTS:implement specializes the std::uses_allocator type trait +// std::uses_allocator + +// index of the variant in the invalid state (constant) + +#if variant_CPP11_OR_GREATER +variant_constexpr std::size_t variant_npos = static_cast(-1); +#else +static const std::size_t variant_npos = static_cast(-1); +#endif + +#if !variant_CONFIG_NO_EXCEPTIONS + +// 19.7.11 Class bad_variant_access + +class bad_variant_access : public std::exception { +public: +#if variant_CPP11_OR_GREATER + virtual const char *what() const variant_noexcept variant_override +#else + virtual const char *what() const throw() +#endif + { + return "bad variant access"; + } +}; + +#endif // variant_CONFIG_NO_EXCEPTIONS + +// 19.7.3 Class template variant + +template +class variant { + typedef detail::helper + helper_type; + typedef variant_TL16(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, + T15) variant_types; + +public: + // 19.7.3.1 Constructors + + variant() : type_index(0) { new (ptr()) T0(); } + + variant(T0 const &t0) : type_index(0) { new (ptr()) T0(t0); } + variant(T1 const &t1) : type_index(1) { new (ptr()) T1(t1); } + variant(T2 const &t2) : type_index(2) { new (ptr()) T2(t2); } + variant(T3 const &t3) : type_index(3) { new (ptr()) T3(t3); } + variant(T4 const &t4) : type_index(4) { new (ptr()) T4(t4); } + variant(T5 const &t5) : type_index(5) { new (ptr()) T5(t5); } + variant(T6 const &t6) : type_index(6) { new (ptr()) T6(t6); } + variant(T7 const &t7) : type_index(7) { new (ptr()) T7(t7); } + variant(T8 const &t8) : type_index(8) { new (ptr()) T8(t8); } + variant(T9 const &t9) : type_index(9) { new (ptr()) T9(t9); } + variant(T10 const &t10) : type_index(10) { new (ptr()) T10(t10); } + variant(T11 const &t11) : type_index(11) { new (ptr()) T11(t11); } + variant(T12 const &t12) : type_index(12) { new (ptr()) T12(t12); } + variant(T13 const &t13) : type_index(13) { new (ptr()) T13(t13); } + variant(T14 const &t14) : type_index(14) { new (ptr()) T14(t14); } + variant(T15 const &t15) : type_index(15) { new (ptr()) T15(t15); } + +#if variant_CPP11_OR_GREATER + variant(T0 &&t0) : type_index(0) { new (ptr()) T0(std::move(t0)); } + variant(T1 &&t1) : type_index(1) { new (ptr()) T1(std::move(t1)); } + variant(T2 &&t2) : type_index(2) { new (ptr()) T2(std::move(t2)); } + variant(T3 &&t3) : type_index(3) { new (ptr()) T3(std::move(t3)); } + variant(T4 &&t4) : type_index(4) { new (ptr()) T4(std::move(t4)); } + variant(T5 &&t5) : type_index(5) { new (ptr()) T5(std::move(t5)); } + variant(T6 &&t6) : type_index(6) { new (ptr()) T6(std::move(t6)); } + variant(T7 &&t7) : type_index(7) { new (ptr()) T7(std::move(t7)); } + variant(T8 &&t8) : type_index(8) { new (ptr()) T8(std::move(t8)); } + variant(T9 &&t9) : type_index(9) { new (ptr()) T9(std::move(t9)); } + variant(T10 &&t10) : type_index(10) { new (ptr()) T10(std::move(t10)); } + variant(T11 &&t11) : type_index(11) { new (ptr()) T11(std::move(t11)); } + variant(T12 &&t12) : type_index(12) { new (ptr()) T12(std::move(t12)); } + variant(T13 &&t13) : type_index(13) { new (ptr()) T13(std::move(t13)); } + variant(T14 &&t14) : type_index(14) { new (ptr()) T14(std::move(t14)); } + variant(T15 &&t15) : type_index(15) { new (ptr()) T15(std::move(t15)); } + +#endif + + variant(variant const &other) : type_index(other.type_index) { + (void)helper_type::copy_construct(other.type_index, other.ptr(), ptr()); + } + +#if variant_CPP11_OR_GREATER + + variant(variant &&other) noexcept( + std::is_nothrow_move_constructible::value &&std::is_nothrow_move_constructible::value + &&std::is_nothrow_move_constructible::value &&std::is_nothrow_move_constructible< + T3>::value &&std::is_nothrow_move_constructible::value + &&std::is_nothrow_move_constructible::value &&std::is_nothrow_move_constructible< + T6>::value &&std::is_nothrow_move_constructible::value + &&std::is_nothrow_move_constructible::value + &&std::is_nothrow_move_constructible::value + &&std::is_nothrow_move_constructible::value + &&std::is_nothrow_move_constructible::value + &&std::is_nothrow_move_constructible::value + &&std::is_nothrow_move_constructible::value + &&std::is_nothrow_move_constructible::value + &&std::is_nothrow_move_constructible::value) + : type_index(other.type_index) { + (void)helper_type::move_construct(other.type_index, other.ptr(), ptr()); + } + + template + using type_at_t = typename detail::typelist_type_at::type; + + template ::value)> + explicit variant(nonstd_lite_in_place_type_t(T), Args &&... args) { + type_index = variant_npos_internal(); + type_index = helper_type::template construct_t(ptr(), std::forward(args)...); + } + + template &, Args...>::value)> + explicit variant(nonstd_lite_in_place_type_t(T), std::initializer_list il, Args &&... args) { + type_index = variant_npos_internal(); + type_index = helper_type::template construct_t(ptr(), il, std::forward(args)...); + } + + template , Args...>::value)> + explicit variant(nonstd_lite_in_place_index_t(K), Args &&... args) { + type_index = variant_npos_internal(); + type_index = helper_type::template construct_i(ptr(), std::forward(args)...); + } + + template , std::initializer_list &, Args...>::value)> + explicit variant(nonstd_lite_in_place_index_t(K), std::initializer_list il, Args &&... args) { + type_index = variant_npos_internal(); + type_index = helper_type::template construct_i(ptr(), il, std::forward(args)...); + } + +#endif // variant_CPP11_OR_GREATER + + // 19.7.3.2 Destructor + + ~variant() { + if (!valueless_by_exception()) { + helper_type::destroy(type_index, ptr()); + } + } + + // 19.7.3.3 Assignment + + variant &operator=(variant const &other) { return copy_assign(other); } + +#if variant_CPP11_OR_GREATER + + variant &operator=(variant &&other) noexcept( + std::is_nothrow_move_assignable::value &&std::is_nothrow_move_assignable::value + &&std::is_nothrow_move_assignable::value &&std::is_nothrow_move_assignable::value + &&std::is_nothrow_move_assignable::value &&std::is_nothrow_move_assignable< + T5>::value &&std::is_nothrow_move_assignable::value + &&std::is_nothrow_move_assignable::value &&std::is_nothrow_move_assignable< + T8>::value &&std::is_nothrow_move_assignable::value && + std::is_nothrow_move_assignable::value &&std::is_nothrow_move_assignable< + T11>::value &&std::is_nothrow_move_assignable::value + &&std::is_nothrow_move_assignable::value + &&std::is_nothrow_move_assignable::value + &&std::is_nothrow_move_assignable::value) { + return move_assign(std::move(other)); + } + + variant &operator=(T0 &&t0) { return assign_value<0>(std::move(t0)); } + variant &operator=(T1 &&t1) { return assign_value<1>(std::move(t1)); } + variant &operator=(T2 &&t2) { return assign_value<2>(std::move(t2)); } + variant &operator=(T3 &&t3) { return assign_value<3>(std::move(t3)); } + variant &operator=(T4 &&t4) { return assign_value<4>(std::move(t4)); } + variant &operator=(T5 &&t5) { return assign_value<5>(std::move(t5)); } + variant &operator=(T6 &&t6) { return assign_value<6>(std::move(t6)); } + variant &operator=(T7 &&t7) { return assign_value<7>(std::move(t7)); } + variant &operator=(T8 &&t8) { return assign_value<8>(std::move(t8)); } + variant &operator=(T9 &&t9) { return assign_value<9>(std::move(t9)); } + variant &operator=(T10 &&t10) { return assign_value<10>(std::move(t10)); } + variant &operator=(T11 &&t11) { return assign_value<11>(std::move(t11)); } + variant &operator=(T12 &&t12) { return assign_value<12>(std::move(t12)); } + variant &operator=(T13 &&t13) { return assign_value<13>(std::move(t13)); } + variant &operator=(T14 &&t14) { return assign_value<14>(std::move(t14)); } + variant &operator=(T15 &&t15) { return assign_value<15>(std::move(t15)); } + +#endif + + variant &operator=(T0 const &t0) { return assign_value<0>(t0); } + variant &operator=(T1 const &t1) { return assign_value<1>(t1); } + variant &operator=(T2 const &t2) { return assign_value<2>(t2); } + variant &operator=(T3 const &t3) { return assign_value<3>(t3); } + variant &operator=(T4 const &t4) { return assign_value<4>(t4); } + variant &operator=(T5 const &t5) { return assign_value<5>(t5); } + variant &operator=(T6 const &t6) { return assign_value<6>(t6); } + variant &operator=(T7 const &t7) { return assign_value<7>(t7); } + variant &operator=(T8 const &t8) { return assign_value<8>(t8); } + variant &operator=(T9 const &t9) { return assign_value<9>(t9); } + variant &operator=(T10 const &t10) { return assign_value<10>(t10); } + variant &operator=(T11 const &t11) { return assign_value<11>(t11); } + variant &operator=(T12 const &t12) { return assign_value<12>(t12); } + variant &operator=(T13 const &t13) { return assign_value<13>(t13); } + variant &operator=(T14 const &t14) { return assign_value<14>(t14); } + variant &operator=(T15 const &t15) { return assign_value<15>(t15); } + + std::size_t index() const { + return variant_npos_internal() == type_index ? variant_npos + : static_cast(type_index); + } + + // 19.7.3.4 Modifiers + +#if variant_CPP11_OR_GREATER + template ::value)> + T &emplace(Args &&... args) { + helper_type::destroy(type_index, ptr()); + type_index = variant_npos_internal(); + type_index = helper_type::template construct_t(ptr(), std::forward(args)...); + + return *as(); + } + + template &, Args...>::value)> + T &emplace(std::initializer_list il, Args &&... args) { + helper_type::destroy(type_index, ptr()); + type_index = variant_npos_internal(); + type_index = helper_type::template construct_t(ptr(), il, std::forward(args)...); + + return *as(); + } + + template , Args...>::value)> + variant_alternative_t &emplace(Args &&... args) { + return this->template emplace>(std::forward(args)...); + } + + template , std::initializer_list &, Args...>::value)> + variant_alternative_t &emplace(std::initializer_list il, Args &&... args) { + return this->template emplace>(il, std::forward(args)...); + } + +#endif // variant_CPP11_OR_GREATER + + // 19.7.3.5 Value status + + bool valueless_by_exception() const { return type_index == variant_npos_internal(); } + + // 19.7.3.6 Swap + + void swap(variant &other) +#if variant_CPP11_OR_GREATER + noexcept( + std::is_nothrow_move_constructible::value &&std17::is_nothrow_swappable< + T0>::value &&std::is_nothrow_move_constructible::value + &&std17::is_nothrow_swappable::value &&std::is_nothrow_move_constructible< + T2>::value &&std17::is_nothrow_swappable::value + &&std::is_nothrow_move_constructible::value &&std17::is_nothrow_swappable< + T3>::value &&std::is_nothrow_move_constructible::value + &&std17::is_nothrow_swappable::value &&std::is_nothrow_move_constructible< + T5>::value &&std17::is_nothrow_swappable::value &&std:: + is_nothrow_move_constructible::value &&std17::is_nothrow_swappable< + T6>::value &&std::is_nothrow_move_constructible::value &&std17:: + is_nothrow_swappable::value &&std::is_nothrow_move_constructible< + T8>::value &&std17::is_nothrow_swappable::value + &&std::is_nothrow_move_constructible< + T9>::value &&std17::is_nothrow_swappable::value + &&std::is_nothrow_move_constructible< + T10>::value &&std17::is_nothrow_swappable::value + &&std::is_nothrow_move_constructible< + T11>::value &&std17::is_nothrow_swappable::value + &&std::is_nothrow_move_constructible::value + &&std17::is_nothrow_swappable::value && + std::is_nothrow_move_constructible::value + &&std17::is_nothrow_swappable::value + &&std::is_nothrow_move_constructible< + T14>::value + &&std17::is_nothrow_swappable< + T14>::value &&std:: + is_nothrow_move_constructible< + T15>::value &&std17:: + is_nothrow_swappable< + T15>::value + + ) +#endif + { + if (valueless_by_exception() && other.valueless_by_exception()) { + // no effect + } else if (type_index == other.type_index) { + this->swap_value(type_index, other); + } else { +#if variant_CPP11_OR_GREATER + variant tmp(std::move(*this)); + *this = std::move(other); + other = std::move(tmp); +#else + variant tmp(*this); + *this = other; + other = tmp; +#endif + } + } + + // + // non-standard: + // + + template static variant_constexpr std::size_t index_of() variant_noexcept { + return to_size_t( + detail::typelist_index_of::type>::value); + } + + template T &get() { +#if variant_CONFIG_NO_EXCEPTIONS + assert(index_of() == index()); +#else + if (index_of() != index()) { + throw bad_variant_access(); + } +#endif + return *as(); + } + + template T const &get() const { +#if variant_CONFIG_NO_EXCEPTIONS + assert(index_of() == index()); +#else + if (index_of() != index()) { + throw bad_variant_access(); + } +#endif + return *as(); + } + + template typename variant_alternative::type &get() { + return this->template get::type>(); + } + + template typename variant_alternative::type const &get() const { + return this->template get::type>(); + } + +private: + typedef typename helper_type::type_index_t type_index_t; + + void *ptr() variant_noexcept { return &data; } + + void const *ptr() const variant_noexcept { return &data; } + + template U *as() { return reinterpret_cast(ptr()); } + + template U const *as() const { return reinterpret_cast(ptr()); } + + template static variant_constexpr std::size_t to_size_t(U index) { + return static_cast(index); + } + + variant_constexpr type_index_t variant_npos_internal() const variant_noexcept { + return static_cast(-1); + } + + variant ©_assign(variant const &other) { + if (valueless_by_exception() && other.valueless_by_exception()) { + // no effect + } else if (!valueless_by_exception() && other.valueless_by_exception()) { + helper_type::destroy(type_index, ptr()); + type_index = variant_npos_internal(); + } else if (index() == other.index()) { + type_index = helper_type::copy_assign(other.type_index, other.ptr(), ptr()); + } else { + helper_type::destroy(type_index, ptr()); + type_index = variant_npos_internal(); + type_index = helper_type::copy_construct(other.type_index, other.ptr(), ptr()); + } + return *this; + } + +#if variant_CPP11_OR_GREATER + + variant &move_assign(variant &&other) { + if (valueless_by_exception() && other.valueless_by_exception()) { + // no effect + } else if (!valueless_by_exception() && other.valueless_by_exception()) { + helper_type::destroy(type_index, ptr()); + type_index = variant_npos_internal(); + } else if (index() == other.index()) { + type_index = helper_type::move_assign(other.type_index, other.ptr(), ptr()); + } else { + helper_type::destroy(type_index, ptr()); + type_index = variant_npos_internal(); + type_index = helper_type::move_construct(other.type_index, other.ptr(), ptr()); + } + return *this; + } + + template variant &assign_value(T &&value) { + if (index() == K) { + *as() = std::forward(value); + } else { + helper_type::destroy(type_index, ptr()); + type_index = variant_npos_internal(); + new (ptr()) T(std::forward(value)); + type_index = K; + } + return *this; + } + +#endif // variant_CPP11_OR_GREATER + + template variant &assign_value(T const &value) { + if (index() == K) { + *as() = value; + } else { + helper_type::destroy(type_index, ptr()); + type_index = variant_npos_internal(); + new (ptr()) T(value); + type_index = K; + } + return *this; + } + + void swap_value(type_index_t index, variant &other) { + using std::swap; + switch (index) { + case 0: + swap(this->get<0>(), other.get<0>()); + break; + case 1: + swap(this->get<1>(), other.get<1>()); + break; + case 2: + swap(this->get<2>(), other.get<2>()); + break; + case 3: + swap(this->get<3>(), other.get<3>()); + break; + case 4: + swap(this->get<4>(), other.get<4>()); + break; + case 5: + swap(this->get<5>(), other.get<5>()); + break; + case 6: + swap(this->get<6>(), other.get<6>()); + break; + case 7: + swap(this->get<7>(), other.get<7>()); + break; + case 8: + swap(this->get<8>(), other.get<8>()); + break; + case 9: + swap(this->get<9>(), other.get<9>()); + break; + case 10: + swap(this->get<10>(), other.get<10>()); + break; + case 11: + swap(this->get<11>(), other.get<11>()); + break; + case 12: + swap(this->get<12>(), other.get<12>()); + break; + case 13: + swap(this->get<13>(), other.get<13>()); + break; + case 14: + swap(this->get<14>(), other.get<14>()); + break; + case 15: + swap(this->get<15>(), other.get<15>()); + break; + } + } + +private: + enum { data_size = detail::typelist_max::value }; + +#if variant_CPP11_OR_GREATER + + enum { data_align = detail::typelist_max_alignof::value }; + + using aligned_storage_t = typename std::aligned_storage::type; + aligned_storage_t data; + +#elif variant_CONFIG_MAX_ALIGN_HACK + + typedef union { + unsigned char data[data_size]; + } aligned_storage_t; + + detail::max_align_t hack; + aligned_storage_t data; + +#else + typedef typename detail::typelist_max::type max_type; + + typedef variant_ALIGN_AS(max_type) align_as_type; + + typedef union { + align_as_type data[1 + (data_size - 1) / sizeof(align_as_type)]; + } aligned_storage_t; + aligned_storage_t data; + + // # undef variant_ALIGN_AS + +#endif // variant_CONFIG_MAX_ALIGN_HACK + + type_index_t type_index; +}; + +// 19.7.5 Value access + +template +inline bool holds_alternative( + variant const &v) + variant_noexcept { + return v.index() == variant::template index_of(); +} + +template +inline R &get(variant &v, + nonstd_lite_in_place_type_t(R) = nonstd_lite_in_place_type(R)) { + return v.template get(); +} + +template +inline R const & +get(variant const &v, + nonstd_lite_in_place_type_t(R) = nonstd_lite_in_place_type(R)) { + return v.template get(); +} + +template +inline typename variant_alternative< + K, variant>::type & +get(variant &v, + nonstd_lite_in_place_index_t(K) = nonstd_lite_in_place_index(K)) { +#if variant_CONFIG_NO_EXCEPTIONS + assert(K == v.index()); +#else + if (K != v.index()) { + throw bad_variant_access(); + } +#endif + return v.template get(); +} + +template +inline typename variant_alternative< + K, variant>::type const & +get(variant const &v, + nonstd_lite_in_place_index_t(K) = nonstd_lite_in_place_index(K)) { +#if variant_CONFIG_NO_EXCEPTIONS + assert(K == v.index()); +#else + if (K != v.index()) { + throw bad_variant_access(); + } +#endif + return v.template get(); +} + +#if variant_CPP11_OR_GREATER + +template +inline R &&get(variant &&v, + nonstd_lite_in_place_type_t(R) = nonstd_lite_in_place_type(R)) { + return std::move(v.template get()); +} + +template +inline R const && +get(variant const &&v, + nonstd_lite_in_place_type_t(R) = nonstd_lite_in_place_type(R)) { + return std::move(v.template get()); +} + +template +inline typename variant_alternative< + K, variant>::type && +get(variant &&v, + nonstd_lite_in_place_index_t(K) = nonstd_lite_in_place_index(K)) { +#if variant_CONFIG_NO_EXCEPTIONS + assert(K == v.index()); +#else + if (K != v.index()) { + throw bad_variant_access(); + } +#endif + return std::move(v.template get()); +} + +template +inline typename variant_alternative< + K, variant>::type const && +get(variant const &&v, + nonstd_lite_in_place_index_t(K) = nonstd_lite_in_place_index(K)) { +#if variant_CONFIG_NO_EXCEPTIONS + assert(K == v.index()); +#else + if (K != v.index()) { + throw bad_variant_access(); + } +#endif + return std::move(v.template get()); +} + +#endif // variant_CPP11_OR_GREATER + +template +inline typename std11::add_pointer::type +get_if(variant *pv, + nonstd_lite_in_place_type_t(T) = nonstd_lite_in_place_type(T)) { + return (pv->index() == variant::template index_of()) + ? &get(*pv) + : variant_nullptr; +} + +template +inline typename std11::add_pointer::type +get_if(variant const *pv, + nonstd_lite_in_place_type_t(T) = nonstd_lite_in_place_type(T)) { + return (pv->index() == variant::template index_of()) + ? &get(*pv) + : variant_nullptr; +} + +template +inline typename std11::add_pointer>::type>::type +get_if(variant *pv, + nonstd_lite_in_place_index_t(K) = nonstd_lite_in_place_index(K)) { + return (pv->index() == K) ? &get(*pv) : variant_nullptr; +} + +template +inline typename std11::add_pointer>::type>::type +get_if(variant const *pv, + nonstd_lite_in_place_index_t(K) = nonstd_lite_in_place_index(K)) { + return (pv->index() == K) ? &get(*pv) : variant_nullptr; +} + +// 19.7.10 Specialized algorithms + +template < + class T0, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, + class T9, class T10, class T11, class T12, class T13, class T14, + class T15 +#if variant_CPP11_OR_GREATER + variant_REQUIRES_T( + std::is_move_constructible::value &&std17::is_swappable< + T0>::value &&std::is_move_constructible::value &&std17::is_swappable::value + &&std::is_move_constructible::value &&std17::is_swappable< + T2>::value &&std::is_move_constructible::value &&std17::is_swappable:: + value &&std::is_move_constructible::value &&std17::is_swappable::value + &&std::is_move_constructible::value &&std17::is_swappable< + T5>::value &&std::is_move_constructible::value + &&std17::is_swappable::value &&std::is_move_constructible< + T7>::value &&std17::is_swappable::value + &&std::is_move_constructible::value &&std17::is_swappable< + T8>::value &&std::is_move_constructible::value + &&std17::is_swappable::value &&std::is_move_constructible< + T10>::value &&std17::is_swappable::value &&std:: + is_move_constructible::value &&std17::is_swappable< + T11>::value &&std::is_move_constructible::value + &&std17::is_swappable< + T12>::value &&std::is_move_constructible::value + &&std17::is_swappable::value + &&std::is_move_constructible::value + &&std17::is_swappable::value + &&std::is_move_constructible::value + &&std17::is_swappable::value) +#endif + > +inline void swap(variant &a, + variant &b) +#if variant_CPP11_OR_GREATER + noexcept(noexcept(a.swap(b))) +#endif +{ + a.swap(b); +} + +// 19.7.7 Visitation + +// Variant 'visitor' implementation + +namespace detail { + +template struct VisitorApplicatorImpl { + template static R apply(Visitor const &v, T const &arg) { + return v(arg); + } +}; + +template struct VisitorApplicatorImpl> { + template static R apply(Visitor const &, T) { + // prevent default construction of a const reference, see issue #39: + std::terminate(); + } +}; + +template struct VisitorApplicator; + +template struct VisitorUnwrapper; + +#if variant_CPP11_OR_GREATER +template +#else +template +#endif +struct TypedVisitorUnwrapper; + +template +struct TypedVisitorUnwrapper<2, R, Visitor, T2> { + const Visitor &visitor; + T2 const &val2; + + TypedVisitorUnwrapper(const Visitor &visitor_, T2 const &val2_) + : visitor(visitor_), val2(val2_) + + {} + + template R operator()(const T &val1) const { return visitor(val1, val2); } +}; + +template +struct TypedVisitorUnwrapper<3, R, Visitor, T2, T3> { + const Visitor &visitor; + T2 const &val2; + T3 const &val3; + + TypedVisitorUnwrapper(const Visitor &visitor_, T2 const &val2_, T3 const &val3_) + : visitor(visitor_), val2(val2_), val3(val3_) + + {} + + template R operator()(const T &val1) const { return visitor(val1, val2, val3); } +}; + +template +struct TypedVisitorUnwrapper<4, R, Visitor, T2, T3, T4> { + const Visitor &visitor; + T2 const &val2; + T3 const &val3; + T4 const &val4; + + TypedVisitorUnwrapper(const Visitor &visitor_, T2 const &val2_, T3 const &val3_, T4 const &val4_) + : visitor(visitor_), val2(val2_), val3(val3_), val4(val4_) + + {} + + template R operator()(const T &val1) const { + return visitor(val1, val2, val3, val4); + } +}; + +template +struct TypedVisitorUnwrapper<5, R, Visitor, T2, T3, T4, T5> { + const Visitor &visitor; + T2 const &val2; + T3 const &val3; + T4 const &val4; + T5 const &val5; + + TypedVisitorUnwrapper(const Visitor &visitor_, T2 const &val2_, T3 const &val3_, T4 const &val4_, + T5 const &val5_) + : visitor(visitor_), val2(val2_), val3(val3_), val4(val4_), val5(val5_) + + {} + + template R operator()(const T &val1) const { + return visitor(val1, val2, val3, val4, val5); + } +}; + +template struct VisitorUnwrapper { + const Visitor &visitor; + const V2 &r; + + VisitorUnwrapper(const Visitor &visitor_, const V2 &r_) : visitor(visitor_), r(r_) {} + + template R operator()(T1 const &val1) const { + typedef TypedVisitorUnwrapper<2, R, Visitor, T1> visitor_type; + return VisitorApplicator::apply(visitor_type(visitor, val1), r); + } + + template R operator()(T1 const &val1, T2 const &val2) const { + typedef TypedVisitorUnwrapper<3, R, Visitor, T1, T2> visitor_type; + return VisitorApplicator::apply(visitor_type(visitor, val1, val2), r); + } + + template + R operator()(T1 const &val1, T2 const &val2, T3 const &val3) const { + typedef TypedVisitorUnwrapper<4, R, Visitor, T1, T2, T3> visitor_type; + return VisitorApplicator::apply(visitor_type(visitor, val1, val2, val3), r); + } + + template + R operator()(T1 const &val1, T2 const &val2, T3 const &val3, T4 const &val4) const { + typedef TypedVisitorUnwrapper<5, R, Visitor, T1, T2, T3, T4> visitor_type; + return VisitorApplicator::apply(visitor_type(visitor, val1, val2, val3, val4), r); + } + + template + R operator()(T1 const &val1, T2 const &val2, T3 const &val3, T4 const &val4, + T5 const &val5) const { + typedef TypedVisitorUnwrapper<6, R, Visitor, T1, T2, T3, T4, T5> visitor_type; + return VisitorApplicator::apply(visitor_type(visitor, val1, val2, val3, val4, val5), r); + } +}; + +template struct VisitorApplicator { + template static R apply(const Visitor &v, const V1 &arg) { + switch (arg.index()) { + case 0: + return apply_visitor<0>(v, arg); + case 1: + return apply_visitor<1>(v, arg); + case 2: + return apply_visitor<2>(v, arg); + case 3: + return apply_visitor<3>(v, arg); + case 4: + return apply_visitor<4>(v, arg); + case 5: + return apply_visitor<5>(v, arg); + case 6: + return apply_visitor<6>(v, arg); + case 7: + return apply_visitor<7>(v, arg); + case 8: + return apply_visitor<8>(v, arg); + case 9: + return apply_visitor<9>(v, arg); + case 10: + return apply_visitor<10>(v, arg); + case 11: + return apply_visitor<11>(v, arg); + case 12: + return apply_visitor<12>(v, arg); + case 13: + return apply_visitor<13>(v, arg); + case 14: + return apply_visitor<14>(v, arg); + case 15: + return apply_visitor<15>(v, arg); + + // prevent default construction of a const reference, see issue #39: + default: + std::terminate(); + } + } + + template + static R apply_visitor(const Visitor &v, const V1 &arg) { + +#if variant_CPP11_OR_GREATER + typedef typename variant_alternative::type>::type value_type; +#else + typedef typename variant_alternative::type value_type; +#endif + return VisitorApplicatorImpl::apply(v, get(arg)); + } + +#if variant_CPP11_OR_GREATER + template + static R apply(const Visitor &v, const V1 &arg1, const V2 &arg2, const V... args) { + typedef VisitorUnwrapper Unwrapper; + Unwrapper unwrapper(v, arg1); + return apply(unwrapper, arg2, args...); + } +#else + + template + static R apply(const Visitor &v, V1 const &arg1, V2 const &arg2) { + typedef VisitorUnwrapper Unwrapper; + Unwrapper unwrapper(v, arg1); + return apply(unwrapper, arg2); + } + + template + static R apply(const Visitor &v, V1 const &arg1, V2 const &arg2, V3 const &arg3) { + typedef VisitorUnwrapper Unwrapper; + Unwrapper unwrapper(v, arg1); + return apply(unwrapper, arg2, arg3); + } + + template + static R apply(const Visitor &v, V1 const &arg1, V2 const &arg2, V3 const &arg3, V4 const &arg4) { + typedef VisitorUnwrapper Unwrapper; + Unwrapper unwrapper(v, arg1); + return apply(unwrapper, arg2, arg3, arg4); + } + + template + static R apply(const Visitor &v, V1 const &arg1, V2 const &arg2, V3 const &arg3, V4 const &arg4, + V5 const &arg5) { + typedef VisitorUnwrapper Unwrapper; + Unwrapper unwrapper(v, arg1); + return apply(unwrapper, arg2, arg3, arg4, arg5); + } + +#endif +}; + +#if variant_CPP11_OR_GREATER +template struct VisitorImpl { + typedef decltype( + std::declval()(get<0>(static_cast(std::declval()))...)) result_type; + typedef VisitorApplicator applicator_type; +}; +#endif +} // namespace detail + +#if variant_CPP11_OR_GREATER +// No perfect forwarding here in order to simplify code +template +inline auto visit(Visitor const &v, V const &... vars) -> + typename detail::VisitorImpl::result_type { + typedef detail::VisitorImpl impl_type; + return impl_type::applicator_type::apply(v, vars...); +} +#else + +template +inline R visit(const Visitor &v, V1 const &arg1) { + return detail::VisitorApplicator::apply(v, arg1); +} + +template +inline R visit(const Visitor &v, V1 const &arg1, V2 const &arg2) { + return detail::VisitorApplicator::apply(v, arg1, arg2); +} + +template +inline R visit(const Visitor &v, V1 const &arg1, V2 const &arg2, V3 const &arg3) { + return detail::VisitorApplicator::apply(v, arg1, arg2, arg3); +} + +template +inline R visit(const Visitor &v, V1 const &arg1, V2 const &arg2, V3 const &arg3, V4 const &arg4) { + return detail::VisitorApplicator::apply(v, arg1, arg2, arg3, arg4); +} + +template +inline R visit(const Visitor &v, V1 const &arg1, V2 const &arg2, V3 const &arg3, V4 const &arg4, + V5 const &arg5) { + return detail::VisitorApplicator::apply(v, arg1, arg2, arg3, arg4, arg5); +} + +#endif + +// 19.7.6 Relational operators + +namespace detail { + +template struct Comparator { + static inline bool equal(Variant const &v, Variant const &w) { + switch (v.index()) { + case 0: + return get<0>(v) == get<0>(w); + case 1: + return get<1>(v) == get<1>(w); + case 2: + return get<2>(v) == get<2>(w); + case 3: + return get<3>(v) == get<3>(w); + case 4: + return get<4>(v) == get<4>(w); + case 5: + return get<5>(v) == get<5>(w); + case 6: + return get<6>(v) == get<6>(w); + case 7: + return get<7>(v) == get<7>(w); + case 8: + return get<8>(v) == get<8>(w); + case 9: + return get<9>(v) == get<9>(w); + case 10: + return get<10>(v) == get<10>(w); + case 11: + return get<11>(v) == get<11>(w); + case 12: + return get<12>(v) == get<12>(w); + case 13: + return get<13>(v) == get<13>(w); + case 14: + return get<14>(v) == get<14>(w); + case 15: + return get<15>(v) == get<15>(w); + + default: + return false; + } + } + + static inline bool less_than(Variant const &v, Variant const &w) { + switch (v.index()) { + case 0: + return get<0>(v) < get<0>(w); + case 1: + return get<1>(v) < get<1>(w); + case 2: + return get<2>(v) < get<2>(w); + case 3: + return get<3>(v) < get<3>(w); + case 4: + return get<4>(v) < get<4>(w); + case 5: + return get<5>(v) < get<5>(w); + case 6: + return get<6>(v) < get<6>(w); + case 7: + return get<7>(v) < get<7>(w); + case 8: + return get<8>(v) < get<8>(w); + case 9: + return get<9>(v) < get<9>(w); + case 10: + return get<10>(v) < get<10>(w); + case 11: + return get<11>(v) < get<11>(w); + case 12: + return get<12>(v) < get<12>(w); + case 13: + return get<13>(v) < get<13>(w); + case 14: + return get<14>(v) < get<14>(w); + case 15: + return get<15>(v) < get<15>(w); + + default: + return false; + } + } +}; + +} // namespace detail + +template +inline bool +operator==(variant const &v, + variant const &w) { + if (v.index() != w.index()) + return false; + else if (v.valueless_by_exception()) + return true; + else + return detail::Comparator< + variant>::equal(v, w); +} + +template +inline bool +operator!=(variant const &v, + variant const &w) { + return !(v == w); +} + +template +inline bool +operator<(variant const &v, + variant const &w) { + if (w.valueless_by_exception()) + return false; + else if (v.valueless_by_exception()) + return true; + else if (v.index() < w.index()) + return true; + else if (v.index() > w.index()) + return false; + else + return detail::Comparator>::less_than(v, w); +} + +template +inline bool +operator>(variant const &v, + variant const &w) { + return w < v; +} + +template +inline bool +operator<=(variant const &v, + variant const &w) { + return !(v > w); +} + +template +inline bool +operator>=(variant const &v, + variant const &w) { + return !(v < w); +} + +} // namespace variants + +using namespace variants; + +} // namespace nonstd + +#if variant_CPP11_OR_GREATER + +// 19.7.12 Hash support + +namespace std { + +template <> struct hash { + std::size_t operator()(nonstd::monostate) const variant_noexcept { return 42; } +}; + +template +struct hash> { + std::size_t operator()(nonstd::variant const &v) const variant_noexcept { + namespace nvd = nonstd::variants::detail; + + switch (v.index()) { + case 0: + return nvd::hash(0) ^ nvd::hash(get<0>(v)); + case 1: + return nvd::hash(1) ^ nvd::hash(get<1>(v)); + case 2: + return nvd::hash(2) ^ nvd::hash(get<2>(v)); + case 3: + return nvd::hash(3) ^ nvd::hash(get<3>(v)); + case 4: + return nvd::hash(4) ^ nvd::hash(get<4>(v)); + case 5: + return nvd::hash(5) ^ nvd::hash(get<5>(v)); + case 6: + return nvd::hash(6) ^ nvd::hash(get<6>(v)); + case 7: + return nvd::hash(7) ^ nvd::hash(get<7>(v)); + case 8: + return nvd::hash(8) ^ nvd::hash(get<8>(v)); + case 9: + return nvd::hash(9) ^ nvd::hash(get<9>(v)); + case 10: + return nvd::hash(10) ^ nvd::hash(get<10>(v)); + case 11: + return nvd::hash(11) ^ nvd::hash(get<11>(v)); + case 12: + return nvd::hash(12) ^ nvd::hash(get<12>(v)); + case 13: + return nvd::hash(13) ^ nvd::hash(get<13>(v)); + case 14: + return nvd::hash(14) ^ nvd::hash(get<14>(v)); + case 15: + return nvd::hash(15) ^ nvd::hash(get<15>(v)); + + default: + return 0; + } + } +}; + +} // namespace std + +#endif // variant_CPP11_OR_GREATER + +#if variant_BETWEEN(variant_COMPILER_MSVC_VER, 1300, 1900) +#pragma warning(pop) +#endif + +#endif // variant_USES_STD_VARIANT + +#endif // NONSTD_VARIANT_LITE_HPP diff --git a/libs/test/rnd/fill_rnd_data_e2_setup_req.c b/libs/test/rnd/fill_rnd_data_e2_setup_req.c index b1faf94..a3362cc 100644 --- a/libs/test/rnd/fill_rnd_data_e2_setup_req.c +++ b/libs/test/rnd/fill_rnd_data_e2_setup_req.c @@ -1,134 +1,134 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698 - * - * 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. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include "fill_rnd_data_e2_setup_req.h" -#include "../../src/lib/e2ap/e2ap_node_comp_interface_type_wrapper.h" -#include "../../src/util/byte_array.h" -#include -#include -#include - -#ifdef E2AP_V1 - -#elif defined(E2AP_V2) || defined(E2AP_V3) - -e2ap_node_component_config_add_t fill_ngap_e2ap_node_component_config_add(void) -{ - e2ap_node_component_config_add_t dst = {0}; - - // Mandatory - // 9.2.26 - dst.e2_node_comp_interface_type = NG_E2AP_NODE_COMP_INTERFACE_TYPE; - // Bug!! Optional in the standard, mandatory in ASN.1 - // 9.2.32 - dst.e2_node_comp_id.type = NG_E2AP_NODE_COMP_INTERFACE_TYPE; - - const char ng_msg[] = "Dummy message"; - dst.e2_node_comp_id.ng_amf_name = cp_str_to_ba(ng_msg); - - // Mandatory - // 9.2.27 - const char req[] = "NGAP Request Message sent"; - const char res[] = "NGAP Response Message reveived"; - - dst.e2_node_comp_conf.request = cp_str_to_ba(req); - dst.e2_node_comp_conf.response = cp_str_to_ba(res); - return dst; -} - -// F1AP -e2ap_node_component_config_add_t fill_f1ap_e2ap_node_component_config_add(void) -{ - e2ap_node_component_config_add_t dst = {0}; - - // Mandatory - // 9.2.26 - dst.e2_node_comp_interface_type = F1_E2AP_NODE_COMP_INTERFACE_TYPE; - // Bug!! Optional in the standard, mandatory in ASN.1 - // 9.2.32 - dst.e2_node_comp_id.type = F1_E2AP_NODE_COMP_INTERFACE_TYPE; - - dst.e2_node_comp_id.f1_gnb_du_id = 1023; - - // Mandatory - // 9.2.27 - const char req[] = "F1AP Request Message sent"; - const char res[] = "F1AP Response Message reveived"; - - dst.e2_node_comp_conf.request = cp_str_to_ba(req); - dst.e2_node_comp_conf.response = cp_str_to_ba(res); - return dst; -} -// E1AP -e2ap_node_component_config_add_t fill_e1ap_e2ap_node_component_config_add(void) -{ - e2ap_node_component_config_add_t dst = {0}; - - // Mandatory - // 9.2.26 - dst.e2_node_comp_interface_type = E1_E2AP_NODE_COMP_INTERFACE_TYPE; - // Bug!! Optional in the standard, mandatory in ASN.1 - // 9.2.32 - dst.e2_node_comp_id.type = E1_E2AP_NODE_COMP_INTERFACE_TYPE; - - dst.e2_node_comp_id.e1_gnb_cu_up_id = 1025; - - // Mandatory - // 9.2.27 - const char req[] = "E1AP Request Message sent"; - const char res[] = "E1AP Response Message reveived"; - - dst.e2_node_comp_conf.request = cp_str_to_ba(req); - dst.e2_node_comp_conf.response = cp_str_to_ba(res); - return dst; -} - -// S1AP -e2ap_node_component_config_add_t fill_s1ap_e2ap_node_component_config_add(void) -{ - e2ap_node_component_config_add_t dst = {0}; - - // Mandatory - // 9.2.26 - dst.e2_node_comp_interface_type = S1_E2AP_NODE_COMP_INTERFACE_TYPE; - // Bug!! Optional in the standard, mandatory in ASN.1 - // 9.2.32 - dst.e2_node_comp_id.type = S1_E2AP_NODE_COMP_INTERFACE_TYPE; - - const char str[] = "S1 NAME"; - dst.e2_node_comp_id.s1_mme_name = cp_str_to_ba(str); - - // Mandatory - // 9.2.27 - const char req[] = "S1AP Request Message sent"; - const char res[] = "S1AP Response Message reveived"; - - dst.e2_node_comp_conf.request = cp_str_to_ba(req); - dst.e2_node_comp_conf.response = cp_str_to_ba(res); - return dst; -} - - - -#else -static_assert(0!=0, "Unknown E2AP version"); -#endif - +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698 + * + * 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. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#include "fill_rnd_data_e2_setup_req.h" +#include "../../src/lib/e2ap/e2ap_node_comp_interface_type_wrapper.h" +#include "../../src/util/byte_array.h" +#include +#include +#include + +#ifdef E2AP_V1 + +#elif defined(E2AP_V2) || defined(E2AP_V3) + +e2ap_node_component_config_add_t fill_ngap_e2ap_node_component_config_add(void) +{ + e2ap_node_component_config_add_t dst = {0}; + + // Mandatory + // 9.2.26 + dst.e2_node_comp_interface_type = NG_E2AP_NODE_COMP_INTERFACE_TYPE; + // Bug!! Optional in the standard, mandatory in ASN.1 + // 9.2.32 + dst.e2_node_comp_id.type = NG_E2AP_NODE_COMP_INTERFACE_TYPE; + + const char ng_msg[] = "Dummy message"; + dst.e2_node_comp_id.ng_amf_name = cp_str_to_ba(ng_msg); + + // Mandatory + // 9.2.27 + const char req[] = "NGAP Request Message sent"; + const char res[] = "NGAP Response Message reveived"; + + dst.e2_node_comp_conf.request = cp_str_to_ba(req); + dst.e2_node_comp_conf.response = cp_str_to_ba(res); + return dst; +} + +// F1AP +e2ap_node_component_config_add_t fill_f1ap_e2ap_node_component_config_add(void) +{ + e2ap_node_component_config_add_t dst = {0}; + + // Mandatory + // 9.2.26 + dst.e2_node_comp_interface_type = F1_E2AP_NODE_COMP_INTERFACE_TYPE; + // Bug!! Optional in the standard, mandatory in ASN.1 + // 9.2.32 + dst.e2_node_comp_id.type = F1_E2AP_NODE_COMP_INTERFACE_TYPE; + + dst.e2_node_comp_id.f1_gnb_du_id = 1023; + + // Mandatory + // 9.2.27 + const char req[] = "F1AP Request Message sent"; + const char res[] = "F1AP Response Message reveived"; + + dst.e2_node_comp_conf.request = cp_str_to_ba(req); + dst.e2_node_comp_conf.response = cp_str_to_ba(res); + return dst; +} +// E1AP +e2ap_node_component_config_add_t fill_e1ap_e2ap_node_component_config_add(void) +{ + e2ap_node_component_config_add_t dst = {0}; + + // Mandatory + // 9.2.26 + dst.e2_node_comp_interface_type = E1_E2AP_NODE_COMP_INTERFACE_TYPE; + // Bug!! Optional in the standard, mandatory in ASN.1 + // 9.2.32 + dst.e2_node_comp_id.type = E1_E2AP_NODE_COMP_INTERFACE_TYPE; + + dst.e2_node_comp_id.e1_gnb_cu_up_id = 1025; + + // Mandatory + // 9.2.27 + const char req[] = "E1AP Request Message sent"; + const char res[] = "E1AP Response Message reveived"; + + dst.e2_node_comp_conf.request = cp_str_to_ba(req); + dst.e2_node_comp_conf.response = cp_str_to_ba(res); + return dst; +} + +// S1AP +e2ap_node_component_config_add_t fill_s1ap_e2ap_node_component_config_add(void) +{ + e2ap_node_component_config_add_t dst = {0}; + + // Mandatory + // 9.2.26 + dst.e2_node_comp_interface_type = S1_E2AP_NODE_COMP_INTERFACE_TYPE; + // Bug!! Optional in the standard, mandatory in ASN.1 + // 9.2.32 + dst.e2_node_comp_id.type = S1_E2AP_NODE_COMP_INTERFACE_TYPE; + + const char str[] = "S1 NAME"; + dst.e2_node_comp_id.s1_mme_name = cp_str_to_ba(str); + + // Mandatory + // 9.2.27 + const char req[] = "S1AP Request Message sent"; + const char res[] = "S1AP Response Message reveived"; + + dst.e2_node_comp_conf.request = cp_str_to_ba(req); + dst.e2_node_comp_conf.response = cp_str_to_ba(res); + return dst; +} + + + +#else +static_assert(0!=0, "Unknown E2AP version"); +#endif + diff --git a/libs/test/rnd/fill_rnd_data_e2_setup_req.h b/libs/test/rnd/fill_rnd_data_e2_setup_req.h index c9935f5..ac1cf21 100644 --- a/libs/test/rnd/fill_rnd_data_e2_setup_req.h +++ b/libs/test/rnd/fill_rnd_data_e2_setup_req.h @@ -1,44 +1,44 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698 - * - * 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. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include "../../src/lib/e2ap/e2ap_node_component_config_add_wrapper.h" - -#ifdef E2AP_V1 - -#elif defined(E2AP_V2) || defined(E2AP_V3) - -e2ap_node_component_config_add_t fill_ngap_e2ap_node_component_config_add(void); - -e2ap_node_component_config_add_t fill_f1ap_e2ap_node_component_config_add(void); - -e2ap_node_component_config_add_t fill_e1ap_e2ap_node_component_config_add(void); - -e2ap_node_component_config_add_t fill_s1ap_e2ap_node_component_config_add(void); - -#else -static_assert(0!=0, "Unknown E2AP version"); -#endif - - - - - - +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698 + * + * 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. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#include "../../src/lib/e2ap/e2ap_node_component_config_add_wrapper.h" + +#ifdef E2AP_V1 + +#elif defined(E2AP_V2) || defined(E2AP_V3) + +e2ap_node_component_config_add_t fill_ngap_e2ap_node_component_config_add(void); + +e2ap_node_component_config_add_t fill_f1ap_e2ap_node_component_config_add(void); + +e2ap_node_component_config_add_t fill_e1ap_e2ap_node_component_config_add(void); + +e2ap_node_component_config_add_t fill_s1ap_e2ap_node_component_config_add(void); + +#else +static_assert(0!=0, "Unknown E2AP version"); +#endif + + + + + + diff --git a/libs/test/rnd/fill_rnd_data_gtp.c b/libs/test/rnd/fill_rnd_data_gtp.c index 7da2e83..71aecbe 100644 --- a/libs/test/rnd/fill_rnd_data_gtp.c +++ b/libs/test/rnd/fill_rnd_data_gtp.c @@ -1,60 +1,60 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698 - * - * 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. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include "fill_rnd_data_gtp.h" -#include "../../src/util/time_now_us.h" - -#include -#include -#include - -void fill_gtp_ind_data(gtp_ind_data_t* ind) -{ - assert(ind != NULL); - - srand(time(0)); - - int const mod = 1024; - - // Get indication message - gtp_ind_msg_t* ind_msg = &ind->msg; - - // Set time now - ind_msg->tstamp = time_now_us(); - - // Set random number of messages - ind_msg->len = rand()%4; - if(ind_msg->len > 0 ){ - ind_msg->ngut = calloc(ind_msg->len, sizeof(gtp_ngu_t_stats_t) ); - assert(ind_msg->ngut != NULL); - } - - for(uint32_t i = 0; i < ind_msg->len; ++i){ - gtp_ngu_t_stats_t* ngut = &ind_msg->ngut[i]; - - // Fill dummy data in your data structure - ngut->rnti=abs(rand()%mod) ; - ngut->qfi=abs(rand()%mod); - ngut->teidgnb=abs(rand()%mod); - ngut->teidupf=abs(rand()%mod); - } -} - +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698 + * + * 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. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#include "fill_rnd_data_gtp.h" +#include "../../src/util/time_now_us.h" + +#include +#include +#include + +void fill_gtp_ind_data(gtp_ind_data_t* ind) +{ + assert(ind != NULL); + + srand(time(0)); + + int const mod = 1024; + + // Get indication message + gtp_ind_msg_t* ind_msg = &ind->msg; + + // Set time now + ind_msg->tstamp = time_now_us(); + + // Set random number of messages + ind_msg->len = rand()%4; + if(ind_msg->len > 0 ){ + ind_msg->ngut = calloc(ind_msg->len, sizeof(gtp_ngu_t_stats_t) ); + assert(ind_msg->ngut != NULL); + } + + for(uint32_t i = 0; i < ind_msg->len; ++i){ + gtp_ngu_t_stats_t* ngut = &ind_msg->ngut[i]; + + // Fill dummy data in your data structure + ngut->rnti=abs(rand()%mod) ; + ngut->qfi=abs(rand()%mod); + ngut->teidgnb=abs(rand()%mod); + ngut->teidupf=abs(rand()%mod); + } +} + diff --git a/libs/test/rnd/fill_rnd_data_gtp.h b/libs/test/rnd/fill_rnd_data_gtp.h index e5028e3..311cdc7 100644 --- a/libs/test/rnd/fill_rnd_data_gtp.h +++ b/libs/test/rnd/fill_rnd_data_gtp.h @@ -1,31 +1,31 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698 - * - * 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. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#ifndef FILL_RND_DATA_GTP_H -#define FILL_RND_DATA_GTP_H - -#include "../../src/sm/gtp_sm/ie/gtp_data_ie.h" - -void fill_gtp_ind_data(gtp_ind_data_t* ind); - -#endif - - +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698 + * + * 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. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#ifndef FILL_RND_DATA_GTP_H +#define FILL_RND_DATA_GTP_H + +#include "../../src/sm/gtp_sm/ie/gtp_data_ie.h" + +void fill_gtp_ind_data(gtp_ind_data_t* ind); + +#endif + + diff --git a/libs/test/rnd/fill_rnd_data_kpm.c b/libs/test/rnd/fill_rnd_data_kpm.c index 2344140..4c2fb33 100644 --- a/libs/test/rnd/fill_rnd_data_kpm.c +++ b/libs/test/rnd/fill_rnd_data_kpm.c @@ -1,1595 +1,1595 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698 - * - * 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. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include "fill_rnd_data_kpm.h" -#include "../../src/sm/kpm_sm/kpm_sm_id_wrapper.h" -#include "../../src/util/time_now_us.h" - - -#include -#include -#include -#include - -kpm_event_trigger_def_t fill_rnd_kpm_event_trigger_def(void) -{ - kpm_event_trigger_def_t dst = {0}; - - dst.type = rand()%END_FORMAT_RIC_EVENT_TRIGGER; - - if(dst.type == FORMAT_1_RIC_EVENT_TRIGGER ){ - // Normally the period is not free, need to check in the specs - dst.kpm_ric_event_trigger_format_1.report_period_ms = (rand()% 10000) + 1; //(rand()%4294967295) + 1 ; - } else { - assert(0 != 0 && "unknown type"); - } - - return dst; -} - -#if defined KPM_V2_03 || defined KPM_V3_00 -static bin_range_def_t fill_rnd_bin_range_def(void) -{ - bin_range_def_t bin_range_def = {0}; - - bin_range_def.bin_x_lst_len = 3; // (rand() % 65535) + 1; - - bin_range_def.bin_x_lst = calloc(bin_range_def.bin_x_lst_len, sizeof(bin_distr_t)); - assert(bin_range_def.bin_x_lst != NULL && "Memory exhausted"); - - for (size_t j = 0; jmeas_type.type = rand()%END_MEAS_TYPE; - - switch (meas_info->meas_type.type) - { - case NAME_MEAS_TYPE: - meas_info->meas_type.type = NAME_MEAS_TYPE; - meas_info->meas_type.name.buf = calloc(strlen("test") + 1, sizeof(uint8_t)); - memcpy(meas_info->meas_type.name.buf, "test", strlen("test")); - meas_info->meas_type.name.len = strlen("test"); - break; - - case ID_MEAS_TYPE: - meas_info->meas_type.type = ID_MEAS_TYPE; - meas_info->meas_type.id = (rand() % 65536) + 1; - break; - - default: - assert(false && "Unknown Measurement Type"); - } - - - // Label Information - // [1, 2147483647] - meas_info->label_info_lst_len = 2 ; // With the real number, we can run out of memory i.e., 2147483647 - meas_info->label_info_lst = calloc(meas_info->label_info_lst_len, sizeof(label_info_lst_t)); - assert(meas_info->label_info_lst != NULL && "Memory exhausted" ); - - for (size_t j = 0; j < meas_info->label_info_lst_len; j++) - { - if(j%2){ - meas_info->label_info_lst[j].plmn_id = malloc(sizeof(e2sm_plmn_t)); - assert(meas_info->label_info_lst[j].plmn_id != NULL); - - *meas_info->label_info_lst[j].plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; - } else { - // action_def_frm_1.meas_info_lst[i].label_info_lst[j].noLabel = malloc(sizeof(enum_value_e)); - // *action_def_frm_1.meas_info_lst[i].label_info_lst[j].noLabel = TRUE_ENUM_VALUE; - //action_def_frm_1.meas_info_lst[i].label_info_lst[j].fiveQI = calloc(1, sizeof(uint8_t)); - //assert(action_def_frm_1.meas_info_lst[i].label_info_lst[j].fiveQI != NULL && "Memory exhausted"); - //*action_def_frm_1.meas_info_lst[i].label_info_lst[j].fiveQI = (rand() % 256) + 1; - action_def_frm_1.meas_info_lst[i].label_info_lst[j].sliceID = calloc(1, sizeof(s_nssai_e2sm_t)); - action_def_frm_1.meas_info_lst[i].label_info_lst[j].sliceID->sST = (rand() % (1 << 8)) + 1; - action_def_frm_1.meas_info_lst[i].label_info_lst[j].sliceID->sD = calloc(1, sizeof(uint32_t)); - *action_def_frm_1.meas_info_lst[i].label_info_lst[j].sliceID->sD = 786432; // (rand() % 2^24) + 0; - } - } - } - - // Granularity Period - action_def_frm_1.gran_period_ms = (rand() % 4294967295) + 0; - - // Cell Global ID - OPTIONAL - action_def_frm_1.cell_global_id = calloc(1, sizeof(*action_def_frm_1.cell_global_id)); - action_def_frm_1.cell_global_id->type = rand()%END_CGI_RAT_TYPE; - - switch (action_def_frm_1.cell_global_id->type) - { - case NR_CGI_RAT_TYPE: - action_def_frm_1.cell_global_id->nr_cgi.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; - action_def_frm_1.cell_global_id->nr_cgi.nr_cell_id = (rand() % 2^36) + 1; - break; - - case EUTRA_CGI_RAT_TYPE: - action_def_frm_1.cell_global_id->eutra.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; - action_def_frm_1.cell_global_id->eutra.eutra_cell_id = (rand() % 2^28) + 0; - break; - - default: - assert(false && "Unknown Cell Global ID Type"); - } - -#if defined KPM_V2_03 || defined KPM_V3_00 - - // Measurement Bin Range - OPTIONAL - // not yet implemented in ASN.1 - possible extension - action_def_frm_1.meas_bin_range_info_lst_len = 3; // (rand() % 65535) + 0; - action_def_frm_1.meas_bin_info_lst = calloc(action_def_frm_1.meas_bin_range_info_lst_len, sizeof(meas_bin_range_info_lst_t)); - assert(action_def_frm_1.meas_bin_info_lst != NULL && "Memory exhausted"); - - for (size_t i = 0; itype = GNB_TYPE_ID; - gnb.global_gnb_id->plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; - gnb.global_gnb_id->gnb_id.nb_id = (rand() % 4294967296) + 0; - gnb.global_gnb_id->gnb_id.unused = (rand() % 11); - gnb.global_gnb_id->gnb_id.nb_id &= (0xFFFFFFFF >> (32 - gnb.global_gnb_id->gnb_id.unused) ); - - // Global NG-RAN Node ID - // C-ifDCSetup - // 6.2.3.2 - gnb.global_ng_ran_node_id = calloc(1, sizeof(*gnb.global_ng_ran_node_id)); - gnb.global_ng_ran_node_id->type = rand()%END_GLOBAL_TYPE_ID; - - switch (gnb.global_ng_ran_node_id->type) - { - case GNB_GLOBAL_TYPE_ID: - gnb.global_ng_ran_node_id->global_gnb_id.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; - gnb.global_ng_ran_node_id->global_gnb_id.type = GNB_TYPE_ID; - gnb.global_ng_ran_node_id->global_gnb_id.gnb_id.nb_id = (rand() % 4294967296) + 0; - gnb.global_ng_ran_node_id->global_gnb_id.gnb_id.unused = (rand() % 11); - gnb.global_ng_ran_node_id->global_gnb_id.gnb_id.nb_id &= (0xFFFFFFFF >> (32 - gnb.global_ng_ran_node_id->global_gnb_id.gnb_id.unused)); - break; - - case NG_ENB_GLOBAL_TYPE_ID: - gnb.global_ng_ran_node_id->global_ng_enb_id.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; - gnb.global_ng_ran_node_id->global_ng_enb_id.type = rand()%END_NG_ENB_TYPE_ID; - - switch (gnb.global_ng_ran_node_id->global_ng_enb_id.type) - { - case MACRO_NG_ENB_TYPE_ID: - gnb.global_ng_ran_node_id->global_ng_enb_id.macro_ng_enb_id = (rand() % 2^20) + 0; - break; - - case SHORT_MACRO_NG_ENB_TYPE_ID: - gnb.global_ng_ran_node_id->global_ng_enb_id.short_macro_ng_enb_id = (rand() % 2^18) + 0; - break; - - case LONG_MACRO_NG_ENB_TYPE_ID: - gnb.global_ng_ran_node_id->global_ng_enb_id.long_macro_ng_enb_id = (rand() % 2^21) + 0; - break; - - default: - assert(false && "Unknown Global NG eNB ID Type"); - } - break; - - default: - assert(false && "Unknown Global NG-RAN Node ID Type"); - } - - return gnb; -} - -static gnb_du_e2sm_t fill_rnd_gnb_du_data(void) -{ - gnb_du_e2sm_t gnb_du = {0}; - gnb_du.gnb_cu_ue_f1ap = (rand() % 4294967296) + 0; - - gnb_du.ran_ue_id = calloc(1, sizeof(*gnb_du.ran_ue_id)); - *gnb_du.ran_ue_id = (rand() % 2^64) + 0; - - return gnb_du; -} - -static gnb_cu_up_e2sm_t fill_rnd_gnb_cu_up_data(void) -{ - gnb_cu_up_e2sm_t gnb_cu_up = {0}; - gnb_cu_up.gnb_cu_cp_ue_e1ap = (rand() % 4294967296) + 0; - - gnb_cu_up.ran_ue_id = calloc(1, sizeof(*gnb_cu_up.ran_ue_id)); - *gnb_cu_up.ran_ue_id = (rand() % 2^64) + 0; - - return gnb_cu_up; -} - -static ng_enb_e2sm_t fill_rnd_ng_enb_data(void) -{ - ng_enb_e2sm_t ng_enb = {0}; - - // 6.2.3.16 - // Mandatory - // AMF UE NGAP ID - ng_enb.amf_ue_ngap_id = (rand() % 2^40) + 0; - - // 6.2.3.17 - // Mandatory - // GUAMI - ng_enb.guami.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; - - ng_enb.guami.amf_region_id = (rand() % 2^8) + 0; - ng_enb.guami.amf_set_id = (rand() % 2^10) + 0; - ng_enb.guami.amf_ptr = (rand() % 2^6) + 0; - - // 6.2.3.22 - // C-if CU DU separated - // ng-eNB-CU UE W1AP ID - ng_enb.ng_enb_cu_ue_w1ap_id = calloc(1, sizeof(uint32_t)); - assert(ng_enb.ng_enb_cu_ue_w1ap_id != NULL && "Memory exhausted"); - *ng_enb.ng_enb_cu_ue_w1ap_id = (rand() % 4294967296) + 0; - - // 6.2.3.19 - // C- ifDCSetup - // M-NG-RAN node UE XnAP ID - ng_enb.ng_ran_node_ue_xnap_id = calloc(1, sizeof(uint32_t)); - assert(ng_enb.ng_ran_node_ue_xnap_id != NULL && "Memory exhausted"); - *ng_enb.ng_ran_node_ue_xnap_id = (rand() % 4294967296) + 0; - - // OPTIONAL - // This IE shall not be used. Global NG-RAN Node ID IE shall replace this IE - ng_enb.global_ng_enb_id = calloc(1, sizeof(*ng_enb.global_ng_enb_id)); - assert(ng_enb.global_ng_enb_id != NULL && "Memory exhausted"); - ng_enb.global_ng_enb_id->plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; - - ng_enb.global_ng_enb_id->type = rand()%END_NG_ENB_TYPE_ID; - - switch (ng_enb.global_ng_enb_id->type) - { - case MACRO_NG_ENB_TYPE_ID: - ng_enb.global_ng_enb_id->macro_ng_enb_id = (rand() % 2^20) + 0; - break; - - case SHORT_MACRO_NG_ENB_TYPE_ID: - ng_enb.global_ng_enb_id->short_macro_ng_enb_id = (rand() % 2^18) + 0; - break; - - case LONG_MACRO_NG_ENB_TYPE_ID: - ng_enb.global_ng_enb_id->long_macro_ng_enb_id = (rand() % 2^21) + 0; - break; - - default: - assert(false && "Unknown Global NG eNB ID Type"); - } - - - // Global NG-RAN Node ID - // C-ifDCSetup - // 6.2.3.2 - ng_enb.global_ng_ran_node_id = calloc(1, sizeof(*ng_enb.global_ng_ran_node_id)); - assert(ng_enb.global_ng_ran_node_id != NULL && "Memory exhausted"); - ng_enb.global_ng_ran_node_id->type = rand()%END_GLOBAL_TYPE_ID; - - switch (ng_enb.global_ng_ran_node_id->type) - { - case GNB_GLOBAL_TYPE_ID: - ng_enb.global_ng_ran_node_id->global_gnb_id.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; - ng_enb.global_ng_ran_node_id->global_gnb_id.type = GNB_TYPE_ID; - ng_enb.global_ng_ran_node_id->global_gnb_id.gnb_id.nb_id = (rand() % 4294967296) + 0; - ng_enb.global_ng_ran_node_id->global_gnb_id.gnb_id.unused = (rand() % 11); - ng_enb.global_ng_ran_node_id->global_gnb_id.gnb_id.nb_id &= (0xFFFFFFFF >> (32 - ng_enb.global_ng_ran_node_id->global_gnb_id.gnb_id.unused)); - break; - - case NG_ENB_GLOBAL_TYPE_ID: - ng_enb.global_ng_ran_node_id->global_ng_enb_id.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; - ng_enb.global_ng_ran_node_id->global_ng_enb_id.type = rand()%END_NG_ENB_TYPE_ID; - - switch (ng_enb.global_ng_ran_node_id->global_ng_enb_id.type) - { - case MACRO_NG_ENB_TYPE_ID: - ng_enb.global_ng_ran_node_id->global_ng_enb_id.macro_ng_enb_id = (rand() % 2^20) + 0; - break; - - case SHORT_MACRO_NG_ENB_TYPE_ID: - ng_enb.global_ng_ran_node_id->global_ng_enb_id.short_macro_ng_enb_id = (rand() % 2^18) + 0; - break; - - case LONG_MACRO_NG_ENB_TYPE_ID: - ng_enb.global_ng_ran_node_id->global_ng_enb_id.long_macro_ng_enb_id = (rand() % 2^21) + 0; - break; - - default: - assert(false && "Unknown Global NG eNB ID Type"); - } - break; - - default: - assert(false && "Unknown Global NG-RAN Node ID Type"); - } - - return ng_enb; -} - -static ng_enb_du_e2sm_t fill_rnd_ng_enb_du_data(void) -{ - ng_enb_du_e2sm_t ng_enb_du = {0}; - - // 6.2.3.22 - // C-if CU DU separated - // ng-eNB-CU UE W1AP ID - ng_enb_du.ng_enb_cu_ue_w1ap_id = (rand() % 4294967296) + 0; - - return ng_enb_du; -} - -static en_gnb_e2sm_t fill_rnd_en_gnb_data(void) -{ - en_gnb_e2sm_t en_gnb = {0}; - - // 6.2.3.23 - // Mandatory - // MeNB UE X2AP ID - en_gnb.enb_ue_x2ap_id = rand() % 4096; - - // 6.2.3.24 - // OPTIONAL - // MeNB UE X2AP ID Extension - en_gnb.enb_ue_x2ap_id_extension = calloc(1, sizeof(uint16_t)); - assert(en_gnb.enb_ue_x2ap_id_extension != NULL && "Memory exhausted"); - *en_gnb.enb_ue_x2ap_id_extension = rand() % 4096; - - // 6.2.3.9 - // Mandatory - // Global eNB ID - en_gnb.global_enb_id.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; - - en_gnb.global_enb_id.type = rand()%SHORT_MACRO_ENB_TYPE_ID; - - switch (en_gnb.global_enb_id.type) - { - case MACRO_ENB_TYPE_ID: - en_gnb.global_enb_id.macro_enb_id = (rand() % 2^20) + 0; - break; - - case HOME_ENB_TYPE_ID: - en_gnb.global_enb_id.home_enb_id = (rand() % 2^28) + 0; - break; - - /* Possible extensions: */ - // case SHORT_MACRO_ENB_TYPE_ID: - // en_gnb.global_enb_id.short_macro_enb_id = (rand() % 2^18) + 0; - // break; - - // case LONG_MACRO_ENB_TYPE_ID: - // en_gnb.global_enb_id.long_macro_enb_id = (rand() % 2^21) + 0; - // break; - - default: - break; - } - - // 6.2.3.21 - // gNB-CU UE F1AP ID - // C-ifCUDUseparated - en_gnb.gnb_cu_ue_f1ap_lst = calloc(1, sizeof(uint32_t)); - assert(en_gnb.gnb_cu_ue_f1ap_lst != NULL && "Memory exhausted"); - *en_gnb.gnb_cu_ue_f1ap_lst = (rand() % 4294967296) + 0; - - // gNB-CU-CP UE E1AP ID List - // C-ifCPUPseparated - en_gnb.gnb_cu_cp_ue_e1ap_lst_len = 3; - en_gnb.gnb_cu_cp_ue_e1ap_lst = calloc(en_gnb.gnb_cu_cp_ue_e1ap_lst_len, sizeof(uint32_t)); - for (size_t i = 0; i < en_gnb.gnb_cu_cp_ue_e1ap_lst_len; i++) - { - en_gnb.gnb_cu_cp_ue_e1ap_lst[i] = (rand() % 4294967296) + 0; - } - - // RAN UE ID - // Optional - // 6.2.3.25 - en_gnb.ran_ue_id = calloc(1, sizeof(uint64_t)); - assert(en_gnb.ran_ue_id != NULL && "Memory exhausted"); - *en_gnb.ran_ue_id = (rand() % 2^64) + 0; - - return en_gnb; -} - -static enb_e2sm_t fill_rnd_enb_data(void) -{ - enb_e2sm_t enb = {0}; - - // 6.2.3.26 - // Mandatory - // MME UE S1AP ID - enb.mme_ue_s1ap_id = (rand() % 4294967296) + 0; - - // 6.2.3.18 - // Mandatory - // GUMMEI - enb.gummei.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; - enb.gummei.mme_group_id = (rand() % 2^16) + 0; - enb.gummei.mme_code = (rand() % 2^8) + 0; - - // 6.2.3.23 - // C-ifDCSetup - // MeNB UE X2AP ID - enb.enb_ue_x2ap_id = calloc(1, sizeof(uint16_t)); - assert(enb.enb_ue_x2ap_id != NULL && "Memory exhausted"); - *enb.enb_ue_x2ap_id = rand() % 4096; - - // 6.2.3.24 - // C-ifDCSetup - // MeNB UE X2AP ID Extension - enb.enb_ue_x2ap_id_extension = calloc(1, sizeof(uint16_t)); - assert(enb.enb_ue_x2ap_id_extension != NULL && "Memory exhausted"); - *enb.enb_ue_x2ap_id_extension = rand() % 4096; - - // 6.2.3.9 - // C-ifDCSetup - // Global eNB ID - enb.global_enb_id = calloc(1, sizeof(*enb.global_enb_id)); - assert(enb.global_enb_id != NULL && "Memory exhausted"); - - enb.global_enb_id->plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; - - enb.global_enb_id->type = rand()%SHORT_MACRO_ENB_TYPE_ID; - - switch (enb.global_enb_id->type) - { - case MACRO_ENB_TYPE_ID: - enb.global_enb_id->macro_enb_id = (rand() % 2^20) + 0; - break; - - case HOME_ENB_TYPE_ID: - enb.global_enb_id->home_enb_id = (rand() % 2^28) + 0; - break; - - /* Possible extensions: */ - // case SHORT_MACRO_ENB_TYPE_ID: - // enb.global_enb_id->short_macro_enb_id = (rand() % 2^18) + 0; - // break; - - // case LONG_MACRO_ENB_TYPE_ID: - // enb.global_enb_id->long_macro_enb_id = (rand() % 2^21) + 0; - // break; - - default: - break; - } - - return enb; -} - -static ue_id_e2sm_t fill_rnd_ue_id_data(void) -{ - ue_id_e2sm_t ue_id_data = {0}; - - ue_id_data.type = rand()%END_UE_ID_E2SM; - - switch (ue_id_data.type) - { - case GNB_UE_ID_E2SM: - ue_id_data.gnb = fill_rnd_gnb_data(); - break; - - case GNB_DU_UE_ID_E2SM: - ue_id_data.gnb_du = fill_rnd_gnb_du_data(); - break; - - case GNB_CU_UP_UE_ID_E2SM: - ue_id_data.gnb_cu_up = fill_rnd_gnb_cu_up_data(); - break; - - case NG_ENB_UE_ID_E2SM: - ue_id_data.ng_enb = fill_rnd_ng_enb_data(); - break; - - case NG_ENB_DU_UE_ID_E2SM: - ue_id_data.ng_enb_du = fill_rnd_ng_enb_du_data(); - break; - - case EN_GNB_UE_ID_E2SM: - ue_id_data.en_gnb = fill_rnd_en_gnb_data(); - break; - - case ENB_UE_ID_E2SM: - ue_id_data.enb = fill_rnd_enb_data(); - break; - - default: - assert(false && "Unknown UE ID Type"); - } - - return ue_id_data; -} - -static kpm_act_def_format_2_t fill_rnd_kpm_action_def_frm_2(void) -{ - kpm_act_def_format_2_t action_def_frm_2 = {0}; - - // UE ID - action_def_frm_2.ue_id = fill_rnd_ue_id_data(); - - // Action Definition Format 1 - action_def_frm_2.action_def_format_1 = fill_rnd_kpm_action_def_frm_1(); - - return action_def_frm_2; -} - -static -test_cond_value_t fill_rnd_test_cond_value(void) -{ - test_cond_value_t dst = {0}; - -label: - dst.type = rand() % END_TEST_COND_VALUE; - - if(dst.type == BIT_STRING_TEST_COND_VALUE ) - goto label; // Not implemented - - if(dst.type == INTEGER_TEST_COND_VALUE){ - dst.int_value = calloc(1, sizeof(int64_t)); - assert(dst.int_value != NULL && "Memory exhausted"); - *dst.int_value = rand(); - } else if (dst.type == ENUMERATED_TEST_COND_VALUE){ - dst.enum_value = calloc(1, sizeof(int64_t )); - assert(dst.enum_value != NULL && "Memory exhausted"); - *dst.enum_value = rand(); - } else if(dst.type == BOOLEAN_TEST_COND_VALUE ){ - dst.bool_value = calloc(1, sizeof(bool)); - assert(dst.bool_value != NULL && "Memory exhausted"); - *dst.bool_value = rand(); - } else if(dst.type == BIT_STRING_TEST_COND_VALUE){ - assert(0!= 0 && "Not implemented"); - //dst.bit_string_value = calloc(1, sizeof(byte_array_t)); - //assert(dst.bit_string_value != NULL && "Memory exhausted"); - //*dst.bit_string_value = cp_str_to_ba("Test"); - } else if(dst.type == OCTET_STRING_TEST_COND_VALUE){ - dst.octet_string_value = calloc(1, sizeof(byte_array_t)); - assert(dst. octet_string_value != NULL && "Memory exhausted"); - *dst.octet_string_value = cp_str_to_ba("Test"); - } else if(dst.type == PRINTABLE_STRING_TEST_COND_VALUE){ - dst.printable_string_value = calloc(1, sizeof(byte_array_t)); - assert(dst. printable_string_value != NULL && "Memory exhausted"); - *dst.printable_string_value = cp_str_to_ba("Test"); -#if defined KPM_V2_03 || defined KPM_V3_00 - } else if(dst.type == REAL_TEST_COND_VALUE){ - dst.real_value = calloc(1, sizeof(double)); - assert(dst.real_value != NULL && "Memory exhausted"); - *dst.real_value= rand(); -#endif - } else { - assert(0!= 0 && "Unknown condition value"); - } - - return dst; -} - - - -static test_info_lst_t fill_rnd_kpm_test_info(void) -{ - test_info_lst_t test_info = {0}; - -#if defined KPM_V2_01 - test_info.test_cond_type = rand()% UL_RSRP_TEST_COND_TYPE; -#elif defined KPM_V2_03 || defined KPM_V3_00 - test_info.test_cond_type = rand()%END_TEST_COND_TYPE_KPM_V2_01; -#else - _Static_assert(0!=0 && "Unknown KPM Version"); -#endif - - - switch (test_info.test_cond_type) - { - case GBR_TEST_COND_TYPE: - test_info.GBR = TRUE_TEST_COND_TYPE; - break; - - case AMBR_TEST_COND_TYPE: - test_info.AMBR = TRUE_TEST_COND_TYPE; - break; - - case IsStat_TEST_COND_TYPE: - test_info.IsStat = TRUE_TEST_COND_TYPE; - break; - - case IsCatM_TEST_COND_TYPE: - test_info.IsCatM = TRUE_TEST_COND_TYPE; - break; - - case DL_RSRP_TEST_COND_TYPE: - test_info.DL_RSRP = TRUE_TEST_COND_TYPE; - break; - - case DL_RSRQ_TEST_COND_TYPE: - test_info.DL_RSRQ = TRUE_TEST_COND_TYPE; - break; -#if defined KPM_V2_03 || defined KPM_V3_00 - /* Possible extensions: */ - case UL_RSRP_TEST_COND_TYPE: - test_info.UL_RSRP = TRUE_TEST_COND_TYPE; - break; - - case CQI_TEST_COND_TYPE: - test_info.CQI = TRUE_TEST_COND_TYPE; - break; - - case fiveQI_TEST_COND_TYPE: - test_info.fiveQI = TRUE_TEST_COND_TYPE; - break; - - case QCI_TEST_COND_TYPE: - test_info.QCI = TRUE_TEST_COND_TYPE; - break; - - case S_NSSAI_TEST_COND_TYPE: - test_info.S_NSSAI = TRUE_TEST_COND_TYPE; - break; -#endif - - default: - assert(false && "Condition type out of the range"); - break; - } - - // Test Condition - // Optional english, mandatory ASN - test_info.test_cond = calloc(1, sizeof(test_cond_e)); - assert(test_info.test_cond != NULL ); - *test_info.test_cond = rand() %END_TEST_COND; - - // Test Condition Value - // Optional english, mandatory ASN - test_info.test_cond_value = calloc(1, sizeof(test_cond_value_t)); - assert(test_info.test_cond_value != NULL && "Memory exhausted"); - *test_info.test_cond_value = fill_rnd_test_cond_value(); - - return test_info; -} - -static kpm_act_def_format_3_t fill_rnd_kpm_action_def_frm_3(void) -{ - kpm_act_def_format_3_t action_def_frm_3 = {0}; - - // Measurement Information - // [1, 65535] - action_def_frm_3.meas_info_lst_len = 2; //(rand() % 65535) + 1; - - action_def_frm_3.meas_info_lst = calloc(action_def_frm_3.meas_info_lst_len, sizeof(meas_info_format_3_lst_t)); - assert(action_def_frm_3.meas_info_lst != NULL && "Memory exhausted" ); - - for (size_t i = 0; i < action_def_frm_3.meas_info_lst_len; i++) - { - meas_info_format_3_lst_t* meas_info = &action_def_frm_3.meas_info_lst[i]; - - // Measurement Type - meas_info->meas_type.type = rand()%END_MEAS_TYPE; - - switch (meas_info->meas_type.type) - { - case NAME_MEAS_TYPE: - meas_info->meas_type.type = NAME_MEAS_TYPE; - meas_info->meas_type.name.buf = calloc(strlen("test") + 1, sizeof(uint8_t)); - memcpy(meas_info->meas_type.name.buf, "test", strlen("test")); - meas_info->meas_type.name.len = strlen("test"); - break; - - case ID_MEAS_TYPE: - meas_info->meas_type.type = ID_MEAS_TYPE; - meas_info->meas_type.id = (rand() % 65536) + 1; - break; - - default: - assert(false && "Unknown Measurement Type"); - } - - // Matching Condition Format 3 - // [1, 32768] - meas_info->matching_cond_lst_len = 10; // (rand() % 32768) + 1; - - meas_info->matching_cond_lst = calloc(meas_info->matching_cond_lst_len, sizeof(*meas_info->matching_cond_lst)); - assert(meas_info->matching_cond_lst != NULL && "Memory exhausted" ); - - for (size_t j = 0; j < meas_info->matching_cond_lst_len; j++) - { - // Matching Condition Type - meas_info->matching_cond_lst[j].cond_type = rand()%END_INFO; - - switch (meas_info->matching_cond_lst[j].cond_type) - { - case LABEL_INFO: - meas_info->matching_cond_lst[j].label_info_lst.plmn_id = calloc(1, sizeof(e2sm_plmn_t)); - assert(meas_info->matching_cond_lst[j].label_info_lst.plmn_id != NULL && "Memory exhausted"); - *meas_info->matching_cond_lst[j].label_info_lst.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; - break; - - case TEST_INFO: - meas_info->matching_cond_lst[j].test_info_lst = fill_rnd_kpm_test_info(); - break; - - default: - assert(false && "Unknown Matching Condition Type"); - } - -#if defined KPM_V2_03 || defined KPM_V3_00 - // Logical OR - meas_info->matching_cond_lst[j].logical_OR = calloc(1, sizeof(enum_value_e)); - assert(meas_info->matching_cond_lst[j].logical_OR != NULL && "Memory exhausted"); - *meas_info->matching_cond_lst[j].logical_OR = TRUE_ENUM_VALUE; -#endif - } - - -#if defined KPM_V2_03 || defined KPM_V3_00 - // Bin Range Definition - // not yet implemented in ASN.1 - possible extension - - meas_info->bin_range_def = calloc(1, sizeof(bin_range_def_t)); - assert(meas_info->bin_range_def != NULL && "Memory exhausted"); - - meas_info->bin_range_def->bin_x_lst_len = 3; // (rand() % 65535) + 1; - - meas_info->bin_range_def->bin_x_lst = calloc(meas_info->bin_range_def->bin_x_lst_len, sizeof(bin_distr_t)); - assert(meas_info->bin_range_def->bin_x_lst != NULL && "Memory exhausted"); - - for (size_t j = 0; jbin_range_def->bin_x_lst_len; j++) - { - meas_info->bin_range_def->bin_x_lst[j].bin_index = (rand() % 65535) + 0; - meas_info->bin_range_def->bin_x_lst[j].start_value.value = rand()%END_BIN_RANGE; - - // start value - switch (meas_info->bin_range_def->bin_x_lst[j].start_value.value) - { - case INTEGER_BIN_RANGE: - meas_info->bin_range_def->bin_x_lst[j].start_value.int_value = (rand() % 4294967296) + 0; - break; - - case REAL_BIN_RANGE: - meas_info->bin_range_def->bin_x_lst[j].start_value.real_value = (rand() % 256) + 0; - - default: - break; - } - - // end value - meas_info->bin_range_def->bin_x_lst[j].end_value.value = rand()%END_BIN_RANGE; - - switch (meas_info->bin_range_def->bin_x_lst[j].end_value.value) - { - case INTEGER_BIN_RANGE: - meas_info->bin_range_def->bin_x_lst[j].end_value.int_value = (rand() % 4294967296) + 0; - break; - - case REAL_BIN_RANGE: - meas_info->bin_range_def->bin_x_lst[j].end_value.real_value = (rand() % 256) + 0; - - default: - break; - } - } - - meas_info->bin_range_def->bin_y_lst_len = 0; - meas_info->bin_range_def->bin_y_lst = NULL; - - meas_info->bin_range_def->bin_z_lst_len = 0; - meas_info->bin_range_def->bin_z_lst = NULL; - -#endif // defined KPM_V2_03 || defined KPM_V3_00 - } - - // Granularity Period - // [0, 4294967295] - action_def_frm_3.gran_period_ms = (rand() % 4294967295) + 0; - - // Cell Global ID - // Optional - action_def_frm_3.cell_global_id = calloc(1, sizeof(*action_def_frm_3.cell_global_id)); - action_def_frm_3.cell_global_id->type = rand()%END_CGI_RAT_TYPE; - - switch (action_def_frm_3.cell_global_id->type) - { - case NR_CGI_RAT_TYPE: - action_def_frm_3.cell_global_id->nr_cgi.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; - action_def_frm_3.cell_global_id->nr_cgi.nr_cell_id = (rand() % 2^36) + 1; - break; - - case EUTRA_CGI_RAT_TYPE: - action_def_frm_3.cell_global_id->eutra.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; - action_def_frm_3.cell_global_id->eutra.eutra_cell_id = (rand() % 2^28) + 0; - break; - - default: - assert(false && "Unknown Cell Global ID Type"); - } - - return action_def_frm_3; -} - -#if defined KPM_V2_03 || defined KPM_V3_00 - -static kpm_act_def_format_4_t fill_rnd_kpm_action_def_frm_4(void) -{ - kpm_act_def_format_4_t action_def_frm_4 = {0}; - - // Matching Condition - action_def_frm_4.matching_cond_lst_len = 1; // (rand() % 32768) + 1; - - action_def_frm_4.matching_cond_lst = calloc(action_def_frm_4.matching_cond_lst_len, sizeof(matching_condition_format_4_lst_t)); - assert(action_def_frm_4.matching_cond_lst != NULL && "Memory exhausted" ); - - for (size_t i = 0; ibuf = calloc(strlen("My OAI-CU") + 1, sizeof(uint8_t)); - memcpy(hdr_frm_1.sender_name->buf, "My OAI-CU", strlen("My OAI-CU")); - hdr_frm_1.sender_name->len = strlen("My OAI-CU"); - - hdr_frm_1.sender_type = calloc(1, sizeof(byte_array_t)); - hdr_frm_1.sender_type->buf = calloc(strlen("CU") + 1, sizeof(uint8_t)); - memcpy(hdr_frm_1.sender_type->buf, "CU", strlen("CU")); - hdr_frm_1.sender_type->len = strlen("CU"); - - hdr_frm_1.vendor_name = calloc(1, sizeof(byte_array_t)); - hdr_frm_1.vendor_name->buf = calloc(strlen("OAI") + 1, sizeof(uint8_t)); - memcpy(hdr_frm_1.vendor_name->buf, "OAI", strlen("OAI")); - hdr_frm_1.vendor_name->len = strlen("OAI"); - - return hdr_frm_1; -} - -kpm_ind_hdr_t fill_rnd_kpm_ind_hdr(void) -{ - kpm_ind_hdr_t hdr = {0}; - - hdr.type = rand()%END_INDICATION_HEADER; - - switch (hdr.type) - { - case FORMAT_1_INDICATION_HEADER: - hdr.kpm_ric_ind_hdr_format_1 = fill_rnd_kpm_ind_hdr_frm_1(); - break; - - default: - assert(false && "Unknown KPM Indication Header Type"); - } - - - return hdr; -} - -static kpm_ind_msg_format_1_t fill_rnd_kpm_ind_msg_frm_1(void) -{ - kpm_ind_msg_format_1_t msg_frm_1 = {0}; - - // Measurement Data - msg_frm_1.meas_data_lst_len = 3; // (rand() % 65535) + 1; - msg_frm_1.meas_data_lst = calloc(msg_frm_1.meas_data_lst_len, sizeof(*msg_frm_1.meas_data_lst)); - assert(msg_frm_1.meas_data_lst != NULL && "Memory exhausted" ); - - for (size_t i = 0; i < msg_frm_1.meas_data_lst_len; i++) - { - // Incomplete Flag - msg_frm_1.meas_data_lst[i].incomplete_flag = calloc(1, sizeof(enum_value_e)); - assert(msg_frm_1.meas_data_lst[i].incomplete_flag != NULL && "Memory exhausted"); - *msg_frm_1.meas_data_lst[i].incomplete_flag = TRUE_ENUM_VALUE; - - // Measurement Record - msg_frm_1.meas_data_lst[i].meas_record_len = 4; // (rand() % 65535) + 1; - msg_frm_1.meas_data_lst[i].meas_record_lst = calloc(msg_frm_1.meas_data_lst[i].meas_record_len, sizeof(meas_record_lst_t)); - assert(msg_frm_1.meas_data_lst[i].meas_record_lst != NULL && "Memory exhausted" ); - - for (size_t j = 0; j < msg_frm_1.meas_data_lst[i].meas_record_len; j++) - { - msg_frm_1.meas_data_lst[i].meas_record_lst[j].value = rand()%END_MEAS_VALUE; - - switch (msg_frm_1.meas_data_lst[i].meas_record_lst[j].value) - { - case INTEGER_MEAS_VALUE: - msg_frm_1.meas_data_lst[i].meas_record_lst[j].int_val = (rand() % 4294967295) + 0; - break; - - case REAL_MEAS_VALUE: - msg_frm_1.meas_data_lst[i].meas_record_lst[j].real_val = (rand() % 256) + 0; - break; - - case NO_VALUE_MEAS_VALUE: - msg_frm_1.meas_data_lst[i].meas_record_lst[j].no_value = NULL; - break; - - default: - assert(false && "Unknown Measurement Record Type"); - } - - } - } - - // Granularity Period - OPTIONAL: (1..4294967295) - msg_frm_1.gran_period_ms = calloc(1, sizeof(*msg_frm_1.gran_period_ms)); - assert(msg_frm_1.gran_period_ms != NULL && "Memory exhausted"); - *msg_frm_1.gran_period_ms = (rand() % 4294967295) + 1; - -#if defined KPM_V2_03 || defined KPM_V3_00 - - // Measurement Information - OPTIONAL - msg_frm_1.meas_info_lst_len = 2; - msg_frm_1.meas_info_lst = calloc(msg_frm_1.meas_info_lst_len, sizeof(meas_info_format_1_lst_t)); - assert(msg_frm_1.meas_info_lst != NULL && "Memory exhausted" ); - - for (size_t i = 0; i < msg_frm_1.meas_info_lst_len; i++) - { - // Measurement Type - msg_frm_1.meas_info_lst[i].meas_type.type = rand()%END_MEAS_TYPE; - - switch (msg_frm_1.meas_info_lst[i].meas_type.type) - { - case NAME_MEAS_TYPE: - msg_frm_1.meas_info_lst[i].meas_type.type = NAME_MEAS_TYPE; - char s[100]; - snprintf(s, 100, "RNTI %04x PrbDlUsage", (unsigned) (1111*i + 1111)); - msg_frm_1.meas_info_lst[i].meas_type.name.buf = calloc(strlen(s) + 1, sizeof(uint8_t)); - memcpy(msg_frm_1.meas_info_lst[i].meas_type.name.buf, s, strlen(s)); - msg_frm_1.meas_info_lst[i].meas_type.name.len = strlen(s); - break; - - case ID_MEAS_TYPE: - msg_frm_1.meas_info_lst[i].meas_type.type = ID_MEAS_TYPE; - msg_frm_1.meas_info_lst[i].meas_type.id = (rand() % 65536) + 1; - break; - - default: - assert(false && "Unknown Measurement Type"); - } - - // Label Information - msg_frm_1.meas_info_lst[i].label_info_lst_len = 1; - msg_frm_1.meas_info_lst[i].label_info_lst = calloc(msg_frm_1.meas_info_lst[i].label_info_lst_len, sizeof(label_info_lst_t)); - assert(msg_frm_1.meas_info_lst[i].label_info_lst != NULL && "Memory exhausted" ); - - for (size_t j = 0; j < msg_frm_1.meas_info_lst[i].label_info_lst_len; j++) - { - // msg_frm_1.meas_info_lst[i].label_info_lst[j].plmn_id = malloc(sizeof(plmn_t)); - // *msg_frm_1.meas_info_lst[i].label_info_lst[j].plmn_id = (plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; - msg_frm_1.meas_info_lst[i].label_info_lst[j].noLabel = malloc(sizeof(enum_value_e)); - *msg_frm_1.meas_info_lst[i].label_info_lst[j].noLabel = TRUE_ENUM_VALUE; - } - } - -#endif // defined KPM_V2_03 || defined KPM_V3_00 - - return msg_frm_1; -} - -static kpm_ind_msg_format_2_t fill_rnd_kpm_ind_msg_frm_2(void) -{ - kpm_ind_msg_format_2_t msg_frm_2 = {0}; - - // Measurement Data - msg_frm_2.meas_data_lst_len = 2; // (rand() % 65535) + 1; - msg_frm_2.meas_data_lst = calloc(msg_frm_2.meas_data_lst_len, sizeof(*msg_frm_2.meas_data_lst)); - assert(msg_frm_2.meas_data_lst != NULL && "Memory exhausted" ); - - for (size_t i = 0; i < msg_frm_2.meas_data_lst_len; i++) - { - // Incomplete Flag - msg_frm_2.meas_data_lst[i].incomplete_flag = calloc(1, sizeof(enum_value_e)); - assert(msg_frm_2.meas_data_lst[i].incomplete_flag != NULL && "Memory exhausted"); - *msg_frm_2.meas_data_lst[i].incomplete_flag = TRUE_ENUM_VALUE; - - // Measurement Record - msg_frm_2.meas_data_lst[i].meas_record_len = 1; // (rand() % 65535) + 1; - msg_frm_2.meas_data_lst[i].meas_record_lst = calloc(msg_frm_2.meas_data_lst[i].meas_record_len, sizeof(meas_record_lst_t)); - assert(msg_frm_2.meas_data_lst[i].meas_record_lst != NULL && "Memory exhausted" ); - - for (size_t j = 0; j < msg_frm_2.meas_data_lst[i].meas_record_len; j++) - { - msg_frm_2.meas_data_lst[i].meas_record_lst[j].value = rand()%END_MEAS_VALUE; - - switch (msg_frm_2.meas_data_lst[i].meas_record_lst[j].value) - { - case INTEGER_MEAS_VALUE: - msg_frm_2.meas_data_lst[i].meas_record_lst[j].int_val = (rand() % 4294967295) + 0; - break; - - case REAL_MEAS_VALUE: - msg_frm_2.meas_data_lst[i].meas_record_lst[j].real_val = (rand() % 256) + 0; - break; - - case NO_VALUE_MEAS_VALUE: - msg_frm_2.meas_data_lst[i].meas_record_lst[j].no_value = NULL; - break; - - default: - assert(false && "Unknown Measurement Record Type"); - } - } - } - - // Granularity Period - OPTIONAL - msg_frm_2.gran_period_ms = calloc(1, sizeof(*msg_frm_2.gran_period_ms)); - assert(msg_frm_2.gran_period_ms != NULL && "Memory exhausted"); - *msg_frm_2.gran_period_ms = (rand() % 4294967295) + 1; - - // Measurement Information Condition UE - // [1, 65535] - msg_frm_2.meas_info_cond_ue_lst_len = 1; // (rand() % 65535) + 1; - msg_frm_2.meas_info_cond_ue_lst = calloc(msg_frm_2.meas_info_cond_ue_lst_len, sizeof(meas_info_cond_ue_lst_t)); - assert(msg_frm_2.meas_info_cond_ue_lst != NULL && "Memory exhausted"); - - for (size_t i = 0; imeas_type.type = rand()%END_MEAS_TYPE; - - switch (cond_ue->meas_type.type) - { - case NAME_MEAS_TYPE: - cond_ue->meas_type.type = NAME_MEAS_TYPE; - cond_ue->meas_type.name.buf = calloc(strlen("condition UE measurement") + 1, sizeof(uint8_t)); - memcpy(cond_ue->meas_type.name.buf, "condition UE measurement", strlen("condition UE measurement")); - cond_ue->meas_type.name.len = strlen("condition UE measurement"); - break; - - case ID_MEAS_TYPE: - cond_ue->meas_type.type = ID_MEAS_TYPE; - cond_ue->meas_type.id = (rand() % 65536) + 1; - break; - - default: - assert(false && "Unknown Measurement Type"); - } - - - // Matching Condition Format 3 - // [1, 32768] - cond_ue->matching_cond_lst_len = 1; // (rand() % 32768) + 1; - cond_ue->matching_cond_lst = calloc(cond_ue->matching_cond_lst_len, sizeof(*cond_ue->matching_cond_lst)); - assert(cond_ue->matching_cond_lst != NULL && "Memory exhausted" ); - - for (size_t j = 0; j < cond_ue->matching_cond_lst_len; j++) - { - // Matching Condition Type - cond_ue->matching_cond_lst[j].cond_type = rand()%END_INFO; - - switch (cond_ue->matching_cond_lst[j].cond_type) - { - case LABEL_INFO: - cond_ue->matching_cond_lst[j].label_info_lst.plmn_id = calloc(1, sizeof(e2sm_plmn_t)); - assert(cond_ue->matching_cond_lst[j].label_info_lst.plmn_id != NULL && "Memory exhausted"); - *cond_ue->matching_cond_lst[j].label_info_lst.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; - break; - - case TEST_INFO: - cond_ue->matching_cond_lst[j].test_info_lst = fill_rnd_kpm_test_info(); - break; - - default: - assert(false && "Unknown Matching Condition Type"); - } - -#if defined KPM_V2_03 || defined KPM_V3_00 - // Logical OR - cond_ue->matching_cond_lst[j].logical_OR = calloc(1, sizeof(enum_value_e)); - assert(cond_ue->matching_cond_lst[j].logical_OR != NULL && "Memory exhausted"); - *cond_ue->matching_cond_lst[j].logical_OR = TRUE_ENUM_VALUE; -#endif - } - - // List of matched UE IDs - // Optional [0, 65535] - cond_ue->ue_id_matched_lst_len = 1; // (rand() % 65535) + 0; - cond_ue->ue_id_matched_lst = calloc(cond_ue->ue_id_matched_lst_len, sizeof(ue_id_e2sm_t)); - assert(cond_ue->ue_id_matched_lst != NULL && "Memory exhausted"); - - for (size_t j = 0; jue_id_matched_lst_len; j++) - { - cond_ue->ue_id_matched_lst[j] = fill_rnd_ue_id_data(); - } - -#if defined KPM_V2_03 || defined KPM_V3_00 - // Sequence of Matched UE IDs for Granularity Periods - // not yet implemented in ASN.1 - possible extension - cond_ue->ue_id_gran_period_lst_len = 3; // (rand() % 65535) + 0; - cond_ue->ue_id_gran_period_lst = calloc(cond_ue->ue_id_gran_period_lst_len, sizeof(ue_id_gran_period_lst_t)); - assert(cond_ue->ue_id_gran_period_lst != NULL && "Memory exhausted"); - - for (size_t j = 0; jue_id_gran_period_lst_len; j++) - { - cond_ue->ue_id_gran_period_lst[j].num_matched_ue = rand()%END_MATCHED_UE; - - switch (cond_ue->ue_id_gran_period_lst[j].num_matched_ue) - { - case NONE_MATCHED_UE: - { - cond_ue->ue_id_gran_period_lst[j].no_matched_ue = TRUE_ENUM_VALUE; - break; - } - - case ONE_OR_MORE_MATCHED_UE: - { - cond_ue->ue_id_gran_period_lst[j].matched_ue_lst.ue_lst_len = 5; // (rand() % 65535) + 1; - cond_ue->ue_id_gran_period_lst[j].matched_ue_lst.ue_lst = calloc(cond_ue->ue_id_gran_period_lst[j].matched_ue_lst.ue_lst_len, sizeof(ue_id_e2sm_t)); - assert(cond_ue->ue_id_gran_period_lst[j].matched_ue_lst.ue_lst != NULL && "Memory exhausted"); - - for (size_t z = 0; zue_id_gran_period_lst[j].matched_ue_lst.ue_lst_len; z++) - { - cond_ue->ue_id_gran_period_lst[j].matched_ue_lst.ue_lst[z] = fill_rnd_ue_id_data(); - } - break; - } - - default: - break; - } - } -#endif // defined KPM_V2_03 || defined KPM_V3_00 - } - - return msg_frm_2; -} - -#if defined KPM_V2_03 || defined KPM_V3_00 -static -kpm_ind_msg_format_3_t fill_rnd_kpm_ind_msg_frm_3(void) -{ - kpm_ind_msg_format_3_t msg_frm_3 = {0}; - - msg_frm_3.ue_meas_report_lst_len = 3; // (rand() % 65535) + 1; - - msg_frm_3.meas_report_per_ue = calloc(msg_frm_3.ue_meas_report_lst_len, sizeof(meas_report_per_ue_t)); - assert(msg_frm_3.meas_report_per_ue != NULL && "Memory exhausted"); - - for (size_t i = 0; i +#include +#include +#include + +kpm_event_trigger_def_t fill_rnd_kpm_event_trigger_def(void) +{ + kpm_event_trigger_def_t dst = {0}; + + dst.type = rand()%END_FORMAT_RIC_EVENT_TRIGGER; + + if(dst.type == FORMAT_1_RIC_EVENT_TRIGGER ){ + // Normally the period is not free, need to check in the specs + dst.kpm_ric_event_trigger_format_1.report_period_ms = (rand()% 10000) + 1; //(rand()%4294967295) + 1 ; + } else { + assert(0 != 0 && "unknown type"); + } + + return dst; +} + +#if defined KPM_V2_03 || defined KPM_V3_00 +static bin_range_def_t fill_rnd_bin_range_def(void) +{ + bin_range_def_t bin_range_def = {0}; + + bin_range_def.bin_x_lst_len = 3; // (rand() % 65535) + 1; + + bin_range_def.bin_x_lst = calloc(bin_range_def.bin_x_lst_len, sizeof(bin_distr_t)); + assert(bin_range_def.bin_x_lst != NULL && "Memory exhausted"); + + for (size_t j = 0; jmeas_type.type = rand()%END_MEAS_TYPE; + + switch (meas_info->meas_type.type) + { + case NAME_MEAS_TYPE: + meas_info->meas_type.type = NAME_MEAS_TYPE; + meas_info->meas_type.name.buf = calloc(strlen("test") + 1, sizeof(uint8_t)); + memcpy(meas_info->meas_type.name.buf, "test", strlen("test")); + meas_info->meas_type.name.len = strlen("test"); + break; + + case ID_MEAS_TYPE: + meas_info->meas_type.type = ID_MEAS_TYPE; + meas_info->meas_type.id = (rand() % 65536) + 1; + break; + + default: + assert(false && "Unknown Measurement Type"); + } + + + // Label Information + // [1, 2147483647] + meas_info->label_info_lst_len = 2 ; // With the real number, we can run out of memory i.e., 2147483647 + meas_info->label_info_lst = calloc(meas_info->label_info_lst_len, sizeof(label_info_lst_t)); + assert(meas_info->label_info_lst != NULL && "Memory exhausted" ); + + for (size_t j = 0; j < meas_info->label_info_lst_len; j++) + { + if(j%2){ + meas_info->label_info_lst[j].plmn_id = malloc(sizeof(e2sm_plmn_t)); + assert(meas_info->label_info_lst[j].plmn_id != NULL); + + *meas_info->label_info_lst[j].plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; + } else { + // action_def_frm_1.meas_info_lst[i].label_info_lst[j].noLabel = malloc(sizeof(enum_value_e)); + // *action_def_frm_1.meas_info_lst[i].label_info_lst[j].noLabel = TRUE_ENUM_VALUE; + //action_def_frm_1.meas_info_lst[i].label_info_lst[j].fiveQI = calloc(1, sizeof(uint8_t)); + //assert(action_def_frm_1.meas_info_lst[i].label_info_lst[j].fiveQI != NULL && "Memory exhausted"); + //*action_def_frm_1.meas_info_lst[i].label_info_lst[j].fiveQI = (rand() % 256) + 1; + action_def_frm_1.meas_info_lst[i].label_info_lst[j].sliceID = calloc(1, sizeof(s_nssai_e2sm_t)); + action_def_frm_1.meas_info_lst[i].label_info_lst[j].sliceID->sST = (rand() % (1 << 8)) + 1; + action_def_frm_1.meas_info_lst[i].label_info_lst[j].sliceID->sD = calloc(1, sizeof(uint32_t)); + *action_def_frm_1.meas_info_lst[i].label_info_lst[j].sliceID->sD = 786432; // (rand() % 2^24) + 0; + } + } + } + + // Granularity Period + action_def_frm_1.gran_period_ms = (rand() % 4294967295) + 0; + + // Cell Global ID - OPTIONAL + action_def_frm_1.cell_global_id = calloc(1, sizeof(*action_def_frm_1.cell_global_id)); + action_def_frm_1.cell_global_id->type = rand()%END_CGI_RAT_TYPE; + + switch (action_def_frm_1.cell_global_id->type) + { + case NR_CGI_RAT_TYPE: + action_def_frm_1.cell_global_id->nr_cgi.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; + action_def_frm_1.cell_global_id->nr_cgi.nr_cell_id = (rand() % 2^36) + 1; + break; + + case EUTRA_CGI_RAT_TYPE: + action_def_frm_1.cell_global_id->eutra.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; + action_def_frm_1.cell_global_id->eutra.eutra_cell_id = (rand() % 2^28) + 0; + break; + + default: + assert(false && "Unknown Cell Global ID Type"); + } + +#if defined KPM_V2_03 || defined KPM_V3_00 + + // Measurement Bin Range - OPTIONAL + // not yet implemented in ASN.1 - possible extension + action_def_frm_1.meas_bin_range_info_lst_len = 3; // (rand() % 65535) + 0; + action_def_frm_1.meas_bin_info_lst = calloc(action_def_frm_1.meas_bin_range_info_lst_len, sizeof(meas_bin_range_info_lst_t)); + assert(action_def_frm_1.meas_bin_info_lst != NULL && "Memory exhausted"); + + for (size_t i = 0; itype = GNB_TYPE_ID; + gnb.global_gnb_id->plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; + gnb.global_gnb_id->gnb_id.nb_id = (rand() % 4294967296) + 0; + gnb.global_gnb_id->gnb_id.unused = (rand() % 11); + gnb.global_gnb_id->gnb_id.nb_id &= (0xFFFFFFFF >> (32 - gnb.global_gnb_id->gnb_id.unused) ); + + // Global NG-RAN Node ID + // C-ifDCSetup + // 6.2.3.2 + gnb.global_ng_ran_node_id = calloc(1, sizeof(*gnb.global_ng_ran_node_id)); + gnb.global_ng_ran_node_id->type = rand()%END_GLOBAL_TYPE_ID; + + switch (gnb.global_ng_ran_node_id->type) + { + case GNB_GLOBAL_TYPE_ID: + gnb.global_ng_ran_node_id->global_gnb_id.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; + gnb.global_ng_ran_node_id->global_gnb_id.type = GNB_TYPE_ID; + gnb.global_ng_ran_node_id->global_gnb_id.gnb_id.nb_id = (rand() % 4294967296) + 0; + gnb.global_ng_ran_node_id->global_gnb_id.gnb_id.unused = (rand() % 11); + gnb.global_ng_ran_node_id->global_gnb_id.gnb_id.nb_id &= (0xFFFFFFFF >> (32 - gnb.global_ng_ran_node_id->global_gnb_id.gnb_id.unused)); + break; + + case NG_ENB_GLOBAL_TYPE_ID: + gnb.global_ng_ran_node_id->global_ng_enb_id.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; + gnb.global_ng_ran_node_id->global_ng_enb_id.type = rand()%END_NG_ENB_TYPE_ID; + + switch (gnb.global_ng_ran_node_id->global_ng_enb_id.type) + { + case MACRO_NG_ENB_TYPE_ID: + gnb.global_ng_ran_node_id->global_ng_enb_id.macro_ng_enb_id = (rand() % 2^20) + 0; + break; + + case SHORT_MACRO_NG_ENB_TYPE_ID: + gnb.global_ng_ran_node_id->global_ng_enb_id.short_macro_ng_enb_id = (rand() % 2^18) + 0; + break; + + case LONG_MACRO_NG_ENB_TYPE_ID: + gnb.global_ng_ran_node_id->global_ng_enb_id.long_macro_ng_enb_id = (rand() % 2^21) + 0; + break; + + default: + assert(false && "Unknown Global NG eNB ID Type"); + } + break; + + default: + assert(false && "Unknown Global NG-RAN Node ID Type"); + } + + return gnb; +} + +static gnb_du_e2sm_t fill_rnd_gnb_du_data(void) +{ + gnb_du_e2sm_t gnb_du = {0}; + gnb_du.gnb_cu_ue_f1ap = (rand() % 4294967296) + 0; + + gnb_du.ran_ue_id = calloc(1, sizeof(*gnb_du.ran_ue_id)); + *gnb_du.ran_ue_id = (rand() % 2^64) + 0; + + return gnb_du; +} + +static gnb_cu_up_e2sm_t fill_rnd_gnb_cu_up_data(void) +{ + gnb_cu_up_e2sm_t gnb_cu_up = {0}; + gnb_cu_up.gnb_cu_cp_ue_e1ap = (rand() % 4294967296) + 0; + + gnb_cu_up.ran_ue_id = calloc(1, sizeof(*gnb_cu_up.ran_ue_id)); + *gnb_cu_up.ran_ue_id = (rand() % 2^64) + 0; + + return gnb_cu_up; +} + +static ng_enb_e2sm_t fill_rnd_ng_enb_data(void) +{ + ng_enb_e2sm_t ng_enb = {0}; + + // 6.2.3.16 + // Mandatory + // AMF UE NGAP ID + ng_enb.amf_ue_ngap_id = (rand() % 2^40) + 0; + + // 6.2.3.17 + // Mandatory + // GUAMI + ng_enb.guami.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; + + ng_enb.guami.amf_region_id = (rand() % 2^8) + 0; + ng_enb.guami.amf_set_id = (rand() % 2^10) + 0; + ng_enb.guami.amf_ptr = (rand() % 2^6) + 0; + + // 6.2.3.22 + // C-if CU DU separated + // ng-eNB-CU UE W1AP ID + ng_enb.ng_enb_cu_ue_w1ap_id = calloc(1, sizeof(uint32_t)); + assert(ng_enb.ng_enb_cu_ue_w1ap_id != NULL && "Memory exhausted"); + *ng_enb.ng_enb_cu_ue_w1ap_id = (rand() % 4294967296) + 0; + + // 6.2.3.19 + // C- ifDCSetup + // M-NG-RAN node UE XnAP ID + ng_enb.ng_ran_node_ue_xnap_id = calloc(1, sizeof(uint32_t)); + assert(ng_enb.ng_ran_node_ue_xnap_id != NULL && "Memory exhausted"); + *ng_enb.ng_ran_node_ue_xnap_id = (rand() % 4294967296) + 0; + + // OPTIONAL + // This IE shall not be used. Global NG-RAN Node ID IE shall replace this IE + ng_enb.global_ng_enb_id = calloc(1, sizeof(*ng_enb.global_ng_enb_id)); + assert(ng_enb.global_ng_enb_id != NULL && "Memory exhausted"); + ng_enb.global_ng_enb_id->plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; + + ng_enb.global_ng_enb_id->type = rand()%END_NG_ENB_TYPE_ID; + + switch (ng_enb.global_ng_enb_id->type) + { + case MACRO_NG_ENB_TYPE_ID: + ng_enb.global_ng_enb_id->macro_ng_enb_id = (rand() % 2^20) + 0; + break; + + case SHORT_MACRO_NG_ENB_TYPE_ID: + ng_enb.global_ng_enb_id->short_macro_ng_enb_id = (rand() % 2^18) + 0; + break; + + case LONG_MACRO_NG_ENB_TYPE_ID: + ng_enb.global_ng_enb_id->long_macro_ng_enb_id = (rand() % 2^21) + 0; + break; + + default: + assert(false && "Unknown Global NG eNB ID Type"); + } + + + // Global NG-RAN Node ID + // C-ifDCSetup + // 6.2.3.2 + ng_enb.global_ng_ran_node_id = calloc(1, sizeof(*ng_enb.global_ng_ran_node_id)); + assert(ng_enb.global_ng_ran_node_id != NULL && "Memory exhausted"); + ng_enb.global_ng_ran_node_id->type = rand()%END_GLOBAL_TYPE_ID; + + switch (ng_enb.global_ng_ran_node_id->type) + { + case GNB_GLOBAL_TYPE_ID: + ng_enb.global_ng_ran_node_id->global_gnb_id.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; + ng_enb.global_ng_ran_node_id->global_gnb_id.type = GNB_TYPE_ID; + ng_enb.global_ng_ran_node_id->global_gnb_id.gnb_id.nb_id = (rand() % 4294967296) + 0; + ng_enb.global_ng_ran_node_id->global_gnb_id.gnb_id.unused = (rand() % 11); + ng_enb.global_ng_ran_node_id->global_gnb_id.gnb_id.nb_id &= (0xFFFFFFFF >> (32 - ng_enb.global_ng_ran_node_id->global_gnb_id.gnb_id.unused)); + break; + + case NG_ENB_GLOBAL_TYPE_ID: + ng_enb.global_ng_ran_node_id->global_ng_enb_id.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; + ng_enb.global_ng_ran_node_id->global_ng_enb_id.type = rand()%END_NG_ENB_TYPE_ID; + + switch (ng_enb.global_ng_ran_node_id->global_ng_enb_id.type) + { + case MACRO_NG_ENB_TYPE_ID: + ng_enb.global_ng_ran_node_id->global_ng_enb_id.macro_ng_enb_id = (rand() % 2^20) + 0; + break; + + case SHORT_MACRO_NG_ENB_TYPE_ID: + ng_enb.global_ng_ran_node_id->global_ng_enb_id.short_macro_ng_enb_id = (rand() % 2^18) + 0; + break; + + case LONG_MACRO_NG_ENB_TYPE_ID: + ng_enb.global_ng_ran_node_id->global_ng_enb_id.long_macro_ng_enb_id = (rand() % 2^21) + 0; + break; + + default: + assert(false && "Unknown Global NG eNB ID Type"); + } + break; + + default: + assert(false && "Unknown Global NG-RAN Node ID Type"); + } + + return ng_enb; +} + +static ng_enb_du_e2sm_t fill_rnd_ng_enb_du_data(void) +{ + ng_enb_du_e2sm_t ng_enb_du = {0}; + + // 6.2.3.22 + // C-if CU DU separated + // ng-eNB-CU UE W1AP ID + ng_enb_du.ng_enb_cu_ue_w1ap_id = (rand() % 4294967296) + 0; + + return ng_enb_du; +} + +static en_gnb_e2sm_t fill_rnd_en_gnb_data(void) +{ + en_gnb_e2sm_t en_gnb = {0}; + + // 6.2.3.23 + // Mandatory + // MeNB UE X2AP ID + en_gnb.enb_ue_x2ap_id = rand() % 4096; + + // 6.2.3.24 + // OPTIONAL + // MeNB UE X2AP ID Extension + en_gnb.enb_ue_x2ap_id_extension = calloc(1, sizeof(uint16_t)); + assert(en_gnb.enb_ue_x2ap_id_extension != NULL && "Memory exhausted"); + *en_gnb.enb_ue_x2ap_id_extension = rand() % 4096; + + // 6.2.3.9 + // Mandatory + // Global eNB ID + en_gnb.global_enb_id.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; + + en_gnb.global_enb_id.type = rand()%SHORT_MACRO_ENB_TYPE_ID; + + switch (en_gnb.global_enb_id.type) + { + case MACRO_ENB_TYPE_ID: + en_gnb.global_enb_id.macro_enb_id = (rand() % 2^20) + 0; + break; + + case HOME_ENB_TYPE_ID: + en_gnb.global_enb_id.home_enb_id = (rand() % 2^28) + 0; + break; + + /* Possible extensions: */ + // case SHORT_MACRO_ENB_TYPE_ID: + // en_gnb.global_enb_id.short_macro_enb_id = (rand() % 2^18) + 0; + // break; + + // case LONG_MACRO_ENB_TYPE_ID: + // en_gnb.global_enb_id.long_macro_enb_id = (rand() % 2^21) + 0; + // break; + + default: + break; + } + + // 6.2.3.21 + // gNB-CU UE F1AP ID + // C-ifCUDUseparated + en_gnb.gnb_cu_ue_f1ap_lst = calloc(1, sizeof(uint32_t)); + assert(en_gnb.gnb_cu_ue_f1ap_lst != NULL && "Memory exhausted"); + *en_gnb.gnb_cu_ue_f1ap_lst = (rand() % 4294967296) + 0; + + // gNB-CU-CP UE E1AP ID List + // C-ifCPUPseparated + en_gnb.gnb_cu_cp_ue_e1ap_lst_len = 3; + en_gnb.gnb_cu_cp_ue_e1ap_lst = calloc(en_gnb.gnb_cu_cp_ue_e1ap_lst_len, sizeof(uint32_t)); + for (size_t i = 0; i < en_gnb.gnb_cu_cp_ue_e1ap_lst_len; i++) + { + en_gnb.gnb_cu_cp_ue_e1ap_lst[i] = (rand() % 4294967296) + 0; + } + + // RAN UE ID + // Optional + // 6.2.3.25 + en_gnb.ran_ue_id = calloc(1, sizeof(uint64_t)); + assert(en_gnb.ran_ue_id != NULL && "Memory exhausted"); + *en_gnb.ran_ue_id = (rand() % 2^64) + 0; + + return en_gnb; +} + +static enb_e2sm_t fill_rnd_enb_data(void) +{ + enb_e2sm_t enb = {0}; + + // 6.2.3.26 + // Mandatory + // MME UE S1AP ID + enb.mme_ue_s1ap_id = (rand() % 4294967296) + 0; + + // 6.2.3.18 + // Mandatory + // GUMMEI + enb.gummei.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; + enb.gummei.mme_group_id = (rand() % 2^16) + 0; + enb.gummei.mme_code = (rand() % 2^8) + 0; + + // 6.2.3.23 + // C-ifDCSetup + // MeNB UE X2AP ID + enb.enb_ue_x2ap_id = calloc(1, sizeof(uint16_t)); + assert(enb.enb_ue_x2ap_id != NULL && "Memory exhausted"); + *enb.enb_ue_x2ap_id = rand() % 4096; + + // 6.2.3.24 + // C-ifDCSetup + // MeNB UE X2AP ID Extension + enb.enb_ue_x2ap_id_extension = calloc(1, sizeof(uint16_t)); + assert(enb.enb_ue_x2ap_id_extension != NULL && "Memory exhausted"); + *enb.enb_ue_x2ap_id_extension = rand() % 4096; + + // 6.2.3.9 + // C-ifDCSetup + // Global eNB ID + enb.global_enb_id = calloc(1, sizeof(*enb.global_enb_id)); + assert(enb.global_enb_id != NULL && "Memory exhausted"); + + enb.global_enb_id->plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; + + enb.global_enb_id->type = rand()%SHORT_MACRO_ENB_TYPE_ID; + + switch (enb.global_enb_id->type) + { + case MACRO_ENB_TYPE_ID: + enb.global_enb_id->macro_enb_id = (rand() % 2^20) + 0; + break; + + case HOME_ENB_TYPE_ID: + enb.global_enb_id->home_enb_id = (rand() % 2^28) + 0; + break; + + /* Possible extensions: */ + // case SHORT_MACRO_ENB_TYPE_ID: + // enb.global_enb_id->short_macro_enb_id = (rand() % 2^18) + 0; + // break; + + // case LONG_MACRO_ENB_TYPE_ID: + // enb.global_enb_id->long_macro_enb_id = (rand() % 2^21) + 0; + // break; + + default: + break; + } + + return enb; +} + +static ue_id_e2sm_t fill_rnd_ue_id_data(void) +{ + ue_id_e2sm_t ue_id_data = {0}; + + ue_id_data.type = rand()%END_UE_ID_E2SM; + + switch (ue_id_data.type) + { + case GNB_UE_ID_E2SM: + ue_id_data.gnb = fill_rnd_gnb_data(); + break; + + case GNB_DU_UE_ID_E2SM: + ue_id_data.gnb_du = fill_rnd_gnb_du_data(); + break; + + case GNB_CU_UP_UE_ID_E2SM: + ue_id_data.gnb_cu_up = fill_rnd_gnb_cu_up_data(); + break; + + case NG_ENB_UE_ID_E2SM: + ue_id_data.ng_enb = fill_rnd_ng_enb_data(); + break; + + case NG_ENB_DU_UE_ID_E2SM: + ue_id_data.ng_enb_du = fill_rnd_ng_enb_du_data(); + break; + + case EN_GNB_UE_ID_E2SM: + ue_id_data.en_gnb = fill_rnd_en_gnb_data(); + break; + + case ENB_UE_ID_E2SM: + ue_id_data.enb = fill_rnd_enb_data(); + break; + + default: + assert(false && "Unknown UE ID Type"); + } + + return ue_id_data; +} + +static kpm_act_def_format_2_t fill_rnd_kpm_action_def_frm_2(void) +{ + kpm_act_def_format_2_t action_def_frm_2 = {0}; + + // UE ID + action_def_frm_2.ue_id = fill_rnd_ue_id_data(); + + // Action Definition Format 1 + action_def_frm_2.action_def_format_1 = fill_rnd_kpm_action_def_frm_1(); + + return action_def_frm_2; +} + +static +test_cond_value_t fill_rnd_test_cond_value(void) +{ + test_cond_value_t dst = {0}; + +label: + dst.type = rand() % END_TEST_COND_VALUE; + + if(dst.type == BIT_STRING_TEST_COND_VALUE ) + goto label; // Not implemented + + if(dst.type == INTEGER_TEST_COND_VALUE){ + dst.int_value = calloc(1, sizeof(int64_t)); + assert(dst.int_value != NULL && "Memory exhausted"); + *dst.int_value = rand(); + } else if (dst.type == ENUMERATED_TEST_COND_VALUE){ + dst.enum_value = calloc(1, sizeof(int64_t )); + assert(dst.enum_value != NULL && "Memory exhausted"); + *dst.enum_value = rand(); + } else if(dst.type == BOOLEAN_TEST_COND_VALUE ){ + dst.bool_value = calloc(1, sizeof(bool)); + assert(dst.bool_value != NULL && "Memory exhausted"); + *dst.bool_value = rand(); + } else if(dst.type == BIT_STRING_TEST_COND_VALUE){ + assert(0!= 0 && "Not implemented"); + //dst.bit_string_value = calloc(1, sizeof(byte_array_t)); + //assert(dst.bit_string_value != NULL && "Memory exhausted"); + //*dst.bit_string_value = cp_str_to_ba("Test"); + } else if(dst.type == OCTET_STRING_TEST_COND_VALUE){ + dst.octet_string_value = calloc(1, sizeof(byte_array_t)); + assert(dst. octet_string_value != NULL && "Memory exhausted"); + *dst.octet_string_value = cp_str_to_ba("Test"); + } else if(dst.type == PRINTABLE_STRING_TEST_COND_VALUE){ + dst.printable_string_value = calloc(1, sizeof(byte_array_t)); + assert(dst. printable_string_value != NULL && "Memory exhausted"); + *dst.printable_string_value = cp_str_to_ba("Test"); +#if defined KPM_V2_03 || defined KPM_V3_00 + } else if(dst.type == REAL_TEST_COND_VALUE){ + dst.real_value = calloc(1, sizeof(double)); + assert(dst.real_value != NULL && "Memory exhausted"); + *dst.real_value= rand(); +#endif + } else { + assert(0!= 0 && "Unknown condition value"); + } + + return dst; +} + + + +static test_info_lst_t fill_rnd_kpm_test_info(void) +{ + test_info_lst_t test_info = {0}; + +#if defined KPM_V2_01 + test_info.test_cond_type = rand()% UL_RSRP_TEST_COND_TYPE; +#elif defined KPM_V2_03 || defined KPM_V3_00 + test_info.test_cond_type = rand()%END_TEST_COND_TYPE_KPM_V2_01; +#else + _Static_assert(0!=0 && "Unknown KPM Version"); +#endif + + + switch (test_info.test_cond_type) + { + case GBR_TEST_COND_TYPE: + test_info.GBR = TRUE_TEST_COND_TYPE; + break; + + case AMBR_TEST_COND_TYPE: + test_info.AMBR = TRUE_TEST_COND_TYPE; + break; + + case IsStat_TEST_COND_TYPE: + test_info.IsStat = TRUE_TEST_COND_TYPE; + break; + + case IsCatM_TEST_COND_TYPE: + test_info.IsCatM = TRUE_TEST_COND_TYPE; + break; + + case DL_RSRP_TEST_COND_TYPE: + test_info.DL_RSRP = TRUE_TEST_COND_TYPE; + break; + + case DL_RSRQ_TEST_COND_TYPE: + test_info.DL_RSRQ = TRUE_TEST_COND_TYPE; + break; +#if defined KPM_V2_03 || defined KPM_V3_00 + /* Possible extensions: */ + case UL_RSRP_TEST_COND_TYPE: + test_info.UL_RSRP = TRUE_TEST_COND_TYPE; + break; + + case CQI_TEST_COND_TYPE: + test_info.CQI = TRUE_TEST_COND_TYPE; + break; + + case fiveQI_TEST_COND_TYPE: + test_info.fiveQI = TRUE_TEST_COND_TYPE; + break; + + case QCI_TEST_COND_TYPE: + test_info.QCI = TRUE_TEST_COND_TYPE; + break; + + case S_NSSAI_TEST_COND_TYPE: + test_info.S_NSSAI = TRUE_TEST_COND_TYPE; + break; +#endif + + default: + assert(false && "Condition type out of the range"); + break; + } + + // Test Condition + // Optional english, mandatory ASN + test_info.test_cond = calloc(1, sizeof(test_cond_e)); + assert(test_info.test_cond != NULL ); + *test_info.test_cond = rand() %END_TEST_COND; + + // Test Condition Value + // Optional english, mandatory ASN + test_info.test_cond_value = calloc(1, sizeof(test_cond_value_t)); + assert(test_info.test_cond_value != NULL && "Memory exhausted"); + *test_info.test_cond_value = fill_rnd_test_cond_value(); + + return test_info; +} + +static kpm_act_def_format_3_t fill_rnd_kpm_action_def_frm_3(void) +{ + kpm_act_def_format_3_t action_def_frm_3 = {0}; + + // Measurement Information + // [1, 65535] + action_def_frm_3.meas_info_lst_len = 2; //(rand() % 65535) + 1; + + action_def_frm_3.meas_info_lst = calloc(action_def_frm_3.meas_info_lst_len, sizeof(meas_info_format_3_lst_t)); + assert(action_def_frm_3.meas_info_lst != NULL && "Memory exhausted" ); + + for (size_t i = 0; i < action_def_frm_3.meas_info_lst_len; i++) + { + meas_info_format_3_lst_t* meas_info = &action_def_frm_3.meas_info_lst[i]; + + // Measurement Type + meas_info->meas_type.type = rand()%END_MEAS_TYPE; + + switch (meas_info->meas_type.type) + { + case NAME_MEAS_TYPE: + meas_info->meas_type.type = NAME_MEAS_TYPE; + meas_info->meas_type.name.buf = calloc(strlen("test") + 1, sizeof(uint8_t)); + memcpy(meas_info->meas_type.name.buf, "test", strlen("test")); + meas_info->meas_type.name.len = strlen("test"); + break; + + case ID_MEAS_TYPE: + meas_info->meas_type.type = ID_MEAS_TYPE; + meas_info->meas_type.id = (rand() % 65536) + 1; + break; + + default: + assert(false && "Unknown Measurement Type"); + } + + // Matching Condition Format 3 + // [1, 32768] + meas_info->matching_cond_lst_len = 10; // (rand() % 32768) + 1; + + meas_info->matching_cond_lst = calloc(meas_info->matching_cond_lst_len, sizeof(*meas_info->matching_cond_lst)); + assert(meas_info->matching_cond_lst != NULL && "Memory exhausted" ); + + for (size_t j = 0; j < meas_info->matching_cond_lst_len; j++) + { + // Matching Condition Type + meas_info->matching_cond_lst[j].cond_type = rand()%END_INFO; + + switch (meas_info->matching_cond_lst[j].cond_type) + { + case LABEL_INFO: + meas_info->matching_cond_lst[j].label_info_lst.plmn_id = calloc(1, sizeof(e2sm_plmn_t)); + assert(meas_info->matching_cond_lst[j].label_info_lst.plmn_id != NULL && "Memory exhausted"); + *meas_info->matching_cond_lst[j].label_info_lst.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; + break; + + case TEST_INFO: + meas_info->matching_cond_lst[j].test_info_lst = fill_rnd_kpm_test_info(); + break; + + default: + assert(false && "Unknown Matching Condition Type"); + } + +#if defined KPM_V2_03 || defined KPM_V3_00 + // Logical OR + meas_info->matching_cond_lst[j].logical_OR = calloc(1, sizeof(enum_value_e)); + assert(meas_info->matching_cond_lst[j].logical_OR != NULL && "Memory exhausted"); + *meas_info->matching_cond_lst[j].logical_OR = TRUE_ENUM_VALUE; +#endif + } + + +#if defined KPM_V2_03 || defined KPM_V3_00 + // Bin Range Definition + // not yet implemented in ASN.1 - possible extension + + meas_info->bin_range_def = calloc(1, sizeof(bin_range_def_t)); + assert(meas_info->bin_range_def != NULL && "Memory exhausted"); + + meas_info->bin_range_def->bin_x_lst_len = 3; // (rand() % 65535) + 1; + + meas_info->bin_range_def->bin_x_lst = calloc(meas_info->bin_range_def->bin_x_lst_len, sizeof(bin_distr_t)); + assert(meas_info->bin_range_def->bin_x_lst != NULL && "Memory exhausted"); + + for (size_t j = 0; jbin_range_def->bin_x_lst_len; j++) + { + meas_info->bin_range_def->bin_x_lst[j].bin_index = (rand() % 65535) + 0; + meas_info->bin_range_def->bin_x_lst[j].start_value.value = rand()%END_BIN_RANGE; + + // start value + switch (meas_info->bin_range_def->bin_x_lst[j].start_value.value) + { + case INTEGER_BIN_RANGE: + meas_info->bin_range_def->bin_x_lst[j].start_value.int_value = (rand() % 4294967296) + 0; + break; + + case REAL_BIN_RANGE: + meas_info->bin_range_def->bin_x_lst[j].start_value.real_value = (rand() % 256) + 0; + + default: + break; + } + + // end value + meas_info->bin_range_def->bin_x_lst[j].end_value.value = rand()%END_BIN_RANGE; + + switch (meas_info->bin_range_def->bin_x_lst[j].end_value.value) + { + case INTEGER_BIN_RANGE: + meas_info->bin_range_def->bin_x_lst[j].end_value.int_value = (rand() % 4294967296) + 0; + break; + + case REAL_BIN_RANGE: + meas_info->bin_range_def->bin_x_lst[j].end_value.real_value = (rand() % 256) + 0; + + default: + break; + } + } + + meas_info->bin_range_def->bin_y_lst_len = 0; + meas_info->bin_range_def->bin_y_lst = NULL; + + meas_info->bin_range_def->bin_z_lst_len = 0; + meas_info->bin_range_def->bin_z_lst = NULL; + +#endif // defined KPM_V2_03 || defined KPM_V3_00 + } + + // Granularity Period + // [0, 4294967295] + action_def_frm_3.gran_period_ms = (rand() % 4294967295) + 0; + + // Cell Global ID + // Optional + action_def_frm_3.cell_global_id = calloc(1, sizeof(*action_def_frm_3.cell_global_id)); + action_def_frm_3.cell_global_id->type = rand()%END_CGI_RAT_TYPE; + + switch (action_def_frm_3.cell_global_id->type) + { + case NR_CGI_RAT_TYPE: + action_def_frm_3.cell_global_id->nr_cgi.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; + action_def_frm_3.cell_global_id->nr_cgi.nr_cell_id = (rand() % 2^36) + 1; + break; + + case EUTRA_CGI_RAT_TYPE: + action_def_frm_3.cell_global_id->eutra.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; + action_def_frm_3.cell_global_id->eutra.eutra_cell_id = (rand() % 2^28) + 0; + break; + + default: + assert(false && "Unknown Cell Global ID Type"); + } + + return action_def_frm_3; +} + +#if defined KPM_V2_03 || defined KPM_V3_00 + +static kpm_act_def_format_4_t fill_rnd_kpm_action_def_frm_4(void) +{ + kpm_act_def_format_4_t action_def_frm_4 = {0}; + + // Matching Condition + action_def_frm_4.matching_cond_lst_len = 1; // (rand() % 32768) + 1; + + action_def_frm_4.matching_cond_lst = calloc(action_def_frm_4.matching_cond_lst_len, sizeof(matching_condition_format_4_lst_t)); + assert(action_def_frm_4.matching_cond_lst != NULL && "Memory exhausted" ); + + for (size_t i = 0; ibuf = calloc(strlen("My OAI-CU") + 1, sizeof(uint8_t)); + memcpy(hdr_frm_1.sender_name->buf, "My OAI-CU", strlen("My OAI-CU")); + hdr_frm_1.sender_name->len = strlen("My OAI-CU"); + + hdr_frm_1.sender_type = calloc(1, sizeof(byte_array_t)); + hdr_frm_1.sender_type->buf = calloc(strlen("CU") + 1, sizeof(uint8_t)); + memcpy(hdr_frm_1.sender_type->buf, "CU", strlen("CU")); + hdr_frm_1.sender_type->len = strlen("CU"); + + hdr_frm_1.vendor_name = calloc(1, sizeof(byte_array_t)); + hdr_frm_1.vendor_name->buf = calloc(strlen("OAI") + 1, sizeof(uint8_t)); + memcpy(hdr_frm_1.vendor_name->buf, "OAI", strlen("OAI")); + hdr_frm_1.vendor_name->len = strlen("OAI"); + + return hdr_frm_1; +} + +kpm_ind_hdr_t fill_rnd_kpm_ind_hdr(void) +{ + kpm_ind_hdr_t hdr = {0}; + + hdr.type = rand()%END_INDICATION_HEADER; + + switch (hdr.type) + { + case FORMAT_1_INDICATION_HEADER: + hdr.kpm_ric_ind_hdr_format_1 = fill_rnd_kpm_ind_hdr_frm_1(); + break; + + default: + assert(false && "Unknown KPM Indication Header Type"); + } + + + return hdr; +} + +static kpm_ind_msg_format_1_t fill_rnd_kpm_ind_msg_frm_1(void) +{ + kpm_ind_msg_format_1_t msg_frm_1 = {0}; + + // Measurement Data + msg_frm_1.meas_data_lst_len = 3; // (rand() % 65535) + 1; + msg_frm_1.meas_data_lst = calloc(msg_frm_1.meas_data_lst_len, sizeof(*msg_frm_1.meas_data_lst)); + assert(msg_frm_1.meas_data_lst != NULL && "Memory exhausted" ); + + for (size_t i = 0; i < msg_frm_1.meas_data_lst_len; i++) + { + // Incomplete Flag + msg_frm_1.meas_data_lst[i].incomplete_flag = calloc(1, sizeof(enum_value_e)); + assert(msg_frm_1.meas_data_lst[i].incomplete_flag != NULL && "Memory exhausted"); + *msg_frm_1.meas_data_lst[i].incomplete_flag = TRUE_ENUM_VALUE; + + // Measurement Record + msg_frm_1.meas_data_lst[i].meas_record_len = 4; // (rand() % 65535) + 1; + msg_frm_1.meas_data_lst[i].meas_record_lst = calloc(msg_frm_1.meas_data_lst[i].meas_record_len, sizeof(meas_record_lst_t)); + assert(msg_frm_1.meas_data_lst[i].meas_record_lst != NULL && "Memory exhausted" ); + + for (size_t j = 0; j < msg_frm_1.meas_data_lst[i].meas_record_len; j++) + { + msg_frm_1.meas_data_lst[i].meas_record_lst[j].value = rand()%END_MEAS_VALUE; + + switch (msg_frm_1.meas_data_lst[i].meas_record_lst[j].value) + { + case INTEGER_MEAS_VALUE: + msg_frm_1.meas_data_lst[i].meas_record_lst[j].int_val = (rand() % 4294967295) + 0; + break; + + case REAL_MEAS_VALUE: + msg_frm_1.meas_data_lst[i].meas_record_lst[j].real_val = (rand() % 256) + 0; + break; + + case NO_VALUE_MEAS_VALUE: + msg_frm_1.meas_data_lst[i].meas_record_lst[j].no_value = NULL; + break; + + default: + assert(false && "Unknown Measurement Record Type"); + } + + } + } + + // Granularity Period - OPTIONAL: (1..4294967295) + msg_frm_1.gran_period_ms = calloc(1, sizeof(*msg_frm_1.gran_period_ms)); + assert(msg_frm_1.gran_period_ms != NULL && "Memory exhausted"); + *msg_frm_1.gran_period_ms = (rand() % 4294967295) + 1; + +#if defined KPM_V2_03 || defined KPM_V3_00 + + // Measurement Information - OPTIONAL + msg_frm_1.meas_info_lst_len = 2; + msg_frm_1.meas_info_lst = calloc(msg_frm_1.meas_info_lst_len, sizeof(meas_info_format_1_lst_t)); + assert(msg_frm_1.meas_info_lst != NULL && "Memory exhausted" ); + + for (size_t i = 0; i < msg_frm_1.meas_info_lst_len; i++) + { + // Measurement Type + msg_frm_1.meas_info_lst[i].meas_type.type = rand()%END_MEAS_TYPE; + + switch (msg_frm_1.meas_info_lst[i].meas_type.type) + { + case NAME_MEAS_TYPE: + msg_frm_1.meas_info_lst[i].meas_type.type = NAME_MEAS_TYPE; + char s[100]; + snprintf(s, 100, "RNTI %04x PrbDlUsage", (unsigned) (1111*i + 1111)); + msg_frm_1.meas_info_lst[i].meas_type.name.buf = calloc(strlen(s) + 1, sizeof(uint8_t)); + memcpy(msg_frm_1.meas_info_lst[i].meas_type.name.buf, s, strlen(s)); + msg_frm_1.meas_info_lst[i].meas_type.name.len = strlen(s); + break; + + case ID_MEAS_TYPE: + msg_frm_1.meas_info_lst[i].meas_type.type = ID_MEAS_TYPE; + msg_frm_1.meas_info_lst[i].meas_type.id = (rand() % 65536) + 1; + break; + + default: + assert(false && "Unknown Measurement Type"); + } + + // Label Information + msg_frm_1.meas_info_lst[i].label_info_lst_len = 1; + msg_frm_1.meas_info_lst[i].label_info_lst = calloc(msg_frm_1.meas_info_lst[i].label_info_lst_len, sizeof(label_info_lst_t)); + assert(msg_frm_1.meas_info_lst[i].label_info_lst != NULL && "Memory exhausted" ); + + for (size_t j = 0; j < msg_frm_1.meas_info_lst[i].label_info_lst_len; j++) + { + // msg_frm_1.meas_info_lst[i].label_info_lst[j].plmn_id = malloc(sizeof(plmn_t)); + // *msg_frm_1.meas_info_lst[i].label_info_lst[j].plmn_id = (plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; + msg_frm_1.meas_info_lst[i].label_info_lst[j].noLabel = malloc(sizeof(enum_value_e)); + *msg_frm_1.meas_info_lst[i].label_info_lst[j].noLabel = TRUE_ENUM_VALUE; + } + } + +#endif // defined KPM_V2_03 || defined KPM_V3_00 + + return msg_frm_1; +} + +static kpm_ind_msg_format_2_t fill_rnd_kpm_ind_msg_frm_2(void) +{ + kpm_ind_msg_format_2_t msg_frm_2 = {0}; + + // Measurement Data + msg_frm_2.meas_data_lst_len = 2; // (rand() % 65535) + 1; + msg_frm_2.meas_data_lst = calloc(msg_frm_2.meas_data_lst_len, sizeof(*msg_frm_2.meas_data_lst)); + assert(msg_frm_2.meas_data_lst != NULL && "Memory exhausted" ); + + for (size_t i = 0; i < msg_frm_2.meas_data_lst_len; i++) + { + // Incomplete Flag + msg_frm_2.meas_data_lst[i].incomplete_flag = calloc(1, sizeof(enum_value_e)); + assert(msg_frm_2.meas_data_lst[i].incomplete_flag != NULL && "Memory exhausted"); + *msg_frm_2.meas_data_lst[i].incomplete_flag = TRUE_ENUM_VALUE; + + // Measurement Record + msg_frm_2.meas_data_lst[i].meas_record_len = 1; // (rand() % 65535) + 1; + msg_frm_2.meas_data_lst[i].meas_record_lst = calloc(msg_frm_2.meas_data_lst[i].meas_record_len, sizeof(meas_record_lst_t)); + assert(msg_frm_2.meas_data_lst[i].meas_record_lst != NULL && "Memory exhausted" ); + + for (size_t j = 0; j < msg_frm_2.meas_data_lst[i].meas_record_len; j++) + { + msg_frm_2.meas_data_lst[i].meas_record_lst[j].value = rand()%END_MEAS_VALUE; + + switch (msg_frm_2.meas_data_lst[i].meas_record_lst[j].value) + { + case INTEGER_MEAS_VALUE: + msg_frm_2.meas_data_lst[i].meas_record_lst[j].int_val = (rand() % 4294967295) + 0; + break; + + case REAL_MEAS_VALUE: + msg_frm_2.meas_data_lst[i].meas_record_lst[j].real_val = (rand() % 256) + 0; + break; + + case NO_VALUE_MEAS_VALUE: + msg_frm_2.meas_data_lst[i].meas_record_lst[j].no_value = NULL; + break; + + default: + assert(false && "Unknown Measurement Record Type"); + } + } + } + + // Granularity Period - OPTIONAL + msg_frm_2.gran_period_ms = calloc(1, sizeof(*msg_frm_2.gran_period_ms)); + assert(msg_frm_2.gran_period_ms != NULL && "Memory exhausted"); + *msg_frm_2.gran_period_ms = (rand() % 4294967295) + 1; + + // Measurement Information Condition UE + // [1, 65535] + msg_frm_2.meas_info_cond_ue_lst_len = 1; // (rand() % 65535) + 1; + msg_frm_2.meas_info_cond_ue_lst = calloc(msg_frm_2.meas_info_cond_ue_lst_len, sizeof(meas_info_cond_ue_lst_t)); + assert(msg_frm_2.meas_info_cond_ue_lst != NULL && "Memory exhausted"); + + for (size_t i = 0; imeas_type.type = rand()%END_MEAS_TYPE; + + switch (cond_ue->meas_type.type) + { + case NAME_MEAS_TYPE: + cond_ue->meas_type.type = NAME_MEAS_TYPE; + cond_ue->meas_type.name.buf = calloc(strlen("condition UE measurement") + 1, sizeof(uint8_t)); + memcpy(cond_ue->meas_type.name.buf, "condition UE measurement", strlen("condition UE measurement")); + cond_ue->meas_type.name.len = strlen("condition UE measurement"); + break; + + case ID_MEAS_TYPE: + cond_ue->meas_type.type = ID_MEAS_TYPE; + cond_ue->meas_type.id = (rand() % 65536) + 1; + break; + + default: + assert(false && "Unknown Measurement Type"); + } + + + // Matching Condition Format 3 + // [1, 32768] + cond_ue->matching_cond_lst_len = 1; // (rand() % 32768) + 1; + cond_ue->matching_cond_lst = calloc(cond_ue->matching_cond_lst_len, sizeof(*cond_ue->matching_cond_lst)); + assert(cond_ue->matching_cond_lst != NULL && "Memory exhausted" ); + + for (size_t j = 0; j < cond_ue->matching_cond_lst_len; j++) + { + // Matching Condition Type + cond_ue->matching_cond_lst[j].cond_type = rand()%END_INFO; + + switch (cond_ue->matching_cond_lst[j].cond_type) + { + case LABEL_INFO: + cond_ue->matching_cond_lst[j].label_info_lst.plmn_id = calloc(1, sizeof(e2sm_plmn_t)); + assert(cond_ue->matching_cond_lst[j].label_info_lst.plmn_id != NULL && "Memory exhausted"); + *cond_ue->matching_cond_lst[j].label_info_lst.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; + break; + + case TEST_INFO: + cond_ue->matching_cond_lst[j].test_info_lst = fill_rnd_kpm_test_info(); + break; + + default: + assert(false && "Unknown Matching Condition Type"); + } + +#if defined KPM_V2_03 || defined KPM_V3_00 + // Logical OR + cond_ue->matching_cond_lst[j].logical_OR = calloc(1, sizeof(enum_value_e)); + assert(cond_ue->matching_cond_lst[j].logical_OR != NULL && "Memory exhausted"); + *cond_ue->matching_cond_lst[j].logical_OR = TRUE_ENUM_VALUE; +#endif + } + + // List of matched UE IDs + // Optional [0, 65535] + cond_ue->ue_id_matched_lst_len = 1; // (rand() % 65535) + 0; + cond_ue->ue_id_matched_lst = calloc(cond_ue->ue_id_matched_lst_len, sizeof(ue_id_e2sm_t)); + assert(cond_ue->ue_id_matched_lst != NULL && "Memory exhausted"); + + for (size_t j = 0; jue_id_matched_lst_len; j++) + { + cond_ue->ue_id_matched_lst[j] = fill_rnd_ue_id_data(); + } + +#if defined KPM_V2_03 || defined KPM_V3_00 + // Sequence of Matched UE IDs for Granularity Periods + // not yet implemented in ASN.1 - possible extension + cond_ue->ue_id_gran_period_lst_len = 3; // (rand() % 65535) + 0; + cond_ue->ue_id_gran_period_lst = calloc(cond_ue->ue_id_gran_period_lst_len, sizeof(ue_id_gran_period_lst_t)); + assert(cond_ue->ue_id_gran_period_lst != NULL && "Memory exhausted"); + + for (size_t j = 0; jue_id_gran_period_lst_len; j++) + { + cond_ue->ue_id_gran_period_lst[j].num_matched_ue = rand()%END_MATCHED_UE; + + switch (cond_ue->ue_id_gran_period_lst[j].num_matched_ue) + { + case NONE_MATCHED_UE: + { + cond_ue->ue_id_gran_period_lst[j].no_matched_ue = TRUE_ENUM_VALUE; + break; + } + + case ONE_OR_MORE_MATCHED_UE: + { + cond_ue->ue_id_gran_period_lst[j].matched_ue_lst.ue_lst_len = 5; // (rand() % 65535) + 1; + cond_ue->ue_id_gran_period_lst[j].matched_ue_lst.ue_lst = calloc(cond_ue->ue_id_gran_period_lst[j].matched_ue_lst.ue_lst_len, sizeof(ue_id_e2sm_t)); + assert(cond_ue->ue_id_gran_period_lst[j].matched_ue_lst.ue_lst != NULL && "Memory exhausted"); + + for (size_t z = 0; zue_id_gran_period_lst[j].matched_ue_lst.ue_lst_len; z++) + { + cond_ue->ue_id_gran_period_lst[j].matched_ue_lst.ue_lst[z] = fill_rnd_ue_id_data(); + } + break; + } + + default: + break; + } + } +#endif // defined KPM_V2_03 || defined KPM_V3_00 + } + + return msg_frm_2; +} + +#if defined KPM_V2_03 || defined KPM_V3_00 +static +kpm_ind_msg_format_3_t fill_rnd_kpm_ind_msg_frm_3(void) +{ + kpm_ind_msg_format_3_t msg_frm_3 = {0}; + + msg_frm_3.ue_meas_report_lst_len = 3; // (rand() % 65535) + 1; + + msg_frm_3.meas_report_per_ue = calloc(msg_frm_3.ue_meas_report_lst_len, sizeof(meas_report_per_ue_t)); + assert(msg_frm_3.meas_report_per_ue != NULL && "Memory exhausted"); + + for (size_t i = 0; i -#include -#include - -void fill_mac_ind_data(mac_ind_data_t* ind) -{ - assert(ind != NULL); - srand(time(0)); - - int const mod = 1024; - - mac_ind_msg_t* ind_msg = &ind->msg; - - int const NUM_UES = abs(rand()%5); - - ind_msg->len_ue_stats = NUM_UES; - - ind_msg->tstamp = time_now_us(); - - if(NUM_UES > 0){ - ind_msg->ue_stats = calloc(NUM_UES, sizeof(mac_ue_stats_impl_t)); - assert(ind_msg->ue_stats != NULL && "memory exhausted"); - } - - const size_t numDLHarq = 4; - const size_t numUlHarq = 4; - - for(uint32_t i = 0; i < ind_msg->len_ue_stats; ++i){ - ind_msg->ue_stats[i].dl_aggr_tbs = abs(rand()%mod); - ind_msg->ue_stats[i].ul_aggr_tbs = abs(rand()%mod); - ind_msg->ue_stats[i].dl_aggr_bytes_sdus = abs(rand()%mod); - ind_msg->ue_stats[i].ul_aggr_bytes_sdus = abs(rand()%mod); - ind_msg->ue_stats[i].pusch_snr = 64.0; //: float = -64; - ind_msg->ue_stats[i].pucch_snr = 64.0; //: float = -64; - ind_msg->ue_stats[i].rnti = abs(rand()%mod); - ind_msg->ue_stats[i].dl_aggr_prb = abs(rand()%mod); - ind_msg->ue_stats[i].ul_aggr_prb = abs(rand()%mod); - ind_msg->ue_stats[i].dl_aggr_sdus = abs(rand()%mod); - ind_msg->ue_stats[i].ul_aggr_sdus= abs(rand()%mod); - ind_msg->ue_stats[i].dl_aggr_retx_prb= abs(rand()%mod); - ind_msg->ue_stats[i].ul_aggr_retx_prb= abs(rand()%mod); - ind_msg->ue_stats[i].wb_cqi= abs(rand()%mod); - ind_msg->ue_stats[i].dl_mcs1= abs(rand()%mod); - ind_msg->ue_stats[i].ul_mcs1= abs(rand()%mod); - ind_msg->ue_stats[i].dl_mcs2= abs(rand()%mod); - ind_msg->ue_stats[i].ul_mcs2= abs(rand()%mod); - ind_msg->ue_stats[i].phr= (rand()%64) - 23; // 41 abs(rand()%mod); - ind_msg->ue_stats[i].bsr= abs(rand()%mod); - ind_msg->ue_stats[i].dl_num_harq = numUlHarq; - for (uint8_t j = 0; j < numDLHarq; j++) - ind_msg->ue_stats[i].dl_harq[j] = abs(rand()%mod); - ind_msg->ue_stats[i].ul_num_harq = numUlHarq; - for (uint8_t j = 0; j < numUlHarq; j++) - ind_msg->ue_stats[i].ul_harq[j] = abs(rand()%mod); - } -} - - +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698 + * + * 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. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#include "fill_rnd_data_mac.h" +#include "../../src/util/time_now_us.h" + +#include +#include +#include + +void fill_mac_ind_data(mac_ind_data_t* ind) +{ + assert(ind != NULL); + srand(time(0)); + + int const mod = 1024; + + mac_ind_msg_t* ind_msg = &ind->msg; + + int const NUM_UES = abs(rand()%5); + + ind_msg->len_ue_stats = NUM_UES; + + ind_msg->tstamp = time_now_us(); + + if(NUM_UES > 0){ + ind_msg->ue_stats = calloc(NUM_UES, sizeof(mac_ue_stats_impl_t)); + assert(ind_msg->ue_stats != NULL && "memory exhausted"); + } + + const size_t numDLHarq = 4; + const size_t numUlHarq = 4; + + for(uint32_t i = 0; i < ind_msg->len_ue_stats; ++i){ + ind_msg->ue_stats[i].dl_aggr_tbs = abs(rand()%mod); + ind_msg->ue_stats[i].ul_aggr_tbs = abs(rand()%mod); + ind_msg->ue_stats[i].dl_aggr_bytes_sdus = abs(rand()%mod); + ind_msg->ue_stats[i].ul_aggr_bytes_sdus = abs(rand()%mod); + ind_msg->ue_stats[i].pusch_snr = 64.0; //: float = -64; + ind_msg->ue_stats[i].pucch_snr = 64.0; //: float = -64; + ind_msg->ue_stats[i].rnti = abs(rand()%mod); + ind_msg->ue_stats[i].dl_aggr_prb = abs(rand()%mod); + ind_msg->ue_stats[i].ul_aggr_prb = abs(rand()%mod); + ind_msg->ue_stats[i].dl_aggr_sdus = abs(rand()%mod); + ind_msg->ue_stats[i].ul_aggr_sdus= abs(rand()%mod); + ind_msg->ue_stats[i].dl_aggr_retx_prb= abs(rand()%mod); + ind_msg->ue_stats[i].ul_aggr_retx_prb= abs(rand()%mod); + ind_msg->ue_stats[i].wb_cqi= abs(rand()%mod); + ind_msg->ue_stats[i].dl_mcs1= abs(rand()%mod); + ind_msg->ue_stats[i].ul_mcs1= abs(rand()%mod); + ind_msg->ue_stats[i].dl_mcs2= abs(rand()%mod); + ind_msg->ue_stats[i].ul_mcs2= abs(rand()%mod); + ind_msg->ue_stats[i].phr= (rand()%64) - 23; // 41 abs(rand()%mod); + ind_msg->ue_stats[i].bsr= abs(rand()%mod); + ind_msg->ue_stats[i].dl_num_harq = numUlHarq; + for (uint8_t j = 0; j < numDLHarq; j++) + ind_msg->ue_stats[i].dl_harq[j] = abs(rand()%mod); + ind_msg->ue_stats[i].ul_num_harq = numUlHarq; + for (uint8_t j = 0; j < numUlHarq; j++) + ind_msg->ue_stats[i].ul_harq[j] = abs(rand()%mod); + } +} + + diff --git a/libs/test/rnd/fill_rnd_data_mac.h b/libs/test/rnd/fill_rnd_data_mac.h index 323c2d5..635c15a 100644 --- a/libs/test/rnd/fill_rnd_data_mac.h +++ b/libs/test/rnd/fill_rnd_data_mac.h @@ -1,28 +1,28 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698 - * - * 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. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ -#ifndef FILL_RND_DATA_MAC_H -#define FILL_RND_DATA_MAC_H - -#include "../../src/sm/mac_sm/ie/mac_data_ie.h" - -void fill_mac_ind_data(mac_ind_data_t* ind); - -#endif +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698 + * + * 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. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ +#ifndef FILL_RND_DATA_MAC_H +#define FILL_RND_DATA_MAC_H + +#include "../../src/sm/mac_sm/ie/mac_data_ie.h" + +void fill_mac_ind_data(mac_ind_data_t* ind); + +#endif diff --git a/libs/test/rnd/fill_rnd_data_pdcp.c b/libs/test/rnd/fill_rnd_data_pdcp.c index 14e6802..a08d008 100644 --- a/libs/test/rnd/fill_rnd_data_pdcp.c +++ b/libs/test/rnd/fill_rnd_data_pdcp.c @@ -1,72 +1,72 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698 - * - * 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. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include "fill_rnd_data_pdcp.h" -#include "../../src/util/time_now_us.h" - -#include -#include -#include - -void fill_pdcp_ind_data(pdcp_ind_data_t* ind) -{ - assert(ind != NULL); - - srand(time(0)); - - pdcp_ind_msg_t* ind_msg = &ind->msg; - - ind_msg->len = abs(rand()%8); - ind_msg->tstamp = time_now_us(); - - if(ind_msg->len > 0){ - ind_msg->rb = calloc(ind_msg->len, sizeof(pdcp_radio_bearer_stats_t)); - assert(ind_msg->rb != NULL && "Memory exhausted!"); - } - - for(uint32_t i = 0; i < ind_msg->len; ++i){ - pdcp_radio_bearer_stats_t* rb = &ind_msg->rb[i]; - - int const mod = 1024; - rb->txpdu_bytes = abs(rand()%mod); /* aggregated bytes of tx packets */ - rb->txpdu_pkts = rb->txpdu_bytes != 0 ? rb->txpdu_bytes - rand()%rb->txpdu_bytes : 0; /* aggregated number of tx packets */ - rb->txpdu_sn= abs(rand()%mod); /* current sequence number of last tx packet (or TX_NEXT) */ - - rb->rxpdu_bytes = abs(rand()%mod); /* aggregated bytes of rx packets */ - rb->rxpdu_pkts = rb->rxpdu_bytes != 0 ? rb->rxpdu_bytes - rand()%rb->rxpdu_bytes : 0; /* aggregated number of rx packets */ - rb->rxpdu_sn= abs(rand()%mod); /* current sequence number of last rx packet (or RX_NEXT) */ - rb->rxpdu_oo_pkts= abs(rand()%mod); /* aggregated number of out-of-order rx pkts (or RX_REORD) */ - rb->rxpdu_oo_bytes= abs(rand()%mod); /* aggregated amount of out-of-order rx bytes */ - rb->rxpdu_dd_pkts= abs(rand()%mod); /* aggregated number of duplicated discarded packets (or dropped packets because of other reasons such as integrity failure) (or RX_DELIV) */ - rb->rxpdu_dd_bytes= abs(rand()%mod); /* aggregated amount of discarded packets' bytes */ - rb->rxpdu_ro_count= abs(rand()%mod); /* this state variable indicates the COUNT value following the COUNT value associated with the PDCP Data PDU which triggered t-Reordering. (RX_REORD) */ - rb->txsdu_bytes = abs(rand()%mod); /* number of bytes of SDUs delivered */ - rb->txsdu_pkts = rb->txsdu_bytes != 0 ? rb->txsdu_bytes - rand()% rb->txsdu_bytes : 0; /* number of SDUs delivered */ - - rb->rxsdu_bytes = abs(rand()%mod); /* number of bytes of SDUs received */ - rb->rxsdu_pkts = rb->rxsdu_bytes != 0 ? rb->rxsdu_bytes - rand()%rb->rxsdu_bytes : 0; /* number of SDUs received */ - - rb->rnti= abs(rand()%mod); - rb->mode= abs(rand()%3); /* 0: PDCP AM, 1: PDCP UM, 2: PDCP TM */ - rb->rbid= abs(rand()%11); - } -} - +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698 + * + * 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. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#include "fill_rnd_data_pdcp.h" +#include "../../src/util/time_now_us.h" + +#include +#include +#include + +void fill_pdcp_ind_data(pdcp_ind_data_t* ind) +{ + assert(ind != NULL); + + srand(time(0)); + + pdcp_ind_msg_t* ind_msg = &ind->msg; + + ind_msg->len = abs(rand()%8); + ind_msg->tstamp = time_now_us(); + + if(ind_msg->len > 0){ + ind_msg->rb = calloc(ind_msg->len, sizeof(pdcp_radio_bearer_stats_t)); + assert(ind_msg->rb != NULL && "Memory exhausted!"); + } + + for(uint32_t i = 0; i < ind_msg->len; ++i){ + pdcp_radio_bearer_stats_t* rb = &ind_msg->rb[i]; + + int const mod = 1024; + rb->txpdu_bytes = abs(rand()%mod); /* aggregated bytes of tx packets */ + rb->txpdu_pkts = rb->txpdu_bytes != 0 ? rb->txpdu_bytes - rand()%rb->txpdu_bytes : 0; /* aggregated number of tx packets */ + rb->txpdu_sn= abs(rand()%mod); /* current sequence number of last tx packet (or TX_NEXT) */ + + rb->rxpdu_bytes = abs(rand()%mod); /* aggregated bytes of rx packets */ + rb->rxpdu_pkts = rb->rxpdu_bytes != 0 ? rb->rxpdu_bytes - rand()%rb->rxpdu_bytes : 0; /* aggregated number of rx packets */ + rb->rxpdu_sn= abs(rand()%mod); /* current sequence number of last rx packet (or RX_NEXT) */ + rb->rxpdu_oo_pkts= abs(rand()%mod); /* aggregated number of out-of-order rx pkts (or RX_REORD) */ + rb->rxpdu_oo_bytes= abs(rand()%mod); /* aggregated amount of out-of-order rx bytes */ + rb->rxpdu_dd_pkts= abs(rand()%mod); /* aggregated number of duplicated discarded packets (or dropped packets because of other reasons such as integrity failure) (or RX_DELIV) */ + rb->rxpdu_dd_bytes= abs(rand()%mod); /* aggregated amount of discarded packets' bytes */ + rb->rxpdu_ro_count= abs(rand()%mod); /* this state variable indicates the COUNT value following the COUNT value associated with the PDCP Data PDU which triggered t-Reordering. (RX_REORD) */ + rb->txsdu_bytes = abs(rand()%mod); /* number of bytes of SDUs delivered */ + rb->txsdu_pkts = rb->txsdu_bytes != 0 ? rb->txsdu_bytes - rand()% rb->txsdu_bytes : 0; /* number of SDUs delivered */ + + rb->rxsdu_bytes = abs(rand()%mod); /* number of bytes of SDUs received */ + rb->rxsdu_pkts = rb->rxsdu_bytes != 0 ? rb->rxsdu_bytes - rand()%rb->rxsdu_bytes : 0; /* number of SDUs received */ + + rb->rnti= abs(rand()%mod); + rb->mode= abs(rand()%3); /* 0: PDCP AM, 1: PDCP UM, 2: PDCP TM */ + rb->rbid= abs(rand()%11); + } +} + diff --git a/libs/test/rnd/fill_rnd_data_pdcp.h b/libs/test/rnd/fill_rnd_data_pdcp.h index 0d42895..e83c7fe 100644 --- a/libs/test/rnd/fill_rnd_data_pdcp.h +++ b/libs/test/rnd/fill_rnd_data_pdcp.h @@ -1,31 +1,31 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698 - * - * 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. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#ifndef FILL_RND_DATA_PDCP_H -#define FILL_RND_DATA_PDCP_H - -#include "../../src/sm/pdcp_sm/ie/pdcp_data_ie.h" - -void fill_pdcp_ind_data(pdcp_ind_data_t* ind); - -#endif - - +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698 + * + * 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. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#ifndef FILL_RND_DATA_PDCP_H +#define FILL_RND_DATA_PDCP_H + +#include "../../src/sm/pdcp_sm/ie/pdcp_data_ie.h" + +void fill_pdcp_ind_data(pdcp_ind_data_t* ind); + +#endif + + diff --git a/libs/test/rnd/fill_rnd_data_rc.c b/libs/test/rnd/fill_rnd_data_rc.c index 11c315d..280177e 100644 --- a/libs/test/rnd/fill_rnd_data_rc.c +++ b/libs/test/rnd/fill_rnd_data_rc.c @@ -1,3111 +1,3111 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698 - * - * 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. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include "fill_rnd_data_rc.h" - -#include "../../src/sm/rc_sm/rc_sm_id.h" -#include "../../src/sm/rc_sm/ie/ir/ran_param_struct.h" -#include "../../src/sm/rc_sm/ie/ir/ran_param_list.h" - -#include -#include -#include - -/* -static -double rand_double() -{ - union { - double a; - uint8_t b[sizeof(double)]; - } tmp; - - for(size_t i = 0; i < sizeof(double); ++i){ - tmp.b[i] = rand(); - } - - return tmp.a; -} -*/ -static -float rand_float(float ceil) -{ - return (float)rand()/(float)((float)RAND_MAX/ceil); -} - - -///////////////////////////// -///////////////////////////// -//////////RC Event Trigger ////////// -///////////////////////////// -///////////////////////////// - - - - -static -network_interface_e2rc_t fill_rnd_network_interface(void) -{ - network_interface_e2rc_t dst = {0}; - - // NI Type - // Mandatory - // 9.3.32 - dst.ni_type = rand() % END_NETWORK_INTERFACE_TYPE; - - // NI Identifier - // Optional - // 9.3.33 - dst.ni_id = NULL; - - // NI Message - // Optional - // 9.3.34 - dst.ni_msg_id = NULL; - - return dst; -} - -static -rrc_msg_id_t fill_rnd_rrc_msg_id(void) -{ - rrc_msg_id_t dst = {0}; - - // Mandatory - dst.type = rand() % END_RRC_MESSAGE_ID; - if(dst.type == LTE_RRC_MESSAGE_ID){ - dst.lte = rand() % END_LTE_RRC_CLASS; - } else if(dst.type == NR_RRC_MESSAGE_ID){ - dst.nr = rand() % END_NR_RRC_CLASS; - } else { - assert(0 != 0 && "Unknown type"); - } - - // Mandatory - // Integer - // Number starts from 0 from the first - // entry of a given RRC message class - // defined in TS 36.331 [14] or TS - // 38.331 [15]. - dst.rrc_msg_id = rand(); - - return dst; -} - - -static -msg_ev_trg_t fill_rnd_msg_ev_trg(void) -{ - msg_ev_trg_t dst = {0}; - - // Event Trigger Condition ID - // Mandatory - // 9.3.21 - // [1- 65535] - dst.ev_trigger_cond_id = (rand()% 65535) + 1; - - // CHOICE Message Type - // Mandatory - dst.msg_type = rand() % END_MSG_MSG_TYPE_EV_TRG; - if(dst.msg_type == NETWORK_INTERFACE_MSG_TYPE_EV_TRG){ - dst.net = fill_rnd_network_interface(); - } else if(dst.msg_type == RRC_MSG_MSG_TYPE_EV_TRG){ - dst.rrc_msg = fill_rnd_rrc_msg_id(); - } else { - assert( 0 != 0 && "Unknown type"); - } - - //Message Direction - //Optional - dst.msg_dir = NULL; - - // Associated UE Info - // Optional - // 9.3.26 - dst.assoc_ue_info = NULL; - - // Logical OR - // Optional - // 9.3.25 - dst.log_or = NULL; - - return dst; -} - -static -e2sm_rc_ev_trg_frmt_1_t fill_rnd_rc_event_trigger_frmt_1(void) -{ - e2sm_rc_ev_trg_frmt_1_t dst = {0}; - - // [1 - 65535] - dst.sz_msg_ev_trg = (rand() % 64) + 1; // Limited for memory constraints 65535 - - dst.msg_ev_trg = calloc(dst.sz_msg_ev_trg, sizeof(msg_ev_trg_t)); - assert(dst.msg_ev_trg != NULL && "Memory exhausted"); - - for(size_t i = 0; i < dst.sz_msg_ev_trg; ++i){ - dst.msg_ev_trg[i] = fill_rnd_msg_ev_trg(); - } - - // Global Associated UE Info - // Optional - // 9.3.26 - dst.global_assoc_ue_info = NULL; - - return dst; -} - -static -e2sm_rc_ev_trg_frmt_2_t fill_rnd_rc_event_trigger_frmt_2(void) -{ - e2sm_rc_ev_trg_frmt_2_t dst = {0}; - - // Call Process Type ID - // Mandatory - // 9.3.15 - // INTEGER (1.. 65535, …) - dst.call_proc_type_id = (rand()% 65535) + 1; - - // Call Breakpoint ID - // Mandatory - // 9.3.49 - // INTEGER (1.. 65535, …) - dst.call_break_id = rand(); - - // Associated E2 Node Info - // Optional - // 9.3.29 - // ran_param_cond_crit_def_t* assoc_e2_node_info; - - // Associated UE Info - // Optional - // 9.3.26 - // ev_trigger_ue_info_t* assoc_ue_info; - - return dst; -} - -static -e2_node_info_chng_t fill_rnd_e2_node_info_chng(void) -{ - e2_node_info_chng_t dst = {0}; - - //Event Trigger Condition ID - //Mandatory - //9.3.21 - // INTEGER (1..65535, …) - dst.ev_trigger_cond_id = (rand()% 65535) + 1 ; - - // E2 Node Information Change ID - // Mandatory - // INTEGER (1..512, ...) - dst.e2_node_info_chng_id = (rand()% 512) + 1; - - // Associated Cell Info - // Optional - // 9.3.27 - // ev_trigger_cell_info_t* ev_trigger_cell_info; - - // Logical OR - // Optional - // 9.3.25 - // logical_or_e* log_or; - - return dst; -} - -e2sm_rc_ev_trg_frmt_3_t fill_rnd_rc_event_trigger_frmt_3(void) -{ - e2sm_rc_ev_trg_frmt_3_t dst = {0}; - - // Sequence of E2 Node - // Information Change - // [1 - 65535] - dst.sz_e2_node_info_chng = (rand() % 128) + 1; // For not exhasuting the memory - - - dst.e2_node_info_chng = calloc(dst.sz_e2_node_info_chng, sizeof(e2_node_info_chng_t)); - assert(dst.e2_node_info_chng != NULL && "Memory exhasuted"); - - for(size_t i = 0; i < dst.sz_e2_node_info_chng; ++i){ - dst.e2_node_info_chng[i] = fill_rnd_e2_node_info_chng(); - } - - return dst; -} - -static -rrc_state_t fill_rnd_state_chng_to(void) -{ - rrc_state_t dst = {0}; - - // 9.3.37 - dst.state_chngd_to = rand() % END_RRC_STATE_E2SM_RC; - - // 9.3.25 - // Logical OR - dst.log_or = NULL; - - return dst; -} - -static -rrc_state_lst_t fill_rnd_rrc_state_lst(void) -{ - rrc_state_lst_t dst = {0}; - - // 9.3.37 - // [1 - 8] - dst.sz_rrc_state = (rand()% 8) + 1; - - dst.state_chng_to = calloc(dst.sz_rrc_state , sizeof(rrc_state_t)); - assert(dst.state_chng_to != NULL && "Memory exhausted" ); - - for(size_t i = 0; i < dst.sz_rrc_state; ++i){ - dst.state_chng_to[i] = fill_rnd_state_chng_to(); - } - - return dst; -} - -static -ran_param_test_t fill_rnd_ran_param_test(void); - - -static -ran_param_test_lst_t fill_rnd_ran_param_test_lst(void) -{ - ran_param_test_lst_t dst = {0}; - -// [1- 65535] - dst.sz_lst = 1; //(rand() % 2) + 1; // This can grow the tree very quickly - dst.ran_param_test = calloc(dst.sz_lst, sizeof( ran_param_test_t)); - assert(dst.ran_param_test != NULL && "Memory exhausted"); - - for(size_t i = 0; i < dst.sz_lst; ++i){ - dst.ran_param_test[i] = fill_rnd_ran_param_test(); - } - - return dst; -} - -static -ran_param_test_strct_t fill_rnd_ran_param_test_struct(void) -{ - ran_param_test_strct_t dst = {0}; - - // [1-65535] - dst.sz_strct = 1; //(rand()%2) + 1; // This can grow vey quickly if not... - - dst.ran_param_test = calloc(dst.sz_strct, sizeof(ran_param_test_t)); - assert(dst.ran_param_test != NULL && "Memory exhausted" ); - - for(size_t i = 0; i < dst.sz_strct; ++i){ - dst.ran_param_test[i] = fill_rnd_ran_param_test(); - } - - return dst; -} - -static -ran_parameter_value_t fill_rnd_ran_param_val(void) -{ - ran_parameter_value_t dst = {0}; - - dst.type = rand() % END_RAN_PARAMETER_VALUE ; - - if(dst.type == BOOLEAN_RAN_PARAMETER_VALUE){ - dst.bool_ran = rand()%2; - } else if(dst.type == INTEGER_RAN_PARAMETER_VALUE) { - dst.int_ran = rand()%4098; - } else if(dst.type == REAL_RAN_PARAMETER_VALUE) { - dst.real_ran = rand_float(1024); - } else if(dst.type == BIT_STRING_RAN_PARAMETER_VALUE ) { - dst.bit_str_ran = cp_str_to_ba("Bit string copy "); - } else if(dst.type == OCTET_STRING_RAN_PARAMETER_VALUE){ - dst.octet_str_ran = cp_str_to_ba("Octet string copy"); - } else if(dst.type == PRINTABLESTRING_RAN_PARAMETER_VALUE){ - dst.printable_str_ran = cp_str_to_ba("Printable string"); - } else { - assert(0!=0 && "Unknown type"); - } - - return dst; -} - -static -ran_parameter_value_t fill_rnd_ran_param_elm_key_true(void) -{ - // 9.3.14 - return fill_rnd_ran_param_val(); -} - -static -ran_param_struct_t fill_rnd_ran_param_struct(void); - -static -lst_ran_param_t fill_rnd_lst_ran_param(void) -{ - lst_ran_param_t dst = {0}; - // Bug in the standard. RAN Parameter List 9.3.13 - // has a mandatory ie RAN Parameter ID 9.3.8 - // and a mandatory ie RAN Parameter Structure 9.3.12 - // However, the ASN - // RANParameter-LIST ::= SEQUENCE { - // list-of-ranParameter SEQUENCE (SIZE(1..maxnoofItemsinList)) OF RANParameter-STRUCTURE, - // .. - // } - // - // Misses RAN Parameter ID and only has RAN Parameter Structure - - // RAN Parameter ID - // Mandatory - // 9.3.8 - //1.. 4294967295 - // Let's ignore the english written standard and believe the ASN.1 is the correct - // uint32_t ran_param_id; - - // RAN Parameter Structure - // Mandatory - // 9.3.12 - //ran_param_struct_t ran_param_struct; - - - // RAN Parameter ID - // Mandatory - // 9.3.8 - //1.. 4294967295 - //dst.ran_param_id = (rand() % 4096) + 1; - - // RAN Parameter Structure - // Mandatory - // 9.3.12 - dst.ran_param_struct = fill_rnd_ran_param_struct(); - - return dst; -} - -static -ran_param_list_t fill_rnd_ran_param_lst(void) -{ - ran_param_list_t dst = {0}; - - // [0- 65535] - dst.sz_lst_ran_param = (rand() % 2) + 1; - dst.lst_ran_param = calloc(dst.sz_lst_ran_param, sizeof(lst_ran_param_t )); - assert(dst.lst_ran_param != NULL && "Memory exhausted"); - - for(size_t i = 0 ; i < dst.sz_lst_ran_param; ++i){ - dst.lst_ran_param[i] = fill_rnd_lst_ran_param(); - } - - return dst; -} - -static -seq_ran_param_t fill_rnd_seq_ran_param(void); - -static -ran_param_struct_t fill_rnd_ran_param_struct(void) -{ - ran_param_struct_t dst = {0}; - - // [1-65535] - dst.sz_ran_param_struct = (rand() % 2 ) +1 ; - - dst.ran_param_struct = calloc(dst.sz_ran_param_struct, sizeof(seq_ran_param_t)); - assert(dst.ran_param_struct != NULL && "Memory exhausted" ); - - for(size_t i = 0; i < dst.sz_ran_param_struct ; ++i){ - dst.ran_param_struct[i] = fill_rnd_seq_ran_param(); - } - - return dst; -} - -static -ran_param_test_cond_t fill_rnd_ran_param_test_cond(void) -{ - ran_param_test_cond_t dst = {0}; - - dst.cond = rand() % END_RAN_PARAM_TEST_COND; - - if(dst.cond == COMPARISON_RAN_PARAM_TEST_COND){ - dst.comp = rand() % END_RAN_PARAM_TEST_COND_COMP; - } else if(dst.cond == PRESENCE_RAN_PARAM_TEST_COND){ - dst.presence = rand() % END_RAN_PARAM_TEST_COND_PRESENCE; - } else { - assert(0!=0 && "Unknown type"); - } - - return dst; -} - -static -ran_param_elm_key_false_t fill_rnd_ran_param_elm_key_false() -{ - ran_param_elm_key_false_t dst = {0}; - - // RAN Parameter Test Condition - // 9.3.31 - // Mandatory - dst.test_cond = fill_rnd_ran_param_test_cond(); - - // RAN Parameter Value - // Optional - // 9.3.14 - dst.value = NULL; - - // Logical OR - // Optional - // 9.3.25 - dst.logical_or = NULL; - - return dst; -} - -static -ran_param_test_t fill_rnd_ran_param_test(void) -{ - ran_param_test_t dst = {0}; - - //RAN Parameter ID - //Mandatory - //Bug in the standard. 9.3.9 wrote in section 9. - //9.3.8 in ASN language. Probably 9.3.8 intended - //1.. 4294967295 - dst.ran_param_id = (rand() % 4294967295) + 1; - - dst.type = rand() % END_RAN_PARAMETER_TYPE; - - static int max_depth; - max_depth++; - if(max_depth == 4){ - max_depth = 0; - dst.type = ELEMENT_WITH_KEY_FLAG_TRUE_RAN_PARAMETER_TYPE; - } - - - if(dst.type == LIST_RAN_PARAMETER_TYPE){ - dst.lst = fill_rnd_ran_param_test_lst(); - } else if(dst.type == STRUCTURE_RAN_PARAMETER_TYPE ){ - dst.strct = fill_rnd_ran_param_test_struct() ; - } else if(dst.type == ELEMENT_WITH_KEY_FLAG_TRUE_RAN_PARAMETER_TYPE){ - dst.flag_true = fill_rnd_ran_param_elm_key_true(); - } else if(dst.type == ELEMENT_WITH_KEY_FLAG_FALSE_RAN_PARAMETER_TYPE ){ - dst.flag_false = fill_rnd_ran_param_elm_key_false(); - } - - return dst; -} - -static -ran_param_cond_crit_def_t fill_rnd_ran_param_cond_crit_def(void) -{ - ran_param_cond_crit_def_t dst = {0}; - - // [1 - 255 ] - dst.sz_ran_param_test = 1; //(rand()%16) + 1; - - // RAN Parameter Test - // 9.3.30 - dst.ran_param_test = calloc(dst.sz_ran_param_test, sizeof(ran_param_test_t)); - assert(dst.ran_param_test != NULL && "Memory exhausted"); - - for(size_t i = 0; i < dst.sz_ran_param_test; ++i){ - dst.ran_param_test[i] = fill_rnd_ran_param_test(); - } - - return dst; -} - -static -ue_info_chng_t fill_rnd_ue_info_chng() -{ - ue_info_chng_t dst = {0}; - - // Event Trigger Condition ID - // Mandatory - // 9.3.21 - // INTEGER (1..65535, …) - dst.ev_trig_cond_id = (rand()%65535) + 1; - - // CHOICE Trigger Type - - dst.type = rand()%END_UE_INFO_CHNG_TRIGGER_TYPE; - - if( dst.type == RRC_STATE_UE_INFO_CHNG_TRIGGER_TYPE){ - // RRC State - dst.rrc_state = fill_rnd_rrc_state_lst(); - - } else if(dst.type == UE_ID_CHANGE_UE_INFO_CHNG_TRIGGER_TYPE){ - // UE Identifier Change - // [1 - 512] - dst.ue_id_chng = (rand() % 512) + 1; - - } else if(dst.type == L2_STATE_UE_INFO_CHNG_TRIGGER_TYPE){ - // 9.3.29 - // RAN Parameter Conditional Criteria Definition - dst.l2_state = fill_rnd_ran_param_cond_crit_def(); - - } else { - assert(0!=0 && "Unknown type"); - } - - - // Associated UE Info - // Optional - // 9.3.26 - dst.assoc_ue_info = NULL; - - // Logical OR - // Optional - // 9.3.25 - dst.log_or = NULL; - - return dst; -} - - -static -e2sm_rc_ev_trg_frmt_4_t fill_rnd_rc_event_trigger_frmt_4(void) -{ - e2sm_rc_ev_trg_frmt_4_t dst = {0}; - - // Sequence of UE Information Change - // [ 1 - 65535] - dst.sz_ue_info_chng = 1; //(rand()% 128) + 1; - - dst.ue_info_chng = calloc(dst.sz_ue_info_chng, sizeof(ue_info_chng_t) ); - assert(dst.ue_info_chng != NULL && "Memory exhausted"); - - for(size_t i = 0; i < dst.sz_ue_info_chng; ++i){ - dst.ue_info_chng[i] = fill_rnd_ue_info_chng(); - } - - return dst; -} - - -static -e2sm_rc_ev_trg_frmt_5_t fill_rnd_rc_event_trigger_frmt_5() -{ - e2sm_rc_ev_trg_frmt_5_t dst = {0} ; - - // On Demand - // Mandatory - dst.on_demand = rand()% END_ON_DEMAND_FRMT_5 ; - - // Associated UE Info - // Optional - // 9.3.26 - // ev_trigger_ue_info_t* assoc_ue_info; - - // Associated Cell Info - // Optional - // 9.3.27 - // ev_trigger_cell_info_t* assoc_cell_info; - - return dst; -} - - -e2sm_rc_event_trigger_t fill_rnd_rc_event_trigger(void) -{ - e2sm_rc_event_trigger_t dst = {0}; - - dst.format = rand() % END_E2SM_RC_EV_TRIGGER_FORMAT; - - if(dst.format == FORMAT_1_E2SM_RC_EV_TRIGGER_FORMAT){ - dst.frmt_1 = fill_rnd_rc_event_trigger_frmt_1() ; - - }else if(dst.format == FORMAT_2_E2SM_RC_EV_TRIGGER_FORMAT){ - dst.frmt_2 = fill_rnd_rc_event_trigger_frmt_2() ; - - }else if(dst.format == FORMAT_3_E2SM_RC_EV_TRIGGER_FORMAT){ - dst.frmt_3 = fill_rnd_rc_event_trigger_frmt_3() ; - - }else if(dst.format == FORMAT_4_E2SM_RC_EV_TRIGGER_FORMAT){ - dst.frmt_4 = fill_rnd_rc_event_trigger_frmt_4() ; - - }else if(dst.format == FORMAT_5_E2SM_RC_EV_TRIGGER_FORMAT){ - dst.frmt_5 = fill_rnd_rc_event_trigger_frmt_5() ; - - } else { - assert(0!=0 && "Unknown format"); - } - - return dst; -} - -///////////////////////////// -///////////////////////////// -////////// End of RC Event Trigger ////////// -///////////////////////////// -///////////////////////////// - - - -///////////////////////////// -///////////////////////////// -////////// Start of RC Action Definition ////////////////// -///////////////////////////// -///////////////////////////// - -static -param_report_def_t fill_rnd_param_report_def(void) -{ - param_report_def_t dst = {0}; - - // RAN Parameter ID - // Mandatory - // 9.3.8 - // [1 - 4294967295] - dst.ran_param_id = (rand() % 4294967295) + 1; - - // RAN Parameter Definition - // Optional - // 9.3.51 - dst.ran_param_def = calloc(1, sizeof(ran_param_def_t)); - assert(dst.ran_param_def != NULL && "Memory exhausyted"); - - dst.ran_param_def->type = rand()%END_RAN_PARAMETER_DEF_TYPE; - - switch (dst.ran_param_def->type) - { - case LIST_RAN_PARAMETER_DEF_TYPE: - dst.ran_param_def->lst = calloc(1, sizeof(ran_param_type_t)); - assert(dst.ran_param_def->lst != NULL && "Memory exhausyted"); - - dst.ran_param_def->lst->sz_ran_param = 10; // (rand()% 65535) + 1; - dst.ran_param_def->lst->ran_param = calloc(dst.ran_param_def->lst->sz_ran_param, sizeof(ran_param_lst_struct_t)); - assert(dst.ran_param_def->lst->ran_param != NULL && "Memory exhausyted"); - - for (size_t i = 0; i < dst.ran_param_def->lst->sz_ran_param; i++) - { - // RAN Parameter ID - // Mandatory - // 9.3.8 - dst.ran_param_def->lst->ran_param[i].ran_param_id = rand() + 1; - - // RAN Parameter Name - // Mandatory - // 9.3.9 - const char name[] = "RAN Parameter Name"; - dst.ran_param_def->lst->ran_param[i].ran_param_name = cp_str_to_ba(name); - - // RAN Parameter Definition - // Optional - // 9.3.51 - dst.ran_param_def->lst->ran_param[i].ran_param_def = NULL; - } - - break; - - case STRUCTURE_RAN_PARAMETER_DEF_TYPE: - dst.ran_param_def->strct = calloc(1, sizeof(ran_param_type_t)); - assert(dst.ran_param_def->strct != NULL && "Memory exhausyted"); - - dst.ran_param_def->strct->sz_ran_param = 10; // (rand()% 65535) + 1; - dst.ran_param_def->strct->ran_param = calloc(dst.ran_param_def->strct->sz_ran_param, sizeof(ran_param_lst_struct_t)); - assert(dst.ran_param_def->strct->ran_param != NULL && "Memory exhausyted"); - - for (size_t i = 0; i < dst.ran_param_def->strct->sz_ran_param; i++) - { - // RAN Parameter ID - // Mandatory - // 9.3.8 - dst.ran_param_def->strct->ran_param[i].ran_param_id = (rand() % 4294967295) + 1; - - // RAN Parameter Name - // Mandatory - // 9.3.9 - const char name[] = "RAN Parameter Name"; - dst.ran_param_def->strct->ran_param[i].ran_param_name = cp_str_to_ba(name); - - // RAN Parameter Definition - // Optional - // 9.3.51 - dst.ran_param_def->strct->ran_param[i].ran_param_def = NULL; - } - - break; - - default: - assert(false && "Unknown RAN Parameter Type"); - } - - return dst; -} - - -static -e2sm_rc_act_def_frmt_1_t fill_rnd_rc_action_def_frmt_1(void) -{ - e2sm_rc_act_def_frmt_1_t dst = {0}; - - // Parameters to be Reported List - // [1-65535] - dst.sz_param_report_def = (rand()%4) + 1; // (rand()% 65535) + 1; - - dst.param_report_def = calloc(dst.sz_param_report_def, sizeof( param_report_def_t)); - assert(dst.param_report_def != NULL && "Memory exhausyted"); - - for(size_t i = 0; i < dst.sz_param_report_def; ++i){ - dst.param_report_def[i] = fill_rnd_param_report_def() ; - } - - return dst; -} - -static _Atomic -int recursion_fill_rnd_ran_param_val_type = 0; - -static -ran_param_val_type_t fill_rnd_ran_param_val_type() -{ - ran_param_val_type_t dst = {0}; - - dst.type = rand() % END_RAN_PARAMETER_VAL_TYPE; // STRUCTURE_RAN_PARAMETER_VAL_TYPE; // - - recursion_fill_rnd_ran_param_val_type += 1; - if(recursion_fill_rnd_ran_param_val_type > 4){ -// recursion_fill_rnd_ran_param_val_type = 0; - dst.type = ELEMENT_KEY_FLAG_TRUE_RAN_PARAMETER_VAL_TYPE; - } - - if(dst.type == ELEMENT_KEY_FLAG_TRUE_RAN_PARAMETER_VAL_TYPE){ - dst.flag_true = calloc(1, sizeof( ran_parameter_value_t)); - assert(dst.flag_true != NULL && "Memory exhausted" ); - *dst.flag_true = fill_rnd_ran_param_val(); - } else if(dst.type == ELEMENT_KEY_FLAG_FALSE_RAN_PARAMETER_VAL_TYPE ){ - dst.flag_false = calloc(1, sizeof( ran_parameter_value_t)); - assert(dst.flag_false != NULL && "Memory exhausted" ); - *dst.flag_false = fill_rnd_ran_param_val(); - }else if(dst.type == STRUCTURE_RAN_PARAMETER_VAL_TYPE){ - dst.strct = calloc(1, sizeof(ran_param_struct_t)); - assert(dst.strct != NULL && "Memory exhausted" ); - *dst.strct = fill_rnd_ran_param_struct(); - }else if(dst.type == LIST_RAN_PARAMETER_VAL_TYPE ){ - dst.lst = calloc(1, sizeof(ran_param_list_t)); - assert(dst.lst != NULL && "memory exhausted"); - *dst.lst = fill_rnd_ran_param_lst(); - } else { - assert(0!=0 && "not implemented" ); - } - - return dst; -} - -static -seq_ran_param_t fill_rnd_seq_ran_param(void) -{ - seq_ran_param_t dst = {0}; - - //RAN Parameter ID - //Mandatory - //9.3.8 - // [1 - 4294967295] - dst.ran_param_id = (rand()% 4096) +1 ; - - // RAN Parameter Value Type - // 9.3.11 - // Mandatory - dst.ran_param_val = fill_rnd_ran_param_val_type(); - - return dst; -} - -static -policy_action_t fill_rnd_policy_action(void) -{ - policy_action_t dst = {0}; - - // Policy Action ID - // Mandatory - // 9.3.6 - // [1 - 65535] - dst.policy_act_id = (rand()% 65535) +1; - - // Sequence of RAN Parameters - // [0- 65535] - dst.sz_seq_ran_param = rand()% 2; //65535; - - if(dst.sz_seq_ran_param > 0){ - dst.seq_ran_param = calloc(dst.sz_seq_ran_param, sizeof(seq_ran_param_t)); - assert(dst.seq_ran_param != NULL && "Memory exhausted" ); - } - - for(size_t i = 0 ; i < dst.sz_seq_ran_param; ++i){ - dst.seq_ran_param[i] = fill_rnd_seq_ran_param(); - } - - // RIC Policy decision - // Optional - dst.pol_dec = NULL; - - return dst; -} - -static -policy_cond_t fill_rnd_policy_cond(void) -{ - policy_cond_t dst = {0}; - - // Policy Action Definition - // Mandatory - // 9.3.20 - dst.pol_act = fill_rnd_policy_action(); - - // Policy Condition Definition - // Optional - // 9.3.29 - dst.pol = NULL; - - return dst; -} - -static -e2sm_rc_act_def_frmt_2_t fill_rnd_rc_action_def_frmt_2(void) -{ - e2sm_rc_act_def_frmt_2_t dst = {0}; - - // Sequence of Policy Conditions - // [1 - 65535] - dst.sz_policy_cond = (rand() % 2) + 1; // Too large 65535 - - dst.policy_cond = calloc(dst.sz_policy_cond, sizeof(policy_cond_t) ); - assert(dst.policy_cond != NULL && "memory exhausted" ); - - for(size_t i = 0; i < dst.sz_policy_cond; ++i){ - dst.policy_cond[i] = fill_rnd_policy_cond(); - } - - return dst; -} - -static -ran_param_ins_t fill_rnd_ran_param_ins(void) -{ - ran_param_ins_t dst = {0}; - - // RAN Parameter ID - // Mandatory - // 9.3.8 - // [1 - 4294967295] - dst.ran_id = (rand()% 4294967295) + 1; - - // RAN Parameter Definition - // Optional - // 9.3.51 - dst.def = NULL; - - return dst; -} - -static -e2sm_rc_act_def_frmt_3_t fill_rnd_rc_action_def_frmt_3(void) -{ - e2sm_rc_act_def_frmt_3_t dst = {0}; - - // Insert Indication ID - // Mandatory - // 9.3.16 - // [1 - 65535] - dst.id = rand()% 65535 + 1; - - // List of RAN parameters for Insert - // Indication - // [1 - 65535] - dst.sz_ran_param_ins = (rand() % 64) + 1; - dst.ran_param = calloc(dst.sz_ran_param_ins, sizeof(ran_param_ins_t) ); - assert(dst.ran_param != NULL && "Memory exhausted"); - - for(size_t i = 0; i < dst.sz_ran_param_ins; ++i){ - dst.ran_param[i] = fill_rnd_ran_param_ins(); - } - - // UE ID - // Optional - // 9.3.10 - dst.ue_id = NULL; - - return dst; -} - -static -ran_param_ins_ind_t fill_rnd_ran_param_ins_ind(void) -{ - ran_param_ins_ind_t dst = {0}; - // RAN Parameter ID - // Mandatory - // 9.3.8 - // [1.. 429496729 ] - dst.ran_param_id = (rand() % 4294967295) + 1; - - // RAN Parameter Definition - // Optional - // 9.3.51 - dst.ran_param_def = NULL; - - return dst; -} - -static -seq_ins_ind_act_def_t fill_rnd_seq_ins_ind_act_def(void) -{ - seq_ins_ind_act_def_t dst = {0}; - - // Insert Indication ID - // Mandatory - // 9.3.16 - // [1 - 65535] - dst.ind_id = (rand()% 65535 ) +1; - - // List of RAN parameters for - // Insert Indication - // [1-65535] - dst.sz_ran_param_ins_ind = (rand() % 16) + 1; - - dst.ran_param_ins_ind = calloc(dst.sz_ran_param_ins_ind, sizeof(ran_param_ins_ind_t)); - assert(dst.ran_param_ins_ind != NULL && "Memory exhausted"); - - for(size_t i = 0; i < dst.sz_ran_param_ins_ind; ++i){ - dst.ran_param_ins_ind[i] = fill_rnd_ran_param_ins_ind(); - } - - return dst; -} - - -static -seq_ins_style_t fill_rnd_seq_ins_style(void) -{ - seq_ins_style_t dst = {0}; - - // Requested Insert Style - // Mandatory - // 9.3.3 - // 6.2.2.2. in E2 SM common - // Integer - dst.req_insert_style = rand() % 1024; - - // Sequence of Insert Indication - // Action Definition - // [1-63] - dst.sz_seq_ins_ind_act_def = (rand()%4) + 1; // (rand()% 63) + 1; - - dst.seq_ins_ind_act_def = calloc(dst.sz_seq_ins_ind_act_def, sizeof( seq_ins_ind_act_def_t)); - assert(dst.seq_ins_ind_act_def != NULL && "Memory exhausted"); - - for(size_t i = 0; i < dst.sz_seq_ins_ind_act_def; ++i){ - dst.seq_ins_ind_act_def[i] = fill_rnd_seq_ins_ind_act_def(); - } - - return dst; -} - -static -e2sm_rc_act_def_frmt_4_t fill_rnd_rc_action_def_frmt_4(void) -{ - e2sm_rc_act_def_frmt_4_t dst = {0}; - - // Sequence of Insert Styles for - // Multiple Actions - // [1-4] - dst.sz_seq_ins_style = (rand() % 4) + 1; - - dst.seq_ins_style = calloc(dst.sz_seq_ins_style, sizeof(seq_ins_style_t) ); - assert(dst.seq_ins_style != NULL && "Memory exhausted" ); - - for(size_t i = 0; i < dst.sz_seq_ins_style; ++i){ - dst.seq_ins_style[i] = fill_rnd_seq_ins_style(); - } - - - // UE ID - // Optional - // 9.3.10 - dst.ue_id = NULL; - - return dst; -} - - -e2sm_rc_action_def_t fill_rnd_rc_action_def(void) -{ - e2sm_rc_action_def_t dst = {0}; - - // RIC Style Type - // Mandatory - // 9.3.3 - // Defined in common 6.2.2.2. - dst.ric_style_type = (rand()%1024) + 1; - - dst.format = rand() % END_E2SM_RC_ACT_DEF; - - if(dst.format == FORMAT_1_E2SM_RC_ACT_DEF ){ - dst.frmt_1 = fill_rnd_rc_action_def_frmt_1(); - - } else if(dst.format == FORMAT_2_E2SM_RC_ACT_DEF){ - dst.frmt_2 = fill_rnd_rc_action_def_frmt_2(); - - } else if(dst.format == FORMAT_3_E2SM_RC_ACT_DEF){ - dst.frmt_3 = fill_rnd_rc_action_def_frmt_3(); - - } else if(dst.format == FORMAT_4_E2SM_RC_ACT_DEF){ - dst.frmt_4 = fill_rnd_rc_action_def_frmt_4(); - - } else { - assert(0 != 0 && "Unknown format"); - } - - return dst; -} - -e2sm_rc_ind_hdr_frmt_1_t fill_rnd_rc_ind_hdr_frmt_1(void) -{ - e2sm_rc_ind_hdr_frmt_1_t dst = {0}; - - dst.ev_trigger_id = malloc(sizeof(uint16_t)); - assert(dst.ev_trigger_id != NULL && "Memory exhausted" ); - - // Event Trigger Condition ID - // Optional - // 9.3.21 - // [1 - 65535] - *dst.ev_trigger_id = (rand() % 65535) + 1; - - return dst; -} - -static -gnb_e2sm_t fill_rnd_gnb_data(void) -{ - gnb_e2sm_t gnb = {0}; - - // 6.2.3.16 - // Mandatory - // AMF UE NGAP ID - gnb.amf_ue_ngap_id = (rand() % 2^40) + 0; - - // Mandatory - //GUAMI 6.2.3.17 - gnb.guami.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; - - gnb.guami.amf_region_id = (rand() % 2^8) + 0; - gnb.guami.amf_set_id = (rand() % 2^10) + 0; - gnb.guami.amf_ptr = (rand() % 2^6) + 0; - - // gNB-CU UE F1AP ID List - // C-ifCUDUseparated - gnb.gnb_cu_ue_f1ap_lst_len = (rand() % 4) + 1; - gnb.gnb_cu_ue_f1ap_lst = calloc(gnb.gnb_cu_ue_f1ap_lst_len, sizeof(uint32_t)); - for (size_t i = 0; i < gnb.gnb_cu_ue_f1ap_lst_len; i++) - { - gnb.gnb_cu_ue_f1ap_lst[i] = (rand() % 4294967296) + 0; - } - - //gNB-CU-CP UE E1AP ID List - //C-ifCPUPseparated - gnb.gnb_cu_cp_ue_e1ap_lst_len = 3; //(rand() % 65535) + 1; - gnb.gnb_cu_cp_ue_e1ap_lst = calloc(gnb.gnb_cu_cp_ue_e1ap_lst_len, sizeof(uint32_t)); - for (size_t i = 0; i < gnb.gnb_cu_cp_ue_e1ap_lst_len; i++) - { - gnb.gnb_cu_cp_ue_e1ap_lst[i] = (rand() % 4294967296) + 0; - } - - // RAN UE ID - // Optional - // 6.2.3.25 - gnb.ran_ue_id = calloc(1, sizeof(uint64_t)); - assert(gnb.ran_ue_id != NULL && "Memory exhausted"); - *gnb.ran_ue_id = 14294967296; // (rand() % 2^64) + 0; - - // M-NG-RAN node UE XnAP ID - // C- ifDCSetup - // 6.2.3.19 - gnb.ng_ran_node_ue_xnap_id = calloc(1, sizeof(uint32_t)); - assert(gnb.ng_ran_node_ue_xnap_id != NULL && "Memory exhausted"); - *gnb.ng_ran_node_ue_xnap_id = (rand() % 4294967296) + 0; - - // Global gNB ID - // 6.2.3.3 - // Optional - // This IE shall not be used. Global NG-RAN Node ID IE shall replace this IE - //gnb.global_gnb_id = calloc(1, sizeof(global_gnb_id_t)); - //assert(gnb.global_gnb_id != NULL && "Memory exhausted"); - //gnb.global_gnb_id->type = GNB_TYPE_ID; - //gnb.global_gnb_id->plmn_id = (plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; - //gnb.global_gnb_id->gnb_id = (rand() % 4294967296) + 0; - - // Global NG-RAN Node ID - // C-ifDCSetup - // 6.2.3.2 - gnb.global_ng_ran_node_id = calloc(1, sizeof(*gnb.global_ng_ran_node_id)); - gnb.global_ng_ran_node_id->type = rand()%END_GLOBAL_TYPE_ID; - - switch (gnb.global_ng_ran_node_id->type) - { - case GNB_GLOBAL_TYPE_ID: - gnb.global_ng_ran_node_id->global_gnb_id.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; -// gnb.global_ng_ran_node_id->global_gnb_id.type = GNB_TYPE_ID; - gnb.global_ng_ran_node_id->global_gnb_id.gnb_id.nb_id = (rand() % 4294967296) + 0; - gnb.global_ng_ran_node_id->global_gnb_id.gnb_id.unused = rand() % 11; - gnb.global_ng_ran_node_id->global_gnb_id.gnb_id.nb_id &= (0xFFFFFFFF & (32 - gnb.global_ng_ran_node_id->global_gnb_id.gnb_id.unused)); - break; - - case NG_ENB_GLOBAL_TYPE_ID: - gnb.global_ng_ran_node_id->global_ng_enb_id.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; - gnb.global_ng_ran_node_id->global_ng_enb_id.type = LONG_MACRO_NG_ENB_TYPE_ID; // rand()%END_NG_ENB_TYPE_ID; - - switch (gnb.global_ng_ran_node_id->global_ng_enb_id.type) - { - case MACRO_NG_ENB_TYPE_ID: - gnb.global_ng_ran_node_id->global_ng_enb_id.macro_ng_enb_id = (rand() % 2^20) + 0; - break; - - case SHORT_MACRO_NG_ENB_TYPE_ID: - gnb.global_ng_ran_node_id->global_ng_enb_id.short_macro_ng_enb_id = (rand() % 2^18) + 0; - break; - - case LONG_MACRO_NG_ENB_TYPE_ID: - gnb.global_ng_ran_node_id->global_ng_enb_id.long_macro_ng_enb_id = (rand() % 2^21) + 0; - break; - - default: - assert(false && "Unknown Global NG eNB ID Type"); - } - break; - - default: - assert(false && "Unknown Global NG-RAN Node ID Type"); - } - - return gnb; -} - -static -gnb_du_e2sm_t fill_rnd_gnb_du_data(void) -{ - gnb_du_e2sm_t gnb_du = {0}; - gnb_du.gnb_cu_ue_f1ap = (rand() % 4294967296) + 0; - - gnb_du.ran_ue_id = calloc(1, sizeof(*gnb_du.ran_ue_id)); - *gnb_du.ran_ue_id = (rand() % 2^64) + 0; - - return gnb_du; -} - -static -gnb_cu_up_e2sm_t fill_rnd_gnb_cu_up_data(void) -{ - gnb_cu_up_e2sm_t gnb_cu_up = {0}; - gnb_cu_up.gnb_cu_cp_ue_e1ap = (rand() % 4294967296) + 0; - - gnb_cu_up.ran_ue_id = calloc(1, sizeof(*gnb_cu_up.ran_ue_id)); - *gnb_cu_up.ran_ue_id = (rand() % 2^64) + 0; - - return gnb_cu_up; -} - -ng_enb_e2sm_t fill_rnd_ng_enb_data(void) -{ - ng_enb_e2sm_t ng_enb = {0}; - - // 6.2.3.16 - // Mandatory - // AMF UE NGAP ID - ng_enb.amf_ue_ngap_id = (rand() % 2^40) + 0; - - // 6.2.3.17 - // Mandatory - // GUAMI - ng_enb.guami.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; - - ng_enb.guami.amf_region_id = (rand() % 2^8) + 0; - ng_enb.guami.amf_set_id = (rand() % 2^10) + 0; - ng_enb.guami.amf_ptr = (rand() % 2^6) + 0; - - // 6.2.3.22 - // C-if CU DU separated - // ng-eNB-CU UE W1AP ID - ng_enb.ng_enb_cu_ue_w1ap_id = calloc(1, sizeof(uint32_t)); - assert(ng_enb.ng_enb_cu_ue_w1ap_id != NULL && "Memory exhausted"); - *ng_enb.ng_enb_cu_ue_w1ap_id = (rand() % 4294967296) + 0; - - // 6.2.3.19 - // C- ifDCSetup - // M-NG-RAN node UE XnAP ID - ng_enb.ng_ran_node_ue_xnap_id = calloc(1, sizeof(uint32_t)); - assert(ng_enb.ng_ran_node_ue_xnap_id != NULL && "Memory exhausted"); - *ng_enb.ng_ran_node_ue_xnap_id = (rand() % 4294967296) + 0; - - // OPTIONAL - // This IE shall not be used. Global NG-RAN Node ID IE shall replace this IE - ng_enb.global_ng_enb_id = calloc(1, sizeof(*ng_enb.global_ng_enb_id)); - assert(ng_enb.global_ng_enb_id != NULL && "Memory exhausted"); - ng_enb.global_ng_enb_id->plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; - - ng_enb.global_ng_enb_id->type = rand()%END_NG_ENB_TYPE_ID; - - switch (ng_enb.global_ng_enb_id->type) - { - case MACRO_NG_ENB_TYPE_ID: - ng_enb.global_ng_enb_id->macro_ng_enb_id = (rand() % 2^20) + 0; - break; - - case SHORT_MACRO_NG_ENB_TYPE_ID: - ng_enb.global_ng_enb_id->short_macro_ng_enb_id = (rand() % 2^18) + 0; - break; - - case LONG_MACRO_NG_ENB_TYPE_ID: - ng_enb.global_ng_enb_id->long_macro_ng_enb_id = (rand() % 2^21) + 0; - break; - - default: - assert(false && "Unknown Global NG eNB ID Type"); - } - - - // Global NG-RAN Node ID - // C-ifDCSetup - // 6.2.3.2 - ng_enb.global_ng_ran_node_id = calloc(1, sizeof(*ng_enb.global_ng_ran_node_id)); - assert(ng_enb.global_ng_ran_node_id != NULL && "Memory exhausted"); - ng_enb.global_ng_ran_node_id->type = rand()%END_GLOBAL_TYPE_ID; - - switch (ng_enb.global_ng_ran_node_id->type) - { - case GNB_GLOBAL_TYPE_ID: - ng_enb.global_ng_ran_node_id->global_gnb_id.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; - //ng_enb.global_ng_ran_node_id->global_gnb_id.type = GNB_TYPE_ID; - ng_enb.global_ng_ran_node_id->global_gnb_id.gnb_id.nb_id = (rand() % 4294967296) + 0; - ng_enb.global_ng_ran_node_id->global_gnb_id.gnb_id.unused = (rand() % 11); - ng_enb.global_ng_ran_node_id->global_gnb_id.gnb_id.nb_id &= (0xFFFFFFFF >> ( 32 - ng_enb.global_ng_ran_node_id->global_gnb_id.gnb_id.unused)); - - break; - - case NG_ENB_GLOBAL_TYPE_ID: - ng_enb.global_ng_ran_node_id->global_ng_enb_id.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; - ng_enb.global_ng_ran_node_id->global_ng_enb_id.type = LONG_MACRO_NG_ENB_TYPE_ID; // rand()%END_NG_ENB_TYPE_ID; - - switch (ng_enb.global_ng_ran_node_id->global_ng_enb_id.type) - { - case MACRO_NG_ENB_TYPE_ID: - ng_enb.global_ng_ran_node_id->global_ng_enb_id.macro_ng_enb_id = (rand() % 2^20) + 0; - break; - - case SHORT_MACRO_NG_ENB_TYPE_ID: - ng_enb.global_ng_ran_node_id->global_ng_enb_id.short_macro_ng_enb_id = (rand() % 2^18) + 0; - break; - - case LONG_MACRO_NG_ENB_TYPE_ID: - ng_enb.global_ng_ran_node_id->global_ng_enb_id.long_macro_ng_enb_id = (rand() % 2^21) + 0; - break; - - default: - assert(false && "Unknown Global NG eNB ID Type"); - } - break; - - default: - assert(false && "Unknown Global NG-RAN Node ID Type"); - } - - return ng_enb; -} - -ng_enb_du_e2sm_t fill_rnd_ng_enb_du_data(void) -{ - ng_enb_du_e2sm_t ng_enb_du = {0}; - - // 6.2.3.22 - // C-if CU DU separated - // ng-eNB-CU UE W1AP ID - ng_enb_du.ng_enb_cu_ue_w1ap_id = (rand() % 4294967296) + 0; - - return ng_enb_du; -} - -en_gnb_e2sm_t fill_rnd_en_gnb_data(void) -{ - en_gnb_e2sm_t en_gnb = {0}; - - // 6.2.3.23 - // Mandatory - // MeNB UE X2AP ID - en_gnb.enb_ue_x2ap_id = (rand() % 4095) + 1; - - // 6.2.3.24 - // OPTIONAL - // MeNB UE X2AP ID Extension - en_gnb.enb_ue_x2ap_id_extension = calloc(1, sizeof(uint16_t)); - assert(en_gnb.enb_ue_x2ap_id_extension != NULL && "Memory exhausted"); - *en_gnb.enb_ue_x2ap_id_extension = (rand() % 4095) + 1; - - // 6.2.3.9 - // Mandatory - // Global eNB ID - en_gnb.global_enb_id.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; - - en_gnb.global_enb_id.type = rand()%SHORT_MACRO_ENB_TYPE_ID; - - switch (en_gnb.global_enb_id.type) - { - case MACRO_ENB_TYPE_ID: - en_gnb.global_enb_id.macro_enb_id = (rand() % 2^20) + 0; - break; - - case HOME_ENB_TYPE_ID: - en_gnb.global_enb_id.home_enb_id = (rand() % 2^28) + 0; - break; - - /* Possible extensions: */ - // case SHORT_MACRO_ENB_TYPE_ID: - // en_gnb.global_enb_id.short_macro_enb_id = (rand() % 2^18) + 0; - // break; - - // case LONG_MACRO_ENB_TYPE_ID: - // en_gnb.global_enb_id.long_macro_enb_id = (rand() % 2^21) + 0; - // break; - - default: - break; - } - - // 6.2.3.21 - // gNB-CU UE F1AP ID - // C-ifCUDUseparated - en_gnb.gnb_cu_ue_f1ap_lst = calloc(1, sizeof(uint32_t)); - assert(en_gnb.gnb_cu_ue_f1ap_lst != NULL && "Memory exhausted"); - *en_gnb.gnb_cu_ue_f1ap_lst = (rand() % 4294967296) + 0; - - // gNB-CU-CP UE E1AP ID List - // C-ifCPUPseparated - en_gnb.gnb_cu_cp_ue_e1ap_lst_len = 3; - en_gnb.gnb_cu_cp_ue_e1ap_lst = calloc(en_gnb.gnb_cu_cp_ue_e1ap_lst_len, sizeof(uint32_t)); - for (size_t i = 0; i < en_gnb.gnb_cu_cp_ue_e1ap_lst_len; i++) - { - en_gnb.gnb_cu_cp_ue_e1ap_lst[i] = (rand() % 4294967296) + 0; - } - - // RAN UE ID - // Optional - // 6.2.3.25 - en_gnb.ran_ue_id = calloc(1, sizeof(uint64_t)); - assert(en_gnb.ran_ue_id != NULL && "Memory exhausted"); - *en_gnb.ran_ue_id = (rand() % 2^64) + 0; - - return en_gnb; -} - -enb_e2sm_t fill_rnd_enb_data(void) -{ - enb_e2sm_t enb = {0}; - - // 6.2.3.26 - // Mandatory - // MME UE S1AP ID - enb.mme_ue_s1ap_id = (rand() % 4294967296) + 0; - - // 6.2.3.18 - // Mandatory - // GUMMEI - enb.gummei.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; - enb.gummei.mme_group_id = (rand() % 2^16) + 0; - enb.gummei.mme_code = (rand() % 2^8) + 0; - - // 6.2.3.23 - // C-ifDCSetup - // MeNB UE X2AP ID - enb.enb_ue_x2ap_id = calloc(1, sizeof(uint16_t)); - assert(enb.enb_ue_x2ap_id != NULL && "Memory exhausted"); - *enb.enb_ue_x2ap_id = (rand() % 4095) + 1; - - // 6.2.3.24 - // C-ifDCSetup - // MeNB UE X2AP ID Extension - enb.enb_ue_x2ap_id_extension = calloc(1, sizeof(uint16_t)); - assert(enb.enb_ue_x2ap_id_extension != NULL && "Memory exhausted"); - *enb.enb_ue_x2ap_id_extension = (rand() % 4095) + 1; - - // 6.2.3.9 - // C-ifDCSetup - // Global eNB ID - enb.global_enb_id = calloc(1, sizeof(*enb.global_enb_id)); - assert(enb.global_enb_id != NULL && "Memory exhausted"); - - enb.global_enb_id->plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; - - enb.global_enb_id->type = MACRO_ENB_TYPE_ID; // rand()%END_ENB_TYPE_ID; - - switch (enb.global_enb_id->type) - { - case MACRO_ENB_TYPE_ID: - enb.global_enb_id->macro_enb_id = (rand() % 2^20) + 0; - break; - - case HOME_ENB_TYPE_ID: - enb.global_enb_id->home_enb_id = (rand() % 2^28) + 0; - break; - - /* Possible extensions: */ - // case SHORT_MACRO_ENB_TYPE_ID: - // enb.global_enb_id->short_macro_enb_id = (rand() % 2^18) + 0; - // break; - - // case LONG_MACRO_ENB_TYPE_ID: - // enb.global_enb_id->long_macro_enb_id = (rand() % 2^21) + 0; - // break; - - default: - break; - } - - return enb; -} - -static -ue_id_e2sm_t fill_rnd_ue_id(void) -{ - ue_id_e2sm_t ue_id_data = {0}; - - ue_id_data.type = GNB_UE_ID_E2SM; // rand()%END_UE_ID; - - switch (ue_id_data.type) - { - case GNB_UE_ID_E2SM: - ue_id_data.gnb = fill_rnd_gnb_data(); - break; - - case GNB_DU_UE_ID_E2SM: - ue_id_data.gnb_du = fill_rnd_gnb_du_data(); - break; - - case GNB_CU_UP_UE_ID_E2SM: - ue_id_data.gnb_cu_up = fill_rnd_gnb_cu_up_data(); - break; - - case NG_ENB_UE_ID_E2SM: - ue_id_data.ng_enb = fill_rnd_ng_enb_data(); - break; - - case NG_ENB_DU_UE_ID_E2SM: - ue_id_data.ng_enb_du = fill_rnd_ng_enb_du_data(); - break; - - case EN_GNB_UE_ID_E2SM: - ue_id_data.en_gnb = fill_rnd_en_gnb_data(); - break; - - case ENB_UE_ID_E2SM: - ue_id_data.enb = fill_rnd_enb_data(); - break; - - default: - assert(false && "Unknown UE ID Type"); - } - - - return ue_id_data; -} - - - -static -e2sm_rc_ind_hdr_frmt_2_t fill_rnd_rc_ind_hdr_frmt_2(void) -{ - e2sm_rc_ind_hdr_frmt_2_t dst = {0}; - - // UE ID - // Mandatory - // 9.3.10 - dst.ue_id = fill_rnd_ue_id (); - - // RIC Insert Style Type - // Mandatory - // 9.3.3 - // 6.2.2.2. From common SM - // RIC Style Type - // Integer - dst.ric_style_type = rand()% 2048; - - // Insert Indication ID - // Mandatory - // 9.3.16 - // [1 - 65535] - dst.ins_ind_id = (rand() % 65535 ) + 1; - - return dst; -} - -static -e2sm_rc_ind_hdr_frmt_3_t fill_rnd_rc_ind_hdr_frmt_3(void) -{ - e2sm_rc_ind_hdr_frmt_3_t dst = {0}; - - // Event Trigger Condition ID - // Optional - // 9.3.21 - // [1 - 65535] - dst.ev_trigger_cond = malloc(sizeof(uint16_t)); - assert(dst.ev_trigger_cond != NULL && "Memory exhausted" ); - - *dst.ev_trigger_cond = (rand() % 65535) + 1; - - // UE ID - // Optional - // 9.3.10 - dst.ue_id = calloc(1, sizeof( ue_id_e2sm_t)); - assert(dst.ue_id != NULL && "Memory exhausted" ); - - *dst.ue_id = fill_rnd_ue_id(); - - return dst; -} - - -e2sm_rc_ind_hdr_t fill_rnd_rc_ind_hdr(void) -{ - e2sm_rc_ind_hdr_t dst = {0}; - - dst.format = rand()%END_E2SM_RC_IND_HDR; - - if(dst.format == FORMAT_1_E2SM_RC_IND_HDR){ - dst.frmt_1 = fill_rnd_rc_ind_hdr_frmt_1(); - } else if(dst.format == FORMAT_2_E2SM_RC_IND_HDR ){ - dst.frmt_2 = fill_rnd_rc_ind_hdr_frmt_2(); - }else if(dst.format == FORMAT_3_E2SM_RC_IND_HDR ){ - dst.frmt_3 = fill_rnd_rc_ind_hdr_frmt_3(); - }else { - assert(0!=0 && "Unknown format"); - } - - return dst; -} - -static -e2sm_rc_ind_msg_frmt_1_t fill_rnd_ind_msg_frmt_1(void) -{ - e2sm_rc_ind_msg_frmt_1_t dst = {0}; - - // Sequence of RAN - // Parameters - // [1 - 65535] - dst.sz_seq_ran_param = (rand() % 64) + 1; - - dst.seq_ran_param = calloc(dst.sz_seq_ran_param, sizeof(seq_ran_param_t)); - assert(dst.seq_ran_param != NULL && "Memory exhausted"); - - for(size_t i = 0; i < dst.sz_seq_ran_param; ++i){ - dst.seq_ran_param[i] = fill_rnd_seq_ran_param(); - } - - return dst; -} - -static -seq_ue_id_t fill_rnd_seq_ue_id(void) -{ - seq_ue_id_t dst = {0}; - - // UE ID - // Mandatory - // 9.3.10 - dst.ue_id = fill_rnd_ue_id(); - - // Sequence of - // RAN Parameter - // [1- 65535] - dst.sz_seq_ran_param = (rand() % 8) + 1; - - dst.seq_ran_param = calloc(dst.sz_seq_ran_param, sizeof(seq_ran_param_t ) ); - assert(dst.seq_ran_param != NULL && "Memory exhausted"); - - for(size_t i = 0; i < dst.sz_seq_ran_param; ++i){ - dst.seq_ran_param[i] = fill_rnd_seq_ran_param(); - } - - - return dst; -} - -e2sm_rc_ind_msg_frmt_2_t fill_rnd_ind_msg_frmt_2(void) -{ - e2sm_rc_ind_msg_frmt_2_t dst = {0}; - - //Sequence of UE Identifier - //[1-65535] - dst.sz_seq_ue_id = (rand() % 8) +1; - - dst.seq_ue_id = calloc(dst.sz_seq_ue_id, sizeof(seq_ue_id_t)); - assert(dst.seq_ue_id != NULL && "Memory exhausted"); - - for(size_t i = 0; i 0){ - dst.seq_ue_info = calloc(dst.sz_seq_ue_info, sizeof(seq_ue_info_t)); - assert(dst.seq_ue_info != NULL && "memory exhausted"); - } - - for(size_t i = 0; i < dst.sz_seq_ue_info; ++i){ - dst.seq_ue_info[i] = fill_rnd_seq_ue_info(); - } - - // Sequence of Cell Information - // [0-65535] - dst.sz_seq_cell_info_2 = rand()%8; - - if(dst.sz_seq_cell_info_2 > 0){ - dst.seq_cell_info_2 = calloc(dst.sz_seq_cell_info_2, sizeof( seq_cell_info_2_t ) ); - assert(dst.seq_cell_info_2 != NULL && "Memory exhausted"); - } - - for(size_t i = 0; i < dst.sz_seq_cell_info_2; ++i){ - dst.seq_cell_info_2[i] = fill_rnd_seq_cell_info_2(); - } - - return dst; -} - -static -e2sm_rc_ind_msg_frmt_5_t fill_rnd_ind_msg_frmt_5(void) -{ - e2sm_rc_ind_msg_frmt_5_t dst = {0}; - - // List of RAN parameters requested - // [0-65535] - dst.sz_seq_ran_param = rand() % 8; - - if(dst.sz_seq_ran_param > 0){ - dst.seq_ran_param = calloc(dst.sz_seq_ran_param, sizeof(seq_ran_param_t)); - assert(dst.seq_ran_param != NULL && "memory exhausted"); - } - - for(size_t i = 0; i < dst.sz_seq_ran_param; ++i){ - dst.seq_ran_param[i] = fill_rnd_seq_ran_param(); - } - - return dst; -} - -static -ran_param_req_t fill_rnd_ran_param_req(void) -{ - ran_param_req_t dst = {0}; - - // RAN Parameter ID - // Mandatory - // 9.3.8 - // 1 4294967295, - dst.ran_param_id = (rand() % 4294967295) + 1; - - // RAN Parameter Value Type - // Mandatory - // 9.3.11 - dst.ran_param = fill_rnd_ran_param_val_type(); - - return dst; -} - -static -seq_ins_ind_act_2_t fill_rnd_seq_ins_ind_act_2(void) -{ - seq_ins_ind_act_2_t dst = {0}; - - // Insert Indication ID - // Mandatory - // 9.3.16 - // 1.. 65535 - dst.ins_ind_id = (rand() % 65535) + 1; - - // List of RAN parameters requested - // [0-65535] - dst.sz_ran_param_req = rand() % 4; - - if(dst.sz_ran_param_req > 0){ - dst.ran_param_req = calloc(dst.sz_ran_param_req, sizeof(ran_param_req_t )); - assert(dst.ran_param_req != NULL && "Memory exhausted"); - } - - for(size_t i = 0; i < dst.sz_ran_param_req; ++i){ - dst.ran_param_req[i] = fill_rnd_ran_param_req(); - } - - return dst; -} - -static -seq_ins_style_2_t fill_rnd_seq_ins_style_2(void) -{ - - seq_ins_style_2_t dst = {0}; - - // Indicated Insert Style - // Mandatory - // 9.3.3 - // 6.2.2.2. - // INTEGER - dst.ind_ins_style = rand(); - - // Sequence of Insert Indication Actions - // [1-63] - dst.sz_seq_ins_ind_act_2 = (rand()%4) + 1; // (rand()%63) + 1; - - dst.seq_ins_ind_act = calloc(dst.sz_seq_ins_ind_act_2, sizeof(seq_ins_ind_act_2_t)); - assert(dst.seq_ins_ind_act != NULL && "Memory exhausted"); - - for(size_t i = 0; i < dst.sz_seq_ins_ind_act_2; ++i){ - dst.seq_ins_ind_act[i] = fill_rnd_seq_ins_ind_act_2(); - } - - return dst; -} - - -static -e2sm_rc_ind_msg_frmt_6_t fill_rnd_ind_msg_frmt_6(void) -{ - e2sm_rc_ind_msg_frmt_6_t dst = {0}; - - // Sequence of Insert Styles for Multiple Actions - // [1-63] - dst.sz_seq_ins_style_ind_msg = (rand()%8) + 1; - - dst.seq_ins_style = calloc(dst.sz_seq_ins_style_ind_msg, sizeof(seq_ins_style_2_t)); - assert(dst.seq_ins_style != NULL && "Memory exhausted"); - - for(size_t i = 0; i < dst.sz_seq_ins_style_ind_msg; ++i){ - dst.seq_ins_style[i] = fill_rnd_seq_ins_style_2(); - } - - return dst; -} - -e2sm_rc_ind_msg_t fill_rnd_rc_ind_msg(void) -{ - e2sm_rc_ind_msg_t dst = {0}; - - dst.format = rand()% END_E2SM_RC_IND_MSG; - - if(dst.format == FORMAT_1_E2SM_RC_IND_MSG){ - dst.frmt_1 = fill_rnd_ind_msg_frmt_1(); - } else if(dst.format == FORMAT_2_E2SM_RC_IND_MSG){ - dst.frmt_2 = fill_rnd_ind_msg_frmt_2(); - }else if(dst.format == FORMAT_3_E2SM_RC_IND_MSG){ - dst.frmt_3 = fill_rnd_ind_msg_frmt_3(); - }else if(dst.format == FORMAT_4_E2SM_RC_IND_MSG){ - dst.frmt_4 = fill_rnd_ind_msg_frmt_4(); - }else if(dst.format == FORMAT_5_E2SM_RC_IND_MSG){ - dst.frmt_5 = fill_rnd_ind_msg_frmt_5(); - }else if(dst.format == FORMAT_6_E2SM_RC_IND_MSG){ - dst.frmt_6 = fill_rnd_ind_msg_frmt_6(); - } else { - assert(0!=0 && "Unknown type"); - } - - return dst; -} - -///////////////////////////// -///////////////////////////// -////////// End of RC Message Indication ////////// -///////////////////////////// -///////////////////////////// - - - -///////////////////////////// -///////////////////////////// -////////// Start of RC Call Process ID ////////////////// -///////////////////////////// -///////////////////////////// - -e2sm_rc_cpid_t fill_rnd_rc_cpid(void) -{ - e2sm_rc_cpid_t dst = {0}; - - // RIC Call Process ID - // Mandatory - // 9.3.18 - // [ 1 - 4294967295] - dst.ric_cpid = (rand()% 4294967295) + 1; - - return dst; -} - -///////////////////////////// -///////////////////////////// -////////// End of RC Call Process ID -///////////////////////////// -///////////////////////////// - - - -///////////////////////////// -///////////////////////////// -////////// Start of RC Control Header -///////////////////////////// -///////////////////////////// - -static -e2sm_rc_ctrl_hdr_frmt_1_t fill_rnd_rc_ctrl_hdr_frmat_1(void) -{ - e2sm_rc_ctrl_hdr_frmt_1_t dst = {0}; - - // UE ID - // Mandatory - // 9.3.10 - dst.ue_id = fill_rnd_ue_id(); - - // RIC Style Type - // Mandatory - // 9.3.3 - // 6.2.2.2. - // INTEGER - dst.ric_style_type = rand(); - - // Control Action ID - // Mandatory - // 9.3.6 - // [1- 65535] - dst.ctrl_act_id = (rand() % 65535) + 1; - - // RIC Control decision - // Optional - dst.ric_ctrl_decision = NULL; - - return dst; -} - -static -e2sm_rc_ctrl_hdr_frmt_2_t fill_rnd_rc_ctrl_hdr_frmat_2(void) -{ - e2sm_rc_ctrl_hdr_frmt_2_t dst = {0}; - // UE ID - // Optional - // 9.3.10 - dst.ue_id = calloc(1, sizeof(ue_id_e2sm_t)); - assert(dst.ue_id != NULL && "Memory exhausted"); - - *dst.ue_id = fill_rnd_ue_id(); - - // RIC Control decision - // Optional - dst.ric_ctrl_dec = NULL; - - return dst; -} - -e2sm_rc_ctrl_hdr_t fill_rnd_rc_ctrl_hdr(void) -{ - e2sm_rc_ctrl_hdr_t dst = {0}; - - dst.format = rand() % END_E2SM_RC_CTRL_HDR; - - if(dst.format == FORMAT_1_E2SM_RC_CTRL_HDR){ - dst.frmt_1 = fill_rnd_rc_ctrl_hdr_frmat_1(); - } else if(dst.format == FORMAT_2_E2SM_RC_CTRL_HDR){ - dst.frmt_2 = fill_rnd_rc_ctrl_hdr_frmat_2(); - } else { - assert(0!=0 && "Not implemented"); - } - - return dst; -} - - -///////////////////////////// -///////////////////////////// -////////// End of RC Control Header -///////////////////////////// -///////////////////////////// - -///////////////////////////// -///////////////////////////// -////////// Start of RC Control Message -///////////////////////////// -///////////////////////////// - -static -e2sm_rc_ctrl_msg_frmt_1_t fill_rnd_ctrl_msg_frmt_1(void) -{ - e2sm_rc_ctrl_msg_frmt_1_t dst = {0}; - - // List of RAN parameters - // [0- 65535] - dst.sz_ran_param = rand() % 8; - - if(dst.sz_ran_param > 0){ - dst.ran_param = calloc(dst.sz_ran_param , sizeof(seq_ran_param_t)); - assert(dst.ran_param != NULL && "Memory exhausted"); - } - - for(size_t i = 0; i < dst.sz_ran_param; ++i){ - dst.ran_param[i] = fill_rnd_seq_ran_param(); - } - - return dst; -} - -static -seq_ctrl_act_t fill_rnd_seq_ctrl_act(void) -{ - seq_ctrl_act_t dst = {0}; - - //Control Action ID - //Mandatory - //9.3.6 - // [1 - 65535] - dst.ctrl_act_id = (rand() % 65535) + 1; - - // Control Action Parameters - // Optional - // 9.2.1.7.1 E2SM-RC Control Message Format 1 - dst.ctrl_msg_frmt_1 = calloc(1 , sizeof(e2sm_rc_ctrl_msg_frmt_1_t )); - assert(dst.ctrl_msg_frmt_1 != NULL && "Memory exhausted" ); - - *dst.ctrl_msg_frmt_1 = fill_rnd_ctrl_msg_frmt_1(); - - return dst; -} - -static -seq_ctrl_sma_t fill_rnd_seq_ctrl_sma(void) -{ - seq_ctrl_sma_t dst = {0}; - - // Indicated Control Style - // Mandatory - // 9.3.3 - // 6.2.2.2. - // INTEGER - dst.ctrl_style = rand(); - - // Sequence of Control Actions - // [1-63] - dst.sz_seq_ctrl_act = (rand() % 8) +1; - - dst.seq_ctrl_act = calloc(dst.sz_seq_ctrl_act, sizeof(seq_ctrl_act_t )); - assert(dst.seq_ctrl_act != NULL && "Memory exhausted" ); - - for(size_t i = 0; i < dst.sz_seq_ctrl_act; ++i){ - dst.seq_ctrl_act[i] = fill_rnd_seq_ctrl_act(); - } - - return dst; -} - - -static -e2sm_rc_ctrl_msg_frmt_2_t fill_rnd_ctrl_msg_frmt_2(void) -{ - e2sm_rc_ctrl_msg_frmt_2_t dst = {0}; - - // Sequence of Control Styles - // for Multiple Actions - // [1 - 63] - dst.sz_seq_ctrl_sma = (rand() % 8) + 1; - - dst.action = calloc(dst.sz_seq_ctrl_sma, sizeof(seq_ctrl_sma_t)); - assert(dst.action != NULL && "Memory exhausted"); - - for(size_t i = 0 ; i < dst.sz_seq_ctrl_sma; ++i){ - dst.action[i] = fill_rnd_seq_ctrl_sma(); - } - - return dst; -} - - -e2sm_rc_ctrl_msg_t fill_rnd_rc_ctrl_msg(void) -{ - e2sm_rc_ctrl_msg_t dst = {0}; - - dst.format = rand() % END_E2SM_RC_CTRL_MSG; - - if(dst.format == FORMAT_1_E2SM_RC_CTRL_MSG){ - dst.frmt_1 = fill_rnd_ctrl_msg_frmt_1(); - } else if (dst.format == FORMAT_2_E2SM_RC_CTRL_MSG){ - dst.frmt_2 = fill_rnd_ctrl_msg_frmt_2(); - } else { - assert(0 && "Unknown format"); - } - - return dst; -} - - -///////////////////////////// -///////////////////////////// -////////// End of RC Control Message -///////////////////////////// -///////////////////////////// - - - - -///////////////////////////// -///////////////////////////// -////////// Start of RC Control Outcome -///////////////////////////// -///////////////////////////// - -static -seq_ran_param_2_t fill_rnd_seq_ran_param_2(void) -{ - seq_ran_param_2_t dst = {0}; - - // RAN Parameter ID - // Mandatory - // 9.3.8 - // [1 - 4294967295] - dst.ran_param_id = (rand() % 4294967295) + 1; - - // RAN Parameter Value - // Mandatory - // 9.3.14 - dst.ran_param_value = fill_rnd_ran_param_val(); - - return dst; -} - -static -e2sm_rc_ctrl_out_frmt_1_t fill_rnd_ctrl_out_frmt_1(void) -{ - e2sm_rc_ctrl_out_frmt_1_t dst = {0}; - - // Sequence of RAN - // Parameters - // [0 - 255] - dst.sz_seq_ran_param_2 = rand() % 8; - - if(dst.sz_seq_ran_param_2 > 0 ){ - dst.ran_param = calloc(dst.sz_seq_ran_param_2, sizeof(seq_ran_param_2_t)); - assert(dst.ran_param != NULL && "Memry exhausted" ); - } - - for(size_t i = 0; i < dst.sz_seq_ran_param_2; ++i){ - dst.ran_param[i] = fill_rnd_seq_ran_param_2(); - } - - return dst; -} - -static -seq_ctrl_act_out_t fill_rnd_seq_ctrl_act_out(void) -{ - seq_ctrl_act_out_t dst = {0}; - - // Control Action ID - // Mandatory - // 9.3.6 - // [1- 65535] - dst.ctrl_act_id = (rand() % 65535)+1; - - //Sequence of RAN - //Parameters - // [1-255] - dst.sz_ran_param = (rand() % 8)+1; - - dst.ran_param = calloc(dst.sz_ran_param, sizeof(seq_ran_param_2_t)); - assert(dst.ran_param != NULL && "Memory exhausted" ); - - for(size_t i = 0; i < dst.sz_ran_param; ++i){ - dst.ran_param[i] = fill_rnd_seq_ran_param_2(); - } - - return dst; -} - - -static -seq_ctrl_sty_mul_out_t fill_rnd_seq_ctrl_sty_mul_out(void) -{ - seq_ctrl_sty_mul_out_t dst = {0}; - - // Indicated Control Style - // Mandatory - // 9.3.3 - // 6.2.2.2. - dst.ind_ctrl_style = rand(); - - //Sequence of Control - //Actions Outcom - // [1-63] - dst.sz_seq_ctrl_act_out = (rand()%8)+ 1; - - dst.seq_ctrl_act_out = calloc(dst.sz_seq_ctrl_act_out, sizeof(seq_ctrl_act_out_t)); - assert(dst.seq_ctrl_act_out != NULL && "Memory exhausted"); - - for(size_t i = 0; i < dst.sz_seq_ctrl_act_out; ++i){ - dst.seq_ctrl_act_out[i] = fill_rnd_seq_ctrl_act_out() ; - } - - return dst; -} - - -static -e2sm_rc_ctrl_out_frmt_2_t fill_rnd_ctrl_out_frmt_2(void) -{ - -// Sequence of Control Styles -// for Multiple Outcomes -// [1-63] - e2sm_rc_ctrl_out_frmt_2_t dst = {0}; - - dst.sz_seq_ctrl_sty_mul_out = (rand() % 8 ) +1; - - dst.seq_ctrl_sty_mul_out = calloc(dst.sz_seq_ctrl_sty_mul_out, sizeof(seq_ctrl_sty_mul_out_t)); - assert(dst.seq_ctrl_sty_mul_out != NULL && "Memory exhausted"); - - for(size_t i = 0; i < dst.sz_seq_ctrl_sty_mul_out; ++i){ - dst.seq_ctrl_sty_mul_out[i] = fill_rnd_seq_ctrl_sty_mul_out(); - } - - return dst; -} - -static -e2sm_rc_ctrl_out_frmt_3_t fill_rnd_ctrl_out_frmt_3() -{ - e2sm_rc_ctrl_out_frmt_3_t dst = {0}; - - // Sequence of RAN Parameters - // [0-255] - dst.sz_seq_ran_param = (rand() % 8) + 1; - dst.ran_param = calloc( dst.sz_seq_ran_param , sizeof(seq_ran_param_t)); - assert(dst.ran_param != NULL && "memory exhausted" ); - - for(size_t i = 0; i < dst.sz_seq_ran_param; ++i){ - dst.ran_param[i] = fill_rnd_seq_ran_param(); - } - - return dst; -} - - -e2sm_rc_ctrl_out_t fill_rnd_rc_ctrl_out(void) -{ - e2sm_rc_ctrl_out_t dst = {0}; - - dst.format = rand() % END_E2SM_RC_CTRL_OUT; - - if(dst.format == FORMAT_1_E2SM_RC_CTRL_OUT){ - dst.frmt_1 = fill_rnd_ctrl_out_frmt_1(); - } else if(dst.format == FORMAT_2_E2SM_RC_CTRL_OUT ){ - dst.frmt_2 = fill_rnd_ctrl_out_frmt_2(); - } else if(dst.format == FORMAT_3_E2SM_RC_CTRL_OUT ){ - dst.frmt_3 = fill_rnd_ctrl_out_frmt_3(); - } else { - assert(0!=0 && "Unknown format"); - } - - return dst; -} - -///////////////////////////// -///////////////////////////// -////////// End of RC Control Outcome -///////////////////////////// -///////////////////////////// - -///////////////////////////// -///////////////////////////// -////////// Start RAN Function Definition -///////////////////////////// -///////////////////////////// - -ran_function_name_t fill_rc_ran_func_name(void) -{ - ran_function_name_t dst = {0}; - - // RAN Function Short Name - // Mandatory - // PrintableString [1-150] - dst.name.buf = calloc(strlen(SM_RAN_CTRL_SHORT_NAME) + 1, sizeof(uint8_t)); - memcpy(dst.name.buf, SM_RAN_CTRL_SHORT_NAME, strlen(SM_RAN_CTRL_SHORT_NAME)); - dst.name.len = strlen(SM_RAN_CTRL_SHORT_NAME); - - // RAN Function Service Model OID - // Mandatory - // PrintableString [1-1000] - - //iso(1) identified-organization(3) - //dod(6) internet(1) private(4) - //enterprise(1) 53148 e2(1) - // version1 (1) e2sm(2) e2sm-RC- - // IEs (3) - dst.oid.buf = calloc(strlen(SM_RAN_CTRL_OID) + 1, sizeof(uint8_t)); - memcpy(dst.oid.buf, SM_RAN_CTRL_OID, strlen(SM_RAN_CTRL_OID)); - dst.oid.len = strlen(SM_RAN_CTRL_OID); - - // RAN Function Description - // Mandatory - // PrintableString [1- 150] - //RAN function RC “RAN Control” performs the following - //functionalities: - //- Exposure of RAN control and UE context related - //information. - //- Modification and initiation of RAN control related call - //processes and messages - //- Execution of policies that may result in change of - //RAN control behavior - - dst.description.buf = calloc(strlen(SM_RAN_CTRL_DESCRIPTION) + 1, sizeof(uint8_t)); - memcpy(dst.description.buf, SM_RAN_CTRL_DESCRIPTION, strlen(SM_RAN_CTRL_DESCRIPTION)); - dst.description.len = strlen(SM_RAN_CTRL_DESCRIPTION); - - // RAN Function Instance - // Optional - // INTEGER -// long* instance; /* OPTIONAL: it is suggested to be used when E2 Node declares -// multiple RAN Function ID supporting the same E2SM specification ask Mikel */ - - return dst; -} - -static -seq_ev_trg_style_t fill_rnd_seq_ev_trg_style(void) -{ - seq_ev_trg_style_t dst = {0}; - - // RIC Event Trigger Style Type - // Mandatory - // 9.3.3 - // 6.2.2.2. - // INTEGER - dst.style = rand(); - - // RIC Event Trigger Style Name - // Mandatory - // 9.3.4 - // 6.2.2.3 - //PrintableString(SIZE(1..150,...)) - const char name[] = "Beatiful"; - dst.name = cp_str_to_ba(name); - - // RIC Event Trigger Format Type - // Mandatory - // 9.3.5 - // 6.2.2.4. - // INTEGER - dst.format = rand(); - - return dst; -} - -static -seq_ran_param_3_t fill_rnd_seq_ran_param_3(void) -{ - seq_ran_param_3_t dst = {0}; - - // RAN Parameter ID - // Mandatory - // 9.3.8 - // [1- 4294967295] - dst.id = rand() % 4294967295 + 1; - - // RAN Parameter Name - // Mandatory - // 9.3.9 - // [1-150] - char name[] = "FooBar42"; - dst.name = cp_str_to_ba(name); - - // RAN Parameter Definition - // Optional - // 9.3.51 - dst.def = NULL; - - return dst; -} - -static -call_proc_break_t fill_rnd_call_proc_break(void) -{ - call_proc_break_t dst = {0}; - - // Call Process Breakpoint ID - // Mandatory - // 9.3.49 - // [1 - 65535] - dst.id = (rand()% 65535) + 1; - - // Call Process Breakpoint Name - // Mandatory - // 9.3.50 - // [1-150] - const char name[] = "Call Process Breakpoint Name"; - dst.name = cp_str_to_ba(name); - - // Sequence of Associated RAN Parameters - // [0-65535] - dst.sz_param = rand() % 4;// 65536; - if(dst.sz_param > 0){ - dst.param = calloc(dst.sz_param , sizeof(seq_ran_param_3_t)); - assert(dst.param != NULL && "Memory exhausted"); - } - for(size_t i = 0; i < dst.sz_param; ++i){ - dst.param[i] = fill_rnd_seq_ran_param_3(); - } - - return dst; -} - - - -static -seq_call_proc_type_t fill_rnd_seq_call_proc_type(void) -{ -seq_call_proc_type_t dst = {0}; - - // Call Process Type ID - // Mandatory - // 9.3.15 - // [1- 65535] - dst.id = (rand()% 65535) + 1; - assert(dst.id > 0); - - // Call Process Type Name - // Mandatory - // 9.3.19 - // [1-150] - const char name[] = "Call Process Type Name"; - dst.name = cp_str_to_ba(name); - - // Sequence of Call Process Breakpoints - // [1-65535] - dst.sz_call_proc_break = (rand()%4) + 1 ;// (rand()%65536) + 1; - if(dst.sz_call_proc_break > 0){ - dst.call_proc_break = calloc(dst.sz_call_proc_break, sizeof( call_proc_break_t ) ); - assert(dst.call_proc_break != NULL && "Memory exhausted"); - } - for(size_t i = 0; i < dst.sz_call_proc_break; ++i){ - dst. call_proc_break[i] = fill_rnd_call_proc_break(); - } - - return dst; -} - -ran_func_def_ev_trig_t fill_ran_func_def_ev_trig(void) -{ - ran_func_def_ev_trig_t dst = {0}; - - // Sequence of EVENT TRIGGER styles - // [1 - 63] - dst.sz_seq_ev_trg_style = (rand()% 4) + 1; // (rand()% 63) + 1; - - dst.seq_ev_trg_style = calloc(dst.sz_seq_ev_trg_style, sizeof(seq_ev_trg_style_t) ); - assert(dst.seq_ev_trg_style != NULL && "memory exhausted"); - - for(size_t i = 0; i < dst. sz_seq_ev_trg_style; ++i){ - dst.seq_ev_trg_style[i] = fill_rnd_seq_ev_trg_style(); - } - - // Sequence of RAN Parameters for L2 Variables - // [0 - 65535] - dst.sz_seq_ran_param_l2_var = rand() % 4; // % 65536; - if(dst.sz_seq_ran_param_l2_var > 0 ){ - dst.seq_ran_param_l2_var = calloc(dst.sz_seq_ran_param_l2_var, sizeof(seq_ran_param_3_t)); - assert(dst.seq_ran_param_l2_var != NULL && "Memory exhausted"); - } - for(size_t i = 0; i < dst.sz_seq_ran_param_l2_var; ++i){ - dst.seq_ran_param_l2_var[i] = fill_rnd_seq_ran_param_3(); - } - - //Sequence of Call Process Types - // [0-65535] - dst.sz_seq_call_proc_type = rand() % 4; // % 65535; - if(dst.sz_seq_call_proc_type > 0){ - dst.seq_call_proc_type = calloc(dst.sz_seq_call_proc_type, sizeof(seq_call_proc_type_t)); - assert(dst.seq_call_proc_type != NULL && "Memory exhausted" ); - } - for(size_t i = 0; i < dst.sz_seq_call_proc_type; ++i){ - dst.seq_call_proc_type[i] = fill_rnd_seq_call_proc_type(); - assert(dst.seq_call_proc_type[i].id > 0); - } - - // Sequence of RAN Parameters for Identifying UEs - // 0-65535 - dst.sz_seq_ran_param_id_ue = rand() % 4; // - if(dst.sz_seq_ran_param_id_ue > 0){ - dst.seq_ran_param_id_ue = calloc(dst.sz_seq_ran_param_id_ue, sizeof(seq_ran_param_3_t)); - assert(dst.seq_ran_param_id_ue != NULL && "Memory exhausted"); - } - for(size_t i = 0; i < dst.sz_seq_ran_param_id_ue; ++i){ - dst.seq_ran_param_id_ue[i] = fill_rnd_seq_ran_param_3(); - } - - // Sequence of RAN Parameters for Identifying Cells - // 0-65535 - dst.sz_seq_ran_param_id_cell = rand() % 4; - if(dst.sz_seq_ran_param_id_cell > 0){ - dst.seq_ran_param_id_cell = calloc(dst.sz_seq_ran_param_id_cell, sizeof(seq_ran_param_3_t) ); - assert(dst.seq_ran_param_id_cell != NULL && "Memory exhausted"); - } - for(size_t i = 0; i < dst. sz_seq_ran_param_id_cell; ++i){ - dst.seq_ran_param_id_cell[i] = fill_rnd_seq_ran_param_3(); - } - - return dst; -} - -static -seq_report_sty_t fill_rnd_seq_report_sty(void) -{ - seq_report_sty_t dst = {0}; - - // RIC Report Style Type - // Mandatory - // 9.3.3 - // 6.2.2.2. - // INTEGER - dst.report_type = rand(); - - // RIC Report Style Name - // Mandatory - // 9.3.4 - // 6.2.2.3. - // PrintableString(SIZE(1..150,...)) - const char name[] = "Claude Shannon"; - dst.name = cp_str_to_ba(name); - - // Supported RIC Event Trigger Style Type - // Mandatory - // 9.3.3 - // 6.2.2.2. - // INTEGER - dst.ev_trig_type = rand(); - - // RIC Report Action Format Type - // Mandatory - // 9.3.5 - // 6.2.2.4. - // INTEGER - dst.act_frmt_type = rand(); - - // RIC Indication Header Format Type - // Mandatory - // 9.3.5 - // 6.2.2.4. - // INTEGER - dst.ind_hdr_type = rand(); - - // RIC Indication Message Format Type - // Mandatory - // 9.3.5 - // 6.2.2.4. - // INTEGER - dst.ind_msg_type = rand(); - - // Sequence of RAN Parameters Supported - // [0 - 65535] - dst.sz_seq_ran_param = rand()%8; - - if(dst.sz_seq_ran_param > 0){ - dst.ran_param = calloc(dst.sz_seq_ran_param, sizeof(seq_ran_param_3_t)); - assert(dst.ran_param != NULL && "Memory exhausted"); - for(size_t i = 0; i < dst.sz_seq_ran_param; ++i){ - dst.ran_param[i] = fill_rnd_seq_ran_param_3(); - } - } - - return dst; -} - -ran_func_def_report_t fill_ran_func_def_report(void) -{ - ran_func_def_report_t dst = {0}; - - // Sequence of REPORT styles - // [1 - 63] - dst.sz_seq_report_sty = (rand()%4) + 1; - dst.seq_report_sty = calloc(dst.sz_seq_report_sty, sizeof(seq_report_sty_t)); - assert(dst.seq_report_sty != NULL && "Memory exhausted"); - - for(size_t i = 0; i < dst.sz_seq_report_sty; ++i){ - dst.seq_report_sty[i] = fill_rnd_seq_report_sty(); - } - - return dst; -} - -static -seq_ins_ind_t fill_rnd_seq_ins_ind(void) -{ - seq_ins_ind_t dst = {0}; - - // Insert Indication ID - // Mandatory - // 9.3.16 - // [1-65535] - dst.id = (rand()% 65535) + 1; - - // Insert Indication Name - // Mandatory - // 9.3.17 - // [1-150] - const char name[] = "Robert Gallager"; - dst.name = cp_str_to_ba(name); - - // Sequence of Insert Indications - // [0-65535] - dst.sz_seq_ins_ind = rand()%4 ; // 65536 - if(dst.sz_seq_ins_ind > 0){ - dst.seq_ins_ind = calloc(dst.sz_seq_ins_ind, sizeof(seq_ran_param_3_t) ); - assert(dst.seq_ins_ind != NULL && "Memory exhausted"); - for(size_t i = 0; i < dst.sz_seq_ins_ind; ++i){ - dst.seq_ins_ind[i] = fill_rnd_seq_ran_param_3(); - } - } - - return dst; -} - -static -seq_ins_sty_t fill_rnd_seq_ins_sty(void) -{ - seq_ins_sty_t dst = {0}; - - // RIC Insert Style Type - // Mandatory - // 9.3.3 - // 6.2.2.2. - // INTEGER - dst.style_type = rand(); - - // RIC Insert Style Name - // Mandatory - // 9.3.4 - // 6.2.2.3. - // [1-150] - const char name[] = "Bob Fanno"; - dst.name = cp_str_to_ba(name); - - // Supported RIC Event Trigger Style Type - // Mandatory - // 9.3.3 - // 6.2.2.2. - dst.ev_trig_style_type = rand(); - - // RIC Action Definition Format Type - // Mandatory - // 9.3.5 - // 6.2.2.4. - dst.act_def_frmt_type = rand(); - - // Sequence of Insert Indications - // [0-65535] - dst.sz_seq_ins_ind = rand() % 4; //65536 - if(dst.sz_seq_ins_ind > 0){ - dst.seq_ins_ind = calloc(dst.sz_seq_ins_ind, sizeof(seq_ins_ind_t)); - assert(dst.seq_ins_ind != NULL && "Memory exhausted"); - for(size_t i = 0; i < dst.sz_seq_ins_ind; ++i){ - dst.seq_ins_ind[i] = fill_rnd_seq_ins_ind(); - } - } - - // RIC Indication Header Format Type - // Mandatoyr - // 9.3.5 - // 6.2.2.4. - dst.ind_hdr_frmt_type= rand(); - - // RIC Indication Message Format Type - // Mandatory - // 9.3.5 - // 6.2.2.4. - dst.ind_msg_frmt_type = rand(); - - // RIC Call Process ID Format Type - // Mandatory - // 9.3.5 - // 6.2.2.4. - dst.call_proc_id_type = rand(); - - return dst; -} - -ran_func_def_insert_t fill_ran_func_def_insert(void) -{ - ran_func_def_insert_t dst = {0}; - - // Sequence of INSERT styles - // [1-63] - dst.sz_seq_ins_sty = (rand()% 4) + 1; // (rand()%63) + 1; - - dst.seq_ins_sty = calloc(dst.sz_seq_ins_sty, sizeof(seq_ins_sty_t)); - assert(dst.seq_ins_sty != NULL && "Memory exhausted"); - - for(size_t i = 0; i < dst.sz_seq_ins_sty; ++i){ - dst.seq_ins_sty[i] = fill_rnd_seq_ins_sty(); - } - - return dst; -} - -static -seq_ctrl_act_2_t fill_rnd_ctrl_act(void) -{ - seq_ctrl_act_2_t dst = {0}; - - // Control Action ID - // Mandatory - // 9.3.6 - // [1-65535] - dst.id = (rand()%65535) +1; - - // Control Action Name - // Mandatory - // 9.3.7 - // [1-150] - const char name[] = "test string"; - dst.name = cp_str_to_ba(name); - - // Sequence of Associated RAN Parameters - // [0-65535] - dst.sz_seq_assoc_ran_param = rand()%4; - if(dst.sz_seq_assoc_ran_param > 0){ - dst.assoc_ran_param = calloc(dst.sz_seq_assoc_ran_param, sizeof(seq_ran_param_3_t) ); - assert(dst.assoc_ran_param != NULL && "Memory exhausted"); - } - for(size_t i = 0; i < dst.sz_seq_assoc_ran_param; ++i){ - dst.assoc_ran_param[i] = fill_rnd_seq_ran_param_3(); - } - - return dst; -} - -static -seq_ctrl_style_t fill_rnd_seq_ctrl_style(void) -{ - seq_ctrl_style_t dst = {0}; - - // RIC Control Style Type - // Mandatory - // 9.3.3 - // 6.2.2.2. - dst.style_type = rand(); - - //RIC Control Style Name - //Mandatory - //9.3.4 - // [1 -150] - const char name[] = "Bjarne Stroustroup"; - dst.name = cp_str_to_ba(name); - - // Sequence of Control Actions - // [0-65535] - dst.sz_seq_ctrl_act = rand() % 4; - if(dst.sz_seq_ctrl_act > 0){ - dst.seq_ctrl_act = calloc(dst.sz_seq_ctrl_act, sizeof(seq_ctrl_act_2_t ) ); - assert(dst.seq_ctrl_act != NULL && "Memory exhausted"); - } - for(size_t i = 0; i < dst.sz_seq_ctrl_act; ++i){ - dst.seq_ctrl_act[i] = fill_rnd_ctrl_act( ); - } - - // RIC Control Header Format Type - // Mandatory - // 9.3.5 - dst.hdr = rand(); - - // RIC Control Message Format Type - // Mandatory - // 9.3.5 - dst.msg = rand(); - - // RIC Call Process ID Format Type - // Optional - - // RIC Control Outcome Format Type - // Mandatory - // 9.3.5 - dst.out_frmt = rand(); - - // Sequence of Associated RAN - // Parameters for Control Outcome - // [0- 255] - dst.sz_ran_param_ctrl_out = 1; // rand()%4; - if(dst.sz_ran_param_ctrl_out > 0){ - dst.ran_param_ctrl_out = calloc(dst.sz_ran_param_ctrl_out, sizeof(seq_ran_param_3_t) ); - assert(dst.ran_param_ctrl_out != NULL && "Memory exhausted"); - } - for(size_t i = 0; i < dst.sz_ran_param_ctrl_out; ++i){ - dst.ran_param_ctrl_out[i] = fill_rnd_seq_ran_param_3(); - } - - return dst; -} - -ran_func_def_ctrl_t fill_ran_func_def_ctrl(void) -{ - ran_func_def_ctrl_t dst = {0}; - - // Sequence of CONTROL styles - // [1 - 63] - dst.sz_seq_ctrl_style = (rand()%4) + 1; - dst.seq_ctrl_style = calloc(dst.sz_seq_ctrl_style, sizeof(seq_ctrl_style_t) ); - assert(dst.seq_ctrl_style != NULL && "Memory exhausted"); - for(size_t i = 0; i < dst.sz_seq_ctrl_style; ++i){ - dst.seq_ctrl_style[i] = fill_rnd_seq_ctrl_style(); - } - - return dst; -} - -static -seq_pol_action_t fill_rnd_seq_pol_action(void) -{ - seq_pol_action_t dst = {0}; - // Policy Action ID - // Mandatory - // 9.3.6 - dst.action_id = rand(); - - // Policy Action Name - // Mandatory - // 9.3.7 - // [1-150] - const char name[] = "Andrei Alexandrescu"; - dst.name = cp_str_to_ba(name); - - // RIC Action Definition Format Type - // Mandatoyr - // 9.3.5 - dst.frmt_type = rand(); - - // Sequence of Associated RAN Parameters for Policy Action - // [0- 65535] - dst.sz_seq_assoc_rp_action = rand()%4; - if(dst.sz_seq_assoc_rp_action > 0){ - dst.seq_assoc_rp_action = calloc(dst.sz_seq_assoc_rp_action, sizeof(seq_ran_param_3_t)); - assert(dst.seq_assoc_rp_action != NULL && "Memory exhausted"); - } - for(size_t i = 0; i < dst.sz_seq_assoc_rp_action; ++i){ - dst.seq_assoc_rp_action[i] = fill_rnd_seq_ran_param_3(); - } - - // Sequence of Associated RAN Parameters for Policy Condition - // [0- 65535] - dst.sz_seq_assoc_rp_policy = rand()%4; - if(dst.sz_seq_assoc_rp_policy > 0){ - dst.seq_assoc_rp_policy = calloc(dst.sz_seq_assoc_rp_policy, sizeof(seq_ran_param_3_t)); - assert(dst.seq_assoc_rp_policy != NULL && "Memory exhausted"); - } - for(size_t i = 0; i < dst.sz_seq_assoc_rp_policy; ++i){ - dst.seq_assoc_rp_policy[i] = fill_rnd_seq_ran_param_3(); - } - - return dst; -} - -static -seq_policy_sty_t fill_rnd_seq_policy_sty(void) -{ - seq_policy_sty_t dst = {0}; - // RIC Policy Style Type - // Mandatory - // 9.3.3 - dst.style_type = rand(); - - // RIC Policy Style Name - // Mandatory - // 9.3.4 - const char name[] = "Sean Parent"; - dst.name = cp_str_to_ba(name); - - // Supported RIC Event Trigger Style Type - // Mandatory - // 9.3.3 - dst.ev_trg_style_type = rand(); - - // Sequence of Policy Actions - // [0-65535] - dst.sz_seq_pol_action = rand() % 4; - if(dst.sz_seq_pol_action > 0){ - dst.seq_pol_action = calloc(dst.sz_seq_pol_action, sizeof(seq_pol_action_t)); - assert(dst.seq_pol_action != NULL && "Memory exhausted"); - } - for(size_t i = 0; i < dst.sz_seq_pol_action; ++i){ - dst.seq_pol_action[i] = fill_rnd_seq_pol_action(); - } - - return dst; -} - -ran_func_def_policy_t fill_ran_func_def_policy(void) -{ - ran_func_def_policy_t dst = {0}; - - // Sequence of POLICY styles - // [1-63] - dst.sz_policy_styles = (rand() % 4) + 1; - dst.seq_policy_sty = calloc(dst.sz_policy_styles, sizeof(seq_policy_sty_t ) ); - assert(dst.seq_policy_sty != NULL && "Memory exhasuted"); - - for(size_t i = 0; i < dst.sz_policy_styles; ++i){ - dst.seq_policy_sty[i] = fill_rnd_seq_policy_sty(); - } - - return dst; -} - -e2sm_rc_func_def_t fill_rnd_rc_ran_func_def(void) -{ - e2sm_rc_func_def_t dst = {0}; - - // RAN Function Name - // Mandatory - // 9.3.2 - // 6.2.2.1. - dst.name = fill_rc_ran_func_name(); - - // RAN Function Definition for EVENT TRIGGER - // Optional - // 9.2.2.2 - dst.ev_trig = calloc(1, sizeof(ran_func_def_ev_trig_t)); - assert(dst.ev_trig != NULL && "Memory exhausted"); - *dst.ev_trig = fill_ran_func_def_ev_trig(); - - // RAN Function Definition for REPORT - // Optional - // 9.2.2.3 - dst.report = calloc(1, sizeof( ran_func_def_report_t )); - assert(dst.report != NULL && "Memory exhausted"); - *dst.report = fill_ran_func_def_report(); - - // RAN Function Definition for INSERT - // Optional - // 9.2.2.4 - dst.insert = calloc(1, sizeof(ran_func_def_insert_t)); - assert(dst.insert != NULL && "Memory exhausted"); - *dst.insert = fill_ran_func_def_insert(); - - // RAN Function Definition for CONTROL - // Optional - // 9.2.2.5 - dst.ctrl = calloc(1, sizeof( ran_func_def_ctrl_t)); - assert(dst.ctrl != NULL && "Memory exhausted"); - *dst.ctrl = fill_ran_func_def_ctrl(); - - // RAN Function Definition for POLICY - // Optional - // 9.2.2.6 - dst.policy = calloc(1, sizeof(ran_func_def_policy_t)); - assert(dst.policy != NULL && "Memory exhausted"); - *dst.policy = fill_ran_func_def_policy(); - - return dst; -} - -///////////////////////////// -///////////////////////////// -////////// End of RAN Function Definition -///////////////////////////// -///////////////////////////// - -rc_ind_data_t fill_rnd_rc_ind_data(void) -{ - rc_ind_data_t dst = {0}; - - dst.hdr = fill_rnd_rc_ind_hdr(); - dst.msg = fill_rnd_rc_ind_msg(); - - return dst; -} - -rc_sub_data_t fill_rnd_rc_subscription(void) -{ - rc_sub_data_t dst = {0}; - - dst.et = fill_rnd_rc_event_trigger(); - - // Action Definition - dst.sz_ad = 1; - dst.ad = calloc( dst.sz_ad, sizeof(e2sm_rc_action_def_t)); - assert(dst.ad != NULL && "Memory exhausted"); - for(size_t i = 0; i < dst.sz_ad; i++){ - dst.ad[i] = fill_rnd_rc_action_def(); - } - - return dst; -} - -e2sm_rc_ctrl_out_t fill_rc_ctrl_out(void) -{ - e2sm_rc_ctrl_out_t dst = fill_rnd_rc_ctrl_out(); - - return dst; -} - -rc_ctrl_req_data_t fill_rc_ctrl(void) -{ - rc_ctrl_req_data_t dst = {0}; - dst.hdr = fill_rnd_rc_ctrl_hdr(); - dst.msg = fill_rnd_rc_ctrl_msg(); - return dst; -} - -e2sm_rc_func_def_t fill_rc_ran_func_def(void) -{ - return fill_rnd_rc_ran_func_def(); -} - - - - - - - +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698 + * + * 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. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#include "fill_rnd_data_rc.h" + +#include "../../src/sm/rc_sm/rc_sm_id.h" +#include "../../src/sm/rc_sm/ie/ir/ran_param_struct.h" +#include "../../src/sm/rc_sm/ie/ir/ran_param_list.h" + +#include +#include +#include + +/* +static +double rand_double() +{ + union { + double a; + uint8_t b[sizeof(double)]; + } tmp; + + for(size_t i = 0; i < sizeof(double); ++i){ + tmp.b[i] = rand(); + } + + return tmp.a; +} +*/ +static +float rand_float(float ceil) +{ + return (float)rand()/(float)((float)RAND_MAX/ceil); +} + + +///////////////////////////// +///////////////////////////// +//////////RC Event Trigger ////////// +///////////////////////////// +///////////////////////////// + + + + +static +network_interface_e2rc_t fill_rnd_network_interface(void) +{ + network_interface_e2rc_t dst = {0}; + + // NI Type + // Mandatory + // 9.3.32 + dst.ni_type = rand() % END_NETWORK_INTERFACE_TYPE; + + // NI Identifier + // Optional + // 9.3.33 + dst.ni_id = NULL; + + // NI Message + // Optional + // 9.3.34 + dst.ni_msg_id = NULL; + + return dst; +} + +static +rrc_msg_id_t fill_rnd_rrc_msg_id(void) +{ + rrc_msg_id_t dst = {0}; + + // Mandatory + dst.type = rand() % END_RRC_MESSAGE_ID; + if(dst.type == LTE_RRC_MESSAGE_ID){ + dst.lte = rand() % END_LTE_RRC_CLASS; + } else if(dst.type == NR_RRC_MESSAGE_ID){ + dst.nr = rand() % END_NR_RRC_CLASS; + } else { + assert(0 != 0 && "Unknown type"); + } + + // Mandatory + // Integer + // Number starts from 0 from the first + // entry of a given RRC message class + // defined in TS 36.331 [14] or TS + // 38.331 [15]. + dst.rrc_msg_id = rand(); + + return dst; +} + + +static +msg_ev_trg_t fill_rnd_msg_ev_trg(void) +{ + msg_ev_trg_t dst = {0}; + + // Event Trigger Condition ID + // Mandatory + // 9.3.21 + // [1- 65535] + dst.ev_trigger_cond_id = (rand()% 65535) + 1; + + // CHOICE Message Type + // Mandatory + dst.msg_type = rand() % END_MSG_MSG_TYPE_EV_TRG; + if(dst.msg_type == NETWORK_INTERFACE_MSG_TYPE_EV_TRG){ + dst.net = fill_rnd_network_interface(); + } else if(dst.msg_type == RRC_MSG_MSG_TYPE_EV_TRG){ + dst.rrc_msg = fill_rnd_rrc_msg_id(); + } else { + assert( 0 != 0 && "Unknown type"); + } + + //Message Direction + //Optional + dst.msg_dir = NULL; + + // Associated UE Info + // Optional + // 9.3.26 + dst.assoc_ue_info = NULL; + + // Logical OR + // Optional + // 9.3.25 + dst.log_or = NULL; + + return dst; +} + +static +e2sm_rc_ev_trg_frmt_1_t fill_rnd_rc_event_trigger_frmt_1(void) +{ + e2sm_rc_ev_trg_frmt_1_t dst = {0}; + + // [1 - 65535] + dst.sz_msg_ev_trg = (rand() % 64) + 1; // Limited for memory constraints 65535 + + dst.msg_ev_trg = calloc(dst.sz_msg_ev_trg, sizeof(msg_ev_trg_t)); + assert(dst.msg_ev_trg != NULL && "Memory exhausted"); + + for(size_t i = 0; i < dst.sz_msg_ev_trg; ++i){ + dst.msg_ev_trg[i] = fill_rnd_msg_ev_trg(); + } + + // Global Associated UE Info + // Optional + // 9.3.26 + dst.global_assoc_ue_info = NULL; + + return dst; +} + +static +e2sm_rc_ev_trg_frmt_2_t fill_rnd_rc_event_trigger_frmt_2(void) +{ + e2sm_rc_ev_trg_frmt_2_t dst = {0}; + + // Call Process Type ID + // Mandatory + // 9.3.15 + // INTEGER (1.. 65535, …) + dst.call_proc_type_id = (rand()% 65535) + 1; + + // Call Breakpoint ID + // Mandatory + // 9.3.49 + // INTEGER (1.. 65535, …) + dst.call_break_id = rand(); + + // Associated E2 Node Info + // Optional + // 9.3.29 + // ran_param_cond_crit_def_t* assoc_e2_node_info; + + // Associated UE Info + // Optional + // 9.3.26 + // ev_trigger_ue_info_t* assoc_ue_info; + + return dst; +} + +static +e2_node_info_chng_t fill_rnd_e2_node_info_chng(void) +{ + e2_node_info_chng_t dst = {0}; + + //Event Trigger Condition ID + //Mandatory + //9.3.21 + // INTEGER (1..65535, …) + dst.ev_trigger_cond_id = (rand()% 65535) + 1 ; + + // E2 Node Information Change ID + // Mandatory + // INTEGER (1..512, ...) + dst.e2_node_info_chng_id = (rand()% 512) + 1; + + // Associated Cell Info + // Optional + // 9.3.27 + // ev_trigger_cell_info_t* ev_trigger_cell_info; + + // Logical OR + // Optional + // 9.3.25 + // logical_or_e* log_or; + + return dst; +} + +e2sm_rc_ev_trg_frmt_3_t fill_rnd_rc_event_trigger_frmt_3(void) +{ + e2sm_rc_ev_trg_frmt_3_t dst = {0}; + + // Sequence of E2 Node + // Information Change + // [1 - 65535] + dst.sz_e2_node_info_chng = (rand() % 128) + 1; // For not exhasuting the memory + + + dst.e2_node_info_chng = calloc(dst.sz_e2_node_info_chng, sizeof(e2_node_info_chng_t)); + assert(dst.e2_node_info_chng != NULL && "Memory exhasuted"); + + for(size_t i = 0; i < dst.sz_e2_node_info_chng; ++i){ + dst.e2_node_info_chng[i] = fill_rnd_e2_node_info_chng(); + } + + return dst; +} + +static +rrc_state_t fill_rnd_state_chng_to(void) +{ + rrc_state_t dst = {0}; + + // 9.3.37 + dst.state_chngd_to = rand() % END_RRC_STATE_E2SM_RC; + + // 9.3.25 + // Logical OR + dst.log_or = NULL; + + return dst; +} + +static +rrc_state_lst_t fill_rnd_rrc_state_lst(void) +{ + rrc_state_lst_t dst = {0}; + + // 9.3.37 + // [1 - 8] + dst.sz_rrc_state = (rand()% 8) + 1; + + dst.state_chng_to = calloc(dst.sz_rrc_state , sizeof(rrc_state_t)); + assert(dst.state_chng_to != NULL && "Memory exhausted" ); + + for(size_t i = 0; i < dst.sz_rrc_state; ++i){ + dst.state_chng_to[i] = fill_rnd_state_chng_to(); + } + + return dst; +} + +static +ran_param_test_t fill_rnd_ran_param_test(void); + + +static +ran_param_test_lst_t fill_rnd_ran_param_test_lst(void) +{ + ran_param_test_lst_t dst = {0}; + +// [1- 65535] + dst.sz_lst = 1; //(rand() % 2) + 1; // This can grow the tree very quickly + dst.ran_param_test = calloc(dst.sz_lst, sizeof( ran_param_test_t)); + assert(dst.ran_param_test != NULL && "Memory exhausted"); + + for(size_t i = 0; i < dst.sz_lst; ++i){ + dst.ran_param_test[i] = fill_rnd_ran_param_test(); + } + + return dst; +} + +static +ran_param_test_strct_t fill_rnd_ran_param_test_struct(void) +{ + ran_param_test_strct_t dst = {0}; + + // [1-65535] + dst.sz_strct = 1; //(rand()%2) + 1; // This can grow vey quickly if not... + + dst.ran_param_test = calloc(dst.sz_strct, sizeof(ran_param_test_t)); + assert(dst.ran_param_test != NULL && "Memory exhausted" ); + + for(size_t i = 0; i < dst.sz_strct; ++i){ + dst.ran_param_test[i] = fill_rnd_ran_param_test(); + } + + return dst; +} + +static +ran_parameter_value_t fill_rnd_ran_param_val(void) +{ + ran_parameter_value_t dst = {0}; + + dst.type = rand() % END_RAN_PARAMETER_VALUE ; + + if(dst.type == BOOLEAN_RAN_PARAMETER_VALUE){ + dst.bool_ran = rand()%2; + } else if(dst.type == INTEGER_RAN_PARAMETER_VALUE) { + dst.int_ran = rand()%4098; + } else if(dst.type == REAL_RAN_PARAMETER_VALUE) { + dst.real_ran = rand_float(1024); + } else if(dst.type == BIT_STRING_RAN_PARAMETER_VALUE ) { + dst.bit_str_ran = cp_str_to_ba("Bit string copy "); + } else if(dst.type == OCTET_STRING_RAN_PARAMETER_VALUE){ + dst.octet_str_ran = cp_str_to_ba("Octet string copy"); + } else if(dst.type == PRINTABLESTRING_RAN_PARAMETER_VALUE){ + dst.printable_str_ran = cp_str_to_ba("Printable string"); + } else { + assert(0!=0 && "Unknown type"); + } + + return dst; +} + +static +ran_parameter_value_t fill_rnd_ran_param_elm_key_true(void) +{ + // 9.3.14 + return fill_rnd_ran_param_val(); +} + +static +ran_param_struct_t fill_rnd_ran_param_struct(void); + +static +lst_ran_param_t fill_rnd_lst_ran_param(void) +{ + lst_ran_param_t dst = {0}; + // Bug in the standard. RAN Parameter List 9.3.13 + // has a mandatory ie RAN Parameter ID 9.3.8 + // and a mandatory ie RAN Parameter Structure 9.3.12 + // However, the ASN + // RANParameter-LIST ::= SEQUENCE { + // list-of-ranParameter SEQUENCE (SIZE(1..maxnoofItemsinList)) OF RANParameter-STRUCTURE, + // .. + // } + // + // Misses RAN Parameter ID and only has RAN Parameter Structure + + // RAN Parameter ID + // Mandatory + // 9.3.8 + //1.. 4294967295 + // Let's ignore the english written standard and believe the ASN.1 is the correct + // uint32_t ran_param_id; + + // RAN Parameter Structure + // Mandatory + // 9.3.12 + //ran_param_struct_t ran_param_struct; + + + // RAN Parameter ID + // Mandatory + // 9.3.8 + //1.. 4294967295 + //dst.ran_param_id = (rand() % 4096) + 1; + + // RAN Parameter Structure + // Mandatory + // 9.3.12 + dst.ran_param_struct = fill_rnd_ran_param_struct(); + + return dst; +} + +static +ran_param_list_t fill_rnd_ran_param_lst(void) +{ + ran_param_list_t dst = {0}; + + // [0- 65535] + dst.sz_lst_ran_param = (rand() % 2) + 1; + dst.lst_ran_param = calloc(dst.sz_lst_ran_param, sizeof(lst_ran_param_t )); + assert(dst.lst_ran_param != NULL && "Memory exhausted"); + + for(size_t i = 0 ; i < dst.sz_lst_ran_param; ++i){ + dst.lst_ran_param[i] = fill_rnd_lst_ran_param(); + } + + return dst; +} + +static +seq_ran_param_t fill_rnd_seq_ran_param(void); + +static +ran_param_struct_t fill_rnd_ran_param_struct(void) +{ + ran_param_struct_t dst = {0}; + + // [1-65535] + dst.sz_ran_param_struct = (rand() % 2 ) +1 ; + + dst.ran_param_struct = calloc(dst.sz_ran_param_struct, sizeof(seq_ran_param_t)); + assert(dst.ran_param_struct != NULL && "Memory exhausted" ); + + for(size_t i = 0; i < dst.sz_ran_param_struct ; ++i){ + dst.ran_param_struct[i] = fill_rnd_seq_ran_param(); + } + + return dst; +} + +static +ran_param_test_cond_t fill_rnd_ran_param_test_cond(void) +{ + ran_param_test_cond_t dst = {0}; + + dst.cond = rand() % END_RAN_PARAM_TEST_COND; + + if(dst.cond == COMPARISON_RAN_PARAM_TEST_COND){ + dst.comp = rand() % END_RAN_PARAM_TEST_COND_COMP; + } else if(dst.cond == PRESENCE_RAN_PARAM_TEST_COND){ + dst.presence = rand() % END_RAN_PARAM_TEST_COND_PRESENCE; + } else { + assert(0!=0 && "Unknown type"); + } + + return dst; +} + +static +ran_param_elm_key_false_t fill_rnd_ran_param_elm_key_false() +{ + ran_param_elm_key_false_t dst = {0}; + + // RAN Parameter Test Condition + // 9.3.31 + // Mandatory + dst.test_cond = fill_rnd_ran_param_test_cond(); + + // RAN Parameter Value + // Optional + // 9.3.14 + dst.value = NULL; + + // Logical OR + // Optional + // 9.3.25 + dst.logical_or = NULL; + + return dst; +} + +static +ran_param_test_t fill_rnd_ran_param_test(void) +{ + ran_param_test_t dst = {0}; + + //RAN Parameter ID + //Mandatory + //Bug in the standard. 9.3.9 wrote in section 9. + //9.3.8 in ASN language. Probably 9.3.8 intended + //1.. 4294967295 + dst.ran_param_id = (rand() % 4294967295) + 1; + + dst.type = rand() % END_RAN_PARAMETER_TYPE; + + static int max_depth; + max_depth++; + if(max_depth == 4){ + max_depth = 0; + dst.type = ELEMENT_WITH_KEY_FLAG_TRUE_RAN_PARAMETER_TYPE; + } + + + if(dst.type == LIST_RAN_PARAMETER_TYPE){ + dst.lst = fill_rnd_ran_param_test_lst(); + } else if(dst.type == STRUCTURE_RAN_PARAMETER_TYPE ){ + dst.strct = fill_rnd_ran_param_test_struct() ; + } else if(dst.type == ELEMENT_WITH_KEY_FLAG_TRUE_RAN_PARAMETER_TYPE){ + dst.flag_true = fill_rnd_ran_param_elm_key_true(); + } else if(dst.type == ELEMENT_WITH_KEY_FLAG_FALSE_RAN_PARAMETER_TYPE ){ + dst.flag_false = fill_rnd_ran_param_elm_key_false(); + } + + return dst; +} + +static +ran_param_cond_crit_def_t fill_rnd_ran_param_cond_crit_def(void) +{ + ran_param_cond_crit_def_t dst = {0}; + + // [1 - 255 ] + dst.sz_ran_param_test = 1; //(rand()%16) + 1; + + // RAN Parameter Test + // 9.3.30 + dst.ran_param_test = calloc(dst.sz_ran_param_test, sizeof(ran_param_test_t)); + assert(dst.ran_param_test != NULL && "Memory exhausted"); + + for(size_t i = 0; i < dst.sz_ran_param_test; ++i){ + dst.ran_param_test[i] = fill_rnd_ran_param_test(); + } + + return dst; +} + +static +ue_info_chng_t fill_rnd_ue_info_chng() +{ + ue_info_chng_t dst = {0}; + + // Event Trigger Condition ID + // Mandatory + // 9.3.21 + // INTEGER (1..65535, …) + dst.ev_trig_cond_id = (rand()%65535) + 1; + + // CHOICE Trigger Type + + dst.type = rand()%END_UE_INFO_CHNG_TRIGGER_TYPE; + + if( dst.type == RRC_STATE_UE_INFO_CHNG_TRIGGER_TYPE){ + // RRC State + dst.rrc_state = fill_rnd_rrc_state_lst(); + + } else if(dst.type == UE_ID_CHANGE_UE_INFO_CHNG_TRIGGER_TYPE){ + // UE Identifier Change + // [1 - 512] + dst.ue_id_chng = (rand() % 512) + 1; + + } else if(dst.type == L2_STATE_UE_INFO_CHNG_TRIGGER_TYPE){ + // 9.3.29 + // RAN Parameter Conditional Criteria Definition + dst.l2_state = fill_rnd_ran_param_cond_crit_def(); + + } else { + assert(0!=0 && "Unknown type"); + } + + + // Associated UE Info + // Optional + // 9.3.26 + dst.assoc_ue_info = NULL; + + // Logical OR + // Optional + // 9.3.25 + dst.log_or = NULL; + + return dst; +} + + +static +e2sm_rc_ev_trg_frmt_4_t fill_rnd_rc_event_trigger_frmt_4(void) +{ + e2sm_rc_ev_trg_frmt_4_t dst = {0}; + + // Sequence of UE Information Change + // [ 1 - 65535] + dst.sz_ue_info_chng = 1; //(rand()% 128) + 1; + + dst.ue_info_chng = calloc(dst.sz_ue_info_chng, sizeof(ue_info_chng_t) ); + assert(dst.ue_info_chng != NULL && "Memory exhausted"); + + for(size_t i = 0; i < dst.sz_ue_info_chng; ++i){ + dst.ue_info_chng[i] = fill_rnd_ue_info_chng(); + } + + return dst; +} + + +static +e2sm_rc_ev_trg_frmt_5_t fill_rnd_rc_event_trigger_frmt_5() +{ + e2sm_rc_ev_trg_frmt_5_t dst = {0} ; + + // On Demand + // Mandatory + dst.on_demand = rand()% END_ON_DEMAND_FRMT_5 ; + + // Associated UE Info + // Optional + // 9.3.26 + // ev_trigger_ue_info_t* assoc_ue_info; + + // Associated Cell Info + // Optional + // 9.3.27 + // ev_trigger_cell_info_t* assoc_cell_info; + + return dst; +} + + +e2sm_rc_event_trigger_t fill_rnd_rc_event_trigger(void) +{ + e2sm_rc_event_trigger_t dst = {0}; + + dst.format = rand() % END_E2SM_RC_EV_TRIGGER_FORMAT; + + if(dst.format == FORMAT_1_E2SM_RC_EV_TRIGGER_FORMAT){ + dst.frmt_1 = fill_rnd_rc_event_trigger_frmt_1() ; + + }else if(dst.format == FORMAT_2_E2SM_RC_EV_TRIGGER_FORMAT){ + dst.frmt_2 = fill_rnd_rc_event_trigger_frmt_2() ; + + }else if(dst.format == FORMAT_3_E2SM_RC_EV_TRIGGER_FORMAT){ + dst.frmt_3 = fill_rnd_rc_event_trigger_frmt_3() ; + + }else if(dst.format == FORMAT_4_E2SM_RC_EV_TRIGGER_FORMAT){ + dst.frmt_4 = fill_rnd_rc_event_trigger_frmt_4() ; + + }else if(dst.format == FORMAT_5_E2SM_RC_EV_TRIGGER_FORMAT){ + dst.frmt_5 = fill_rnd_rc_event_trigger_frmt_5() ; + + } else { + assert(0!=0 && "Unknown format"); + } + + return dst; +} + +///////////////////////////// +///////////////////////////// +////////// End of RC Event Trigger ////////// +///////////////////////////// +///////////////////////////// + + + +///////////////////////////// +///////////////////////////// +////////// Start of RC Action Definition ////////////////// +///////////////////////////// +///////////////////////////// + +static +param_report_def_t fill_rnd_param_report_def(void) +{ + param_report_def_t dst = {0}; + + // RAN Parameter ID + // Mandatory + // 9.3.8 + // [1 - 4294967295] + dst.ran_param_id = (rand() % 4294967295) + 1; + + // RAN Parameter Definition + // Optional + // 9.3.51 + dst.ran_param_def = calloc(1, sizeof(ran_param_def_t)); + assert(dst.ran_param_def != NULL && "Memory exhausyted"); + + dst.ran_param_def->type = rand()%END_RAN_PARAMETER_DEF_TYPE; + + switch (dst.ran_param_def->type) + { + case LIST_RAN_PARAMETER_DEF_TYPE: + dst.ran_param_def->lst = calloc(1, sizeof(ran_param_type_t)); + assert(dst.ran_param_def->lst != NULL && "Memory exhausyted"); + + dst.ran_param_def->lst->sz_ran_param = 10; // (rand()% 65535) + 1; + dst.ran_param_def->lst->ran_param = calloc(dst.ran_param_def->lst->sz_ran_param, sizeof(ran_param_lst_struct_t)); + assert(dst.ran_param_def->lst->ran_param != NULL && "Memory exhausyted"); + + for (size_t i = 0; i < dst.ran_param_def->lst->sz_ran_param; i++) + { + // RAN Parameter ID + // Mandatory + // 9.3.8 + dst.ran_param_def->lst->ran_param[i].ran_param_id = rand() + 1; + + // RAN Parameter Name + // Mandatory + // 9.3.9 + const char name[] = "RAN Parameter Name"; + dst.ran_param_def->lst->ran_param[i].ran_param_name = cp_str_to_ba(name); + + // RAN Parameter Definition + // Optional + // 9.3.51 + dst.ran_param_def->lst->ran_param[i].ran_param_def = NULL; + } + + break; + + case STRUCTURE_RAN_PARAMETER_DEF_TYPE: + dst.ran_param_def->strct = calloc(1, sizeof(ran_param_type_t)); + assert(dst.ran_param_def->strct != NULL && "Memory exhausyted"); + + dst.ran_param_def->strct->sz_ran_param = 10; // (rand()% 65535) + 1; + dst.ran_param_def->strct->ran_param = calloc(dst.ran_param_def->strct->sz_ran_param, sizeof(ran_param_lst_struct_t)); + assert(dst.ran_param_def->strct->ran_param != NULL && "Memory exhausyted"); + + for (size_t i = 0; i < dst.ran_param_def->strct->sz_ran_param; i++) + { + // RAN Parameter ID + // Mandatory + // 9.3.8 + dst.ran_param_def->strct->ran_param[i].ran_param_id = (rand() % 4294967295) + 1; + + // RAN Parameter Name + // Mandatory + // 9.3.9 + const char name[] = "RAN Parameter Name"; + dst.ran_param_def->strct->ran_param[i].ran_param_name = cp_str_to_ba(name); + + // RAN Parameter Definition + // Optional + // 9.3.51 + dst.ran_param_def->strct->ran_param[i].ran_param_def = NULL; + } + + break; + + default: + assert(false && "Unknown RAN Parameter Type"); + } + + return dst; +} + + +static +e2sm_rc_act_def_frmt_1_t fill_rnd_rc_action_def_frmt_1(void) +{ + e2sm_rc_act_def_frmt_1_t dst = {0}; + + // Parameters to be Reported List + // [1-65535] + dst.sz_param_report_def = (rand()%4) + 1; // (rand()% 65535) + 1; + + dst.param_report_def = calloc(dst.sz_param_report_def, sizeof( param_report_def_t)); + assert(dst.param_report_def != NULL && "Memory exhausyted"); + + for(size_t i = 0; i < dst.sz_param_report_def; ++i){ + dst.param_report_def[i] = fill_rnd_param_report_def() ; + } + + return dst; +} + +static _Atomic +int recursion_fill_rnd_ran_param_val_type = 0; + +static +ran_param_val_type_t fill_rnd_ran_param_val_type() +{ + ran_param_val_type_t dst = {0}; + + dst.type = rand() % END_RAN_PARAMETER_VAL_TYPE; // STRUCTURE_RAN_PARAMETER_VAL_TYPE; // + + recursion_fill_rnd_ran_param_val_type += 1; + if(recursion_fill_rnd_ran_param_val_type > 4){ +// recursion_fill_rnd_ran_param_val_type = 0; + dst.type = ELEMENT_KEY_FLAG_TRUE_RAN_PARAMETER_VAL_TYPE; + } + + if(dst.type == ELEMENT_KEY_FLAG_TRUE_RAN_PARAMETER_VAL_TYPE){ + dst.flag_true = calloc(1, sizeof( ran_parameter_value_t)); + assert(dst.flag_true != NULL && "Memory exhausted" ); + *dst.flag_true = fill_rnd_ran_param_val(); + } else if(dst.type == ELEMENT_KEY_FLAG_FALSE_RAN_PARAMETER_VAL_TYPE ){ + dst.flag_false = calloc(1, sizeof( ran_parameter_value_t)); + assert(dst.flag_false != NULL && "Memory exhausted" ); + *dst.flag_false = fill_rnd_ran_param_val(); + }else if(dst.type == STRUCTURE_RAN_PARAMETER_VAL_TYPE){ + dst.strct = calloc(1, sizeof(ran_param_struct_t)); + assert(dst.strct != NULL && "Memory exhausted" ); + *dst.strct = fill_rnd_ran_param_struct(); + }else if(dst.type == LIST_RAN_PARAMETER_VAL_TYPE ){ + dst.lst = calloc(1, sizeof(ran_param_list_t)); + assert(dst.lst != NULL && "memory exhausted"); + *dst.lst = fill_rnd_ran_param_lst(); + } else { + assert(0!=0 && "not implemented" ); + } + + return dst; +} + +static +seq_ran_param_t fill_rnd_seq_ran_param(void) +{ + seq_ran_param_t dst = {0}; + + //RAN Parameter ID + //Mandatory + //9.3.8 + // [1 - 4294967295] + dst.ran_param_id = (rand()% 4096) +1 ; + + // RAN Parameter Value Type + // 9.3.11 + // Mandatory + dst.ran_param_val = fill_rnd_ran_param_val_type(); + + return dst; +} + +static +policy_action_t fill_rnd_policy_action(void) +{ + policy_action_t dst = {0}; + + // Policy Action ID + // Mandatory + // 9.3.6 + // [1 - 65535] + dst.policy_act_id = (rand()% 65535) +1; + + // Sequence of RAN Parameters + // [0- 65535] + dst.sz_seq_ran_param = rand()% 2; //65535; + + if(dst.sz_seq_ran_param > 0){ + dst.seq_ran_param = calloc(dst.sz_seq_ran_param, sizeof(seq_ran_param_t)); + assert(dst.seq_ran_param != NULL && "Memory exhausted" ); + } + + for(size_t i = 0 ; i < dst.sz_seq_ran_param; ++i){ + dst.seq_ran_param[i] = fill_rnd_seq_ran_param(); + } + + // RIC Policy decision + // Optional + dst.pol_dec = NULL; + + return dst; +} + +static +policy_cond_t fill_rnd_policy_cond(void) +{ + policy_cond_t dst = {0}; + + // Policy Action Definition + // Mandatory + // 9.3.20 + dst.pol_act = fill_rnd_policy_action(); + + // Policy Condition Definition + // Optional + // 9.3.29 + dst.pol = NULL; + + return dst; +} + +static +e2sm_rc_act_def_frmt_2_t fill_rnd_rc_action_def_frmt_2(void) +{ + e2sm_rc_act_def_frmt_2_t dst = {0}; + + // Sequence of Policy Conditions + // [1 - 65535] + dst.sz_policy_cond = (rand() % 2) + 1; // Too large 65535 + + dst.policy_cond = calloc(dst.sz_policy_cond, sizeof(policy_cond_t) ); + assert(dst.policy_cond != NULL && "memory exhausted" ); + + for(size_t i = 0; i < dst.sz_policy_cond; ++i){ + dst.policy_cond[i] = fill_rnd_policy_cond(); + } + + return dst; +} + +static +ran_param_ins_t fill_rnd_ran_param_ins(void) +{ + ran_param_ins_t dst = {0}; + + // RAN Parameter ID + // Mandatory + // 9.3.8 + // [1 - 4294967295] + dst.ran_id = (rand()% 4294967295) + 1; + + // RAN Parameter Definition + // Optional + // 9.3.51 + dst.def = NULL; + + return dst; +} + +static +e2sm_rc_act_def_frmt_3_t fill_rnd_rc_action_def_frmt_3(void) +{ + e2sm_rc_act_def_frmt_3_t dst = {0}; + + // Insert Indication ID + // Mandatory + // 9.3.16 + // [1 - 65535] + dst.id = rand()% 65535 + 1; + + // List of RAN parameters for Insert + // Indication + // [1 - 65535] + dst.sz_ran_param_ins = (rand() % 64) + 1; + dst.ran_param = calloc(dst.sz_ran_param_ins, sizeof(ran_param_ins_t) ); + assert(dst.ran_param != NULL && "Memory exhausted"); + + for(size_t i = 0; i < dst.sz_ran_param_ins; ++i){ + dst.ran_param[i] = fill_rnd_ran_param_ins(); + } + + // UE ID + // Optional + // 9.3.10 + dst.ue_id = NULL; + + return dst; +} + +static +ran_param_ins_ind_t fill_rnd_ran_param_ins_ind(void) +{ + ran_param_ins_ind_t dst = {0}; + // RAN Parameter ID + // Mandatory + // 9.3.8 + // [1.. 429496729 ] + dst.ran_param_id = (rand() % 4294967295) + 1; + + // RAN Parameter Definition + // Optional + // 9.3.51 + dst.ran_param_def = NULL; + + return dst; +} + +static +seq_ins_ind_act_def_t fill_rnd_seq_ins_ind_act_def(void) +{ + seq_ins_ind_act_def_t dst = {0}; + + // Insert Indication ID + // Mandatory + // 9.3.16 + // [1 - 65535] + dst.ind_id = (rand()% 65535 ) +1; + + // List of RAN parameters for + // Insert Indication + // [1-65535] + dst.sz_ran_param_ins_ind = (rand() % 16) + 1; + + dst.ran_param_ins_ind = calloc(dst.sz_ran_param_ins_ind, sizeof(ran_param_ins_ind_t)); + assert(dst.ran_param_ins_ind != NULL && "Memory exhausted"); + + for(size_t i = 0; i < dst.sz_ran_param_ins_ind; ++i){ + dst.ran_param_ins_ind[i] = fill_rnd_ran_param_ins_ind(); + } + + return dst; +} + + +static +seq_ins_style_t fill_rnd_seq_ins_style(void) +{ + seq_ins_style_t dst = {0}; + + // Requested Insert Style + // Mandatory + // 9.3.3 + // 6.2.2.2. in E2 SM common + // Integer + dst.req_insert_style = rand() % 1024; + + // Sequence of Insert Indication + // Action Definition + // [1-63] + dst.sz_seq_ins_ind_act_def = (rand()%4) + 1; // (rand()% 63) + 1; + + dst.seq_ins_ind_act_def = calloc(dst.sz_seq_ins_ind_act_def, sizeof( seq_ins_ind_act_def_t)); + assert(dst.seq_ins_ind_act_def != NULL && "Memory exhausted"); + + for(size_t i = 0; i < dst.sz_seq_ins_ind_act_def; ++i){ + dst.seq_ins_ind_act_def[i] = fill_rnd_seq_ins_ind_act_def(); + } + + return dst; +} + +static +e2sm_rc_act_def_frmt_4_t fill_rnd_rc_action_def_frmt_4(void) +{ + e2sm_rc_act_def_frmt_4_t dst = {0}; + + // Sequence of Insert Styles for + // Multiple Actions + // [1-4] + dst.sz_seq_ins_style = (rand() % 4) + 1; + + dst.seq_ins_style = calloc(dst.sz_seq_ins_style, sizeof(seq_ins_style_t) ); + assert(dst.seq_ins_style != NULL && "Memory exhausted" ); + + for(size_t i = 0; i < dst.sz_seq_ins_style; ++i){ + dst.seq_ins_style[i] = fill_rnd_seq_ins_style(); + } + + + // UE ID + // Optional + // 9.3.10 + dst.ue_id = NULL; + + return dst; +} + + +e2sm_rc_action_def_t fill_rnd_rc_action_def(void) +{ + e2sm_rc_action_def_t dst = {0}; + + // RIC Style Type + // Mandatory + // 9.3.3 + // Defined in common 6.2.2.2. + dst.ric_style_type = (rand()%1024) + 1; + + dst.format = rand() % END_E2SM_RC_ACT_DEF; + + if(dst.format == FORMAT_1_E2SM_RC_ACT_DEF ){ + dst.frmt_1 = fill_rnd_rc_action_def_frmt_1(); + + } else if(dst.format == FORMAT_2_E2SM_RC_ACT_DEF){ + dst.frmt_2 = fill_rnd_rc_action_def_frmt_2(); + + } else if(dst.format == FORMAT_3_E2SM_RC_ACT_DEF){ + dst.frmt_3 = fill_rnd_rc_action_def_frmt_3(); + + } else if(dst.format == FORMAT_4_E2SM_RC_ACT_DEF){ + dst.frmt_4 = fill_rnd_rc_action_def_frmt_4(); + + } else { + assert(0 != 0 && "Unknown format"); + } + + return dst; +} + +e2sm_rc_ind_hdr_frmt_1_t fill_rnd_rc_ind_hdr_frmt_1(void) +{ + e2sm_rc_ind_hdr_frmt_1_t dst = {0}; + + dst.ev_trigger_id = malloc(sizeof(uint16_t)); + assert(dst.ev_trigger_id != NULL && "Memory exhausted" ); + + // Event Trigger Condition ID + // Optional + // 9.3.21 + // [1 - 65535] + *dst.ev_trigger_id = (rand() % 65535) + 1; + + return dst; +} + +static +gnb_e2sm_t fill_rnd_gnb_data(void) +{ + gnb_e2sm_t gnb = {0}; + + // 6.2.3.16 + // Mandatory + // AMF UE NGAP ID + gnb.amf_ue_ngap_id = (rand() % 2^40) + 0; + + // Mandatory + //GUAMI 6.2.3.17 + gnb.guami.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; + + gnb.guami.amf_region_id = (rand() % 2^8) + 0; + gnb.guami.amf_set_id = (rand() % 2^10) + 0; + gnb.guami.amf_ptr = (rand() % 2^6) + 0; + + // gNB-CU UE F1AP ID List + // C-ifCUDUseparated + gnb.gnb_cu_ue_f1ap_lst_len = (rand() % 4) + 1; + gnb.gnb_cu_ue_f1ap_lst = calloc(gnb.gnb_cu_ue_f1ap_lst_len, sizeof(uint32_t)); + for (size_t i = 0; i < gnb.gnb_cu_ue_f1ap_lst_len; i++) + { + gnb.gnb_cu_ue_f1ap_lst[i] = (rand() % 4294967296) + 0; + } + + //gNB-CU-CP UE E1AP ID List + //C-ifCPUPseparated + gnb.gnb_cu_cp_ue_e1ap_lst_len = 3; //(rand() % 65535) + 1; + gnb.gnb_cu_cp_ue_e1ap_lst = calloc(gnb.gnb_cu_cp_ue_e1ap_lst_len, sizeof(uint32_t)); + for (size_t i = 0; i < gnb.gnb_cu_cp_ue_e1ap_lst_len; i++) + { + gnb.gnb_cu_cp_ue_e1ap_lst[i] = (rand() % 4294967296) + 0; + } + + // RAN UE ID + // Optional + // 6.2.3.25 + gnb.ran_ue_id = calloc(1, sizeof(uint64_t)); + assert(gnb.ran_ue_id != NULL && "Memory exhausted"); + *gnb.ran_ue_id = 14294967296; // (rand() % 2^64) + 0; + + // M-NG-RAN node UE XnAP ID + // C- ifDCSetup + // 6.2.3.19 + gnb.ng_ran_node_ue_xnap_id = calloc(1, sizeof(uint32_t)); + assert(gnb.ng_ran_node_ue_xnap_id != NULL && "Memory exhausted"); + *gnb.ng_ran_node_ue_xnap_id = (rand() % 4294967296) + 0; + + // Global gNB ID + // 6.2.3.3 + // Optional + // This IE shall not be used. Global NG-RAN Node ID IE shall replace this IE + //gnb.global_gnb_id = calloc(1, sizeof(global_gnb_id_t)); + //assert(gnb.global_gnb_id != NULL && "Memory exhausted"); + //gnb.global_gnb_id->type = GNB_TYPE_ID; + //gnb.global_gnb_id->plmn_id = (plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; + //gnb.global_gnb_id->gnb_id = (rand() % 4294967296) + 0; + + // Global NG-RAN Node ID + // C-ifDCSetup + // 6.2.3.2 + gnb.global_ng_ran_node_id = calloc(1, sizeof(*gnb.global_ng_ran_node_id)); + gnb.global_ng_ran_node_id->type = rand()%END_GLOBAL_TYPE_ID; + + switch (gnb.global_ng_ran_node_id->type) + { + case GNB_GLOBAL_TYPE_ID: + gnb.global_ng_ran_node_id->global_gnb_id.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; +// gnb.global_ng_ran_node_id->global_gnb_id.type = GNB_TYPE_ID; + gnb.global_ng_ran_node_id->global_gnb_id.gnb_id.nb_id = (rand() % 4294967296) + 0; + gnb.global_ng_ran_node_id->global_gnb_id.gnb_id.unused = rand() % 11; + gnb.global_ng_ran_node_id->global_gnb_id.gnb_id.nb_id &= (0xFFFFFFFF & (32 - gnb.global_ng_ran_node_id->global_gnb_id.gnb_id.unused)); + break; + + case NG_ENB_GLOBAL_TYPE_ID: + gnb.global_ng_ran_node_id->global_ng_enb_id.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; + gnb.global_ng_ran_node_id->global_ng_enb_id.type = LONG_MACRO_NG_ENB_TYPE_ID; // rand()%END_NG_ENB_TYPE_ID; + + switch (gnb.global_ng_ran_node_id->global_ng_enb_id.type) + { + case MACRO_NG_ENB_TYPE_ID: + gnb.global_ng_ran_node_id->global_ng_enb_id.macro_ng_enb_id = (rand() % 2^20) + 0; + break; + + case SHORT_MACRO_NG_ENB_TYPE_ID: + gnb.global_ng_ran_node_id->global_ng_enb_id.short_macro_ng_enb_id = (rand() % 2^18) + 0; + break; + + case LONG_MACRO_NG_ENB_TYPE_ID: + gnb.global_ng_ran_node_id->global_ng_enb_id.long_macro_ng_enb_id = (rand() % 2^21) + 0; + break; + + default: + assert(false && "Unknown Global NG eNB ID Type"); + } + break; + + default: + assert(false && "Unknown Global NG-RAN Node ID Type"); + } + + return gnb; +} + +static +gnb_du_e2sm_t fill_rnd_gnb_du_data(void) +{ + gnb_du_e2sm_t gnb_du = {0}; + gnb_du.gnb_cu_ue_f1ap = (rand() % 4294967296) + 0; + + gnb_du.ran_ue_id = calloc(1, sizeof(*gnb_du.ran_ue_id)); + *gnb_du.ran_ue_id = (rand() % 2^64) + 0; + + return gnb_du; +} + +static +gnb_cu_up_e2sm_t fill_rnd_gnb_cu_up_data(void) +{ + gnb_cu_up_e2sm_t gnb_cu_up = {0}; + gnb_cu_up.gnb_cu_cp_ue_e1ap = (rand() % 4294967296) + 0; + + gnb_cu_up.ran_ue_id = calloc(1, sizeof(*gnb_cu_up.ran_ue_id)); + *gnb_cu_up.ran_ue_id = (rand() % 2^64) + 0; + + return gnb_cu_up; +} + +ng_enb_e2sm_t fill_rnd_ng_enb_data(void) +{ + ng_enb_e2sm_t ng_enb = {0}; + + // 6.2.3.16 + // Mandatory + // AMF UE NGAP ID + ng_enb.amf_ue_ngap_id = (rand() % 2^40) + 0; + + // 6.2.3.17 + // Mandatory + // GUAMI + ng_enb.guami.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; + + ng_enb.guami.amf_region_id = (rand() % 2^8) + 0; + ng_enb.guami.amf_set_id = (rand() % 2^10) + 0; + ng_enb.guami.amf_ptr = (rand() % 2^6) + 0; + + // 6.2.3.22 + // C-if CU DU separated + // ng-eNB-CU UE W1AP ID + ng_enb.ng_enb_cu_ue_w1ap_id = calloc(1, sizeof(uint32_t)); + assert(ng_enb.ng_enb_cu_ue_w1ap_id != NULL && "Memory exhausted"); + *ng_enb.ng_enb_cu_ue_w1ap_id = (rand() % 4294967296) + 0; + + // 6.2.3.19 + // C- ifDCSetup + // M-NG-RAN node UE XnAP ID + ng_enb.ng_ran_node_ue_xnap_id = calloc(1, sizeof(uint32_t)); + assert(ng_enb.ng_ran_node_ue_xnap_id != NULL && "Memory exhausted"); + *ng_enb.ng_ran_node_ue_xnap_id = (rand() % 4294967296) + 0; + + // OPTIONAL + // This IE shall not be used. Global NG-RAN Node ID IE shall replace this IE + ng_enb.global_ng_enb_id = calloc(1, sizeof(*ng_enb.global_ng_enb_id)); + assert(ng_enb.global_ng_enb_id != NULL && "Memory exhausted"); + ng_enb.global_ng_enb_id->plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; + + ng_enb.global_ng_enb_id->type = rand()%END_NG_ENB_TYPE_ID; + + switch (ng_enb.global_ng_enb_id->type) + { + case MACRO_NG_ENB_TYPE_ID: + ng_enb.global_ng_enb_id->macro_ng_enb_id = (rand() % 2^20) + 0; + break; + + case SHORT_MACRO_NG_ENB_TYPE_ID: + ng_enb.global_ng_enb_id->short_macro_ng_enb_id = (rand() % 2^18) + 0; + break; + + case LONG_MACRO_NG_ENB_TYPE_ID: + ng_enb.global_ng_enb_id->long_macro_ng_enb_id = (rand() % 2^21) + 0; + break; + + default: + assert(false && "Unknown Global NG eNB ID Type"); + } + + + // Global NG-RAN Node ID + // C-ifDCSetup + // 6.2.3.2 + ng_enb.global_ng_ran_node_id = calloc(1, sizeof(*ng_enb.global_ng_ran_node_id)); + assert(ng_enb.global_ng_ran_node_id != NULL && "Memory exhausted"); + ng_enb.global_ng_ran_node_id->type = rand()%END_GLOBAL_TYPE_ID; + + switch (ng_enb.global_ng_ran_node_id->type) + { + case GNB_GLOBAL_TYPE_ID: + ng_enb.global_ng_ran_node_id->global_gnb_id.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; + //ng_enb.global_ng_ran_node_id->global_gnb_id.type = GNB_TYPE_ID; + ng_enb.global_ng_ran_node_id->global_gnb_id.gnb_id.nb_id = (rand() % 4294967296) + 0; + ng_enb.global_ng_ran_node_id->global_gnb_id.gnb_id.unused = (rand() % 11); + ng_enb.global_ng_ran_node_id->global_gnb_id.gnb_id.nb_id &= (0xFFFFFFFF >> ( 32 - ng_enb.global_ng_ran_node_id->global_gnb_id.gnb_id.unused)); + + break; + + case NG_ENB_GLOBAL_TYPE_ID: + ng_enb.global_ng_ran_node_id->global_ng_enb_id.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; + ng_enb.global_ng_ran_node_id->global_ng_enb_id.type = LONG_MACRO_NG_ENB_TYPE_ID; // rand()%END_NG_ENB_TYPE_ID; + + switch (ng_enb.global_ng_ran_node_id->global_ng_enb_id.type) + { + case MACRO_NG_ENB_TYPE_ID: + ng_enb.global_ng_ran_node_id->global_ng_enb_id.macro_ng_enb_id = (rand() % 2^20) + 0; + break; + + case SHORT_MACRO_NG_ENB_TYPE_ID: + ng_enb.global_ng_ran_node_id->global_ng_enb_id.short_macro_ng_enb_id = (rand() % 2^18) + 0; + break; + + case LONG_MACRO_NG_ENB_TYPE_ID: + ng_enb.global_ng_ran_node_id->global_ng_enb_id.long_macro_ng_enb_id = (rand() % 2^21) + 0; + break; + + default: + assert(false && "Unknown Global NG eNB ID Type"); + } + break; + + default: + assert(false && "Unknown Global NG-RAN Node ID Type"); + } + + return ng_enb; +} + +ng_enb_du_e2sm_t fill_rnd_ng_enb_du_data(void) +{ + ng_enb_du_e2sm_t ng_enb_du = {0}; + + // 6.2.3.22 + // C-if CU DU separated + // ng-eNB-CU UE W1AP ID + ng_enb_du.ng_enb_cu_ue_w1ap_id = (rand() % 4294967296) + 0; + + return ng_enb_du; +} + +en_gnb_e2sm_t fill_rnd_en_gnb_data(void) +{ + en_gnb_e2sm_t en_gnb = {0}; + + // 6.2.3.23 + // Mandatory + // MeNB UE X2AP ID + en_gnb.enb_ue_x2ap_id = (rand() % 4095) + 1; + + // 6.2.3.24 + // OPTIONAL + // MeNB UE X2AP ID Extension + en_gnb.enb_ue_x2ap_id_extension = calloc(1, sizeof(uint16_t)); + assert(en_gnb.enb_ue_x2ap_id_extension != NULL && "Memory exhausted"); + *en_gnb.enb_ue_x2ap_id_extension = (rand() % 4095) + 1; + + // 6.2.3.9 + // Mandatory + // Global eNB ID + en_gnb.global_enb_id.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; + + en_gnb.global_enb_id.type = rand()%SHORT_MACRO_ENB_TYPE_ID; + + switch (en_gnb.global_enb_id.type) + { + case MACRO_ENB_TYPE_ID: + en_gnb.global_enb_id.macro_enb_id = (rand() % 2^20) + 0; + break; + + case HOME_ENB_TYPE_ID: + en_gnb.global_enb_id.home_enb_id = (rand() % 2^28) + 0; + break; + + /* Possible extensions: */ + // case SHORT_MACRO_ENB_TYPE_ID: + // en_gnb.global_enb_id.short_macro_enb_id = (rand() % 2^18) + 0; + // break; + + // case LONG_MACRO_ENB_TYPE_ID: + // en_gnb.global_enb_id.long_macro_enb_id = (rand() % 2^21) + 0; + // break; + + default: + break; + } + + // 6.2.3.21 + // gNB-CU UE F1AP ID + // C-ifCUDUseparated + en_gnb.gnb_cu_ue_f1ap_lst = calloc(1, sizeof(uint32_t)); + assert(en_gnb.gnb_cu_ue_f1ap_lst != NULL && "Memory exhausted"); + *en_gnb.gnb_cu_ue_f1ap_lst = (rand() % 4294967296) + 0; + + // gNB-CU-CP UE E1AP ID List + // C-ifCPUPseparated + en_gnb.gnb_cu_cp_ue_e1ap_lst_len = 3; + en_gnb.gnb_cu_cp_ue_e1ap_lst = calloc(en_gnb.gnb_cu_cp_ue_e1ap_lst_len, sizeof(uint32_t)); + for (size_t i = 0; i < en_gnb.gnb_cu_cp_ue_e1ap_lst_len; i++) + { + en_gnb.gnb_cu_cp_ue_e1ap_lst[i] = (rand() % 4294967296) + 0; + } + + // RAN UE ID + // Optional + // 6.2.3.25 + en_gnb.ran_ue_id = calloc(1, sizeof(uint64_t)); + assert(en_gnb.ran_ue_id != NULL && "Memory exhausted"); + *en_gnb.ran_ue_id = (rand() % 2^64) + 0; + + return en_gnb; +} + +enb_e2sm_t fill_rnd_enb_data(void) +{ + enb_e2sm_t enb = {0}; + + // 6.2.3.26 + // Mandatory + // MME UE S1AP ID + enb.mme_ue_s1ap_id = (rand() % 4294967296) + 0; + + // 6.2.3.18 + // Mandatory + // GUMMEI + enb.gummei.plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; + enb.gummei.mme_group_id = (rand() % 2^16) + 0; + enb.gummei.mme_code = (rand() % 2^8) + 0; + + // 6.2.3.23 + // C-ifDCSetup + // MeNB UE X2AP ID + enb.enb_ue_x2ap_id = calloc(1, sizeof(uint16_t)); + assert(enb.enb_ue_x2ap_id != NULL && "Memory exhausted"); + *enb.enb_ue_x2ap_id = (rand() % 4095) + 1; + + // 6.2.3.24 + // C-ifDCSetup + // MeNB UE X2AP ID Extension + enb.enb_ue_x2ap_id_extension = calloc(1, sizeof(uint16_t)); + assert(enb.enb_ue_x2ap_id_extension != NULL && "Memory exhausted"); + *enb.enb_ue_x2ap_id_extension = (rand() % 4095) + 1; + + // 6.2.3.9 + // C-ifDCSetup + // Global eNB ID + enb.global_enb_id = calloc(1, sizeof(*enb.global_enb_id)); + assert(enb.global_enb_id != NULL && "Memory exhausted"); + + enb.global_enb_id->plmn_id = (e2sm_plmn_t) {.mcc = 505, .mnc = 1, .mnc_digit_len = 2}; + + enb.global_enb_id->type = MACRO_ENB_TYPE_ID; // rand()%END_ENB_TYPE_ID; + + switch (enb.global_enb_id->type) + { + case MACRO_ENB_TYPE_ID: + enb.global_enb_id->macro_enb_id = (rand() % 2^20) + 0; + break; + + case HOME_ENB_TYPE_ID: + enb.global_enb_id->home_enb_id = (rand() % 2^28) + 0; + break; + + /* Possible extensions: */ + // case SHORT_MACRO_ENB_TYPE_ID: + // enb.global_enb_id->short_macro_enb_id = (rand() % 2^18) + 0; + // break; + + // case LONG_MACRO_ENB_TYPE_ID: + // enb.global_enb_id->long_macro_enb_id = (rand() % 2^21) + 0; + // break; + + default: + break; + } + + return enb; +} + +static +ue_id_e2sm_t fill_rnd_ue_id(void) +{ + ue_id_e2sm_t ue_id_data = {0}; + + ue_id_data.type = GNB_UE_ID_E2SM; // rand()%END_UE_ID; + + switch (ue_id_data.type) + { + case GNB_UE_ID_E2SM: + ue_id_data.gnb = fill_rnd_gnb_data(); + break; + + case GNB_DU_UE_ID_E2SM: + ue_id_data.gnb_du = fill_rnd_gnb_du_data(); + break; + + case GNB_CU_UP_UE_ID_E2SM: + ue_id_data.gnb_cu_up = fill_rnd_gnb_cu_up_data(); + break; + + case NG_ENB_UE_ID_E2SM: + ue_id_data.ng_enb = fill_rnd_ng_enb_data(); + break; + + case NG_ENB_DU_UE_ID_E2SM: + ue_id_data.ng_enb_du = fill_rnd_ng_enb_du_data(); + break; + + case EN_GNB_UE_ID_E2SM: + ue_id_data.en_gnb = fill_rnd_en_gnb_data(); + break; + + case ENB_UE_ID_E2SM: + ue_id_data.enb = fill_rnd_enb_data(); + break; + + default: + assert(false && "Unknown UE ID Type"); + } + + + return ue_id_data; +} + + + +static +e2sm_rc_ind_hdr_frmt_2_t fill_rnd_rc_ind_hdr_frmt_2(void) +{ + e2sm_rc_ind_hdr_frmt_2_t dst = {0}; + + // UE ID + // Mandatory + // 9.3.10 + dst.ue_id = fill_rnd_ue_id (); + + // RIC Insert Style Type + // Mandatory + // 9.3.3 + // 6.2.2.2. From common SM + // RIC Style Type + // Integer + dst.ric_style_type = rand()% 2048; + + // Insert Indication ID + // Mandatory + // 9.3.16 + // [1 - 65535] + dst.ins_ind_id = (rand() % 65535 ) + 1; + + return dst; +} + +static +e2sm_rc_ind_hdr_frmt_3_t fill_rnd_rc_ind_hdr_frmt_3(void) +{ + e2sm_rc_ind_hdr_frmt_3_t dst = {0}; + + // Event Trigger Condition ID + // Optional + // 9.3.21 + // [1 - 65535] + dst.ev_trigger_cond = malloc(sizeof(uint16_t)); + assert(dst.ev_trigger_cond != NULL && "Memory exhausted" ); + + *dst.ev_trigger_cond = (rand() % 65535) + 1; + + // UE ID + // Optional + // 9.3.10 + dst.ue_id = calloc(1, sizeof( ue_id_e2sm_t)); + assert(dst.ue_id != NULL && "Memory exhausted" ); + + *dst.ue_id = fill_rnd_ue_id(); + + return dst; +} + + +e2sm_rc_ind_hdr_t fill_rnd_rc_ind_hdr(void) +{ + e2sm_rc_ind_hdr_t dst = {0}; + + dst.format = rand()%END_E2SM_RC_IND_HDR; + + if(dst.format == FORMAT_1_E2SM_RC_IND_HDR){ + dst.frmt_1 = fill_rnd_rc_ind_hdr_frmt_1(); + } else if(dst.format == FORMAT_2_E2SM_RC_IND_HDR ){ + dst.frmt_2 = fill_rnd_rc_ind_hdr_frmt_2(); + }else if(dst.format == FORMAT_3_E2SM_RC_IND_HDR ){ + dst.frmt_3 = fill_rnd_rc_ind_hdr_frmt_3(); + }else { + assert(0!=0 && "Unknown format"); + } + + return dst; +} + +static +e2sm_rc_ind_msg_frmt_1_t fill_rnd_ind_msg_frmt_1(void) +{ + e2sm_rc_ind_msg_frmt_1_t dst = {0}; + + // Sequence of RAN + // Parameters + // [1 - 65535] + dst.sz_seq_ran_param = (rand() % 64) + 1; + + dst.seq_ran_param = calloc(dst.sz_seq_ran_param, sizeof(seq_ran_param_t)); + assert(dst.seq_ran_param != NULL && "Memory exhausted"); + + for(size_t i = 0; i < dst.sz_seq_ran_param; ++i){ + dst.seq_ran_param[i] = fill_rnd_seq_ran_param(); + } + + return dst; +} + +static +seq_ue_id_t fill_rnd_seq_ue_id(void) +{ + seq_ue_id_t dst = {0}; + + // UE ID + // Mandatory + // 9.3.10 + dst.ue_id = fill_rnd_ue_id(); + + // Sequence of + // RAN Parameter + // [1- 65535] + dst.sz_seq_ran_param = (rand() % 8) + 1; + + dst.seq_ran_param = calloc(dst.sz_seq_ran_param, sizeof(seq_ran_param_t ) ); + assert(dst.seq_ran_param != NULL && "Memory exhausted"); + + for(size_t i = 0; i < dst.sz_seq_ran_param; ++i){ + dst.seq_ran_param[i] = fill_rnd_seq_ran_param(); + } + + + return dst; +} + +e2sm_rc_ind_msg_frmt_2_t fill_rnd_ind_msg_frmt_2(void) +{ + e2sm_rc_ind_msg_frmt_2_t dst = {0}; + + //Sequence of UE Identifier + //[1-65535] + dst.sz_seq_ue_id = (rand() % 8) +1; + + dst.seq_ue_id = calloc(dst.sz_seq_ue_id, sizeof(seq_ue_id_t)); + assert(dst.seq_ue_id != NULL && "Memory exhausted"); + + for(size_t i = 0; i 0){ + dst.seq_ue_info = calloc(dst.sz_seq_ue_info, sizeof(seq_ue_info_t)); + assert(dst.seq_ue_info != NULL && "memory exhausted"); + } + + for(size_t i = 0; i < dst.sz_seq_ue_info; ++i){ + dst.seq_ue_info[i] = fill_rnd_seq_ue_info(); + } + + // Sequence of Cell Information + // [0-65535] + dst.sz_seq_cell_info_2 = rand()%8; + + if(dst.sz_seq_cell_info_2 > 0){ + dst.seq_cell_info_2 = calloc(dst.sz_seq_cell_info_2, sizeof( seq_cell_info_2_t ) ); + assert(dst.seq_cell_info_2 != NULL && "Memory exhausted"); + } + + for(size_t i = 0; i < dst.sz_seq_cell_info_2; ++i){ + dst.seq_cell_info_2[i] = fill_rnd_seq_cell_info_2(); + } + + return dst; +} + +static +e2sm_rc_ind_msg_frmt_5_t fill_rnd_ind_msg_frmt_5(void) +{ + e2sm_rc_ind_msg_frmt_5_t dst = {0}; + + // List of RAN parameters requested + // [0-65535] + dst.sz_seq_ran_param = rand() % 8; + + if(dst.sz_seq_ran_param > 0){ + dst.seq_ran_param = calloc(dst.sz_seq_ran_param, sizeof(seq_ran_param_t)); + assert(dst.seq_ran_param != NULL && "memory exhausted"); + } + + for(size_t i = 0; i < dst.sz_seq_ran_param; ++i){ + dst.seq_ran_param[i] = fill_rnd_seq_ran_param(); + } + + return dst; +} + +static +ran_param_req_t fill_rnd_ran_param_req(void) +{ + ran_param_req_t dst = {0}; + + // RAN Parameter ID + // Mandatory + // 9.3.8 + // 1 4294967295, + dst.ran_param_id = (rand() % 4294967295) + 1; + + // RAN Parameter Value Type + // Mandatory + // 9.3.11 + dst.ran_param = fill_rnd_ran_param_val_type(); + + return dst; +} + +static +seq_ins_ind_act_2_t fill_rnd_seq_ins_ind_act_2(void) +{ + seq_ins_ind_act_2_t dst = {0}; + + // Insert Indication ID + // Mandatory + // 9.3.16 + // 1.. 65535 + dst.ins_ind_id = (rand() % 65535) + 1; + + // List of RAN parameters requested + // [0-65535] + dst.sz_ran_param_req = rand() % 4; + + if(dst.sz_ran_param_req > 0){ + dst.ran_param_req = calloc(dst.sz_ran_param_req, sizeof(ran_param_req_t )); + assert(dst.ran_param_req != NULL && "Memory exhausted"); + } + + for(size_t i = 0; i < dst.sz_ran_param_req; ++i){ + dst.ran_param_req[i] = fill_rnd_ran_param_req(); + } + + return dst; +} + +static +seq_ins_style_2_t fill_rnd_seq_ins_style_2(void) +{ + + seq_ins_style_2_t dst = {0}; + + // Indicated Insert Style + // Mandatory + // 9.3.3 + // 6.2.2.2. + // INTEGER + dst.ind_ins_style = rand(); + + // Sequence of Insert Indication Actions + // [1-63] + dst.sz_seq_ins_ind_act_2 = (rand()%4) + 1; // (rand()%63) + 1; + + dst.seq_ins_ind_act = calloc(dst.sz_seq_ins_ind_act_2, sizeof(seq_ins_ind_act_2_t)); + assert(dst.seq_ins_ind_act != NULL && "Memory exhausted"); + + for(size_t i = 0; i < dst.sz_seq_ins_ind_act_2; ++i){ + dst.seq_ins_ind_act[i] = fill_rnd_seq_ins_ind_act_2(); + } + + return dst; +} + + +static +e2sm_rc_ind_msg_frmt_6_t fill_rnd_ind_msg_frmt_6(void) +{ + e2sm_rc_ind_msg_frmt_6_t dst = {0}; + + // Sequence of Insert Styles for Multiple Actions + // [1-63] + dst.sz_seq_ins_style_ind_msg = (rand()%8) + 1; + + dst.seq_ins_style = calloc(dst.sz_seq_ins_style_ind_msg, sizeof(seq_ins_style_2_t)); + assert(dst.seq_ins_style != NULL && "Memory exhausted"); + + for(size_t i = 0; i < dst.sz_seq_ins_style_ind_msg; ++i){ + dst.seq_ins_style[i] = fill_rnd_seq_ins_style_2(); + } + + return dst; +} + +e2sm_rc_ind_msg_t fill_rnd_rc_ind_msg(void) +{ + e2sm_rc_ind_msg_t dst = {0}; + + dst.format = rand()% END_E2SM_RC_IND_MSG; + + if(dst.format == FORMAT_1_E2SM_RC_IND_MSG){ + dst.frmt_1 = fill_rnd_ind_msg_frmt_1(); + } else if(dst.format == FORMAT_2_E2SM_RC_IND_MSG){ + dst.frmt_2 = fill_rnd_ind_msg_frmt_2(); + }else if(dst.format == FORMAT_3_E2SM_RC_IND_MSG){ + dst.frmt_3 = fill_rnd_ind_msg_frmt_3(); + }else if(dst.format == FORMAT_4_E2SM_RC_IND_MSG){ + dst.frmt_4 = fill_rnd_ind_msg_frmt_4(); + }else if(dst.format == FORMAT_5_E2SM_RC_IND_MSG){ + dst.frmt_5 = fill_rnd_ind_msg_frmt_5(); + }else if(dst.format == FORMAT_6_E2SM_RC_IND_MSG){ + dst.frmt_6 = fill_rnd_ind_msg_frmt_6(); + } else { + assert(0!=0 && "Unknown type"); + } + + return dst; +} + +///////////////////////////// +///////////////////////////// +////////// End of RC Message Indication ////////// +///////////////////////////// +///////////////////////////// + + + +///////////////////////////// +///////////////////////////// +////////// Start of RC Call Process ID ////////////////// +///////////////////////////// +///////////////////////////// + +e2sm_rc_cpid_t fill_rnd_rc_cpid(void) +{ + e2sm_rc_cpid_t dst = {0}; + + // RIC Call Process ID + // Mandatory + // 9.3.18 + // [ 1 - 4294967295] + dst.ric_cpid = (rand()% 4294967295) + 1; + + return dst; +} + +///////////////////////////// +///////////////////////////// +////////// End of RC Call Process ID +///////////////////////////// +///////////////////////////// + + + +///////////////////////////// +///////////////////////////// +////////// Start of RC Control Header +///////////////////////////// +///////////////////////////// + +static +e2sm_rc_ctrl_hdr_frmt_1_t fill_rnd_rc_ctrl_hdr_frmat_1(void) +{ + e2sm_rc_ctrl_hdr_frmt_1_t dst = {0}; + + // UE ID + // Mandatory + // 9.3.10 + dst.ue_id = fill_rnd_ue_id(); + + // RIC Style Type + // Mandatory + // 9.3.3 + // 6.2.2.2. + // INTEGER + dst.ric_style_type = rand(); + + // Control Action ID + // Mandatory + // 9.3.6 + // [1- 65535] + dst.ctrl_act_id = (rand() % 65535) + 1; + + // RIC Control decision + // Optional + dst.ric_ctrl_decision = NULL; + + return dst; +} + +static +e2sm_rc_ctrl_hdr_frmt_2_t fill_rnd_rc_ctrl_hdr_frmat_2(void) +{ + e2sm_rc_ctrl_hdr_frmt_2_t dst = {0}; + // UE ID + // Optional + // 9.3.10 + dst.ue_id = calloc(1, sizeof(ue_id_e2sm_t)); + assert(dst.ue_id != NULL && "Memory exhausted"); + + *dst.ue_id = fill_rnd_ue_id(); + + // RIC Control decision + // Optional + dst.ric_ctrl_dec = NULL; + + return dst; +} + +e2sm_rc_ctrl_hdr_t fill_rnd_rc_ctrl_hdr(void) +{ + e2sm_rc_ctrl_hdr_t dst = {0}; + + dst.format = rand() % END_E2SM_RC_CTRL_HDR; + + if(dst.format == FORMAT_1_E2SM_RC_CTRL_HDR){ + dst.frmt_1 = fill_rnd_rc_ctrl_hdr_frmat_1(); + } else if(dst.format == FORMAT_2_E2SM_RC_CTRL_HDR){ + dst.frmt_2 = fill_rnd_rc_ctrl_hdr_frmat_2(); + } else { + assert(0!=0 && "Not implemented"); + } + + return dst; +} + + +///////////////////////////// +///////////////////////////// +////////// End of RC Control Header +///////////////////////////// +///////////////////////////// + +///////////////////////////// +///////////////////////////// +////////// Start of RC Control Message +///////////////////////////// +///////////////////////////// + +static +e2sm_rc_ctrl_msg_frmt_1_t fill_rnd_ctrl_msg_frmt_1(void) +{ + e2sm_rc_ctrl_msg_frmt_1_t dst = {0}; + + // List of RAN parameters + // [0- 65535] + dst.sz_ran_param = rand() % 8; + + if(dst.sz_ran_param > 0){ + dst.ran_param = calloc(dst.sz_ran_param , sizeof(seq_ran_param_t)); + assert(dst.ran_param != NULL && "Memory exhausted"); + } + + for(size_t i = 0; i < dst.sz_ran_param; ++i){ + dst.ran_param[i] = fill_rnd_seq_ran_param(); + } + + return dst; +} + +static +seq_ctrl_act_t fill_rnd_seq_ctrl_act(void) +{ + seq_ctrl_act_t dst = {0}; + + //Control Action ID + //Mandatory + //9.3.6 + // [1 - 65535] + dst.ctrl_act_id = (rand() % 65535) + 1; + + // Control Action Parameters + // Optional + // 9.2.1.7.1 E2SM-RC Control Message Format 1 + dst.ctrl_msg_frmt_1 = calloc(1 , sizeof(e2sm_rc_ctrl_msg_frmt_1_t )); + assert(dst.ctrl_msg_frmt_1 != NULL && "Memory exhausted" ); + + *dst.ctrl_msg_frmt_1 = fill_rnd_ctrl_msg_frmt_1(); + + return dst; +} + +static +seq_ctrl_sma_t fill_rnd_seq_ctrl_sma(void) +{ + seq_ctrl_sma_t dst = {0}; + + // Indicated Control Style + // Mandatory + // 9.3.3 + // 6.2.2.2. + // INTEGER + dst.ctrl_style = rand(); + + // Sequence of Control Actions + // [1-63] + dst.sz_seq_ctrl_act = (rand() % 8) +1; + + dst.seq_ctrl_act = calloc(dst.sz_seq_ctrl_act, sizeof(seq_ctrl_act_t )); + assert(dst.seq_ctrl_act != NULL && "Memory exhausted" ); + + for(size_t i = 0; i < dst.sz_seq_ctrl_act; ++i){ + dst.seq_ctrl_act[i] = fill_rnd_seq_ctrl_act(); + } + + return dst; +} + + +static +e2sm_rc_ctrl_msg_frmt_2_t fill_rnd_ctrl_msg_frmt_2(void) +{ + e2sm_rc_ctrl_msg_frmt_2_t dst = {0}; + + // Sequence of Control Styles + // for Multiple Actions + // [1 - 63] + dst.sz_seq_ctrl_sma = (rand() % 8) + 1; + + dst.action = calloc(dst.sz_seq_ctrl_sma, sizeof(seq_ctrl_sma_t)); + assert(dst.action != NULL && "Memory exhausted"); + + for(size_t i = 0 ; i < dst.sz_seq_ctrl_sma; ++i){ + dst.action[i] = fill_rnd_seq_ctrl_sma(); + } + + return dst; +} + + +e2sm_rc_ctrl_msg_t fill_rnd_rc_ctrl_msg(void) +{ + e2sm_rc_ctrl_msg_t dst = {0}; + + dst.format = rand() % END_E2SM_RC_CTRL_MSG; + + if(dst.format == FORMAT_1_E2SM_RC_CTRL_MSG){ + dst.frmt_1 = fill_rnd_ctrl_msg_frmt_1(); + } else if (dst.format == FORMAT_2_E2SM_RC_CTRL_MSG){ + dst.frmt_2 = fill_rnd_ctrl_msg_frmt_2(); + } else { + assert(0 && "Unknown format"); + } + + return dst; +} + + +///////////////////////////// +///////////////////////////// +////////// End of RC Control Message +///////////////////////////// +///////////////////////////// + + + + +///////////////////////////// +///////////////////////////// +////////// Start of RC Control Outcome +///////////////////////////// +///////////////////////////// + +static +seq_ran_param_2_t fill_rnd_seq_ran_param_2(void) +{ + seq_ran_param_2_t dst = {0}; + + // RAN Parameter ID + // Mandatory + // 9.3.8 + // [1 - 4294967295] + dst.ran_param_id = (rand() % 4294967295) + 1; + + // RAN Parameter Value + // Mandatory + // 9.3.14 + dst.ran_param_value = fill_rnd_ran_param_val(); + + return dst; +} + +static +e2sm_rc_ctrl_out_frmt_1_t fill_rnd_ctrl_out_frmt_1(void) +{ + e2sm_rc_ctrl_out_frmt_1_t dst = {0}; + + // Sequence of RAN + // Parameters + // [0 - 255] + dst.sz_seq_ran_param_2 = rand() % 8; + + if(dst.sz_seq_ran_param_2 > 0 ){ + dst.ran_param = calloc(dst.sz_seq_ran_param_2, sizeof(seq_ran_param_2_t)); + assert(dst.ran_param != NULL && "Memry exhausted" ); + } + + for(size_t i = 0; i < dst.sz_seq_ran_param_2; ++i){ + dst.ran_param[i] = fill_rnd_seq_ran_param_2(); + } + + return dst; +} + +static +seq_ctrl_act_out_t fill_rnd_seq_ctrl_act_out(void) +{ + seq_ctrl_act_out_t dst = {0}; + + // Control Action ID + // Mandatory + // 9.3.6 + // [1- 65535] + dst.ctrl_act_id = (rand() % 65535)+1; + + //Sequence of RAN + //Parameters + // [1-255] + dst.sz_ran_param = (rand() % 8)+1; + + dst.ran_param = calloc(dst.sz_ran_param, sizeof(seq_ran_param_2_t)); + assert(dst.ran_param != NULL && "Memory exhausted" ); + + for(size_t i = 0; i < dst.sz_ran_param; ++i){ + dst.ran_param[i] = fill_rnd_seq_ran_param_2(); + } + + return dst; +} + + +static +seq_ctrl_sty_mul_out_t fill_rnd_seq_ctrl_sty_mul_out(void) +{ + seq_ctrl_sty_mul_out_t dst = {0}; + + // Indicated Control Style + // Mandatory + // 9.3.3 + // 6.2.2.2. + dst.ind_ctrl_style = rand(); + + //Sequence of Control + //Actions Outcom + // [1-63] + dst.sz_seq_ctrl_act_out = (rand()%8)+ 1; + + dst.seq_ctrl_act_out = calloc(dst.sz_seq_ctrl_act_out, sizeof(seq_ctrl_act_out_t)); + assert(dst.seq_ctrl_act_out != NULL && "Memory exhausted"); + + for(size_t i = 0; i < dst.sz_seq_ctrl_act_out; ++i){ + dst.seq_ctrl_act_out[i] = fill_rnd_seq_ctrl_act_out() ; + } + + return dst; +} + + +static +e2sm_rc_ctrl_out_frmt_2_t fill_rnd_ctrl_out_frmt_2(void) +{ + +// Sequence of Control Styles +// for Multiple Outcomes +// [1-63] + e2sm_rc_ctrl_out_frmt_2_t dst = {0}; + + dst.sz_seq_ctrl_sty_mul_out = (rand() % 8 ) +1; + + dst.seq_ctrl_sty_mul_out = calloc(dst.sz_seq_ctrl_sty_mul_out, sizeof(seq_ctrl_sty_mul_out_t)); + assert(dst.seq_ctrl_sty_mul_out != NULL && "Memory exhausted"); + + for(size_t i = 0; i < dst.sz_seq_ctrl_sty_mul_out; ++i){ + dst.seq_ctrl_sty_mul_out[i] = fill_rnd_seq_ctrl_sty_mul_out(); + } + + return dst; +} + +static +e2sm_rc_ctrl_out_frmt_3_t fill_rnd_ctrl_out_frmt_3() +{ + e2sm_rc_ctrl_out_frmt_3_t dst = {0}; + + // Sequence of RAN Parameters + // [0-255] + dst.sz_seq_ran_param = (rand() % 8) + 1; + dst.ran_param = calloc( dst.sz_seq_ran_param , sizeof(seq_ran_param_t)); + assert(dst.ran_param != NULL && "memory exhausted" ); + + for(size_t i = 0; i < dst.sz_seq_ran_param; ++i){ + dst.ran_param[i] = fill_rnd_seq_ran_param(); + } + + return dst; +} + + +e2sm_rc_ctrl_out_t fill_rnd_rc_ctrl_out(void) +{ + e2sm_rc_ctrl_out_t dst = {0}; + + dst.format = rand() % END_E2SM_RC_CTRL_OUT; + + if(dst.format == FORMAT_1_E2SM_RC_CTRL_OUT){ + dst.frmt_1 = fill_rnd_ctrl_out_frmt_1(); + } else if(dst.format == FORMAT_2_E2SM_RC_CTRL_OUT ){ + dst.frmt_2 = fill_rnd_ctrl_out_frmt_2(); + } else if(dst.format == FORMAT_3_E2SM_RC_CTRL_OUT ){ + dst.frmt_3 = fill_rnd_ctrl_out_frmt_3(); + } else { + assert(0!=0 && "Unknown format"); + } + + return dst; +} + +///////////////////////////// +///////////////////////////// +////////// End of RC Control Outcome +///////////////////////////// +///////////////////////////// + +///////////////////////////// +///////////////////////////// +////////// Start RAN Function Definition +///////////////////////////// +///////////////////////////// + +ran_function_name_t fill_rc_ran_func_name(void) +{ + ran_function_name_t dst = {0}; + + // RAN Function Short Name + // Mandatory + // PrintableString [1-150] + dst.name.buf = calloc(strlen(SM_RAN_CTRL_SHORT_NAME) + 1, sizeof(uint8_t)); + memcpy(dst.name.buf, SM_RAN_CTRL_SHORT_NAME, strlen(SM_RAN_CTRL_SHORT_NAME)); + dst.name.len = strlen(SM_RAN_CTRL_SHORT_NAME); + + // RAN Function Service Model OID + // Mandatory + // PrintableString [1-1000] + + //iso(1) identified-organization(3) + //dod(6) internet(1) private(4) + //enterprise(1) 53148 e2(1) + // version1 (1) e2sm(2) e2sm-RC- + // IEs (3) + dst.oid.buf = calloc(strlen(SM_RAN_CTRL_OID) + 1, sizeof(uint8_t)); + memcpy(dst.oid.buf, SM_RAN_CTRL_OID, strlen(SM_RAN_CTRL_OID)); + dst.oid.len = strlen(SM_RAN_CTRL_OID); + + // RAN Function Description + // Mandatory + // PrintableString [1- 150] + //RAN function RC “RAN Control” performs the following + //functionalities: + //- Exposure of RAN control and UE context related + //information. + //- Modification and initiation of RAN control related call + //processes and messages + //- Execution of policies that may result in change of + //RAN control behavior + + dst.description.buf = calloc(strlen(SM_RAN_CTRL_DESCRIPTION) + 1, sizeof(uint8_t)); + memcpy(dst.description.buf, SM_RAN_CTRL_DESCRIPTION, strlen(SM_RAN_CTRL_DESCRIPTION)); + dst.description.len = strlen(SM_RAN_CTRL_DESCRIPTION); + + // RAN Function Instance + // Optional + // INTEGER +// long* instance; /* OPTIONAL: it is suggested to be used when E2 Node declares +// multiple RAN Function ID supporting the same E2SM specification ask Mikel */ + + return dst; +} + +static +seq_ev_trg_style_t fill_rnd_seq_ev_trg_style(void) +{ + seq_ev_trg_style_t dst = {0}; + + // RIC Event Trigger Style Type + // Mandatory + // 9.3.3 + // 6.2.2.2. + // INTEGER + dst.style = rand(); + + // RIC Event Trigger Style Name + // Mandatory + // 9.3.4 + // 6.2.2.3 + //PrintableString(SIZE(1..150,...)) + const char name[] = "Beatiful"; + dst.name = cp_str_to_ba(name); + + // RIC Event Trigger Format Type + // Mandatory + // 9.3.5 + // 6.2.2.4. + // INTEGER + dst.format = rand(); + + return dst; +} + +static +seq_ran_param_3_t fill_rnd_seq_ran_param_3(void) +{ + seq_ran_param_3_t dst = {0}; + + // RAN Parameter ID + // Mandatory + // 9.3.8 + // [1- 4294967295] + dst.id = rand() % 4294967295 + 1; + + // RAN Parameter Name + // Mandatory + // 9.3.9 + // [1-150] + char name[] = "FooBar42"; + dst.name = cp_str_to_ba(name); + + // RAN Parameter Definition + // Optional + // 9.3.51 + dst.def = NULL; + + return dst; +} + +static +call_proc_break_t fill_rnd_call_proc_break(void) +{ + call_proc_break_t dst = {0}; + + // Call Process Breakpoint ID + // Mandatory + // 9.3.49 + // [1 - 65535] + dst.id = (rand()% 65535) + 1; + + // Call Process Breakpoint Name + // Mandatory + // 9.3.50 + // [1-150] + const char name[] = "Call Process Breakpoint Name"; + dst.name = cp_str_to_ba(name); + + // Sequence of Associated RAN Parameters + // [0-65535] + dst.sz_param = rand() % 4;// 65536; + if(dst.sz_param > 0){ + dst.param = calloc(dst.sz_param , sizeof(seq_ran_param_3_t)); + assert(dst.param != NULL && "Memory exhausted"); + } + for(size_t i = 0; i < dst.sz_param; ++i){ + dst.param[i] = fill_rnd_seq_ran_param_3(); + } + + return dst; +} + + + +static +seq_call_proc_type_t fill_rnd_seq_call_proc_type(void) +{ +seq_call_proc_type_t dst = {0}; + + // Call Process Type ID + // Mandatory + // 9.3.15 + // [1- 65535] + dst.id = (rand()% 65535) + 1; + assert(dst.id > 0); + + // Call Process Type Name + // Mandatory + // 9.3.19 + // [1-150] + const char name[] = "Call Process Type Name"; + dst.name = cp_str_to_ba(name); + + // Sequence of Call Process Breakpoints + // [1-65535] + dst.sz_call_proc_break = (rand()%4) + 1 ;// (rand()%65536) + 1; + if(dst.sz_call_proc_break > 0){ + dst.call_proc_break = calloc(dst.sz_call_proc_break, sizeof( call_proc_break_t ) ); + assert(dst.call_proc_break != NULL && "Memory exhausted"); + } + for(size_t i = 0; i < dst.sz_call_proc_break; ++i){ + dst. call_proc_break[i] = fill_rnd_call_proc_break(); + } + + return dst; +} + +ran_func_def_ev_trig_t fill_ran_func_def_ev_trig(void) +{ + ran_func_def_ev_trig_t dst = {0}; + + // Sequence of EVENT TRIGGER styles + // [1 - 63] + dst.sz_seq_ev_trg_style = (rand()% 4) + 1; // (rand()% 63) + 1; + + dst.seq_ev_trg_style = calloc(dst.sz_seq_ev_trg_style, sizeof(seq_ev_trg_style_t) ); + assert(dst.seq_ev_trg_style != NULL && "memory exhausted"); + + for(size_t i = 0; i < dst. sz_seq_ev_trg_style; ++i){ + dst.seq_ev_trg_style[i] = fill_rnd_seq_ev_trg_style(); + } + + // Sequence of RAN Parameters for L2 Variables + // [0 - 65535] + dst.sz_seq_ran_param_l2_var = rand() % 4; // % 65536; + if(dst.sz_seq_ran_param_l2_var > 0 ){ + dst.seq_ran_param_l2_var = calloc(dst.sz_seq_ran_param_l2_var, sizeof(seq_ran_param_3_t)); + assert(dst.seq_ran_param_l2_var != NULL && "Memory exhausted"); + } + for(size_t i = 0; i < dst.sz_seq_ran_param_l2_var; ++i){ + dst.seq_ran_param_l2_var[i] = fill_rnd_seq_ran_param_3(); + } + + //Sequence of Call Process Types + // [0-65535] + dst.sz_seq_call_proc_type = rand() % 4; // % 65535; + if(dst.sz_seq_call_proc_type > 0){ + dst.seq_call_proc_type = calloc(dst.sz_seq_call_proc_type, sizeof(seq_call_proc_type_t)); + assert(dst.seq_call_proc_type != NULL && "Memory exhausted" ); + } + for(size_t i = 0; i < dst.sz_seq_call_proc_type; ++i){ + dst.seq_call_proc_type[i] = fill_rnd_seq_call_proc_type(); + assert(dst.seq_call_proc_type[i].id > 0); + } + + // Sequence of RAN Parameters for Identifying UEs + // 0-65535 + dst.sz_seq_ran_param_id_ue = rand() % 4; // + if(dst.sz_seq_ran_param_id_ue > 0){ + dst.seq_ran_param_id_ue = calloc(dst.sz_seq_ran_param_id_ue, sizeof(seq_ran_param_3_t)); + assert(dst.seq_ran_param_id_ue != NULL && "Memory exhausted"); + } + for(size_t i = 0; i < dst.sz_seq_ran_param_id_ue; ++i){ + dst.seq_ran_param_id_ue[i] = fill_rnd_seq_ran_param_3(); + } + + // Sequence of RAN Parameters for Identifying Cells + // 0-65535 + dst.sz_seq_ran_param_id_cell = rand() % 4; + if(dst.sz_seq_ran_param_id_cell > 0){ + dst.seq_ran_param_id_cell = calloc(dst.sz_seq_ran_param_id_cell, sizeof(seq_ran_param_3_t) ); + assert(dst.seq_ran_param_id_cell != NULL && "Memory exhausted"); + } + for(size_t i = 0; i < dst. sz_seq_ran_param_id_cell; ++i){ + dst.seq_ran_param_id_cell[i] = fill_rnd_seq_ran_param_3(); + } + + return dst; +} + +static +seq_report_sty_t fill_rnd_seq_report_sty(void) +{ + seq_report_sty_t dst = {0}; + + // RIC Report Style Type + // Mandatory + // 9.3.3 + // 6.2.2.2. + // INTEGER + dst.report_type = rand(); + + // RIC Report Style Name + // Mandatory + // 9.3.4 + // 6.2.2.3. + // PrintableString(SIZE(1..150,...)) + const char name[] = "Claude Shannon"; + dst.name = cp_str_to_ba(name); + + // Supported RIC Event Trigger Style Type + // Mandatory + // 9.3.3 + // 6.2.2.2. + // INTEGER + dst.ev_trig_type = rand(); + + // RIC Report Action Format Type + // Mandatory + // 9.3.5 + // 6.2.2.4. + // INTEGER + dst.act_frmt_type = rand(); + + // RIC Indication Header Format Type + // Mandatory + // 9.3.5 + // 6.2.2.4. + // INTEGER + dst.ind_hdr_type = rand(); + + // RIC Indication Message Format Type + // Mandatory + // 9.3.5 + // 6.2.2.4. + // INTEGER + dst.ind_msg_type = rand(); + + // Sequence of RAN Parameters Supported + // [0 - 65535] + dst.sz_seq_ran_param = rand()%8; + + if(dst.sz_seq_ran_param > 0){ + dst.ran_param = calloc(dst.sz_seq_ran_param, sizeof(seq_ran_param_3_t)); + assert(dst.ran_param != NULL && "Memory exhausted"); + for(size_t i = 0; i < dst.sz_seq_ran_param; ++i){ + dst.ran_param[i] = fill_rnd_seq_ran_param_3(); + } + } + + return dst; +} + +ran_func_def_report_t fill_ran_func_def_report(void) +{ + ran_func_def_report_t dst = {0}; + + // Sequence of REPORT styles + // [1 - 63] + dst.sz_seq_report_sty = (rand()%4) + 1; + dst.seq_report_sty = calloc(dst.sz_seq_report_sty, sizeof(seq_report_sty_t)); + assert(dst.seq_report_sty != NULL && "Memory exhausted"); + + for(size_t i = 0; i < dst.sz_seq_report_sty; ++i){ + dst.seq_report_sty[i] = fill_rnd_seq_report_sty(); + } + + return dst; +} + +static +seq_ins_ind_t fill_rnd_seq_ins_ind(void) +{ + seq_ins_ind_t dst = {0}; + + // Insert Indication ID + // Mandatory + // 9.3.16 + // [1-65535] + dst.id = (rand()% 65535) + 1; + + // Insert Indication Name + // Mandatory + // 9.3.17 + // [1-150] + const char name[] = "Robert Gallager"; + dst.name = cp_str_to_ba(name); + + // Sequence of Insert Indications + // [0-65535] + dst.sz_seq_ins_ind = rand()%4 ; // 65536 + if(dst.sz_seq_ins_ind > 0){ + dst.seq_ins_ind = calloc(dst.sz_seq_ins_ind, sizeof(seq_ran_param_3_t) ); + assert(dst.seq_ins_ind != NULL && "Memory exhausted"); + for(size_t i = 0; i < dst.sz_seq_ins_ind; ++i){ + dst.seq_ins_ind[i] = fill_rnd_seq_ran_param_3(); + } + } + + return dst; +} + +static +seq_ins_sty_t fill_rnd_seq_ins_sty(void) +{ + seq_ins_sty_t dst = {0}; + + // RIC Insert Style Type + // Mandatory + // 9.3.3 + // 6.2.2.2. + // INTEGER + dst.style_type = rand(); + + // RIC Insert Style Name + // Mandatory + // 9.3.4 + // 6.2.2.3. + // [1-150] + const char name[] = "Bob Fanno"; + dst.name = cp_str_to_ba(name); + + // Supported RIC Event Trigger Style Type + // Mandatory + // 9.3.3 + // 6.2.2.2. + dst.ev_trig_style_type = rand(); + + // RIC Action Definition Format Type + // Mandatory + // 9.3.5 + // 6.2.2.4. + dst.act_def_frmt_type = rand(); + + // Sequence of Insert Indications + // [0-65535] + dst.sz_seq_ins_ind = rand() % 4; //65536 + if(dst.sz_seq_ins_ind > 0){ + dst.seq_ins_ind = calloc(dst.sz_seq_ins_ind, sizeof(seq_ins_ind_t)); + assert(dst.seq_ins_ind != NULL && "Memory exhausted"); + for(size_t i = 0; i < dst.sz_seq_ins_ind; ++i){ + dst.seq_ins_ind[i] = fill_rnd_seq_ins_ind(); + } + } + + // RIC Indication Header Format Type + // Mandatoyr + // 9.3.5 + // 6.2.2.4. + dst.ind_hdr_frmt_type= rand(); + + // RIC Indication Message Format Type + // Mandatory + // 9.3.5 + // 6.2.2.4. + dst.ind_msg_frmt_type = rand(); + + // RIC Call Process ID Format Type + // Mandatory + // 9.3.5 + // 6.2.2.4. + dst.call_proc_id_type = rand(); + + return dst; +} + +ran_func_def_insert_t fill_ran_func_def_insert(void) +{ + ran_func_def_insert_t dst = {0}; + + // Sequence of INSERT styles + // [1-63] + dst.sz_seq_ins_sty = (rand()% 4) + 1; // (rand()%63) + 1; + + dst.seq_ins_sty = calloc(dst.sz_seq_ins_sty, sizeof(seq_ins_sty_t)); + assert(dst.seq_ins_sty != NULL && "Memory exhausted"); + + for(size_t i = 0; i < dst.sz_seq_ins_sty; ++i){ + dst.seq_ins_sty[i] = fill_rnd_seq_ins_sty(); + } + + return dst; +} + +static +seq_ctrl_act_2_t fill_rnd_ctrl_act(void) +{ + seq_ctrl_act_2_t dst = {0}; + + // Control Action ID + // Mandatory + // 9.3.6 + // [1-65535] + dst.id = (rand()%65535) +1; + + // Control Action Name + // Mandatory + // 9.3.7 + // [1-150] + const char name[] = "test string"; + dst.name = cp_str_to_ba(name); + + // Sequence of Associated RAN Parameters + // [0-65535] + dst.sz_seq_assoc_ran_param = rand()%4; + if(dst.sz_seq_assoc_ran_param > 0){ + dst.assoc_ran_param = calloc(dst.sz_seq_assoc_ran_param, sizeof(seq_ran_param_3_t) ); + assert(dst.assoc_ran_param != NULL && "Memory exhausted"); + } + for(size_t i = 0; i < dst.sz_seq_assoc_ran_param; ++i){ + dst.assoc_ran_param[i] = fill_rnd_seq_ran_param_3(); + } + + return dst; +} + +static +seq_ctrl_style_t fill_rnd_seq_ctrl_style(void) +{ + seq_ctrl_style_t dst = {0}; + + // RIC Control Style Type + // Mandatory + // 9.3.3 + // 6.2.2.2. + dst.style_type = rand(); + + //RIC Control Style Name + //Mandatory + //9.3.4 + // [1 -150] + const char name[] = "Bjarne Stroustroup"; + dst.name = cp_str_to_ba(name); + + // Sequence of Control Actions + // [0-65535] + dst.sz_seq_ctrl_act = rand() % 4; + if(dst.sz_seq_ctrl_act > 0){ + dst.seq_ctrl_act = calloc(dst.sz_seq_ctrl_act, sizeof(seq_ctrl_act_2_t ) ); + assert(dst.seq_ctrl_act != NULL && "Memory exhausted"); + } + for(size_t i = 0; i < dst.sz_seq_ctrl_act; ++i){ + dst.seq_ctrl_act[i] = fill_rnd_ctrl_act( ); + } + + // RIC Control Header Format Type + // Mandatory + // 9.3.5 + dst.hdr = rand(); + + // RIC Control Message Format Type + // Mandatory + // 9.3.5 + dst.msg = rand(); + + // RIC Call Process ID Format Type + // Optional + + // RIC Control Outcome Format Type + // Mandatory + // 9.3.5 + dst.out_frmt = rand(); + + // Sequence of Associated RAN + // Parameters for Control Outcome + // [0- 255] + dst.sz_ran_param_ctrl_out = 1; // rand()%4; + if(dst.sz_ran_param_ctrl_out > 0){ + dst.ran_param_ctrl_out = calloc(dst.sz_ran_param_ctrl_out, sizeof(seq_ran_param_3_t) ); + assert(dst.ran_param_ctrl_out != NULL && "Memory exhausted"); + } + for(size_t i = 0; i < dst.sz_ran_param_ctrl_out; ++i){ + dst.ran_param_ctrl_out[i] = fill_rnd_seq_ran_param_3(); + } + + return dst; +} + +ran_func_def_ctrl_t fill_ran_func_def_ctrl(void) +{ + ran_func_def_ctrl_t dst = {0}; + + // Sequence of CONTROL styles + // [1 - 63] + dst.sz_seq_ctrl_style = (rand()%4) + 1; + dst.seq_ctrl_style = calloc(dst.sz_seq_ctrl_style, sizeof(seq_ctrl_style_t) ); + assert(dst.seq_ctrl_style != NULL && "Memory exhausted"); + for(size_t i = 0; i < dst.sz_seq_ctrl_style; ++i){ + dst.seq_ctrl_style[i] = fill_rnd_seq_ctrl_style(); + } + + return dst; +} + +static +seq_pol_action_t fill_rnd_seq_pol_action(void) +{ + seq_pol_action_t dst = {0}; + // Policy Action ID + // Mandatory + // 9.3.6 + dst.action_id = rand(); + + // Policy Action Name + // Mandatory + // 9.3.7 + // [1-150] + const char name[] = "Andrei Alexandrescu"; + dst.name = cp_str_to_ba(name); + + // RIC Action Definition Format Type + // Mandatoyr + // 9.3.5 + dst.frmt_type = rand(); + + // Sequence of Associated RAN Parameters for Policy Action + // [0- 65535] + dst.sz_seq_assoc_rp_action = rand()%4; + if(dst.sz_seq_assoc_rp_action > 0){ + dst.seq_assoc_rp_action = calloc(dst.sz_seq_assoc_rp_action, sizeof(seq_ran_param_3_t)); + assert(dst.seq_assoc_rp_action != NULL && "Memory exhausted"); + } + for(size_t i = 0; i < dst.sz_seq_assoc_rp_action; ++i){ + dst.seq_assoc_rp_action[i] = fill_rnd_seq_ran_param_3(); + } + + // Sequence of Associated RAN Parameters for Policy Condition + // [0- 65535] + dst.sz_seq_assoc_rp_policy = rand()%4; + if(dst.sz_seq_assoc_rp_policy > 0){ + dst.seq_assoc_rp_policy = calloc(dst.sz_seq_assoc_rp_policy, sizeof(seq_ran_param_3_t)); + assert(dst.seq_assoc_rp_policy != NULL && "Memory exhausted"); + } + for(size_t i = 0; i < dst.sz_seq_assoc_rp_policy; ++i){ + dst.seq_assoc_rp_policy[i] = fill_rnd_seq_ran_param_3(); + } + + return dst; +} + +static +seq_policy_sty_t fill_rnd_seq_policy_sty(void) +{ + seq_policy_sty_t dst = {0}; + // RIC Policy Style Type + // Mandatory + // 9.3.3 + dst.style_type = rand(); + + // RIC Policy Style Name + // Mandatory + // 9.3.4 + const char name[] = "Sean Parent"; + dst.name = cp_str_to_ba(name); + + // Supported RIC Event Trigger Style Type + // Mandatory + // 9.3.3 + dst.ev_trg_style_type = rand(); + + // Sequence of Policy Actions + // [0-65535] + dst.sz_seq_pol_action = rand() % 4; + if(dst.sz_seq_pol_action > 0){ + dst.seq_pol_action = calloc(dst.sz_seq_pol_action, sizeof(seq_pol_action_t)); + assert(dst.seq_pol_action != NULL && "Memory exhausted"); + } + for(size_t i = 0; i < dst.sz_seq_pol_action; ++i){ + dst.seq_pol_action[i] = fill_rnd_seq_pol_action(); + } + + return dst; +} + +ran_func_def_policy_t fill_ran_func_def_policy(void) +{ + ran_func_def_policy_t dst = {0}; + + // Sequence of POLICY styles + // [1-63] + dst.sz_policy_styles = (rand() % 4) + 1; + dst.seq_policy_sty = calloc(dst.sz_policy_styles, sizeof(seq_policy_sty_t ) ); + assert(dst.seq_policy_sty != NULL && "Memory exhasuted"); + + for(size_t i = 0; i < dst.sz_policy_styles; ++i){ + dst.seq_policy_sty[i] = fill_rnd_seq_policy_sty(); + } + + return dst; +} + +e2sm_rc_func_def_t fill_rnd_rc_ran_func_def(void) +{ + e2sm_rc_func_def_t dst = {0}; + + // RAN Function Name + // Mandatory + // 9.3.2 + // 6.2.2.1. + dst.name = fill_rc_ran_func_name(); + + // RAN Function Definition for EVENT TRIGGER + // Optional + // 9.2.2.2 + dst.ev_trig = calloc(1, sizeof(ran_func_def_ev_trig_t)); + assert(dst.ev_trig != NULL && "Memory exhausted"); + *dst.ev_trig = fill_ran_func_def_ev_trig(); + + // RAN Function Definition for REPORT + // Optional + // 9.2.2.3 + dst.report = calloc(1, sizeof( ran_func_def_report_t )); + assert(dst.report != NULL && "Memory exhausted"); + *dst.report = fill_ran_func_def_report(); + + // RAN Function Definition for INSERT + // Optional + // 9.2.2.4 + dst.insert = calloc(1, sizeof(ran_func_def_insert_t)); + assert(dst.insert != NULL && "Memory exhausted"); + *dst.insert = fill_ran_func_def_insert(); + + // RAN Function Definition for CONTROL + // Optional + // 9.2.2.5 + dst.ctrl = calloc(1, sizeof( ran_func_def_ctrl_t)); + assert(dst.ctrl != NULL && "Memory exhausted"); + *dst.ctrl = fill_ran_func_def_ctrl(); + + // RAN Function Definition for POLICY + // Optional + // 9.2.2.6 + dst.policy = calloc(1, sizeof(ran_func_def_policy_t)); + assert(dst.policy != NULL && "Memory exhausted"); + *dst.policy = fill_ran_func_def_policy(); + + return dst; +} + +///////////////////////////// +///////////////////////////// +////////// End of RAN Function Definition +///////////////////////////// +///////////////////////////// + +rc_ind_data_t fill_rnd_rc_ind_data(void) +{ + rc_ind_data_t dst = {0}; + + dst.hdr = fill_rnd_rc_ind_hdr(); + dst.msg = fill_rnd_rc_ind_msg(); + + return dst; +} + +rc_sub_data_t fill_rnd_rc_subscription(void) +{ + rc_sub_data_t dst = {0}; + + dst.et = fill_rnd_rc_event_trigger(); + + // Action Definition + dst.sz_ad = 1; + dst.ad = calloc( dst.sz_ad, sizeof(e2sm_rc_action_def_t)); + assert(dst.ad != NULL && "Memory exhausted"); + for(size_t i = 0; i < dst.sz_ad; i++){ + dst.ad[i] = fill_rnd_rc_action_def(); + } + + return dst; +} + +e2sm_rc_ctrl_out_t fill_rc_ctrl_out(void) +{ + e2sm_rc_ctrl_out_t dst = fill_rnd_rc_ctrl_out(); + + return dst; +} + +rc_ctrl_req_data_t fill_rc_ctrl(void) +{ + rc_ctrl_req_data_t dst = {0}; + dst.hdr = fill_rnd_rc_ctrl_hdr(); + dst.msg = fill_rnd_rc_ctrl_msg(); + return dst; +} + +e2sm_rc_func_def_t fill_rc_ran_func_def(void) +{ + return fill_rnd_rc_ran_func_def(); +} + + + + + + + diff --git a/libs/test/rnd/fill_rnd_data_rc.h b/libs/test/rnd/fill_rnd_data_rc.h index 34bab6f..ec29b9e 100644 --- a/libs/test/rnd/fill_rnd_data_rc.h +++ b/libs/test/rnd/fill_rnd_data_rc.h @@ -1,65 +1,65 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698 - * - * 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. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include "../../src/sm/rc_sm/ie/rc_data_ie.h" - -e2sm_rc_event_trigger_t fill_rnd_rc_event_trigger(void); - -e2sm_rc_action_def_t fill_rnd_rc_action_def(void); - -e2sm_rc_ind_hdr_t fill_rnd_rc_ind_hdr(void); -e2sm_rc_ind_hdr_frmt_1_t fill_rnd_rc_ind_hdr_frmt_1(void); - -e2sm_rc_ind_msg_t fill_rnd_rc_ind_msg(void); -e2sm_rc_ind_msg_frmt_2_t fill_rnd_ind_msg_frmt_2(void); - -e2sm_rc_cpid_t fill_rnd_rc_cpid(void); - -e2sm_rc_ctrl_hdr_t fill_rnd_rc_ctrl_hdr(void); - -e2sm_rc_ctrl_msg_t fill_rnd_rc_ctrl_msg(void); - -e2sm_rc_ctrl_out_t fill_rnd_rc_ctrl_out(void); - -e2sm_rc_func_def_t fill_rnd_rc_ran_func_def(void); - -ran_function_name_t fill_rc_ran_func_name(void); - -ran_func_def_ev_trig_t fill_rc_ran_func_def_ev_trig(void); - -ran_func_def_report_t fill_rc_ran_func_def_report(void); - -ran_func_def_insert_t fill_rc_ran_func_def_insert(void); - -ran_func_def_ctrl_t fill_rc_ran_func_def_ctrl(void); - -ran_func_def_policy_t fill_rc_ran_func_def_policy(void); - -rc_ind_data_t fill_rnd_rc_ind_data(void); - -rc_sub_data_t fill_rnd_rc_subscription(void); - -e2sm_rc_ctrl_out_t fill_rc_ctrl_out(void); - -rc_ctrl_req_data_t fill_rc_ctrl(void); - -e2sm_rc_func_def_t fill_rc_ran_func_def(void); - +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698 + * + * 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. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#include "../../src/sm/rc_sm/ie/rc_data_ie.h" + +e2sm_rc_event_trigger_t fill_rnd_rc_event_trigger(void); + +e2sm_rc_action_def_t fill_rnd_rc_action_def(void); + +e2sm_rc_ind_hdr_t fill_rnd_rc_ind_hdr(void); +e2sm_rc_ind_hdr_frmt_1_t fill_rnd_rc_ind_hdr_frmt_1(void); + +e2sm_rc_ind_msg_t fill_rnd_rc_ind_msg(void); +e2sm_rc_ind_msg_frmt_2_t fill_rnd_ind_msg_frmt_2(void); + +e2sm_rc_cpid_t fill_rnd_rc_cpid(void); + +e2sm_rc_ctrl_hdr_t fill_rnd_rc_ctrl_hdr(void); + +e2sm_rc_ctrl_msg_t fill_rnd_rc_ctrl_msg(void); + +e2sm_rc_ctrl_out_t fill_rnd_rc_ctrl_out(void); + +e2sm_rc_func_def_t fill_rnd_rc_ran_func_def(void); + +ran_function_name_t fill_rc_ran_func_name(void); + +ran_func_def_ev_trig_t fill_rc_ran_func_def_ev_trig(void); + +ran_func_def_report_t fill_rc_ran_func_def_report(void); + +ran_func_def_insert_t fill_rc_ran_func_def_insert(void); + +ran_func_def_ctrl_t fill_rc_ran_func_def_ctrl(void); + +ran_func_def_policy_t fill_rc_ran_func_def_policy(void); + +rc_ind_data_t fill_rnd_rc_ind_data(void); + +rc_sub_data_t fill_rnd_rc_subscription(void); + +e2sm_rc_ctrl_out_t fill_rc_ctrl_out(void); + +rc_ctrl_req_data_t fill_rc_ctrl(void); + +e2sm_rc_func_def_t fill_rc_ran_func_def(void); + diff --git a/libs/test/rnd/fill_rnd_data_rlc.c b/libs/test/rnd/fill_rnd_data_rlc.c index 259dda0..5f30e7a 100644 --- a/libs/test/rnd/fill_rnd_data_rlc.c +++ b/libs/test/rnd/fill_rnd_data_rlc.c @@ -1,103 +1,103 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698 - * - * 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. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include "fill_rnd_data_rlc.h" -#include "../../src/util/time_now_us.h" - -#include -#include -#include - -void fill_rlc_ind_data(rlc_ind_data_t* ind) -{ - assert(ind != NULL); - - srand(time(0)); - - int const mod = 1024; - - rlc_ind_msg_t* ind_msg = &ind->msg; - - ind_msg->tstamp = time_now_us(); - - ind_msg->len = rand()%4; - if(ind_msg->len > 0 ){ - ind_msg->rb = calloc(ind_msg->len, sizeof(rlc_radio_bearer_stats_t) ); - assert(ind_msg->rb != NULL); - } - - for(uint32_t i = 0; i < ind_msg->len; ++i){ - rlc_radio_bearer_stats_t* rb = &ind_msg->rb[i]; - - rb->txpdu_pkts=abs(rand()%mod) ; /* aggregated number of transmitted RLC PDUs */ - rb->txpdu_bytes=abs(rand()%mod); /* aggregated amount of transmitted bytes in RLC PDUs */ - /* TODO? */ - rb->txpdu_wt_ms=abs(rand()%mod); /* aggregated head-of-line tx packet waiting time to be transmitted (i.e. send to the MAC layer) */ - rb->txpdu_dd_pkts=abs(rand()%mod); /* aggregated number of dropped or discarded tx packets by RLC */ - rb->txpdu_dd_bytes=abs(rand()%mod); /* aggregated amount of bytes dropped or discarded tx packets by RLC */ - rb->txpdu_retx_pkts=abs(rand()%mod); /* aggregated number of tx pdus/pkts to be re-transmitted (only applicable to RLC AM) */ - rb->txpdu_retx_bytes=abs(rand()%mod); /* aggregated amount of bytes to be re-transmitted (only applicable to RLC AM) */ - rb->txpdu_segmented=abs(rand()%mod); /* aggregated number of segmentations */ - rb->txpdu_status_pkts=abs(rand()%mod); /* aggregated number of tx status pdus/pkts (only applicable to RLC AM) */ - rb->txpdu_status_bytes=abs(rand()%mod); /* aggregated amount of tx status bytes (only applicable to RLC AM) */ - /* TODO? */ - rb->txbuf_occ_bytes=abs(rand()%mod); /* current tx buffer occupancy in terms of amount of bytes (average: NOT IMPLEMENTED) */ - /* TODO? */ - rb->txbuf_occ_pkts=abs(rand()%mod); /* current tx buffer occupancy in terms of number of packets (average: NOT IMPLEMENTED) */ - /* txbuf_wd_ms: the time window for which the txbuf occupancy value is obtained - NOT IMPLEMENTED */ - - /* RX */ - rb->rxpdu_pkts=abs(rand()%mod); /* aggregated number of received RLC PDUs */ - rb->rxpdu_bytes=abs(rand()%mod); /* amount of bytes received by the RLC */ - rb->rxpdu_dup_pkts=abs(rand()%mod); /* aggregated number of duplicate packets */ - rb->rxpdu_dup_bytes=abs(rand()%mod); /* aggregated amount of duplicated bytes */ - rb->rxpdu_dd_pkts=abs(rand()%mod); /* aggregated number of rx packets dropped or discarded by RLC */ - rb->rxpdu_dd_bytes=abs(rand()%mod); /* aggregated amount of rx bytes dropped or discarded by RLC */ - rb->rxpdu_ow_pkts=abs(rand()%mod); /* aggregated number of out of window received RLC pdu */ - rb->rxpdu_ow_bytes=abs(rand()%mod); /* aggregated number of out of window bytes received RLC pdu */ - rb->rxpdu_status_pkts=abs(rand()%mod); /* aggregated number of rx status pdus/pkts (only applicable to RLC AM) */ - rb->rxpdu_status_bytes=abs(rand()%mod); /* aggregated amount of rx status bytes (only applicable to RLC AM) */ - /* rxpdu_rotout_ms: flag indicating rx reordering timeout in ms - NOT IMPLEMENTED */ - /* rxpdu_potout_ms: flag indicating the poll retransmit time out in ms - NOT IMPLEMENTED */ - /* rxpdu_sptout_ms: flag indicating status prohibit timeout in ms - NOT IMPLEMENTED */ - /* TODO? */ - rb->rxbuf_occ_bytes=abs(rand()%mod); /* current rx buffer occupancy in terms of amount of bytes (average: NOT IMPLEMENTED) */ - /* TODO? */ - rb->rxbuf_occ_pkts=abs(rand()%mod); /* current rx buffer occupancy in terms of number of packets (average: NOT IMPLEMENTED) */ - - /* SDU stats */ - /* TX */ - rb->txsdu_pkts=abs(rand()%mod); /* number of SDUs delivered */ - rb->txsdu_bytes=abs(rand()%mod); /* number of bytes of SDUs delivered */ - - /* RX */ - rb->rxsdu_pkts=abs(rand()%mod); /* number of SDUs received */ - rb->rxsdu_bytes=abs(rand()%mod); /* number of bytes of SDUs received */ - rb->rxsdu_dd_pkts=abs(rand()%mod); /* number of dropped or discarded SDUs */ - rb->rxsdu_dd_bytes=abs(rand()%mod); /* number of bytes of SDUs dropped or discarded */ - - rb->rnti=abs(rand()%mod); - rb->mode=abs(rand()%3); /* 0: RLC AM, 1: RLC UM, 2: RLC TM */ - rb->rbid=abs(rand()%16); - - } -} - +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698 + * + * 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. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#include "fill_rnd_data_rlc.h" +#include "../../src/util/time_now_us.h" + +#include +#include +#include + +void fill_rlc_ind_data(rlc_ind_data_t* ind) +{ + assert(ind != NULL); + + srand(time(0)); + + int const mod = 1024; + + rlc_ind_msg_t* ind_msg = &ind->msg; + + ind_msg->tstamp = time_now_us(); + + ind_msg->len = rand()%4; + if(ind_msg->len > 0 ){ + ind_msg->rb = calloc(ind_msg->len, sizeof(rlc_radio_bearer_stats_t) ); + assert(ind_msg->rb != NULL); + } + + for(uint32_t i = 0; i < ind_msg->len; ++i){ + rlc_radio_bearer_stats_t* rb = &ind_msg->rb[i]; + + rb->txpdu_pkts=abs(rand()%mod) ; /* aggregated number of transmitted RLC PDUs */ + rb->txpdu_bytes=abs(rand()%mod); /* aggregated amount of transmitted bytes in RLC PDUs */ + /* TODO? */ + rb->txpdu_wt_ms=abs(rand()%mod); /* aggregated head-of-line tx packet waiting time to be transmitted (i.e. send to the MAC layer) */ + rb->txpdu_dd_pkts=abs(rand()%mod); /* aggregated number of dropped or discarded tx packets by RLC */ + rb->txpdu_dd_bytes=abs(rand()%mod); /* aggregated amount of bytes dropped or discarded tx packets by RLC */ + rb->txpdu_retx_pkts=abs(rand()%mod); /* aggregated number of tx pdus/pkts to be re-transmitted (only applicable to RLC AM) */ + rb->txpdu_retx_bytes=abs(rand()%mod); /* aggregated amount of bytes to be re-transmitted (only applicable to RLC AM) */ + rb->txpdu_segmented=abs(rand()%mod); /* aggregated number of segmentations */ + rb->txpdu_status_pkts=abs(rand()%mod); /* aggregated number of tx status pdus/pkts (only applicable to RLC AM) */ + rb->txpdu_status_bytes=abs(rand()%mod); /* aggregated amount of tx status bytes (only applicable to RLC AM) */ + /* TODO? */ + rb->txbuf_occ_bytes=abs(rand()%mod); /* current tx buffer occupancy in terms of amount of bytes (average: NOT IMPLEMENTED) */ + /* TODO? */ + rb->txbuf_occ_pkts=abs(rand()%mod); /* current tx buffer occupancy in terms of number of packets (average: NOT IMPLEMENTED) */ + /* txbuf_wd_ms: the time window for which the txbuf occupancy value is obtained - NOT IMPLEMENTED */ + + /* RX */ + rb->rxpdu_pkts=abs(rand()%mod); /* aggregated number of received RLC PDUs */ + rb->rxpdu_bytes=abs(rand()%mod); /* amount of bytes received by the RLC */ + rb->rxpdu_dup_pkts=abs(rand()%mod); /* aggregated number of duplicate packets */ + rb->rxpdu_dup_bytes=abs(rand()%mod); /* aggregated amount of duplicated bytes */ + rb->rxpdu_dd_pkts=abs(rand()%mod); /* aggregated number of rx packets dropped or discarded by RLC */ + rb->rxpdu_dd_bytes=abs(rand()%mod); /* aggregated amount of rx bytes dropped or discarded by RLC */ + rb->rxpdu_ow_pkts=abs(rand()%mod); /* aggregated number of out of window received RLC pdu */ + rb->rxpdu_ow_bytes=abs(rand()%mod); /* aggregated number of out of window bytes received RLC pdu */ + rb->rxpdu_status_pkts=abs(rand()%mod); /* aggregated number of rx status pdus/pkts (only applicable to RLC AM) */ + rb->rxpdu_status_bytes=abs(rand()%mod); /* aggregated amount of rx status bytes (only applicable to RLC AM) */ + /* rxpdu_rotout_ms: flag indicating rx reordering timeout in ms - NOT IMPLEMENTED */ + /* rxpdu_potout_ms: flag indicating the poll retransmit time out in ms - NOT IMPLEMENTED */ + /* rxpdu_sptout_ms: flag indicating status prohibit timeout in ms - NOT IMPLEMENTED */ + /* TODO? */ + rb->rxbuf_occ_bytes=abs(rand()%mod); /* current rx buffer occupancy in terms of amount of bytes (average: NOT IMPLEMENTED) */ + /* TODO? */ + rb->rxbuf_occ_pkts=abs(rand()%mod); /* current rx buffer occupancy in terms of number of packets (average: NOT IMPLEMENTED) */ + + /* SDU stats */ + /* TX */ + rb->txsdu_pkts=abs(rand()%mod); /* number of SDUs delivered */ + rb->txsdu_bytes=abs(rand()%mod); /* number of bytes of SDUs delivered */ + + /* RX */ + rb->rxsdu_pkts=abs(rand()%mod); /* number of SDUs received */ + rb->rxsdu_bytes=abs(rand()%mod); /* number of bytes of SDUs received */ + rb->rxsdu_dd_pkts=abs(rand()%mod); /* number of dropped or discarded SDUs */ + rb->rxsdu_dd_bytes=abs(rand()%mod); /* number of bytes of SDUs dropped or discarded */ + + rb->rnti=abs(rand()%mod); + rb->mode=abs(rand()%3); /* 0: RLC AM, 1: RLC UM, 2: RLC TM */ + rb->rbid=abs(rand()%16); + + } +} + diff --git a/libs/test/rnd/fill_rnd_data_rlc.h b/libs/test/rnd/fill_rnd_data_rlc.h index ce2bbed..b7ed591 100644 --- a/libs/test/rnd/fill_rnd_data_rlc.h +++ b/libs/test/rnd/fill_rnd_data_rlc.h @@ -1,29 +1,29 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698 - * - * 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. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#ifndef FILL_RND_DATA_RLC_H -#define FILL_RND_DATA_RLC_H - -#include "../../src/sm/rlc_sm/ie/rlc_data_ie.h" - -void fill_rlc_ind_data(rlc_ind_data_t* ind); - -#endif +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698 + * + * 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. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#ifndef FILL_RND_DATA_RLC_H +#define FILL_RND_DATA_RLC_H + +#include "../../src/sm/rlc_sm/ie/rlc_data_ie.h" + +void fill_rlc_ind_data(rlc_ind_data_t* ind); + +#endif diff --git a/libs/test/rnd/fill_rnd_data_slice.c b/libs/test/rnd/fill_rnd_data_slice.c index 469a950..44e449b 100644 --- a/libs/test/rnd/fill_rnd_data_slice.c +++ b/libs/test/rnd/fill_rnd_data_slice.c @@ -1,259 +1,259 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698 - * - * 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. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - - - -#include "fill_rnd_data_slice.h" -#include "../../src/util/time_now_us.h" - -#include -#include -#include -#include -#include - - -static -void fill_static_slice(static_slice_t* sta) -{ - assert(sta != NULL); - - sta->pos_high = abs(rand()%25); - sta->pos_low = abs(rand()%25); -} - - -static -void fill_nvs_slice(nvs_slice_t* nvs) -{ - assert(nvs != NULL); - - const uint32_t type = abs(rand() % SLICE_SM_NVS_V0_END); - - if(type == SLICE_SM_NVS_V0_RATE ){ - nvs->conf = SLICE_SM_NVS_V0_RATE; - nvs->u.rate.u2.mbps_reference = 0.8; -// 10.0*((float)rand()/(float)RAND_MAX); - nvs->u.rate.u1.mbps_required = 10.0; - //*((float)rand()/(float)RAND_MAX); - } else if(type ==SLICE_SM_NVS_V0_CAPACITY ){ - nvs->conf = SLICE_SM_NVS_V0_CAPACITY; - nvs->u.capacity.u.pct_reserved = 15.0; - //*((float)rand()/(float)RAND_MAX); - } else { - assert(0!=0 && "Unknown type"); - } - -} - -static -void fill_scn19_slice(scn19_slice_t* scn19) -{ - assert(scn19 != NULL); - - const uint32_t type = abs(rand()% SLICE_SCN19_SM_V0_END); - - if(type == SLICE_SCN19_SM_V0_DYNAMIC ){ - scn19->conf = SLICE_SCN19_SM_V0_DYNAMIC ; - scn19->u.dynamic.u2.mbps_reference = 10.0 * fabs((float)rand()/(float)RAND_MAX); - scn19->u.dynamic.u1.mbps_required = 8.0 * fabs((float)rand()/(float)RAND_MAX); - } else if(type == SLICE_SCN19_SM_V0_FIXED ) { - scn19->conf = SLICE_SCN19_SM_V0_FIXED; - scn19->u.fixed.pos_high = abs(rand()%14); - scn19->u.fixed.pos_low = abs(rand()%10); - } else if(type ==SLICE_SCN19_SM_V0_ON_DEMAND){ - scn19->conf = SLICE_SCN19_SM_V0_ON_DEMAND; -// scn19->u.on_demand.log_delta_byte = abs(rand()%121); - scn19->u.on_demand.log_delta = 1.0 * fabs((float)rand()/(float)RAND_MAX); - scn19->u.on_demand.tau = abs(rand()%256); - scn19->u.on_demand.pct_reserved = fabs((float)rand()/(float)RAND_MAX); - } else { - assert(0 != 0 && "Unknown type!!"); - } - -} - -static -void fill_edf_slice(edf_slice_t* edf) -{ - assert(edf != NULL); - - int mod = 32; - edf->deadline = abs(rand()%mod); - edf->guaranteed_prbs = abs(rand()%mod); - edf->max_replenish = abs(rand()%mod); - - edf->len_over = 1; //abs(rand()%mod); - - if(edf->len_over > 0){ - edf->over = calloc(edf->len_over, sizeof(uint32_t)); - assert(edf->over != NULL && "Memory exhausted"); - } - - for(uint32_t i = 0; i < edf->len_over; ++i){ - edf->over[i] = abs(rand()%mod); - } -} - -static -void fill_ul_dl_slice(ul_dl_slice_conf_t* slice) -{ - assert(slice != NULL); - - char const* name = "MY SLICE"; - slice->len_sched_name = strlen(name); - slice->sched_name = malloc(strlen(name)); - assert(slice->sched_name != NULL && "memory exhausted"); - memcpy(slice->sched_name, name, strlen(name)); - - slice->len_slices = abs(rand()%4); - - if(slice->len_slices > 0){ - slice->slices = calloc(slice->len_slices, sizeof(fr_slice_t)); - assert(slice->slices != NULL && "memory exhausted"); - } - - for(uint32_t i = 0; i < slice->len_slices; ++i){ - slice->slices[i].id = abs(rand()%1024); - fr_slice_t* s = &slice->slices[i]; - - const char* label = "This is my label"; - s->len_label = strlen(label); - s->label = malloc(s->len_label); - assert(s->label != NULL && "Memory exhausted"); - memcpy(s->label, label, s->len_label ); - - const char* sched_str = "Scheduler string"; - s->len_sched = strlen(sched_str); - s->sched = malloc(s->len_sched); - assert(s->sched != NULL && "Memory exhausted"); - memcpy(s->sched, sched_str, s->len_sched); - - uint32_t type = abs(rand()% SLICE_ALG_SM_V0_END); - - if(type == SLICE_ALG_SM_V0_NONE || type == SLICE_ALG_SM_V0_SCN19) - type = SLICE_ALG_SM_V0_STATIC; - - - if(type == SLICE_ALG_SM_V0_NONE ){ - s->params.type =SLICE_ALG_SM_V0_NONE; - } else if (type == SLICE_ALG_SM_V0_STATIC ){ - s->params.type = SLICE_ALG_SM_V0_STATIC; - fill_static_slice(&s->params.u.sta); - } else if (type == SLICE_ALG_SM_V0_NVS){ - s->params.type = SLICE_ALG_SM_V0_NVS; - fill_nvs_slice(&s->params.u.nvs); - } else if (type == SLICE_ALG_SM_V0_SCN19) { - s->params.type = SLICE_ALG_SM_V0_SCN19; - fill_scn19_slice(&s->params.u.scn19); - } else if (type == SLICE_ALG_SM_V0_EDF){ - s->params.type = SLICE_ALG_SM_V0_EDF; - fill_edf_slice(&s->params.u.edf); - } else { - assert(0 != 0 && "Unknown type encountered"); - } - } -} - -static -void fill_slice_conf(slice_conf_t* conf) -{ - assert(conf != NULL); - - fill_ul_dl_slice(&conf->ul); - fill_ul_dl_slice(&conf->dl); -} - -static -void fill_ue_slice_conf(ue_slice_conf_t* conf) -{ - assert(conf != NULL); - conf->len_ue_slice = abs(rand()%10); - if(conf->len_ue_slice > 0){ - conf->ues = calloc(conf->len_ue_slice, sizeof(ue_slice_assoc_t)); - assert(conf->ues != NULL && "memory exhausted"); - } - - for(uint32_t i = 0; i < conf->len_ue_slice; ++i){ - conf->ues[i].rnti = abs(rand()%1024); - conf->ues[i].dl_id = abs(rand()%16); - conf->ues[i].ul_id = abs(rand()%16); - } - -} - -static -void fill_slice_del(del_slice_conf_t* conf) -{ - assert(conf != NULL); - - uint32_t const len_dl = rand()%5; - conf->len_dl = len_dl; - if (conf->len_dl > 0) { - conf->dl = calloc(len_dl, sizeof(uint32_t)); - assert(conf->dl != NULL && "memory exhausted"); - } - for (uint32_t i = 0; i < conf->len_dl; ++i) - conf->dl[i] = abs(rand()%16); - - uint32_t const len_ul = rand()%5; - conf->len_ul = len_ul; - if (conf->len_ul > 0) { - conf->ul = calloc(len_ul, sizeof(uint32_t)); - assert(conf->ul != NULL && "memory exhausted"); - } - for (uint32_t i = 0; i < conf->len_ul; ++i) - conf->ul[i] = abs(rand()%16); - -} - -void fill_slice_ind_data(slice_ind_data_t* ind_msg) -{ - assert(ind_msg != NULL); - - srand(time(0)); - - fill_slice_conf(&ind_msg->msg.slice_conf); - fill_ue_slice_conf(&ind_msg->msg.ue_slice_conf); - ind_msg->msg.tstamp = time_now_us(); -} - -void fill_slice_ctrl(slice_ctrl_req_data_t* ctrl) -{ - assert(ctrl != NULL); - - uint32_t type = rand()%SLICE_CTRL_SM_V0_END; - ctrl->msg.type = type; - - if(type == SLICE_CTRL_SM_V0_ADD){ - fill_slice_conf(&ctrl->msg.u.add_mod_slice); - //printf("SLICE_CTRL_SM_V0_ADD \n"); - } else if (type == SLICE_CTRL_SM_V0_DEL){ - fill_slice_del(&ctrl->msg.u.del_slice); - //printf("SLICE_CTRL_SM_V0_DEL \n"); - } else if (type == SLICE_CTRL_SM_V0_UE_SLICE_ASSOC){ - fill_ue_slice_conf(&ctrl->msg.u.ue_slice); - //printf("SLICE_CTRL_SM_V0_MOD \n"); - } else { - assert(0!=0 && "Unknown type"); - } -} - +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698 + * + * 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. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + + + +#include "fill_rnd_data_slice.h" +#include "../../src/util/time_now_us.h" + +#include +#include +#include +#include +#include + + +static +void fill_static_slice(static_slice_t* sta) +{ + assert(sta != NULL); + + sta->pos_high = abs(rand()%25); + sta->pos_low = abs(rand()%25); +} + + +static +void fill_nvs_slice(nvs_slice_t* nvs) +{ + assert(nvs != NULL); + + const uint32_t type = abs(rand() % SLICE_SM_NVS_V0_END); + + if(type == SLICE_SM_NVS_V0_RATE ){ + nvs->conf = SLICE_SM_NVS_V0_RATE; + nvs->u.rate.u2.mbps_reference = 0.8; +// 10.0*((float)rand()/(float)RAND_MAX); + nvs->u.rate.u1.mbps_required = 10.0; + //*((float)rand()/(float)RAND_MAX); + } else if(type ==SLICE_SM_NVS_V0_CAPACITY ){ + nvs->conf = SLICE_SM_NVS_V0_CAPACITY; + nvs->u.capacity.u.pct_reserved = 15.0; + //*((float)rand()/(float)RAND_MAX); + } else { + assert(0!=0 && "Unknown type"); + } + +} + +static +void fill_scn19_slice(scn19_slice_t* scn19) +{ + assert(scn19 != NULL); + + const uint32_t type = abs(rand()% SLICE_SCN19_SM_V0_END); + + if(type == SLICE_SCN19_SM_V0_DYNAMIC ){ + scn19->conf = SLICE_SCN19_SM_V0_DYNAMIC ; + scn19->u.dynamic.u2.mbps_reference = 10.0 * fabs((float)rand()/(float)RAND_MAX); + scn19->u.dynamic.u1.mbps_required = 8.0 * fabs((float)rand()/(float)RAND_MAX); + } else if(type == SLICE_SCN19_SM_V0_FIXED ) { + scn19->conf = SLICE_SCN19_SM_V0_FIXED; + scn19->u.fixed.pos_high = abs(rand()%14); + scn19->u.fixed.pos_low = abs(rand()%10); + } else if(type ==SLICE_SCN19_SM_V0_ON_DEMAND){ + scn19->conf = SLICE_SCN19_SM_V0_ON_DEMAND; +// scn19->u.on_demand.log_delta_byte = abs(rand()%121); + scn19->u.on_demand.log_delta = 1.0 * fabs((float)rand()/(float)RAND_MAX); + scn19->u.on_demand.tau = abs(rand()%256); + scn19->u.on_demand.pct_reserved = fabs((float)rand()/(float)RAND_MAX); + } else { + assert(0 != 0 && "Unknown type!!"); + } + +} + +static +void fill_edf_slice(edf_slice_t* edf) +{ + assert(edf != NULL); + + int mod = 32; + edf->deadline = abs(rand()%mod); + edf->guaranteed_prbs = abs(rand()%mod); + edf->max_replenish = abs(rand()%mod); + + edf->len_over = 1; //abs(rand()%mod); + + if(edf->len_over > 0){ + edf->over = calloc(edf->len_over, sizeof(uint32_t)); + assert(edf->over != NULL && "Memory exhausted"); + } + + for(uint32_t i = 0; i < edf->len_over; ++i){ + edf->over[i] = abs(rand()%mod); + } +} + +static +void fill_ul_dl_slice(ul_dl_slice_conf_t* slice) +{ + assert(slice != NULL); + + char const* name = "MY SLICE"; + slice->len_sched_name = strlen(name); + slice->sched_name = malloc(strlen(name)); + assert(slice->sched_name != NULL && "memory exhausted"); + memcpy(slice->sched_name, name, strlen(name)); + + slice->len_slices = abs(rand()%4); + + if(slice->len_slices > 0){ + slice->slices = calloc(slice->len_slices, sizeof(fr_slice_t)); + assert(slice->slices != NULL && "memory exhausted"); + } + + for(uint32_t i = 0; i < slice->len_slices; ++i){ + slice->slices[i].id = abs(rand()%1024); + fr_slice_t* s = &slice->slices[i]; + + const char* label = "This is my label"; + s->len_label = strlen(label); + s->label = malloc(s->len_label); + assert(s->label != NULL && "Memory exhausted"); + memcpy(s->label, label, s->len_label ); + + const char* sched_str = "Scheduler string"; + s->len_sched = strlen(sched_str); + s->sched = malloc(s->len_sched); + assert(s->sched != NULL && "Memory exhausted"); + memcpy(s->sched, sched_str, s->len_sched); + + uint32_t type = abs(rand()% SLICE_ALG_SM_V0_END); + + if(type == SLICE_ALG_SM_V0_NONE || type == SLICE_ALG_SM_V0_SCN19) + type = SLICE_ALG_SM_V0_STATIC; + + + if(type == SLICE_ALG_SM_V0_NONE ){ + s->params.type =SLICE_ALG_SM_V0_NONE; + } else if (type == SLICE_ALG_SM_V0_STATIC ){ + s->params.type = SLICE_ALG_SM_V0_STATIC; + fill_static_slice(&s->params.u.sta); + } else if (type == SLICE_ALG_SM_V0_NVS){ + s->params.type = SLICE_ALG_SM_V0_NVS; + fill_nvs_slice(&s->params.u.nvs); + } else if (type == SLICE_ALG_SM_V0_SCN19) { + s->params.type = SLICE_ALG_SM_V0_SCN19; + fill_scn19_slice(&s->params.u.scn19); + } else if (type == SLICE_ALG_SM_V0_EDF){ + s->params.type = SLICE_ALG_SM_V0_EDF; + fill_edf_slice(&s->params.u.edf); + } else { + assert(0 != 0 && "Unknown type encountered"); + } + } +} + +static +void fill_slice_conf(slice_conf_t* conf) +{ + assert(conf != NULL); + + fill_ul_dl_slice(&conf->ul); + fill_ul_dl_slice(&conf->dl); +} + +static +void fill_ue_slice_conf(ue_slice_conf_t* conf) +{ + assert(conf != NULL); + conf->len_ue_slice = abs(rand()%10); + if(conf->len_ue_slice > 0){ + conf->ues = calloc(conf->len_ue_slice, sizeof(ue_slice_assoc_t)); + assert(conf->ues != NULL && "memory exhausted"); + } + + for(uint32_t i = 0; i < conf->len_ue_slice; ++i){ + conf->ues[i].rnti = abs(rand()%1024); + conf->ues[i].dl_id = abs(rand()%16); + conf->ues[i].ul_id = abs(rand()%16); + } + +} + +static +void fill_slice_del(del_slice_conf_t* conf) +{ + assert(conf != NULL); + + uint32_t const len_dl = rand()%5; + conf->len_dl = len_dl; + if (conf->len_dl > 0) { + conf->dl = calloc(len_dl, sizeof(uint32_t)); + assert(conf->dl != NULL && "memory exhausted"); + } + for (uint32_t i = 0; i < conf->len_dl; ++i) + conf->dl[i] = abs(rand()%16); + + uint32_t const len_ul = rand()%5; + conf->len_ul = len_ul; + if (conf->len_ul > 0) { + conf->ul = calloc(len_ul, sizeof(uint32_t)); + assert(conf->ul != NULL && "memory exhausted"); + } + for (uint32_t i = 0; i < conf->len_ul; ++i) + conf->ul[i] = abs(rand()%16); + +} + +void fill_slice_ind_data(slice_ind_data_t* ind_msg) +{ + assert(ind_msg != NULL); + + srand(time(0)); + + fill_slice_conf(&ind_msg->msg.slice_conf); + fill_ue_slice_conf(&ind_msg->msg.ue_slice_conf); + ind_msg->msg.tstamp = time_now_us(); +} + +void fill_slice_ctrl(slice_ctrl_req_data_t* ctrl) +{ + assert(ctrl != NULL); + + uint32_t type = rand()%SLICE_CTRL_SM_V0_END; + ctrl->msg.type = type; + + if(type == SLICE_CTRL_SM_V0_ADD){ + fill_slice_conf(&ctrl->msg.u.add_mod_slice); + //printf("SLICE_CTRL_SM_V0_ADD \n"); + } else if (type == SLICE_CTRL_SM_V0_DEL){ + fill_slice_del(&ctrl->msg.u.del_slice); + //printf("SLICE_CTRL_SM_V0_DEL \n"); + } else if (type == SLICE_CTRL_SM_V0_UE_SLICE_ASSOC){ + fill_ue_slice_conf(&ctrl->msg.u.ue_slice); + //printf("SLICE_CTRL_SM_V0_MOD \n"); + } else { + assert(0!=0 && "Unknown type"); + } +} + diff --git a/libs/test/rnd/fill_rnd_data_slice.h b/libs/test/rnd/fill_rnd_data_slice.h index 8e3f3c8..4e3599f 100644 --- a/libs/test/rnd/fill_rnd_data_slice.h +++ b/libs/test/rnd/fill_rnd_data_slice.h @@ -1,32 +1,32 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698 - * - * 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. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#ifndef FILL_RND_DATA_SLICE_H -#define FILL_RND_DATA_SLICE_H - -#include "../../src/sm/slice_sm/ie/slice_data_ie.h" - -void fill_slice_ind_data(slice_ind_data_t* ind); - -void fill_slice_ctrl(slice_ctrl_req_data_t* ctrl); - - -#endif +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698 + * + * 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. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#ifndef FILL_RND_DATA_SLICE_H +#define FILL_RND_DATA_SLICE_H + +#include "../../src/sm/slice_sm/ie/slice_data_ie.h" + +void fill_slice_ind_data(slice_ind_data_t* ind); + +void fill_slice_ctrl(slice_ctrl_req_data_t* ctrl); + + +#endif diff --git a/libs/test/rnd/fill_rnd_data_tc.c b/libs/test/rnd/fill_rnd_data_tc.c index ec5e2e6..4220971 100644 --- a/libs/test/rnd/fill_rnd_data_tc.c +++ b/libs/test/rnd/fill_rnd_data_tc.c @@ -1,655 +1,655 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698 - * - * 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. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include "fill_rnd_data_tc.h" -#include "../../src/util/time_now_us.h" - -#include -#include -#include - - -static -void fill_tc_mtr(tc_mtr_t* mtr) -{ - assert(mtr != NULL); - - mtr->time_window_ms = rand() % 124; - mtr->bnd_flt = 16.3; -} - -static -void fill_tc_sch(tc_sch_t* sch) -{ - assert(sch != NULL); - sch->type = rand()%TC_SCHED_END; - if(sch->type == TC_SCHED_RR){ -// sch->rr = ; - } else if(sch->type == TC_SCHED_PRIO){ - sch->prio.len_q_prio = rand()%2; - sch->prio.q_prio = calloc(sch->prio.len_q_prio, sizeof(*sch->prio.q_prio) ); - assert(sch->prio.q_prio != NULL && "Memory exhausted"); - for(size_t i = 0; i < sch->prio.len_q_prio; ++i){ - sch->prio.q_prio[i] = rand()%16; - } - } else { - assert(0!=0 && "Unknown scheduler type"); - } -} - -static -void fill_tc_pcr(tc_pcr_t* pcr) -{ - assert(pcr != NULL); - pcr->type = rand()% TC_PCR_END; - - if(pcr->type == TC_PCR_DUMMY){ - pcr->id = rand()%16; - fill_tc_mtr(&pcr->mtr); - } else if(pcr->type == TC_PCR_5G_BDP){ - pcr->id = rand()%16; - fill_tc_mtr(&pcr->mtr); - } else { - assert(0 !=0 && "Unknown pacer"); - } -} - -static -void fill_l3(L3_filter_t* l3) -{ - assert(l3 != NULL); - l3->src_addr = rand()% 4096*1024; - l3->dst_addr = rand()% 4096*1024; -} - -static -void fill_l4(L4_filter_t* l4 ) -{ - assert(l4 != NULL); - - l4->src_port = rand()%1024; - l4->dst_port = rand()%1024; - l4->protocol = 17; -} - -static -void fill_l7(L7_filter_t* l7) -{ - assert(l7 != NULL); - -} - -static -void fill_tc_cls(tc_cls_t* cls) -{ - assert(cls != NULL); - cls->type = rand()%TC_CLS_END; - - if(cls->type == TC_CLS_RR){ - cls->rr.dummy = rand()%16; - } else if(cls->type == TC_CLS_OSI){ - - cls->osi.len = rand()%8; - if(cls->osi.len > 0){ - cls->osi.flt = calloc(cls->osi.len, sizeof(tc_cls_osi_filter_t) ); - assert(cls->osi.flt != NULL && "memory exhausted"); - } - - for(size_t i = 0; i < cls->osi.len; ++i){ - cls->osi.flt[i].id = rand()%128; - fill_l3(&cls->osi.flt[i].l3); - fill_l4(&cls->osi.flt[i].l4); - fill_l7(&cls->osi.flt[i].l7); - cls->osi.flt[i].dst_queue = rand()%8; - } - - } else if(cls->type == TC_CLS_STO){ - cls->sto.dummy = rand()%16; - } else { - assert("Unknown classifier type"); - } - -} - -static -void fill_tc_drp(tc_drp_t* drp) -{ - assert(drp != NULL); - drp->dropped_pkts = rand()%1000; -} - -static -void fill_tc_mrk(tc_mrk_t* mrk) -{ - mrk->marked_pkts = rand()%8; -} - -static -void fill_tc_queue(tc_queue_t* q) -{ - assert(q != NULL); - - q->type = rand()%TC_QUEUE_END; - q->id = rand()%16; - - if(q->type == TC_QUEUE_FIFO){ - q->fifo.bytes = rand()%10000; - q->fifo.pkts = rand()%10000; - q->fifo.bytes_fwd = rand()%10000; - q->fifo.pkts_fwd = rand()%10000; - q->fifo.avg_sojourn_time = 100.5; - q->fifo.last_sojourn_time = rand()%100; - fill_tc_drp(&q->fifo.drp); - - } else if(q->type == TC_QUEUE_CODEL){ - q->codel.bytes = rand()%10000; - q->codel.pkts = rand()%10000; - q->codel.bytes_fwd = rand()%10000; - q->codel.pkts_fwd = rand()%10000; - q->codel.avg_sojourn_time = 100.5; - q->codel.last_sojourn_time = rand()%100; - fill_tc_drp(&q->codel.drp); - } else if(q->type == TC_QUEUE_ECN_CODEL){ - q->ecn.bytes = rand()%10000; - q->ecn.pkts = rand()%10000; - q->ecn.bytes_fwd = rand()%10000; - q->ecn.pkts_fwd = rand()%10000; - q->ecn.avg_sojourn_time = 100.5; - q->ecn.last_sojourn_time = rand()%100; - fill_tc_mrk(&q->ecn.mrk); - } else { - assert(0!=0 && "Unknown queue type"); - } -} - -static -void fill_tc_shp(tc_shp_t* s) -{ - assert(s != NULL); - - s->id = rand()%16; - s->active = rand()%2; - fill_tc_mtr(&s->mtr); -} - -static -void fill_tc_plc(tc_plc_t* p) -{ - assert(p != NULL); - - p->id = rand() % 1024; - fill_tc_mtr(&p->mtr); - fill_tc_drp(&p->drp); - fill_tc_mrk(&p->mrk); - p->max_rate_kbps = 124.5; - p->active = rand()%2; - p->dst_id = rand()%16; - p->dev_id = rand()%16; -} - - -static -void fill_tc_shp_q_plc(tc_ind_msg_t* msg) -{ - assert(msg != NULL); - msg->len_q = rand()%16; - - msg->q = calloc(msg->len_q, sizeof(tc_queue_t)); - assert(msg->q != NULL && "Memory exhausted"); - - msg->shp = calloc(msg->len_q, sizeof(tc_shp_t)); - assert(msg->shp != NULL && "Memory exhausted"); - - msg->plc = calloc(msg->len_q, sizeof(tc_plc_t)); - assert(msg->plc != NULL && "Memory exhausted"); - - for(size_t i = 0; i < msg->len_q; ++i){ - fill_tc_queue(&msg->q[i]); - fill_tc_shp(&msg->shp[i]); - fill_tc_plc(&msg->plc[i]); - } - -} - - - -void fill_tc_ind_data(tc_ind_data_t* ind_msg) -{ - assert(ind_msg != NULL); - - srand(time(0)); - - ind_msg->msg.tstamp = time_now_us(); - - fill_tc_sch(&ind_msg->msg.sch); - fill_tc_pcr(&ind_msg->msg.pcr); - fill_tc_cls(&ind_msg->msg.cls); - fill_tc_shp_q_plc(&ind_msg->msg); - -} - - -static -void fill_tc_ctrl_cls_add(tc_add_ctrl_cls_t* add) -{ - assert(add != NULL); - - tc_cls_e type = rand() % TC_CLS_END; - add->type = type; - - if(type == TC_CLS_RR){ - add->rr.dummy = rand()%16; - } else if(type == TC_CLS_OSI){ - add->osi.dst_queue = rand()%16; - fill_l3(&add->osi.l3); - fill_l4(&add->osi.l4); - fill_l7(&add->osi.l7); - } else if(type == TC_CLS_STO){ - add->sto.dummy = rand()%16; - } else { - assert(0!=0 && "Unknown classifier type"); - } -} - -static -void fill_tc_ctrl_cls_del(tc_del_ctrl_cls_t* del) -{ - assert(del != NULL); - - tc_cls_e type = rand() % TC_CLS_END; - del->type = type; - - if(type == TC_CLS_RR){ - del->rr.dummy = rand()%16; - } else if(type == TC_CLS_OSI){ - del->osi.filter_id = rand()%256; - } else if(type == TC_CLS_STO){ - del->sto.dummy = rand()%16; - } else { - assert(0!=0 && "Unknown classifier type"); - } - -} - -static -void fill_tc_ctrl_cls_mod(tc_mod_ctrl_cls_t* mod) -{ - assert(mod != NULL); - - tc_cls_e type = rand() % TC_CLS_END; - mod->type = type; - - if(type == TC_CLS_RR){ - mod->rr.dummy = rand()%16; - } else if(type == TC_CLS_OSI){ - mod->osi.filter.id = rand()%256; - mod->osi.filter.dst_queue = rand()%256; - fill_l3(&mod->osi.filter.l3) ; - fill_l4(&mod->osi.filter.l4) ; - fill_l7(&mod->osi.filter.l7) ; - } else if(type == TC_CLS_STO){ - mod->sto.dummy = rand()%16; - } else { - assert(0!=0 && "Unknown classifier type"); - } -} - -static -void fill_tc_ctrl_cls(tc_ctrl_cls_t* cls) -{ - assert(cls != NULL); - - cls->act = rand()%TC_CTRL_ACTION_SM_V0_END; - - if(cls->act == TC_CTRL_ACTION_SM_V0_ADD){ - fill_tc_ctrl_cls_add(&cls->add); - } else if(cls->act == TC_CTRL_ACTION_SM_V0_DEL){ - fill_tc_ctrl_cls_del(&cls->del); - } else if(cls->act == TC_CTRL_ACTION_SM_V0_MOD){ - fill_tc_ctrl_cls_mod(&cls->mod); - } else { - assert(0!=0 && "Unknown action type" ); - } - - -/* - uint32_t type = rand() % TC_CLS_END; - - cls->type = type; - - if(type == TC_CLS_RR){ - cls->rr.dummy = rand()%16; - } else if (type == TC_CLS_OSI){ - cls->osi.dummy = rand()%16; - } else if (type == TC_CLS_STO){ - cls->sto.dummy = rand()%16; - } else { - assert("Unknown classifier type"); - } -*/ - - -} - -static -void fill_tc_ctrl_plc(tc_ctrl_plc_t* plc) -{ - assert(plc != NULL); - - tc_ctrl_act_e act = rand() % TC_CTRL_ACTION_SM_V0_END; - plc->act = act; - - if(act == TC_CTRL_ACTION_SM_V0_ADD){ - plc->add.dummy = rand()%16; - } else if(act == TC_CTRL_ACTION_SM_V0_DEL){ - plc->del.id = rand()%8; - } else if(act == TC_CTRL_ACTION_SM_V0_MOD){ - plc->mod.id = rand()%16; - plc->mod.drop_rate_kbps = rand()%16; - plc->mod.dev_id = rand()%16 ; - plc->mod.dev_rate_kbps = rand()% 4096; - plc->mod.active = rand()%2; - } else { - assert(0!=0 && "Unknown action type"); - } -} - -static -void fill_tc_ctrl_queue_fifo( tc_ctrl_queue_fifo_t* fifo) -{ - assert(fifo != NULL); - fifo->dummy = rand()%128; -} - -static -void fill_tc_ctrl_queue_codel(tc_ctrl_queue_codel_t* codel) -{ - assert(codel != NULL); - - codel->interval_ms = rand()%256 + 100; - codel-> target_ms = rand()%10 + 5; -} - -static -void fill_tc_ctrl_queue_ecn_codel(tc_ctrl_queue_ecn_codel_t* ecn) -{ - assert(ecn != NULL); - - ecn->interval_ms = rand()%256 + 100; - ecn->target_ms = rand()%10 + 5; -} - -static -void fill_tc_ctrl_queue_add(tc_add_ctrl_queue_t* add) -{ - assert(add != NULL); - - add->type = rand() % TC_QUEUE_END; - - if(add->type == TC_QUEUE_FIFO ){ - fill_tc_ctrl_queue_fifo(&add->fifo); - } else if(add->type == TC_QUEUE_CODEL){ - fill_tc_ctrl_queue_codel(&add->codel); - } else if(add->type == TC_QUEUE_ECN_CODEL){ - fill_tc_ctrl_queue_ecn_codel(&add->ecn); - } else { - assert(0!=0 && "Unknown type"); - } -} - -static -void fill_tc_ctrl_queue_del(tc_del_ctrl_queue_t* del) -{ - assert(del != NULL); - - del->id = rand() % 10; - del->type = rand() % TC_QUEUE_END; -} - -static -void fill_tc_ctrl_queue_mod(tc_mod_ctrl_queue_t* mod) -{ - assert(mod != NULL); - - mod->id = rand() % 10; - mod->type = rand() % TC_QUEUE_END; - - if(mod->type == TC_QUEUE_FIFO ){ - fill_tc_ctrl_queue_fifo(&mod->fifo); - } else if(mod->type == TC_QUEUE_CODEL){ - fill_tc_ctrl_queue_codel(&mod->codel); - } else if(mod->type == TC_QUEUE_ECN_CODEL){ - fill_tc_ctrl_queue_ecn_codel(&mod->ecn); - } else { - assert(0!=0 && "Unknown type"); - } - -} - - -static -void fill_tc_ctrl_queue(tc_ctrl_queue_t* q) -{ - assert(q != NULL); - - tc_ctrl_act_e act = rand()%TC_CTRL_ACTION_SM_V0_END; - q->act = act; - - if(act == TC_CTRL_ACTION_SM_V0_ADD){ - fill_tc_ctrl_queue_add(&q->add); - } else if (act == TC_CTRL_ACTION_SM_V0_DEL){ - fill_tc_ctrl_queue_del(&q->del); - } else if (act == TC_CTRL_ACTION_SM_V0_MOD){ - fill_tc_ctrl_queue_mod(&q->mod); - } else { - assert(0!=0 && "Unknown actio type"); - } - -/* - tc_queue_e type = rand() % TC_QUEUE_END; - q->type = type; - q->id = rand() % 16; - - if(type == TC_QUEUE_FIFO){ - fill_tc_ctrl_queue_fifo(&q->fifo); - } else if(type == TC_QUEUE_CODEL){ - fill_tc_ctrl_queue_codel(&q->codel); - } else { - assert(0!=0 && "Unknown queue type"); - } -*/ - -} - -static -void fill_tc_ctrl_sch_add(tc_add_ctrl_sch_t* add) -{ - assert(add != NULL); - - add->dummy = rand()%16; -} - -static -void fill_tc_ctrl_sch_del(tc_del_ctrl_sch_t* del) -{ - assert(del != NULL); - - del->dummy = rand()%16; -} - -static -void fill_tc_ctrl_sch_mod(tc_mod_ctrl_sch_t* mod) -{ - assert(mod != NULL); - - tc_sch_e type = rand()%TC_SCHED_END; - mod->type = type; - - if(type == TC_SCHED_RR){ - mod->rr.dummy = rand()%8; - } else if(type == TC_SCHED_PRIO ){ - - mod->prio.len_q_prio = rand()%8; - if(mod->prio.len_q_prio > 0){ - mod->prio.q_prio = calloc(mod->prio.len_q_prio, sizeof(uint32_t)); - assert(mod->prio.q_prio != NULL && "Memory exhausted"); - } - - for(size_t i = 0; i < mod->prio.len_q_prio; ++i){ - mod->prio.q_prio[i] = rand()%16; - } - - } else { - assert(0!=0 && "scheduler type unknown"); - } - -} - - -static -void fill_tc_ctrl_sch(tc_ctrl_sch_t* sch) -{ - assert(sch != NULL); - - tc_ctrl_act_e act = rand()%TC_CTRL_ACTION_SM_V0_END; - sch->act = act; - - if(act == TC_CTRL_ACTION_SM_V0_ADD){ - fill_tc_ctrl_sch_add(&sch->add); - } else if (act == TC_CTRL_ACTION_SM_V0_DEL){ - fill_tc_ctrl_sch_del(&sch->del); - } else if (act == TC_CTRL_ACTION_SM_V0_MOD){ - fill_tc_ctrl_sch_mod(&sch->mod); - } else { - assert(0!=0 && "Unknown actio type"); - } -/* - sch->type = rand()%TC_SCHED_END; - - if(sch->type == TC_SCHED_RR){ - - } else if(sch->type == TC_SCHED_PRIO){ - - } else { - assert(0!=0 && "Unknown scheduler type"); - } -*/ - -} - -static -void fill_tc_mod_ctrl_shp(tc_mod_ctrl_shp_t* mod) -{ - assert(mod != NULL); - - mod->id = rand()%128; - mod->time_window_ms = rand()%128; - mod->max_rate_kbps = rand()%1024; - mod->active = rand()%2; -} - -static -void fill_tc_ctrl_shp(tc_ctrl_shp_t* shp) -{ - assert(shp != NULL); - - tc_ctrl_act_e act = rand()%TC_CTRL_ACTION_SM_V0_END; - shp->act = act; - - if(act == TC_CTRL_ACTION_SM_V0_ADD){ - shp->add.dummy = rand()%16; - } else if(act == TC_CTRL_ACTION_SM_V0_DEL){ - shp->del.id = rand()%16; - } else if(act == TC_CTRL_ACTION_SM_V0_MOD){ - fill_tc_mod_ctrl_shp(&shp->mod); - } else { - assert(0!=0 && "Unknown action type"); - } -} - -static -void fill_tc_mod_ctrl_pcr(tc_mod_ctrl_pcr_t* mod) -{ - assert(mod != NULL); - - tc_pcr_e type = rand()% TC_PCR_END; - mod->type = type; - - if(type == TC_PCR_DUMMY){ - mod->dummy.dummy = rand()%16; - } else if(type == TC_PCR_5G_BDP) { - mod->bdp. drb_sz = rand()% 2048; - mod->bdp.tstamp = 10000 + rand()% 2048; - } else { - assert(0!=0 && "unknown type"); - } - -} - - -static -void fill_tc_ctrl_pcr(tc_ctrl_pcr_t* pcr) -{ - assert(pcr != NULL); - - tc_ctrl_act_e act = rand()%TC_CTRL_ACTION_SM_V0_END; - pcr->act = act; - - if(act == TC_CTRL_ACTION_SM_V0_ADD){ - pcr->add.dummy = rand()%32; - } else if(act == TC_CTRL_ACTION_SM_V0_DEL){ - pcr->del.dummy = rand()%32; - } else if(act == TC_CTRL_ACTION_SM_V0_MOD){ - fill_tc_mod_ctrl_pcr(&pcr->mod); - } else { - assert(0!=0 && "Unknown action type"); - } - -} - -void fill_tc_ctrl(tc_ctrl_req_data_t* ctrl) -{ - assert(ctrl != NULL); - - ctrl->hdr.dummy = rand() % 16; - - uint32_t const type = rand()%TC_CTRL_SM_V0_END; - ctrl->msg.type = type; - - if(type == TC_CTRL_SM_V0_CLS){ - fill_tc_ctrl_cls(&ctrl->msg.cls); - } else if(type == TC_CTRL_SM_V0_PLC) { - fill_tc_ctrl_plc(&ctrl->msg.plc); - } else if(type == TC_CTRL_SM_V0_QUEUE){ - fill_tc_ctrl_queue(&ctrl->msg.q); - } else if(type == TC_CTRL_SM_V0_SCH){ - fill_tc_ctrl_sch(&ctrl->msg.sch); - } else if(type == TC_CTRL_SM_V0_SHP){ - fill_tc_ctrl_shp(&ctrl->msg.shp); - } else if(type == TC_CTRL_SM_V0_PCR){ - fill_tc_ctrl_pcr(&ctrl->msg.pcr); - } else { - assert(0!=0 && "Unknown type"); - } - -} - - +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698 + * + * 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. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#include "fill_rnd_data_tc.h" +#include "../../src/util/time_now_us.h" + +#include +#include +#include + + +static +void fill_tc_mtr(tc_mtr_t* mtr) +{ + assert(mtr != NULL); + + mtr->time_window_ms = rand() % 124; + mtr->bnd_flt = 16.3; +} + +static +void fill_tc_sch(tc_sch_t* sch) +{ + assert(sch != NULL); + sch->type = rand()%TC_SCHED_END; + if(sch->type == TC_SCHED_RR){ +// sch->rr = ; + } else if(sch->type == TC_SCHED_PRIO){ + sch->prio.len_q_prio = rand()%2; + sch->prio.q_prio = calloc(sch->prio.len_q_prio, sizeof(*sch->prio.q_prio) ); + assert(sch->prio.q_prio != NULL && "Memory exhausted"); + for(size_t i = 0; i < sch->prio.len_q_prio; ++i){ + sch->prio.q_prio[i] = rand()%16; + } + } else { + assert(0!=0 && "Unknown scheduler type"); + } +} + +static +void fill_tc_pcr(tc_pcr_t* pcr) +{ + assert(pcr != NULL); + pcr->type = rand()% TC_PCR_END; + + if(pcr->type == TC_PCR_DUMMY){ + pcr->id = rand()%16; + fill_tc_mtr(&pcr->mtr); + } else if(pcr->type == TC_PCR_5G_BDP){ + pcr->id = rand()%16; + fill_tc_mtr(&pcr->mtr); + } else { + assert(0 !=0 && "Unknown pacer"); + } +} + +static +void fill_l3(L3_filter_t* l3) +{ + assert(l3 != NULL); + l3->src_addr = rand()% 4096*1024; + l3->dst_addr = rand()% 4096*1024; +} + +static +void fill_l4(L4_filter_t* l4 ) +{ + assert(l4 != NULL); + + l4->src_port = rand()%1024; + l4->dst_port = rand()%1024; + l4->protocol = 17; +} + +static +void fill_l7(L7_filter_t* l7) +{ + assert(l7 != NULL); + +} + +static +void fill_tc_cls(tc_cls_t* cls) +{ + assert(cls != NULL); + cls->type = rand()%TC_CLS_END; + + if(cls->type == TC_CLS_RR){ + cls->rr.dummy = rand()%16; + } else if(cls->type == TC_CLS_OSI){ + + cls->osi.len = rand()%8; + if(cls->osi.len > 0){ + cls->osi.flt = calloc(cls->osi.len, sizeof(tc_cls_osi_filter_t) ); + assert(cls->osi.flt != NULL && "memory exhausted"); + } + + for(size_t i = 0; i < cls->osi.len; ++i){ + cls->osi.flt[i].id = rand()%128; + fill_l3(&cls->osi.flt[i].l3); + fill_l4(&cls->osi.flt[i].l4); + fill_l7(&cls->osi.flt[i].l7); + cls->osi.flt[i].dst_queue = rand()%8; + } + + } else if(cls->type == TC_CLS_STO){ + cls->sto.dummy = rand()%16; + } else { + assert("Unknown classifier type"); + } + +} + +static +void fill_tc_drp(tc_drp_t* drp) +{ + assert(drp != NULL); + drp->dropped_pkts = rand()%1000; +} + +static +void fill_tc_mrk(tc_mrk_t* mrk) +{ + mrk->marked_pkts = rand()%8; +} + +static +void fill_tc_queue(tc_queue_t* q) +{ + assert(q != NULL); + + q->type = rand()%TC_QUEUE_END; + q->id = rand()%16; + + if(q->type == TC_QUEUE_FIFO){ + q->fifo.bytes = rand()%10000; + q->fifo.pkts = rand()%10000; + q->fifo.bytes_fwd = rand()%10000; + q->fifo.pkts_fwd = rand()%10000; + q->fifo.avg_sojourn_time = 100.5; + q->fifo.last_sojourn_time = rand()%100; + fill_tc_drp(&q->fifo.drp); + + } else if(q->type == TC_QUEUE_CODEL){ + q->codel.bytes = rand()%10000; + q->codel.pkts = rand()%10000; + q->codel.bytes_fwd = rand()%10000; + q->codel.pkts_fwd = rand()%10000; + q->codel.avg_sojourn_time = 100.5; + q->codel.last_sojourn_time = rand()%100; + fill_tc_drp(&q->codel.drp); + } else if(q->type == TC_QUEUE_ECN_CODEL){ + q->ecn.bytes = rand()%10000; + q->ecn.pkts = rand()%10000; + q->ecn.bytes_fwd = rand()%10000; + q->ecn.pkts_fwd = rand()%10000; + q->ecn.avg_sojourn_time = 100.5; + q->ecn.last_sojourn_time = rand()%100; + fill_tc_mrk(&q->ecn.mrk); + } else { + assert(0!=0 && "Unknown queue type"); + } +} + +static +void fill_tc_shp(tc_shp_t* s) +{ + assert(s != NULL); + + s->id = rand()%16; + s->active = rand()%2; + fill_tc_mtr(&s->mtr); +} + +static +void fill_tc_plc(tc_plc_t* p) +{ + assert(p != NULL); + + p->id = rand() % 1024; + fill_tc_mtr(&p->mtr); + fill_tc_drp(&p->drp); + fill_tc_mrk(&p->mrk); + p->max_rate_kbps = 124.5; + p->active = rand()%2; + p->dst_id = rand()%16; + p->dev_id = rand()%16; +} + + +static +void fill_tc_shp_q_plc(tc_ind_msg_t* msg) +{ + assert(msg != NULL); + msg->len_q = rand()%16; + + msg->q = calloc(msg->len_q, sizeof(tc_queue_t)); + assert(msg->q != NULL && "Memory exhausted"); + + msg->shp = calloc(msg->len_q, sizeof(tc_shp_t)); + assert(msg->shp != NULL && "Memory exhausted"); + + msg->plc = calloc(msg->len_q, sizeof(tc_plc_t)); + assert(msg->plc != NULL && "Memory exhausted"); + + for(size_t i = 0; i < msg->len_q; ++i){ + fill_tc_queue(&msg->q[i]); + fill_tc_shp(&msg->shp[i]); + fill_tc_plc(&msg->plc[i]); + } + +} + + + +void fill_tc_ind_data(tc_ind_data_t* ind_msg) +{ + assert(ind_msg != NULL); + + srand(time(0)); + + ind_msg->msg.tstamp = time_now_us(); + + fill_tc_sch(&ind_msg->msg.sch); + fill_tc_pcr(&ind_msg->msg.pcr); + fill_tc_cls(&ind_msg->msg.cls); + fill_tc_shp_q_plc(&ind_msg->msg); + +} + + +static +void fill_tc_ctrl_cls_add(tc_add_ctrl_cls_t* add) +{ + assert(add != NULL); + + tc_cls_e type = rand() % TC_CLS_END; + add->type = type; + + if(type == TC_CLS_RR){ + add->rr.dummy = rand()%16; + } else if(type == TC_CLS_OSI){ + add->osi.dst_queue = rand()%16; + fill_l3(&add->osi.l3); + fill_l4(&add->osi.l4); + fill_l7(&add->osi.l7); + } else if(type == TC_CLS_STO){ + add->sto.dummy = rand()%16; + } else { + assert(0!=0 && "Unknown classifier type"); + } +} + +static +void fill_tc_ctrl_cls_del(tc_del_ctrl_cls_t* del) +{ + assert(del != NULL); + + tc_cls_e type = rand() % TC_CLS_END; + del->type = type; + + if(type == TC_CLS_RR){ + del->rr.dummy = rand()%16; + } else if(type == TC_CLS_OSI){ + del->osi.filter_id = rand()%256; + } else if(type == TC_CLS_STO){ + del->sto.dummy = rand()%16; + } else { + assert(0!=0 && "Unknown classifier type"); + } + +} + +static +void fill_tc_ctrl_cls_mod(tc_mod_ctrl_cls_t* mod) +{ + assert(mod != NULL); + + tc_cls_e type = rand() % TC_CLS_END; + mod->type = type; + + if(type == TC_CLS_RR){ + mod->rr.dummy = rand()%16; + } else if(type == TC_CLS_OSI){ + mod->osi.filter.id = rand()%256; + mod->osi.filter.dst_queue = rand()%256; + fill_l3(&mod->osi.filter.l3) ; + fill_l4(&mod->osi.filter.l4) ; + fill_l7(&mod->osi.filter.l7) ; + } else if(type == TC_CLS_STO){ + mod->sto.dummy = rand()%16; + } else { + assert(0!=0 && "Unknown classifier type"); + } +} + +static +void fill_tc_ctrl_cls(tc_ctrl_cls_t* cls) +{ + assert(cls != NULL); + + cls->act = rand()%TC_CTRL_ACTION_SM_V0_END; + + if(cls->act == TC_CTRL_ACTION_SM_V0_ADD){ + fill_tc_ctrl_cls_add(&cls->add); + } else if(cls->act == TC_CTRL_ACTION_SM_V0_DEL){ + fill_tc_ctrl_cls_del(&cls->del); + } else if(cls->act == TC_CTRL_ACTION_SM_V0_MOD){ + fill_tc_ctrl_cls_mod(&cls->mod); + } else { + assert(0!=0 && "Unknown action type" ); + } + + +/* + uint32_t type = rand() % TC_CLS_END; + + cls->type = type; + + if(type == TC_CLS_RR){ + cls->rr.dummy = rand()%16; + } else if (type == TC_CLS_OSI){ + cls->osi.dummy = rand()%16; + } else if (type == TC_CLS_STO){ + cls->sto.dummy = rand()%16; + } else { + assert("Unknown classifier type"); + } +*/ + + +} + +static +void fill_tc_ctrl_plc(tc_ctrl_plc_t* plc) +{ + assert(plc != NULL); + + tc_ctrl_act_e act = rand() % TC_CTRL_ACTION_SM_V0_END; + plc->act = act; + + if(act == TC_CTRL_ACTION_SM_V0_ADD){ + plc->add.dummy = rand()%16; + } else if(act == TC_CTRL_ACTION_SM_V0_DEL){ + plc->del.id = rand()%8; + } else if(act == TC_CTRL_ACTION_SM_V0_MOD){ + plc->mod.id = rand()%16; + plc->mod.drop_rate_kbps = rand()%16; + plc->mod.dev_id = rand()%16 ; + plc->mod.dev_rate_kbps = rand()% 4096; + plc->mod.active = rand()%2; + } else { + assert(0!=0 && "Unknown action type"); + } +} + +static +void fill_tc_ctrl_queue_fifo( tc_ctrl_queue_fifo_t* fifo) +{ + assert(fifo != NULL); + fifo->dummy = rand()%128; +} + +static +void fill_tc_ctrl_queue_codel(tc_ctrl_queue_codel_t* codel) +{ + assert(codel != NULL); + + codel->interval_ms = rand()%256 + 100; + codel-> target_ms = rand()%10 + 5; +} + +static +void fill_tc_ctrl_queue_ecn_codel(tc_ctrl_queue_ecn_codel_t* ecn) +{ + assert(ecn != NULL); + + ecn->interval_ms = rand()%256 + 100; + ecn->target_ms = rand()%10 + 5; +} + +static +void fill_tc_ctrl_queue_add(tc_add_ctrl_queue_t* add) +{ + assert(add != NULL); + + add->type = rand() % TC_QUEUE_END; + + if(add->type == TC_QUEUE_FIFO ){ + fill_tc_ctrl_queue_fifo(&add->fifo); + } else if(add->type == TC_QUEUE_CODEL){ + fill_tc_ctrl_queue_codel(&add->codel); + } else if(add->type == TC_QUEUE_ECN_CODEL){ + fill_tc_ctrl_queue_ecn_codel(&add->ecn); + } else { + assert(0!=0 && "Unknown type"); + } +} + +static +void fill_tc_ctrl_queue_del(tc_del_ctrl_queue_t* del) +{ + assert(del != NULL); + + del->id = rand() % 10; + del->type = rand() % TC_QUEUE_END; +} + +static +void fill_tc_ctrl_queue_mod(tc_mod_ctrl_queue_t* mod) +{ + assert(mod != NULL); + + mod->id = rand() % 10; + mod->type = rand() % TC_QUEUE_END; + + if(mod->type == TC_QUEUE_FIFO ){ + fill_tc_ctrl_queue_fifo(&mod->fifo); + } else if(mod->type == TC_QUEUE_CODEL){ + fill_tc_ctrl_queue_codel(&mod->codel); + } else if(mod->type == TC_QUEUE_ECN_CODEL){ + fill_tc_ctrl_queue_ecn_codel(&mod->ecn); + } else { + assert(0!=0 && "Unknown type"); + } + +} + + +static +void fill_tc_ctrl_queue(tc_ctrl_queue_t* q) +{ + assert(q != NULL); + + tc_ctrl_act_e act = rand()%TC_CTRL_ACTION_SM_V0_END; + q->act = act; + + if(act == TC_CTRL_ACTION_SM_V0_ADD){ + fill_tc_ctrl_queue_add(&q->add); + } else if (act == TC_CTRL_ACTION_SM_V0_DEL){ + fill_tc_ctrl_queue_del(&q->del); + } else if (act == TC_CTRL_ACTION_SM_V0_MOD){ + fill_tc_ctrl_queue_mod(&q->mod); + } else { + assert(0!=0 && "Unknown actio type"); + } + +/* + tc_queue_e type = rand() % TC_QUEUE_END; + q->type = type; + q->id = rand() % 16; + + if(type == TC_QUEUE_FIFO){ + fill_tc_ctrl_queue_fifo(&q->fifo); + } else if(type == TC_QUEUE_CODEL){ + fill_tc_ctrl_queue_codel(&q->codel); + } else { + assert(0!=0 && "Unknown queue type"); + } +*/ + +} + +static +void fill_tc_ctrl_sch_add(tc_add_ctrl_sch_t* add) +{ + assert(add != NULL); + + add->dummy = rand()%16; +} + +static +void fill_tc_ctrl_sch_del(tc_del_ctrl_sch_t* del) +{ + assert(del != NULL); + + del->dummy = rand()%16; +} + +static +void fill_tc_ctrl_sch_mod(tc_mod_ctrl_sch_t* mod) +{ + assert(mod != NULL); + + tc_sch_e type = rand()%TC_SCHED_END; + mod->type = type; + + if(type == TC_SCHED_RR){ + mod->rr.dummy = rand()%8; + } else if(type == TC_SCHED_PRIO ){ + + mod->prio.len_q_prio = rand()%8; + if(mod->prio.len_q_prio > 0){ + mod->prio.q_prio = calloc(mod->prio.len_q_prio, sizeof(uint32_t)); + assert(mod->prio.q_prio != NULL && "Memory exhausted"); + } + + for(size_t i = 0; i < mod->prio.len_q_prio; ++i){ + mod->prio.q_prio[i] = rand()%16; + } + + } else { + assert(0!=0 && "scheduler type unknown"); + } + +} + + +static +void fill_tc_ctrl_sch(tc_ctrl_sch_t* sch) +{ + assert(sch != NULL); + + tc_ctrl_act_e act = rand()%TC_CTRL_ACTION_SM_V0_END; + sch->act = act; + + if(act == TC_CTRL_ACTION_SM_V0_ADD){ + fill_tc_ctrl_sch_add(&sch->add); + } else if (act == TC_CTRL_ACTION_SM_V0_DEL){ + fill_tc_ctrl_sch_del(&sch->del); + } else if (act == TC_CTRL_ACTION_SM_V0_MOD){ + fill_tc_ctrl_sch_mod(&sch->mod); + } else { + assert(0!=0 && "Unknown actio type"); + } +/* + sch->type = rand()%TC_SCHED_END; + + if(sch->type == TC_SCHED_RR){ + + } else if(sch->type == TC_SCHED_PRIO){ + + } else { + assert(0!=0 && "Unknown scheduler type"); + } +*/ + +} + +static +void fill_tc_mod_ctrl_shp(tc_mod_ctrl_shp_t* mod) +{ + assert(mod != NULL); + + mod->id = rand()%128; + mod->time_window_ms = rand()%128; + mod->max_rate_kbps = rand()%1024; + mod->active = rand()%2; +} + +static +void fill_tc_ctrl_shp(tc_ctrl_shp_t* shp) +{ + assert(shp != NULL); + + tc_ctrl_act_e act = rand()%TC_CTRL_ACTION_SM_V0_END; + shp->act = act; + + if(act == TC_CTRL_ACTION_SM_V0_ADD){ + shp->add.dummy = rand()%16; + } else if(act == TC_CTRL_ACTION_SM_V0_DEL){ + shp->del.id = rand()%16; + } else if(act == TC_CTRL_ACTION_SM_V0_MOD){ + fill_tc_mod_ctrl_shp(&shp->mod); + } else { + assert(0!=0 && "Unknown action type"); + } +} + +static +void fill_tc_mod_ctrl_pcr(tc_mod_ctrl_pcr_t* mod) +{ + assert(mod != NULL); + + tc_pcr_e type = rand()% TC_PCR_END; + mod->type = type; + + if(type == TC_PCR_DUMMY){ + mod->dummy.dummy = rand()%16; + } else if(type == TC_PCR_5G_BDP) { + mod->bdp. drb_sz = rand()% 2048; + mod->bdp.tstamp = 10000 + rand()% 2048; + } else { + assert(0!=0 && "unknown type"); + } + +} + + +static +void fill_tc_ctrl_pcr(tc_ctrl_pcr_t* pcr) +{ + assert(pcr != NULL); + + tc_ctrl_act_e act = rand()%TC_CTRL_ACTION_SM_V0_END; + pcr->act = act; + + if(act == TC_CTRL_ACTION_SM_V0_ADD){ + pcr->add.dummy = rand()%32; + } else if(act == TC_CTRL_ACTION_SM_V0_DEL){ + pcr->del.dummy = rand()%32; + } else if(act == TC_CTRL_ACTION_SM_V0_MOD){ + fill_tc_mod_ctrl_pcr(&pcr->mod); + } else { + assert(0!=0 && "Unknown action type"); + } + +} + +void fill_tc_ctrl(tc_ctrl_req_data_t* ctrl) +{ + assert(ctrl != NULL); + + ctrl->hdr.dummy = rand() % 16; + + uint32_t const type = rand()%TC_CTRL_SM_V0_END; + ctrl->msg.type = type; + + if(type == TC_CTRL_SM_V0_CLS){ + fill_tc_ctrl_cls(&ctrl->msg.cls); + } else if(type == TC_CTRL_SM_V0_PLC) { + fill_tc_ctrl_plc(&ctrl->msg.plc); + } else if(type == TC_CTRL_SM_V0_QUEUE){ + fill_tc_ctrl_queue(&ctrl->msg.q); + } else if(type == TC_CTRL_SM_V0_SCH){ + fill_tc_ctrl_sch(&ctrl->msg.sch); + } else if(type == TC_CTRL_SM_V0_SHP){ + fill_tc_ctrl_shp(&ctrl->msg.shp); + } else if(type == TC_CTRL_SM_V0_PCR){ + fill_tc_ctrl_pcr(&ctrl->msg.pcr); + } else { + assert(0!=0 && "Unknown type"); + } + +} + + diff --git a/libs/test/rnd/fill_rnd_data_tc.h b/libs/test/rnd/fill_rnd_data_tc.h index 74ea3d2..c9999f9 100644 --- a/libs/test/rnd/fill_rnd_data_tc.h +++ b/libs/test/rnd/fill_rnd_data_tc.h @@ -1,32 +1,32 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698 - * - * 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. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#ifndef FILL_RND_DATA_TC_H -#define FILL_RND_DATA_TC_H - -#include "../../src/sm/tc_sm/ie/tc_data_ie.h" - -void fill_tc_ind_data(tc_ind_data_t* ind_msg); - -void fill_tc_ctrl(tc_ctrl_req_data_t* ctrl); - -#endif - +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698 + * + * 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. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#ifndef FILL_RND_DATA_TC_H +#define FILL_RND_DATA_TC_H + +#include "../../src/sm/tc_sm/ie/tc_data_ie.h" + +void fill_tc_ind_data(tc_ind_data_t* ind_msg); + +void fill_tc_ctrl(tc_ctrl_req_data_t* ctrl); + +#endif + diff --git a/scripts/cpRicFiles.sh b/scripts/cpRicFiles.sh index fcdb029..7911c20 100644 --- a/scripts/cpRicFiles.sh +++ b/scripts/cpRicFiles.sh @@ -1,20 +1,20 @@ -#!/bin/bash - -## output dir -mkdir -p out - -## binary -mkdir -p out/bin -cp ./build/xapp_iqos out/bin - -## service models -mkdir -p out/serviceModels - -cp ./build/libs/flexric/src/sm/kpm_sm/kpm_sm_v03.00/libkpm_sm.so out/serviceModels -cp ./build/libs/flexric/src/sm/rc_sm/librc_sm.so out/serviceModels -cp ./build/libs/flexric/src/sm/mac_sm/libmac_sm.so out/serviceModels -cp ./build/libs/flexric/src/sm/slice_sm/libslice_sm.so out/serviceModels -cp ./build/libs/flexric/src/sm/pdcp_sm/libpdcp_sm.so out/serviceModels -cp ./build/libs/flexric/src/sm/gtp_sm/libgtp_sm.so out/serviceModels -cp ./build/libs/flexric/src/sm/tc_sm/libtc_sm.so out/serviceModels +#!/bin/bash + +## output dir +mkdir -p out + +## binary +mkdir -p out/bin +cp ./build/xapp_iqos out/bin + +## service models +mkdir -p out/serviceModels + +cp ./build/libs/flexric/src/sm/kpm_sm/kpm_sm_v03.00/libkpm_sm.so out/serviceModels +cp ./build/libs/flexric/src/sm/rc_sm/librc_sm.so out/serviceModels +cp ./build/libs/flexric/src/sm/mac_sm/libmac_sm.so out/serviceModels +cp ./build/libs/flexric/src/sm/slice_sm/libslice_sm.so out/serviceModels +cp ./build/libs/flexric/src/sm/pdcp_sm/libpdcp_sm.so out/serviceModels +cp ./build/libs/flexric/src/sm/gtp_sm/libgtp_sm.so out/serviceModels +cp ./build/libs/flexric/src/sm/tc_sm/libtc_sm.so out/serviceModels cp ./build/libs/flexric/src/sm/rlc_sm/librlc_sm.so out/serviceModels \ No newline at end of file diff --git a/scripts/genKafkaUuid.py b/scripts/genKafkaUuid.py index e5008d6..e912da1 100644 --- a/scripts/genKafkaUuid.py +++ b/scripts/genKafkaUuid.py @@ -1,13 +1,13 @@ -import uuid -import base64 - -# Generate UUID -generated_uuid = uuid.uuid4() -print(f"Generated UUID: {generated_uuid}") - -# Convert UUID to bytes -uuid_bytes = generated_uuid.bytes - -# Encode the UUID bytes in base64 -base64_uuid = base64.urlsafe_b64encode(uuid_bytes).rstrip(b'=').decode('ascii') +import uuid +import base64 + +# Generate UUID +generated_uuid = uuid.uuid4() +print(f"Generated UUID: {generated_uuid}") + +# Convert UUID to bytes +uuid_bytes = generated_uuid.bytes + +# Encode the UUID bytes in base64 +base64_uuid = base64.urlsafe_b64encode(uuid_bytes).rstrip(b'=').decode('ascii') print(f"Base64-encoded UUID: {base64_uuid}") \ No newline at end of file diff --git a/scripts/largeDnnConstants_1551436.bin b/scripts/largeDnnConstants_1551436.bin new file mode 100644 index 0000000..3c1fc1d Binary files /dev/null and b/scripts/largeDnnConstants_1551436.bin differ diff --git a/scripts/largeDnnConstants_1551441.bin b/scripts/largeDnnConstants_1551441.bin new file mode 100644 index 0000000..f85c1cd Binary files /dev/null and b/scripts/largeDnnConstants_1551441.bin differ diff --git a/scripts/run.sh b/scripts/run.sh index 5f75bc7..48d41be 100644 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -1,7 +1,7 @@ -#!/bin/bash - -## Setup RIC IP -sed -i "s/NEAR_RIC_IP = 127.0.0.1/NEAR_RIC_IP = ${NEAR_RIC_IP}/g" /usr/local/etc/flexric/flexric.conf - -## Exec xApp bin +#!/bin/bash + +## Setup RIC IP +sed -i "s/NEAR_RIC_IP = 127.0.0.1/NEAR_RIC_IP = ${NEAR_RIC_IP}/g" /usr/local/etc/flexric/flexric.conf + +## Exec xApp bin stdbuf -o0 xapp_iqos \ No newline at end of file diff --git a/src/SoftmaxLayer.c b/src/SoftmaxLayer.c new file mode 100644 index 0000000..1545db8 --- /dev/null +++ b/src/SoftmaxLayer.c @@ -0,0 +1,28 @@ +/* + * File: SoftmaxLayer.c + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +/* Include Files */ +#include "SoftmaxLayer.h" +#include "internal_softmax.h" +#include "rt_nonfinite.h" + +/* Function Definitions */ +/* + * Arguments : const float X1_Data[3] + * float Z1_Data[3] + * Return Type : void + */ +void SoftmaxLayer_predict(const float X1_Data[3], float Z1_Data[3]) +{ + iComputeSoftmaxForCpu(X1_Data, Z1_Data); +} + +/* + * File trailer for SoftmaxLayer.c + * + * [EOF] + */ diff --git a/src/cellstr_sort.c b/src/cellstr_sort.c new file mode 100644 index 0000000..e49746c --- /dev/null +++ b/src/cellstr_sort.c @@ -0,0 +1,59 @@ +/* + * File: cellstr_sort.c + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +/* Include Files */ +#include "cellstr_sort.h" +#include "introsort.h" +#include "rt_nonfinite.h" +#include "runPrediction_types.h" + +/* Function Definitions */ +/* + * Arguments : const cell_wrap_1 c_data[] + * int c_size + * cell_wrap_1 sorted_data[] + * int idx_data[] + * int *idx_size + * Return Type : int + */ +int cellstr_sort(const cell_wrap_1 c_data[], int c_size, + cell_wrap_1 sorted_data[], int idx_data[], int *idx_size) +{ + int k; + int n_tmp_tmp; + int sorted_size; + int yk; + short y_data[3]; + n_tmp_tmp = (unsigned char)(c_size - 1) + 1; + y_data[0] = 1; + yk = 1; + for (k = 2; k <= n_tmp_tmp; k++) { + yk++; + y_data[k - 1] = (short)yk; + } + *idx_size = (unsigned char)(c_size - 1) + 1; + for (k = 0; k < n_tmp_tmp; k++) { + idx_data[k] = y_data[k]; + } + introsort(idx_data, c_size, c_data); + sorted_size = c_size; + for (yk = 0; yk < c_size; yk++) { + sorted_data[yk].f1.size[0] = 1; + k = c_data[idx_data[yk] - 1].f1.size[1]; + sorted_data[yk].f1.size[1] = k; + if (k - 1 >= 0) { + sorted_data[yk].f1.data[0] = c_data[idx_data[yk] - 1].f1.data[0]; + } + } + return sorted_size; +} + +/* + * File trailer for cellstr_sort.c + * + * [EOF] + */ diff --git a/src/e2Info.cpp b/src/e2Info.cpp index 8343ad3..ca8de02 100644 --- a/src/e2Info.cpp +++ b/src/e2Info.cpp @@ -1,78 +1,78 @@ -#include "e2Info.hpp" - -E2Info::E2Info(e2_node_arr_xapp_t& e2Nodes) : e2Nodes(e2Nodes) -{} - -void E2Info::printE2Nodes() const -{ - SPDLOG_INFO("Showing E2 node informations..."); - - // creates tables with E2 nodes infos - // table header - tabulate::Table e2NodesInfoTabHdr; - e2NodesInfoTabHdr.add_row({"Information of connected E2 nodes"}); - // format table header - e2NodesInfoTabHdr.format() - .column_separator("") - .border_top("\u2014") - .border_bottom("\u2014"); - e2NodesInfoTabHdr[0].format() - .font_align(tabulate::FontAlign::center); - - // information table - tabulate::Table e2NodesInfoTab; - e2NodesInfoTab.add_row({ - "index", "nb_id", "mcc", "mnc", "mnc_digit_len", "ran_type", "cu_du_id", "supported rf_ids" - }); - - for (size_t i = 0; i < this->e2Nodes.len; ++i) - { - const ngran_node_t ran_type = this->e2Nodes.n[i].id.type; - e2NodesInfoTab.add_row( - tabulate::RowStream{} << - i << - this->e2Nodes.n[i].id.nb_id.nb_id << - this->e2Nodes.n[i].id.plmn.mcc << - this->e2Nodes.n[i].id.plmn.mnc << - static_cast(this->e2Nodes.n[i].id.plmn.mnc_digit_len) << - get_ngran_name(ran_type) - ); - - // FIXME: segmentation fault to show CU's cu_du_id - if (!NODE_IS_MONOLITHIC(ran_type) && !NODE_IS_CU(ran_type)) - { - e2NodesInfoTab.row(i + 1).cell(6).set_text(fmt::to_string(*this->e2Nodes.n[i].id.cu_du_id)); - } - - // print supported RAN Functions - std::string rf_id_lst; - for (size_t j = 0; j < this->e2Nodes.n[i].len_rf; ++j) - { - // TODO: print RAN Function name - rf_id_lst.append(fmt::to_string(this->e2Nodes.n[i].rf[j].id) + ' '); - } - - e2NodesInfoTab.row(i + 1).cell(7).set_text(rf_id_lst); - } - - // format information table - e2NodesInfoTab.format() - .column_separator(""); - e2NodesInfoTab[0].format() - .font_align(tabulate::FontAlign::center) - .font_style({tabulate::FontStyle::bold}); - - e2NodesInfoTabHdr.add_row(tabulate::RowStream{} << e2NodesInfoTab); - - std::cout << e2NodesInfoTabHdr << '\n'; -} - -E2Info::e2NodesIdLst E2Info::getE2NodesIds() const -{ - e2NodesIdLst ids{}; - for (size_t i = 0; i < this->e2Nodes.len; ++i) - { - ids.push_back(this->e2Nodes.n[i].id); - } - return ids; -} +#include "e2Info.hpp" + +E2Info::E2Info(e2_node_arr_xapp_t& e2Nodes) : e2Nodes(e2Nodes) +{} + +void E2Info::printE2Nodes() const +{ + SPDLOG_INFO("Showing E2 node informations..."); + + // creates tables with E2 nodes infos + // table header + tabulate::Table e2NodesInfoTabHdr; + e2NodesInfoTabHdr.add_row({"Information of connected E2 nodes"}); + // format table header + e2NodesInfoTabHdr.format() + .column_separator("") + .border_top("\u2014") + .border_bottom("\u2014"); + e2NodesInfoTabHdr[0].format() + .font_align(tabulate::FontAlign::center); + + // information table + tabulate::Table e2NodesInfoTab; + e2NodesInfoTab.add_row({ + "index", "nb_id", "mcc", "mnc", "mnc_digit_len", "ran_type", "cu_du_id", "supported rf_ids" + }); + + for (size_t i = 0; i < this->e2Nodes.len; ++i) + { + const ngran_node_t ran_type = this->e2Nodes.n[i].id.type; + e2NodesInfoTab.add_row( + tabulate::RowStream{} << + i << + this->e2Nodes.n[i].id.nb_id.nb_id << + this->e2Nodes.n[i].id.plmn.mcc << + this->e2Nodes.n[i].id.plmn.mnc << + static_cast(this->e2Nodes.n[i].id.plmn.mnc_digit_len) << + get_ngran_name(ran_type) + ); + + // FIXME: segmentation fault to show CU's cu_du_id + if (!NODE_IS_MONOLITHIC(ran_type) && !NODE_IS_CU(ran_type)) + { + e2NodesInfoTab.row(i + 1).cell(6).set_text(fmt::to_string(*this->e2Nodes.n[i].id.cu_du_id)); + } + + // print supported RAN Functions + std::string rf_id_lst; + for (size_t j = 0; j < this->e2Nodes.n[i].len_rf; ++j) + { + // TODO: print RAN Function name + rf_id_lst.append(fmt::to_string(this->e2Nodes.n[i].rf[j].id) + ' '); + } + + e2NodesInfoTab.row(i + 1).cell(7).set_text(rf_id_lst); + } + + // format information table + e2NodesInfoTab.format() + .column_separator(""); + e2NodesInfoTab[0].format() + .font_align(tabulate::FontAlign::center) + .font_style({tabulate::FontStyle::bold}); + + e2NodesInfoTabHdr.add_row(tabulate::RowStream{} << e2NodesInfoTab); + + std::cout << e2NodesInfoTabHdr << '\n'; +} + +E2Info::e2NodesIdLst E2Info::getE2NodesIds() const +{ + e2NodesIdLst ids{}; + for (size_t i = 0; i < this->e2Nodes.len; ++i) + { + ids.push_back(this->e2Nodes.n[i].id); + } + return ids; +} diff --git a/src/elementwiseOperationInPlace.c b/src/elementwiseOperationInPlace.c new file mode 100644 index 0000000..b1a4dbb --- /dev/null +++ b/src/elementwiseOperationInPlace.c @@ -0,0 +1,95 @@ +/* + * File: elementwiseOperationInPlace.c + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +/* Include Files */ +#include "elementwiseOperationInPlace.h" +#include "rt_nonfinite.h" +#include "omp.h" +#include + +/* Function Declarations */ +static void b_lambdaForColumnMajorGeneric(float *X); + +static void d_lambdaForColumnMajorGeneric(float *X); + +/* Function Definitions */ +/* + * Arguments : float *X + * Return Type : void + */ +static void b_lambdaForColumnMajorGeneric(float *X) +{ + *X = 1.0F / (expf(-*X) + 1.0F); +} + +/* + * Arguments : float *X + * Return Type : void + */ +static void d_lambdaForColumnMajorGeneric(float *X) +{ + *X = tanhf(*X); +} + +/* + * Arguments : float X[400] + * Return Type : void + */ +void c_lambdaForColumnMajorGeneric(float X[400]) +{ + int iElem; +#pragma omp parallel for num_threads(omp_get_max_threads()) + + for (iElem = 0; iElem < 400; iElem++) { + d_lambdaForColumnMajorGeneric(&X[iElem]); + } +} + +/* + * Arguments : float X[400] + * Return Type : void + */ +void e_lambdaForColumnMajorGeneric(float X[400]) +{ + int iElem; +#pragma omp parallel for num_threads(omp_get_max_threads()) + + for (iElem = 0; iElem < 400; iElem++) { + X[iElem] = tanhf(X[iElem]); + } +} + +/* + * Arguments : float X[3] + * Return Type : void + */ +void f_lambdaForColumnMajorGeneric(float X[3]) +{ + X[0] = expf(X[0]); + X[1] = expf(X[1]); + X[2] = expf(X[2]); +} + +/* + * Arguments : float X[1200] + * Return Type : void + */ +void lambdaForColumnMajorGeneric(float X[1200]) +{ + int iElem; +#pragma omp parallel for num_threads(omp_get_max_threads()) + + for (iElem = 0; iElem < 1200; iElem++) { + b_lambdaForColumnMajorGeneric(&X[iElem]); + } +} + +/* + * File trailer for elementwiseOperationInPlace.c + * + * [EOF] + */ diff --git a/src/find.c b/src/find.c new file mode 100644 index 0000000..8b1b694 --- /dev/null +++ b/src/find.c @@ -0,0 +1,58 @@ +/* + * File: find.c + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +/* Include Files */ +#include "find.h" +#include "rt_nonfinite.h" + +/* Function Definitions */ +/* + * Arguments : const boolean_T x_data[] + * int x_size + * int i_data[] + * Return Type : int + */ +int eml_find(const boolean_T x_data[], int x_size, int i_data[]) +{ + int i_size; + int idx; + int ii; + boolean_T exitg1; + idx = 0; + i_size = x_size; + ii = 0; + exitg1 = false; + while ((!exitg1) && (ii <= x_size - 1)) { + if (x_data[ii]) { + idx++; + i_data[idx - 1] = ii + 1; + if (idx >= x_size) { + exitg1 = true; + } else { + ii++; + } + } else { + ii++; + } + } + if (x_size == 1) { + if (idx == 0) { + i_size = 0; + } + } else if (idx < 1) { + i_size = 0; + } else { + i_size = idx; + } + return i_size; +} + +/* + * File trailer for find.c + * + * [EOF] + */ diff --git a/src/getCategoryNames.c b/src/getCategoryNames.c new file mode 100644 index 0000000..6c0a7ff --- /dev/null +++ b/src/getCategoryNames.c @@ -0,0 +1,47 @@ +/* + * File: getCategoryNames.c + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +/* Include Files */ +#include "getCategoryNames.h" +#include "rt_nonfinite.h" +#include "runPrediction_types.h" + +/* Function Definitions */ +/* + * Arguments : const cell_wrap_1 valueSet_data[] + * int valueSet_size + * cell_wrap_1 outCategoryNames_data[] + * Return Type : int + */ +int categorical_getCategoryNames(const cell_wrap_1 valueSet_data[], + int valueSet_size, + cell_wrap_1 outCategoryNames_data[]) +{ + int i; + int outCategoryNames_size; + if (valueSet_size != 0) { + outCategoryNames_size = valueSet_size; + for (i = 0; i < valueSet_size; i++) { + int b_i; + outCategoryNames_data[i].f1.size[0] = 1; + b_i = valueSet_data[i].f1.size[1]; + outCategoryNames_data[i].f1.size[1] = b_i; + if (b_i - 1 >= 0) { + outCategoryNames_data[i].f1.data[0] = valueSet_data[i].f1.data[0]; + } + } + } else { + outCategoryNames_size = 0; + } + return outCategoryNames_size; +} + +/* + * File trailer for getCategoryNames.c + * + * [EOF] + */ diff --git a/src/insertionsort.c b/src/insertionsort.c new file mode 100644 index 0000000..b82bde6 --- /dev/null +++ b/src/insertionsort.c @@ -0,0 +1,79 @@ +/* + * File: insertionsort.c + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +/* Include Files */ +#include "insertionsort.h" +#include "rt_nonfinite.h" +#include "runPrediction_types.h" +#include + +/* Function Definitions */ +/* + * Arguments : int x_data[] + * int xend + * const cell_wrap_1 cmp_workspace_c_data[] + * Return Type : void + */ +void insertionsort(int x_data[], int xend, + const cell_wrap_1 cmp_workspace_c_data[]) +{ + int k; + for (k = 2; k <= xend; k++) { + int idx; + int xc; + boolean_T exitg1; + xc = x_data[k - 1] - 1; + idx = k - 2; + exitg1 = false; + while ((!exitg1) && (idx + 1 >= 1)) { + int b_k; + int b_n_tmp; + int j; + int n; + int n_tmp; + boolean_T varargout_1; + j = x_data[idx]; + n_tmp = cmp_workspace_c_data[xc].f1.size[1]; + b_n_tmp = cmp_workspace_c_data[x_data[idx] - 1].f1.size[1]; + n = (int)fmin(n_tmp, b_n_tmp); + varargout_1 = (n_tmp < b_n_tmp); + b_k = 0; + int exitg2; + do { + exitg2 = 0; + if (b_k <= n - 1) { + if (cmp_workspace_c_data[xc].f1.data[0] != + cmp_workspace_c_data[x_data[idx] - 1].f1.data[0]) { + varargout_1 = (cmp_workspace_c_data[xc].f1.data[0] < + cmp_workspace_c_data[x_data[idx] - 1].f1.data[0]); + exitg2 = 1; + } else { + b_k = 1; + } + } else { + if (n_tmp == b_n_tmp) { + varargout_1 = (xc + 1 < j); + } + exitg2 = 1; + } + } while (exitg2 == 0); + if (varargout_1) { + x_data[idx + 1] = x_data[idx]; + idx--; + } else { + exitg1 = true; + } + } + x_data[idx + 1] = xc + 1; + } +} + +/* + * File trailer for insertionsort.c + * + * [EOF] + */ diff --git a/src/internal_softmax.c b/src/internal_softmax.c new file mode 100644 index 0000000..b715f91 --- /dev/null +++ b/src/internal_softmax.c @@ -0,0 +1,72 @@ +/* + * File: internal_softmax.c + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +/* Include Files */ +#include "internal_softmax.h" +#include "elementwiseOperationInPlace.h" +#include "rt_nonfinite.h" +#include "rt_nonfinite.h" + +/* Function Definitions */ +/* + * Arguments : const float xdata[3] + * float ydata[3] + * Return Type : void + */ +void iComputeSoftmaxForCpu(const float xdata[3], float ydata[3]) +{ + int k; + int nonChannelDimsProductIdx; + for (nonChannelDimsProductIdx = 0; nonChannelDimsProductIdx < 1; + nonChannelDimsProductIdx++) { + float maxVal; + float sumX; + int idx; + if (!rtIsNaNF(xdata[0])) { + idx = 1; + } else { + boolean_T exitg1; + idx = 0; + k = 2; + exitg1 = false; + while ((!exitg1) && (k < 4)) { + if (!rtIsNaNF(xdata[k - 1])) { + idx = k; + exitg1 = true; + } else { + k++; + } + } + } + if (idx == 0) { + maxVal = xdata[0]; + } else { + maxVal = xdata[idx - 1]; + idx++; + for (k = idx; k < 4; k++) { + sumX = xdata[k - 1]; + if (maxVal < sumX) { + maxVal = sumX; + } + } + } + ydata[0] = xdata[0] - maxVal; + ydata[1] = xdata[1] - maxVal; + ydata[2] = xdata[2] - maxVal; + f_lambdaForColumnMajorGeneric(ydata); + sumX = (ydata[0] + ydata[1]) + ydata[2]; + ydata[0] /= sumX; + ydata[1] /= sumX; + ydata[2] /= sumX; + } +} + +/* + * File trailer for internal_softmax.c + * + * [EOF] + */ diff --git a/src/introsort.c b/src/introsort.c new file mode 100644 index 0000000..a9bcaaa --- /dev/null +++ b/src/introsort.c @@ -0,0 +1,32 @@ +/* + * File: introsort.c + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +/* Include Files */ +#include "introsort.h" +#include "insertionsort.h" +#include "rt_nonfinite.h" +#include "runPrediction_types.h" + +/* Function Definitions */ +/* + * Arguments : int x_data[] + * int xend + * const cell_wrap_1 cmp_workspace_c_data[] + * Return Type : void + */ +void introsort(int x_data[], int xend, const cell_wrap_1 cmp_workspace_c_data[]) +{ + if (xend > 1) { + insertionsort(x_data, xend, cmp_workspace_c_data); + } +} + +/* + * File trailer for introsort.c + * + * [EOF] + */ diff --git a/src/kpmManager.cpp b/src/kpmManager.cpp index 4b0e584..21f777c 100644 --- a/src/kpmManager.cpp +++ b/src/kpmManager.cpp @@ -1,441 +1,441 @@ -#include "kpmManager.hpp" - -namespace KpmManager -{ - static pthread_mutex_t mtx; - - // type to filter and handle with report styles [function()] - using fill_kpm_act_def = kpm_act_def_t (*)(ric_report_style_item_t const* report_item); - - // report styles functions (implementations below) - static kpm_act_def_t fill_report_style_4(ric_report_style_item_t const* report_item); - - // select report style by idx - static fill_kpm_act_def get_kpm_act_def[END_RIC_SERVICE_REPORT] - { - nullptr, - nullptr, - nullptr, - fill_report_style_4, - nullptr, - }; - - // type to filter and handle with meas_type [function()] - using check_meas_type = void (*)(meas_type_t const& meas_type, meas_record_lst_t const& meas_record); - - // meas type functions (implementations below) - static void match_meas_name_type(meas_type_t const& meas_type, meas_record_lst_t const& meas_record); - static void match_meas_type_id(meas_type_t const& meas_type, meas_record_lst_t const& meas_record); - - // select meas_type by idx - static check_meas_type match_meas_type[meas_type_t::END_MEAS_TYPE] - { - match_meas_name_type, // 8.3.9 in O-RAN spec - match_meas_type_id, // 8.3.10 in O-RAN spec - }; - - // type to filter and handle with meas_value [function()] - using handle_meas_value = void (*)(byte_array_t name, meas_record_lst_t meas_record); - - // functions to handle meas value (implementations below) - static void int_meas_value(byte_array_t name, meas_record_lst_t meas_record); - static void real_meas_value(byte_array_t name, meas_record_lst_t meas_record); - - static handle_meas_value get_meas_value[END_MEAS_VALUE] - { - int_meas_value, - real_meas_value, - nullptr, // no value - }; - - // convert a type byte_array_t to string - static std::string ba_to_string(byte_array_t const& byteArray) - { - return std::string{reinterpret_cast(byteArray.buf), byteArray.len}; - } - - static void int_meas_value(byte_array_t name, meas_record_lst_t meas_record) - { - // get meas name on string type - std::string meas_name{ba_to_string(name)}; - - auto it = std::ranges::find( - SUPPORTED_MEASUREMENTS.begin(), - SUPPORTED_MEASUREMENTS.end(), - meas_name); - - if (it != SUPPORTED_MEASUREMENTS.end()) - { - SPDLOG_DEBUG("{}: {:d}", meas_name, meas_record.int_val); - } - else - { - SPDLOG_DEBUG("Measurement {} not yet supported", meas_name); - } - } - - static void real_meas_value(byte_array_t name, meas_record_lst_t meas_record) - { - std::string meas_name{ba_to_string(name)}; - - // TODO: review this - // match meas by name - if (meas_name == "DRB.UEThpDl") - { - SPDLOG_DEBUG("DRB.UEThpDl = {:.2f} [Mbps]", meas_record.real_val/1000); - } - else if (meas_name == "DRB.UEThpUl") - { - SPDLOG_DEBUG("DRB.UEThpUl = {:.2f} [Mbps]", meas_record.real_val/1000); - } - else if (meas_name == "DRB.RlcSduDelayDl") - { - SPDLOG_DEBUG("DRB.RlcSduDelayDl = {:.2f} [μs]", meas_record.real_val); - } - else - { - SPDLOG_DEBUG("Measurement {} not yet supported", meas_name); - } - } - - // print UE id type - static void print_ue_id(ue_id_e2sm_e type, ue_id_e2sm_t ue_id) - { - switch (type) // define UE ID type (only 5G) - { - case ue_id_e2sm_e::GNB_UE_ID_E2SM: - if (ue_id.gnb.gnb_cu_ue_f1ap_lst != nullptr) - { - for (size_t i = 0; i < ue_id.gnb.gnb_cu_ue_f1ap_lst_len; ++i) - { - // split CU - SPDLOG_DEBUG("UE ID type = gNB-CU | gnb_cu_ue_f1ap = {:d}", ue_id.gnb.gnb_cu_ue_f1ap_lst[i]); - } - } - else - { - SPDLOG_DEBUG("UE ID type = gNB | amf_ue_ngap_id = {:d}", ue_id.gnb.amf_ue_ngap_id); // Monolitic ID - } - - if (ue_id.gnb.ran_ue_id != nullptr) - { - SPDLOG_DEBUG("ran_ue_id = {:x}", *ue_id.gnb.ran_ue_id); // RAN UE NGAP ID - } - break; - case ue_id_e2sm_e::GNB_DU_UE_ID_E2SM: - SPDLOG_DEBUG("UE ID type = gNB-DU | gnb_cu_ue_f1ap = {:d}", ue_id.gnb_du.gnb_cu_ue_f1ap); - if (ue_id.gnb_du.ran_ue_id != nullptr) - { - SPDLOG_DEBUG("ran_ue_id = {:x}", *ue_id.gnb_du.ran_ue_id); // RAN UE NGAP ID - } - break; - case ue_id_e2sm_e::GNB_CU_UP_UE_ID_E2SM: - SPDLOG_DEBUG("UE ID type = gNB-CU-UP | gnb_cu_cp_ue_e1ap = {:d}", ue_id.gnb_cu_up.gnb_cu_cp_ue_e1ap); - if (ue_id.gnb_cu_up.ran_ue_id != nullptr) - { - SPDLOG_DEBUG("ran_ue_id = {:x}", *ue_id.gnb_cu_up.ran_ue_id); // RAN UE NGAP ID - } - break; - default: - SPDLOG_WARN("UE ID type not supported!"); - break; - } - } - - // print UE measurements - static void print_measurements(kpm_ind_msg_format_1_t const* msg_frm_1) - { - assert(msg_frm_1->meas_info_lst_len > 0 && "Cannot correctly print measurements"); - - // UE Measurements per granularity period - for (size_t i = 0; i < msg_frm_1->meas_data_lst_len; ++i) - { - meas_data_lst_t const data_item{msg_frm_1->meas_data_lst[i]}; // get item - for (int j = 0; j < data_item.meas_record_len; ++j) - { - const meas_type_t meas_type{msg_frm_1->meas_info_lst[j].meas_type}; // item type - const meas_record_lst_t record_item{data_item.meas_record_lst[j]}; - - match_meas_type[meas_type.type](meas_type, record_item); - - if (data_item.incomplete_flag && *data_item.incomplete_flag == TRUE_ENUM_VALUE) - { - SPDLOG_DEBUG("Measurement Record not reliable"); - } - } - } - } - - static size_t get_kpm_idx(sm_ran_function_t const* rf, size_t rf_size) - { - for (size_t i = 0; i <= rf_size; i++) - { - if (rf[i].id == KPM_RAN_FUNC_ID) - { - return i; - } - } - - assert(0 != 0 && "KPM SM ID could not be found in the RAN Function List"); - } - - // return a filled test info lst - static test_info_lst_t filter_predicate() - { - test_info_lst_t dst{}; - - // filter by S-NSSAI criteria - constexpr test_cond_type_e type{S_NSSAI_TEST_COND_TYPE}; - constexpr test_cond_e condition{EQUAL_TEST_COND}; - constexpr u_int8_t value{1}; - - dst.test_cond_type = {type}; - dst.S_NSSAI = {TRUE_TEST_COND_TYPE}; - - // alloc test cond - dst.test_cond = {static_cast(calloc(1, sizeof(test_cond_e)))}; - assert(dst.test_cond != nullptr && "Memory exhausted!"); - *dst.test_cond = {condition}; - - // alloc test cond type - dst.test_cond_value = {static_cast(calloc(1, sizeof(test_cond_value_t)))}; - assert(dst.test_cond_value != nullptr && "Memory exhausted!"); - dst.test_cond_value->type = {OCTET_STRING_TEST_COND_VALUE}; - - // alloc octet string - dst.test_cond_value->octet_string_value = {static_cast(calloc(1, sizeof(byte_array_t)))}; - assert(dst.test_cond_value->octet_string_value != nullptr && "Memory exhausted!"); - - constexpr size_t len_nssai{1}; - dst.test_cond_value->octet_string_value->len = {len_nssai}; - - // alloc octet buffer - dst.test_cond_value->octet_string_value->buf = {static_cast(calloc(len_nssai, sizeof(uint8_t)))}; - assert(dst.test_cond_value->octet_string_value->buf != nullptr && "Memory exhausted!"); - dst.test_cond_value->octet_string_value->buf[0] = value; - - return dst; - } - - static label_info_lst_t fill_kpm_label() - { - label_info_lst_t label_item{nullptr}; - - label_item.noLabel = {static_cast(calloc(1, sizeof(enum_value_e)))}; - *label_item.noLabel = {TRUE_ENUM_VALUE}; - - return label_item; - } - - // return a type 1 definition format - static kpm_act_def_format_1_t fill_act_def_frm_1(ric_report_style_item_t const* report_item) - { - assert(report_item != nullptr); - kpm_act_def_format_1_t ad_frm_1{0}; - - const size_t size{report_item->meas_info_for_action_lst_len}; - - // [1, 65535] - ad_frm_1.meas_info_lst_len = size; - ad_frm_1.meas_info_lst = static_cast(calloc(size, sizeof(meas_info_format_1_lst_t))); - assert(ad_frm_1.meas_info_lst != nullptr && "Memory exhausted!"); - - // iterate over each measure - for (size_t i = 0; i < size; i++) - { - meas_info_format_1_lst_t* meas_item{&ad_frm_1.meas_info_lst[i]}; - - // Measurement Name - // 8.3.9 in the O-RAN specification - meas_item->meas_type.type = {meas_type_t::NAME_MEAS_TYPE}; - meas_item->meas_type.name = {copy_byte_array(report_item->meas_info_for_action_lst[i].name)}; - - // Measurement Label - // 8.3.11 in the O-RAN specification - meas_item->label_info_lst_len = {1}; - meas_item->label_info_lst = static_cast(calloc(1, sizeof(label_info_lst_t))); - assert(meas_item->label_info_lst != nullptr && "Memory exhausted!"); - meas_item->label_info_lst[0] = fill_kpm_label(); - } - - // Granularity Period - // 8.3.8 in the O-RAN specification - ad_frm_1.gran_period_ms = {PERIOD_MS}; - - // Cell Global ID - // 8.3.20 in the O-RAN specification - OPTIONAL - ad_frm_1.cell_global_id = {nullptr}; - -#if defined KPM_V2_03 || defined KPM_V3_00 - // [0, 65535] - ad_frm_1.meas_bin_range_info_lst_len = {0}; - ad_frm_1.meas_bin_info_lst = {nullptr}; -#endif - - return ad_frm_1; - } - - u_int64_t get_time_now_us() - { - auto now = std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch() - ); - return now.count(); - } - - // callback to handle return data from KPM subscription - static void sm_cb_kpm(sm_ag_if_rd_t const* rd) - { - assert(rd != nullptr); - assert(rd->type == INDICATION_MSG_AGENT_IF_ANS_V0); - assert(rd->ind.type == KPM_STATS_V3_0); - - // Reading Indication Message Format 3 - // 8.2.1.4.3 in the O-RAN specification - kpm_ind_data_t const* ind{&rd->ind.kpm.ind}; // indication - kpm_ric_ind_hdr_format_1_t const* hdr_frm_1{&ind->hdr.kpm_ric_ind_hdr_format_1}; // ind header - kpm_ind_msg_format_3_t const* msg_frm_3{&ind->msg.frm_3}; // ind message - - static int counter = 1; - u_int64_t latency{get_time_now_us() - hdr_frm_1->collectStartTime}; - - // create a new scope - { - pthread_mutex_lock(&mtx); - defer(pthread_mutex_unlock(&mtx)); - - // print latency xApp <-> E2 Node - printf("\n <--------------KPM ind_msg %d | latency = %lu [μs]--------------> \n", counter, - latency); // xApp <-> E2 Node - - // SPDLOG_DEBUG("KPM ind_msg latency = {:d} [μs]",); - - // Reported list of measurements per UE - for (size_t i = 0; i < msg_frm_3->ue_meas_report_lst_len; ++i) - { - // get UE ID - const ue_id_e2sm_t ue_id = msg_frm_3->meas_report_per_ue[i].ue_meas_report_lst; // id - const ue_id_e2sm_e ue_id_type = ue_id.type; // type - print_ue_id(ue_id_type, ue_id); - - // print measurements - print_measurements(&msg_frm_3->meas_report_per_ue[i].ind_msg_format_1); - } - - counter++; - } - } - - // handle with style report type 4 - static kpm_act_def_t fill_report_style_4(ric_report_style_item_t const* report_item) - { - assert(report_item != nullptr); - assert(report_item->act_def_format_type == FORMAT_4_ACTION_DEFINITION); - - // set kpm_act type to 4 - kpm_act_def_t act_def{.type = FORMAT_4_ACTION_DEFINITION}; - - // Fill matching condition - // [1, 32768] - act_def.frm_4.matching_cond_lst_len = 1; - act_def.frm_4.matching_cond_lst = static_cast(calloc( - act_def.frm_4.matching_cond_lst_len, sizeof(matching_condition_format_4_lst_t))); - assert(act_def.frm_4.matching_cond_lst != nullptr && "Memory exhausted"); - - // Filter connected UEs by some criteria - act_def.frm_4.matching_cond_lst[0].test_info_lst = {filter_predicate()}; - - // Fill Action Definition Format 1 - // 8.2.1.2.1 in the O-RAN spec - act_def.frm_4.action_def_format_1 = fill_act_def_frm_1(report_item); - - return act_def; - } - - // handle with meansurement name - static void match_meas_name_type(meas_type_t const& meas_type, meas_record_lst_t const& meas_record) - { - get_meas_value[meas_record.value](meas_type.name, meas_record); - } - - // TODO: not implemented yet - static void match_meas_type_id(meas_type_t const& meas_type, meas_record_lst_t const& meas_record) - { - (void)meas_type; - (void)meas_record; - assert(false && "ID Measurement Type not yet supported"); - } - - static kpm_sub_data_t gen_kpm_subs(kpm_ran_function_def_t const* ran_func) - { - assert(ran_func != nullptr); - assert(ran_func->ric_event_trigger_style_list != nullptr); - - kpm_sub_data_t kpm_sub{}; - - // Generate Event Trigger - assert(ran_func->ric_event_trigger_style_list[0].format_type == FORMAT_1_RIC_EVENT_TRIGGER); - kpm_sub.ev_trg_def.type = FORMAT_1_RIC_EVENT_TRIGGER; - kpm_sub.ev_trg_def.kpm_ric_event_trigger_format_1.report_period_ms = PERIOD_MS; - - // Generate Action Definition - kpm_sub.sz_ad = 1; - kpm_sub.ad = static_cast(calloc(kpm_sub.sz_ad, sizeof(kpm_act_def_t))); - assert(kpm_sub.ad != nullptr && "Memory exhausted"); - - // Multiple Action Definitions in one SUBSCRIPTION message is not supported - // Multiple REPORT Styles = Multiple Action Definition = Multiple SUBSCRIPTION messages - ric_report_style_item_t* const report_item = &ran_func->ric_report_style_list[0]; - ric_service_report_e const report_style_type = report_item->report_style_type; - *kpm_sub.ad = get_kpm_act_def[report_style_type](report_item); - - return kpm_sub; - } - - - void start(e2_node_arr_xapp_t const& e2Nodes) - { - SPDLOG_INFO("Starting KPM module..."); - // configure mutex - pthread_mutexattr_t attr{0}; - int rc{pthread_mutex_init(&mtx, &attr)}; - assert(rc == 0); - - // alloc memory for reports - auto hndl{static_cast(calloc(e2Nodes.len, sizeof(sm_ans_xapp_t)))}; - assert(hndl != nullptr); - defer(free(hndl)); - - for (size_t i = 0; i < e2Nodes.len; ++i) - { - e2_node_connected_xapp_t* e2Node{&e2Nodes.n[i]}; // get E2 node - const size_t kpm_idx{get_kpm_idx(e2Node->rf, e2Node->len_rf)}; // get KPM idx in list - assert(e2Node->rf[kpm_idx].defn.type == KPM_RAN_FUNC_DEF_E && "KPM is not the received RAN Function"); - - // if REPORT Service is supported by E2 node, send SUBSCRIPTION - // e.g. OAI CU-CP - if (e2Node->rf[kpm_idx].defn.kpm.ric_report_style_list != nullptr) - { - // Generate KPM SUBSCRIPTION message - kpm_sub_data_t kpm_sub = gen_kpm_subs(&e2Node->rf[kpm_idx].defn.kpm); - - // use API to send subscription - hndl[i] = {report_sm_xapp_api(&e2Node->id, KPM_RAN_FUNC_ID, &kpm_sub, sm_cb_kpm)}; - assert(hndl[i].success == true); - free_kpm_sub_data(&kpm_sub); - } - } - - // time to received metrics in seconds - std::this_thread::sleep_for(std::chrono::seconds(EXP_TIME)); - - for (size_t i = 0; i < e2Nodes.len; ++i) - { - // Remove the handle previously returned - if (hndl[i].success == true) - { - rm_report_sm_xapp_api(hndl[i].u.handle); - } - } - } -} +#include "kpmManager.hpp" + +namespace KpmManager +{ + static pthread_mutex_t mtx; + + // type to filter and handle with report styles [function()] + using fill_kpm_act_def = kpm_act_def_t (*)(ric_report_style_item_t const* report_item); + + // report styles functions (implementations below) + static kpm_act_def_t fill_report_style_4(ric_report_style_item_t const* report_item); + + // select report style by idx + static fill_kpm_act_def get_kpm_act_def[END_RIC_SERVICE_REPORT] + { + nullptr, + nullptr, + nullptr, + fill_report_style_4, + nullptr, + }; + + // type to filter and handle with meas_type [function()] + using check_meas_type = void (*)(meas_type_t const& meas_type, meas_record_lst_t const& meas_record); + + // meas type functions (implementations below) + static void match_meas_name_type(meas_type_t const& meas_type, meas_record_lst_t const& meas_record); + static void match_meas_type_id(meas_type_t const& meas_type, meas_record_lst_t const& meas_record); + + // select meas_type by idx + static check_meas_type match_meas_type[meas_type_t::END_MEAS_TYPE] + { + match_meas_name_type, // 8.3.9 in O-RAN spec + match_meas_type_id, // 8.3.10 in O-RAN spec + }; + + // type to filter and handle with meas_value [function()] + using handle_meas_value = void (*)(byte_array_t name, meas_record_lst_t meas_record); + + // functions to handle meas value (implementations below) + static void int_meas_value(byte_array_t name, meas_record_lst_t meas_record); + static void real_meas_value(byte_array_t name, meas_record_lst_t meas_record); + + static handle_meas_value get_meas_value[END_MEAS_VALUE] + { + int_meas_value, + real_meas_value, + nullptr, // no value + }; + + // convert a type byte_array_t to string + static std::string ba_to_string(byte_array_t const& byteArray) + { + return std::string{reinterpret_cast(byteArray.buf), byteArray.len}; + } + + static void int_meas_value(byte_array_t name, meas_record_lst_t meas_record) + { + // get meas name on string type + std::string meas_name{ba_to_string(name)}; + + auto it = std::ranges::find( + SUPPORTED_MEASUREMENTS.begin(), + SUPPORTED_MEASUREMENTS.end(), + meas_name); + + if (it != SUPPORTED_MEASUREMENTS.end()) + { + SPDLOG_DEBUG("{}: {:d}", meas_name, meas_record.int_val); + } + else + { + SPDLOG_DEBUG("Measurement {} not yet supported", meas_name); + } + } + + static void real_meas_value(byte_array_t name, meas_record_lst_t meas_record) + { + std::string meas_name{ba_to_string(name)}; + + // TODO: review this + // match meas by name + if (meas_name == "DRB.UEThpDl") + { + SPDLOG_DEBUG("DRB.UEThpDl = {:.2f} [Mbps]", meas_record.real_val/1000); + } + else if (meas_name == "DRB.UEThpUl") + { + SPDLOG_DEBUG("DRB.UEThpUl = {:.2f} [Mbps]", meas_record.real_val/1000); + } + else if (meas_name == "DRB.RlcSduDelayDl") + { + SPDLOG_DEBUG("DRB.RlcSduDelayDl = {:.2f} [μs]", meas_record.real_val); + } + else + { + SPDLOG_DEBUG("Measurement {} not yet supported", meas_name); + } + } + + // print UE id type + static void print_ue_id(ue_id_e2sm_e type, ue_id_e2sm_t ue_id) + { + switch (type) // define UE ID type (only 5G) + { + case ue_id_e2sm_e::GNB_UE_ID_E2SM: + if (ue_id.gnb.gnb_cu_ue_f1ap_lst != nullptr) + { + for (size_t i = 0; i < ue_id.gnb.gnb_cu_ue_f1ap_lst_len; ++i) + { + // split CU + SPDLOG_DEBUG("UE ID type = gNB-CU | gnb_cu_ue_f1ap = {:d}", ue_id.gnb.gnb_cu_ue_f1ap_lst[i]); + } + } + else + { + SPDLOG_DEBUG("UE ID type = gNB | amf_ue_ngap_id = {:d}", ue_id.gnb.amf_ue_ngap_id); // Monolitic ID + } + + if (ue_id.gnb.ran_ue_id != nullptr) + { + SPDLOG_DEBUG("ran_ue_id = {:x}", *ue_id.gnb.ran_ue_id); // RAN UE NGAP ID + } + break; + case ue_id_e2sm_e::GNB_DU_UE_ID_E2SM: + SPDLOG_DEBUG("UE ID type = gNB-DU | gnb_cu_ue_f1ap = {:d}", ue_id.gnb_du.gnb_cu_ue_f1ap); + if (ue_id.gnb_du.ran_ue_id != nullptr) + { + SPDLOG_DEBUG("ran_ue_id = {:x}", *ue_id.gnb_du.ran_ue_id); // RAN UE NGAP ID + } + break; + case ue_id_e2sm_e::GNB_CU_UP_UE_ID_E2SM: + SPDLOG_DEBUG("UE ID type = gNB-CU-UP | gnb_cu_cp_ue_e1ap = {:d}", ue_id.gnb_cu_up.gnb_cu_cp_ue_e1ap); + if (ue_id.gnb_cu_up.ran_ue_id != nullptr) + { + SPDLOG_DEBUG("ran_ue_id = {:x}", *ue_id.gnb_cu_up.ran_ue_id); // RAN UE NGAP ID + } + break; + default: + SPDLOG_WARN("UE ID type not supported!"); + break; + } + } + + // print UE measurements + static void print_measurements(kpm_ind_msg_format_1_t const* msg_frm_1) + { + assert(msg_frm_1->meas_info_lst_len > 0 && "Cannot correctly print measurements"); + + // UE Measurements per granularity period + for (size_t i = 0; i < msg_frm_1->meas_data_lst_len; ++i) + { + meas_data_lst_t const data_item{msg_frm_1->meas_data_lst[i]}; // get item + for (int j = 0; j < data_item.meas_record_len; ++j) + { + const meas_type_t meas_type{msg_frm_1->meas_info_lst[j].meas_type}; // item type + const meas_record_lst_t record_item{data_item.meas_record_lst[j]}; + + match_meas_type[meas_type.type](meas_type, record_item); + + if (data_item.incomplete_flag && *data_item.incomplete_flag == TRUE_ENUM_VALUE) + { + SPDLOG_DEBUG("Measurement Record not reliable"); + } + } + } + } + + static size_t get_kpm_idx(sm_ran_function_t const* rf, size_t rf_size) + { + for (size_t i = 0; i <= rf_size; i++) + { + if (rf[i].id == KPM_RAN_FUNC_ID) + { + return i; + } + } + + assert(0 != 0 && "KPM SM ID could not be found in the RAN Function List"); + } + + // return a filled test info lst + static test_info_lst_t filter_predicate() + { + test_info_lst_t dst{}; + + // filter by S-NSSAI criteria + constexpr test_cond_type_e type{S_NSSAI_TEST_COND_TYPE}; + constexpr test_cond_e condition{EQUAL_TEST_COND}; + constexpr u_int8_t value{1}; + + dst.test_cond_type = {type}; + dst.S_NSSAI = {TRUE_TEST_COND_TYPE}; + + // alloc test cond + dst.test_cond = {static_cast(calloc(1, sizeof(test_cond_e)))}; + assert(dst.test_cond != nullptr && "Memory exhausted!"); + *dst.test_cond = {condition}; + + // alloc test cond type + dst.test_cond_value = {static_cast(calloc(1, sizeof(test_cond_value_t)))}; + assert(dst.test_cond_value != nullptr && "Memory exhausted!"); + dst.test_cond_value->type = {OCTET_STRING_TEST_COND_VALUE}; + + // alloc octet string + dst.test_cond_value->octet_string_value = {static_cast(calloc(1, sizeof(byte_array_t)))}; + assert(dst.test_cond_value->octet_string_value != nullptr && "Memory exhausted!"); + + constexpr size_t len_nssai{1}; + dst.test_cond_value->octet_string_value->len = {len_nssai}; + + // alloc octet buffer + dst.test_cond_value->octet_string_value->buf = {static_cast(calloc(len_nssai, sizeof(uint8_t)))}; + assert(dst.test_cond_value->octet_string_value->buf != nullptr && "Memory exhausted!"); + dst.test_cond_value->octet_string_value->buf[0] = value; + + return dst; + } + + static label_info_lst_t fill_kpm_label() + { + label_info_lst_t label_item{nullptr}; + + label_item.noLabel = {static_cast(calloc(1, sizeof(enum_value_e)))}; + *label_item.noLabel = {TRUE_ENUM_VALUE}; + + return label_item; + } + + // return a type 1 definition format + static kpm_act_def_format_1_t fill_act_def_frm_1(ric_report_style_item_t const* report_item) + { + assert(report_item != nullptr); + kpm_act_def_format_1_t ad_frm_1{0}; + + const size_t size{report_item->meas_info_for_action_lst_len}; + + // [1, 65535] + ad_frm_1.meas_info_lst_len = size; + ad_frm_1.meas_info_lst = static_cast(calloc(size, sizeof(meas_info_format_1_lst_t))); + assert(ad_frm_1.meas_info_lst != nullptr && "Memory exhausted!"); + + // iterate over each measure + for (size_t i = 0; i < size; i++) + { + meas_info_format_1_lst_t* meas_item{&ad_frm_1.meas_info_lst[i]}; + + // Measurement Name + // 8.3.9 in the O-RAN specification + meas_item->meas_type.type = {meas_type_t::NAME_MEAS_TYPE}; + meas_item->meas_type.name = {copy_byte_array(report_item->meas_info_for_action_lst[i].name)}; + + // Measurement Label + // 8.3.11 in the O-RAN specification + meas_item->label_info_lst_len = {1}; + meas_item->label_info_lst = static_cast(calloc(1, sizeof(label_info_lst_t))); + assert(meas_item->label_info_lst != nullptr && "Memory exhausted!"); + meas_item->label_info_lst[0] = fill_kpm_label(); + } + + // Granularity Period + // 8.3.8 in the O-RAN specification + ad_frm_1.gran_period_ms = {PERIOD_MS}; + + // Cell Global ID + // 8.3.20 in the O-RAN specification - OPTIONAL + ad_frm_1.cell_global_id = {nullptr}; + +#if defined KPM_V2_03 || defined KPM_V3_00 + // [0, 65535] + ad_frm_1.meas_bin_range_info_lst_len = {0}; + ad_frm_1.meas_bin_info_lst = {nullptr}; +#endif + + return ad_frm_1; + } + + u_int64_t get_time_now_us() + { + auto now = std::chrono::duration_cast( + std::chrono::system_clock::now().time_since_epoch() + ); + return now.count(); + } + + // callback to handle return data from KPM subscription + static void sm_cb_kpm(sm_ag_if_rd_t const* rd) + { + assert(rd != nullptr); + assert(rd->type == INDICATION_MSG_AGENT_IF_ANS_V0); + assert(rd->ind.type == KPM_STATS_V3_0); + + // Reading Indication Message Format 3 + // 8.2.1.4.3 in the O-RAN specification + kpm_ind_data_t const* ind{&rd->ind.kpm.ind}; // indication + kpm_ric_ind_hdr_format_1_t const* hdr_frm_1{&ind->hdr.kpm_ric_ind_hdr_format_1}; // ind header + kpm_ind_msg_format_3_t const* msg_frm_3{&ind->msg.frm_3}; // ind message + + static int counter = 1; + u_int64_t latency{get_time_now_us() - hdr_frm_1->collectStartTime}; + + // create a new scope + { + pthread_mutex_lock(&mtx); + defer(pthread_mutex_unlock(&mtx)); + + // print latency xApp <-> E2 Node + printf("\n <--------------KPM ind_msg %d | latency = %lu [μs]--------------> \n", counter, + latency); // xApp <-> E2 Node + + // SPDLOG_DEBUG("KPM ind_msg latency = {:d} [μs]",); + + // Reported list of measurements per UE + for (size_t i = 0; i < msg_frm_3->ue_meas_report_lst_len; ++i) + { + // get UE ID + const ue_id_e2sm_t ue_id = msg_frm_3->meas_report_per_ue[i].ue_meas_report_lst; // id + const ue_id_e2sm_e ue_id_type = ue_id.type; // type + print_ue_id(ue_id_type, ue_id); + + // print measurements + print_measurements(&msg_frm_3->meas_report_per_ue[i].ind_msg_format_1); + } + + counter++; + } + } + + // handle with style report type 4 + static kpm_act_def_t fill_report_style_4(ric_report_style_item_t const* report_item) + { + assert(report_item != nullptr); + assert(report_item->act_def_format_type == FORMAT_4_ACTION_DEFINITION); + + // set kpm_act type to 4 + kpm_act_def_t act_def{.type = FORMAT_4_ACTION_DEFINITION}; + + // Fill matching condition + // [1, 32768] + act_def.frm_4.matching_cond_lst_len = 1; + act_def.frm_4.matching_cond_lst = static_cast(calloc( + act_def.frm_4.matching_cond_lst_len, sizeof(matching_condition_format_4_lst_t))); + assert(act_def.frm_4.matching_cond_lst != nullptr && "Memory exhausted"); + + // Filter connected UEs by some criteria + act_def.frm_4.matching_cond_lst[0].test_info_lst = {filter_predicate()}; + + // Fill Action Definition Format 1 + // 8.2.1.2.1 in the O-RAN spec + act_def.frm_4.action_def_format_1 = fill_act_def_frm_1(report_item); + + return act_def; + } + + // handle with meansurement name + static void match_meas_name_type(meas_type_t const& meas_type, meas_record_lst_t const& meas_record) + { + get_meas_value[meas_record.value](meas_type.name, meas_record); + } + + // TODO: not implemented yet + static void match_meas_type_id(meas_type_t const& meas_type, meas_record_lst_t const& meas_record) + { + (void)meas_type; + (void)meas_record; + assert(false && "ID Measurement Type not yet supported"); + } + + static kpm_sub_data_t gen_kpm_subs(kpm_ran_function_def_t const* ran_func) + { + assert(ran_func != nullptr); + assert(ran_func->ric_event_trigger_style_list != nullptr); + + kpm_sub_data_t kpm_sub{}; + + // Generate Event Trigger + assert(ran_func->ric_event_trigger_style_list[0].format_type == FORMAT_1_RIC_EVENT_TRIGGER); + kpm_sub.ev_trg_def.type = FORMAT_1_RIC_EVENT_TRIGGER; + kpm_sub.ev_trg_def.kpm_ric_event_trigger_format_1.report_period_ms = PERIOD_MS; + + // Generate Action Definition + kpm_sub.sz_ad = 1; + kpm_sub.ad = static_cast(calloc(kpm_sub.sz_ad, sizeof(kpm_act_def_t))); + assert(kpm_sub.ad != nullptr && "Memory exhausted"); + + // Multiple Action Definitions in one SUBSCRIPTION message is not supported + // Multiple REPORT Styles = Multiple Action Definition = Multiple SUBSCRIPTION messages + ric_report_style_item_t* const report_item = &ran_func->ric_report_style_list[0]; + ric_service_report_e const report_style_type = report_item->report_style_type; + *kpm_sub.ad = get_kpm_act_def[report_style_type](report_item); + + return kpm_sub; + } + + + void start(e2_node_arr_xapp_t const& e2Nodes) + { + SPDLOG_INFO("Starting KPM module..."); + // configure mutex + pthread_mutexattr_t attr{0}; + int rc{pthread_mutex_init(&mtx, &attr)}; + assert(rc == 0); + + // alloc memory for reports + auto hndl{static_cast(calloc(e2Nodes.len, sizeof(sm_ans_xapp_t)))}; + assert(hndl != nullptr); + defer(free(hndl)); + + for (size_t i = 0; i < e2Nodes.len; ++i) + { + e2_node_connected_xapp_t* e2Node{&e2Nodes.n[i]}; // get E2 node + const size_t kpm_idx{get_kpm_idx(e2Node->rf, e2Node->len_rf)}; // get KPM idx in list + assert(e2Node->rf[kpm_idx].defn.type == KPM_RAN_FUNC_DEF_E && "KPM is not the received RAN Function"); + + // if REPORT Service is supported by E2 node, send SUBSCRIPTION + // e.g. OAI CU-CP + if (e2Node->rf[kpm_idx].defn.kpm.ric_report_style_list != nullptr) + { + // Generate KPM SUBSCRIPTION message + kpm_sub_data_t kpm_sub = gen_kpm_subs(&e2Node->rf[kpm_idx].defn.kpm); + + // use API to send subscription + hndl[i] = {report_sm_xapp_api(&e2Node->id, KPM_RAN_FUNC_ID, &kpm_sub, sm_cb_kpm)}; + assert(hndl[i].success == true); + free_kpm_sub_data(&kpm_sub); + } + } + + // time to received metrics in seconds + std::this_thread::sleep_for(std::chrono::seconds(EXP_TIME)); + + for (size_t i = 0; i < e2Nodes.len; ++i) + { + // Remove the handle previously returned + if (hndl[i].success == true) + { + rm_report_sm_xapp_api(hndl[i].u.handle); + } + } + } +} diff --git a/src/logger.cpp b/src/logger.cpp index 4235508..4c63e74 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -1,12 +1,12 @@ -#include "../include/logger.hpp" - -#include "spdlog/sinks/stdout_color_sinks-inl.h" - -void configureLogger(const std::string& xAppName, spdlog::level::level_enum logLevel) -{ - auto console {spdlog::stdout_color_mt(xAppName)}; - // console->set_pattern("[%Y-%m-%d %H:%M:%S][" + xAppName + "]%^[%l]%$[%s:%#] %v"); - console->set_pattern("[" + xAppName + "]%^[%l]%$[%s:%#] %v"); - console->set_level(logLevel); - spdlog::set_default_logger(console); +#include "../include/logger.hpp" + +#include "spdlog/sinks/stdout_color_sinks-inl.h" + +void configureLogger(const std::string& xAppName, spdlog::level::level_enum logLevel) +{ + auto console {spdlog::stdout_color_mt(xAppName)}; + // console->set_pattern("[%Y-%m-%d %H:%M:%S][" + xAppName + "]%^[%l]%$[%s:%#] %v"); + console->set_pattern("[" + xAppName + "]%^[%l]%$[%s:%#] %v"); + console->set_level(logLevel); + spdlog::set_default_logger(console); } \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index d432613..e4f5a42 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,43 +1,67 @@ -#include -#include - -#include "e42_xapp_api.h" -#include "defer.hpp" -#include "e2Info.hpp" -#include "kpmManager.hpp" -#include "logger.hpp" - -int main(int argc, char* argv[]) -{ - // format args - fr_args_t args{init_fr_args(argc, argv)}; - - // init logger - configureLogger("iqos-xapp", spdlog::level::debug); - - // set FlexRIC IP (just for development) - args.ip = {"192.168.100.44"}; - - // init xApp - init_xapp_api(&args); - std::this_thread::sleep_for(std::chrono::seconds(1)); - - // get E2 Nodes - e2_node_arr_xapp_t e2Nodes{e2_nodes_xapp_api()}; - assert(e2Nodes.len > 0 && "There are no E2 nodes connected!"); - - // free memory allocated to E2 Nodes when finished - defer(free_e2_node_arr_xapp(&e2Nodes)); - - // KPM module - KpmManager::start(e2Nodes); - - // wait until all xApp processes have been completed - while (try_stop_xapp_api() == false) - { - std::this_thread::sleep_for(std::chrono::microseconds(1)); - } - - SPDLOG_INFO("xapp finished!"); - return EXIT_SUCCESS; -} +#include +#include + +#include "e42_xapp_api.h" +#include "defer.hpp" +#include "e2Info.hpp" +#include "kpmManager.hpp" +#include "logger.hpp" + +#include "rt_nonfinite.h" +#include "runPrediction.h" +#include "runPrediction_terminate.h" +#include "runPrediction_types.h" +#include + +int main(int argc, char* argv[]) +{ + // format args + fr_args_t args{init_fr_args(argc, argv)}; + + // init logger + configureLogger("iqos-xapp", spdlog::level::debug); + + // set FlexRIC IP (just for development) + //args.ip = {"127.0.0.1"}; + + // init xApp + init_xapp_api(&args); + std::this_thread::sleep_for(std::chrono::seconds(1)); + // get E2 Nodes + e2_node_arr_xapp_t e2Nodes{e2_nodes_xapp_api()}; + assert(e2Nodes.len > 0 && "There are no E2 nodes connected!"); + + // free memory allocated to E2 Nodes when finished + defer(free_e2_node_arr_xapp(&e2Nodes)); + //////////// + SPDLOG_INFO("Inicio do teste do modelo"); + categorical pred; + cell_wrap_0 r; + r.f1[0] = 0.421761282626275; + r.f1[1] = 0.678735154857774; + r.f1[2] = 0.915735525189067; + r.f1[3] = 0.757740130578333; + r.f1[4] = 0.792207329559554 ; + r.f1[5] = 0.743132468124916; + r.f1[6] = 0.959492426392903; + r.f1[7] = 0.392227019534168; + r.f1[8] = 0.655740699156587; + r.f1[9] = 0.655477890177557; + runPrediction(&r, &pred); + //SPDLOG_INFO("id: %d\n", id); + SPDLOG_INFO("Codes {}", pred.codes); + //SPDLOG_INFO("id: %d\n", pred.categoryNames); + SPDLOG_INFO("Final do teste do modelo"); + + // KPM module + KpmManager::start(e2Nodes); + + // wait until all xApp processes have been completed + while (try_stop_xapp_api() == false) + { + std::this_thread::sleep_for(std::chrono::microseconds(1)); + } + + SPDLOG_INFO("xapp finished!"); + return EXIT_SUCCESS; +} diff --git a/src/postProcessOutputToReturnCategorical.c b/src/postProcessOutputToReturnCategorical.c new file mode 100644 index 0000000..661c723 --- /dev/null +++ b/src/postProcessOutputToReturnCategorical.c @@ -0,0 +1,249 @@ +/* + * File: postProcessOutputToReturnCategorical.c + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +/* Include Files */ +#include "postProcessOutputToReturnCategorical.h" +#include "cellstr_sort.h" +#include "find.h" +#include "getCategoryNames.h" +#include "rt_nonfinite.h" +#include "runPrediction_internal_types.h" +#include "runPrediction_types.h" +#include "strcmp.h" +#include "strtrim.h" +#include "rt_nonfinite.h" +#include +#include + +/* Type Definitions */ +#ifndef c_typedef_emxArray_cell_wrap_1_ +#define c_typedef_emxArray_cell_wrap_1_ +typedef struct { + cell_wrap_1 data[3]; + int size[2]; +} emxArray_cell_wrap_1_1x3; +#endif /* c_typedef_emxArray_cell_wrap_1_ */ + +/* Function Definitions */ +/* + * Arguments : const cell_wrap_32 scores + * cell_wrap_1 c_processedOutput_0_categoryNam[] + * int *d_processedOutput_0_categoryNam + * Return Type : unsigned int + */ +unsigned int +c_DeepLearningNetwork_postProce(const cell_wrap_32 scores, + cell_wrap_1 c_processedOutput_0_categoryNam[], + int *d_processedOutput_0_categoryNam) +{ + static const char cv[3] = {'1', '2', '3'}; + cell_wrap_1 inData; + emxArray_cell_wrap_1_1x3 labelsCells; + emxArray_cell_wrap_1_1x3 r; + emxArray_cell_wrap_1_3 c; + emxArray_cell_wrap_1_3 uB; + int dIdx_data[3]; + int ib_data[3]; + int idx_data[3]; + int b_i; + int i; + int idx; + int idx_size; + int k; + int nz; + boolean_T b_d_data[3]; + boolean_T d_data[2]; + boolean_T exitg1; + if (!rtIsNaNF(scores.f1[0])) { + idx = 1; + } else { + idx = 0; + k = 2; + exitg1 = false; + while ((!exitg1) && (k < 4)) { + if (!rtIsNaNF(scores.f1[k - 1])) { + idx = k; + exitg1 = true; + } else { + k++; + } + } + } + if (idx == 0) { + idx = 1; + } else { + float ex; + ex = scores.f1[idx - 1]; + i = idx + 1; + for (k = i; k < 4; k++) { + float f; + f = scores.f1[k - 1]; + if (ex < f) { + ex = f; + idx = k; + } + } + } + labelsCells.size[1] = 0; + for (b_i = 0; b_i < 3; b_i++) { + nz = labelsCells.size[1] + 1; + labelsCells.size[1]++; + labelsCells.data[nz - 1].f1.size[0] = 1; + labelsCells.data[labelsCells.size[1] - 1].f1.size[1] = 1; + labelsCells.data[labelsCells.size[1] - 1].f1.data[0] = cv[b_i]; + } + strtrim(labelsCells.data[idx - 1].f1.data, labelsCells.data[idx - 1].f1.size, + inData.f1.data, inData.f1.size); + i = labelsCells.size[1]; + for (b_i = 0; b_i < i; b_i++) { + strtrim(labelsCells.data[b_i].f1.data, labelsCells.data[b_i].f1.size, + r.data[b_i].f1.data, r.data[b_i].f1.size); + } + if (labelsCells.size[1] != 0) { + c.size[0] = + cellstr_sort(r.data, labelsCells.size[1], c.data, idx_data, &idx_size); + } + *d_processedOutput_0_categoryNam = categorical_getCategoryNames( + r.data, labelsCells.size[1], c_processedOutput_0_categoryNam); + if (labelsCells.size[1] == 0) { + uB.size[0] = 0; + } else { + int vlen_tmp; + c.size[0] = + cellstr_sort(r.data, labelsCells.size[1], c.data, idx_data, &idx_size); + idx = c.size[0] - 1; + nz = c.size[0]; + for (b_i = 0; b_i <= nz - 2; b_i++) { + d_data[b_i] = !b_strcmp(c.data[b_i].f1.data, c.data[b_i].f1.size, + c.data[b_i + 1].f1.data, c.data[b_i + 1].f1.size); + } + vlen_tmp = c.size[0]; + b_d_data[0] = true; + if (idx - 1 >= 0) { + memcpy(&b_d_data[1], &d_data[0], (unsigned int)idx * sizeof(boolean_T)); + } + nz = b_d_data[0]; + for (k = 2; k <= vlen_tmp; k++) { + nz += b_d_data[k - 1]; + } + uB.size[0] = (int)fmin(nz, labelsCells.size[1]); + vlen_tmp = eml_find(b_d_data, c.size[0], dIdx_data); + for (b_i = 0; b_i < vlen_tmp; b_i++) { + if (b_i + 1 != vlen_tmp) { + double y_data[3]; + double d; + int y_size_idx_1; + d = (double)dIdx_data[b_i + 1] - 1.0; + i = dIdx_data[b_i]; + if (d < i) { + y_size_idx_1 = 0; + } else { + nz = (int)d - i; + y_size_idx_1 = nz + 1; + for (idx = 0; idx <= nz; idx++) { + y_data[idx] = (double)i + (double)idx; + } + } + idx = idx_data[(int)y_data[0] - 1]; + for (k = 2; k <= y_size_idx_1; k++) { + i = idx_data[(int)y_data[1] - 1]; + if (idx > i) { + idx = i; + } + } + ib_data[b_i] = idx; + } else { + double y_data[3]; + int y_size_idx_1; + i = dIdx_data[b_i]; + if (idx_size < i) { + y_size_idx_1 = 0; + } else { + nz = idx_size - i; + y_size_idx_1 = nz + 1; + for (i = 0; i <= nz; i++) { + y_data[i] = dIdx_data[b_i] + i; + } + } + idx = idx_data[(int)y_data[0] - 1]; + for (k = 2; k <= y_size_idx_1; k++) { + i = idx_data[(int)y_data[k - 1] - 1]; + if (idx > i) { + idx = i; + } + } + ib_data[b_i] = idx; + } + uB.data[b_i].f1.size[0] = 1; + i = r.data[idx - 1].f1.size[1]; + uB.data[b_i].f1.size[1] = i; + if (i - 1 >= 0) { + uB.data[b_i].f1.data[0] = r.data[idx - 1].f1.data[0]; + } + } + } + i = 0; + if (uB.size[0] > 0) { + boolean_T is_less_than; + nz = 0; + if (inData.f1.size[1] <= uB.data[0].f1.size[1]) { + idx_size = inData.f1.size[1]; + } else { + idx_size = 0; + } + if (idx_size == 0) { + is_less_than = (inData.f1.size[1] < uB.data[0].f1.size[1]); + } else if (inData.f1.data[0] == uB.data[0].f1.data[0]) { + is_less_than = (inData.f1.size[1] < uB.data[0].f1.size[1]); + } else { + is_less_than = (inData.f1.data[0] < uB.data[0].f1.data[0]); + } + if (!is_less_than) { + if (b_strcmp(inData.f1.data, inData.f1.size, uB.data[0].f1.data, + uB.data[0].f1.size)) { + i = ib_data[0]; + } else { + exitg1 = false; + while ((!exitg1) && (nz + 1 <= uB.size[0])) { + idx = uB.data[nz].f1.size[1]; + if (inData.f1.size[1] <= idx) { + idx_size = inData.f1.size[1]; + } else { + idx_size = 0; + } + if (idx_size == 0) { + is_less_than = (inData.f1.size[1] > idx); + } else if (inData.f1.data[0] == uB.data[nz].f1.data[0]) { + is_less_than = (inData.f1.size[1] > idx); + } else { + is_less_than = (inData.f1.data[0] > uB.data[nz].f1.data[0]); + } + if (is_less_than) { + nz++; + } else { + exitg1 = true; + } + } + if ((nz + 1 <= uB.size[0]) && + b_strcmp(inData.f1.data, inData.f1.size, uB.data[nz].f1.data, + uB.data[nz].f1.size)) { + i = ib_data[nz]; + } + } + } + } + if (i < 0) { + i = 0; + } + return (unsigned int)i; +} + +/* + * File trailer for postProcessOutputToReturnCategorical.c + * + * [EOF] + */ diff --git a/src/predict.c b/src/predict.c new file mode 100644 index 0000000..4ab42ff --- /dev/null +++ b/src/predict.c @@ -0,0 +1,35 @@ +/* + * File: predict.c + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +/* Include Files */ +#include "predict.h" +#include "predictForRNN.h" +#include "rt_nonfinite.h" +#include "runPrediction_internal_types.h" +#include "runPrediction_types.h" + +/* Function Definitions */ +/* + * Arguments : c_coder_internal_ctarget_DeepLe *obj + * const cell_wrap_0 *varargin_1 + * float varargout_1[3] + * Return Type : void + */ +void DeepLearningNetwork_predict(c_coder_internal_ctarget_DeepLe *obj, + const cell_wrap_0 *varargin_1, + float varargout_1[3]) +{ + cell_wrap_7 r; + r.f1[0] = *varargin_1; + c_DeepLearningNetwork_predictFo(obj, &r, varargout_1); +} + +/* + * File trailer for predict.c + * + * [EOF] + */ diff --git a/src/predictForRNN.c b/src/predictForRNN.c new file mode 100644 index 0000000..071caf1 --- /dev/null +++ b/src/predictForRNN.c @@ -0,0 +1,3680 @@ +/* + * File: predictForRNN.c + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +/* Include Files */ +#include "predictForRNN.h" +#include "SoftmaxLayer.h" +#include "elementwiseOperationInPlace.h" +#include "rt_nonfinite.h" +#include "runPrediction_internal_types.h" +#include "runPrediction_types.h" +#include "omp.h" +#include +#include +#include +#include +#include + +/* Function Declarations */ +static char *computeFilePathUsingEnvVariable(const char *unresolvedFilePath); + +static int div_nde_s32_floor(int numerator); + +static int div_s32_floor(int numerator, int denominator); + +static char *getCustomUserDataPathEnvVar(const char *unresolvedFilePath); + +static int getPositionOfLastFileSeparator(const char *filePath); + +static char *getRelativePathToParentFolder(const char *filePath); + +static char *getResolvedFilePath(const char *unresolvedFilePath); + +static void macroKernel1(int M, int K, int N, const float *A, int LDA, + const float *B, int LDB, float *C, int LDC); + +static void macroKernel2(int M, int K, int N, const float *A, int LDA, + const float *B, int LDB, float *C, int LDC); + +static void matrixMultiply1(int M, int K, int N, int blockSizeM, int blockSizeK, + int blockSizeN, const float *A, const float *B, + float *C); + +static void matrixMultiply2(int M, int K, int N, int blockSizeM, int blockSizeK, + int blockSizeN, const float *A, const float *B, + float *C); + +static void microKernel11(int K, const float *A, int LDA, const float *B, + float *C); + +static void microKernel12(int K, const float *A, int LDA, const float *B, + float *C); + +static void microKernel13(int K, const float *A, int LDA, const float *B, + float *C); + +static void readDnnConstants(float *inputBufferPtr, + const char *unresolvedFilePath, + int numElementsToRead); + +static char *resolveBinaryFilePath(const char *unresolvedFilePath); + +static char *sanitizeFilePathForHSP(const char *unSanitizedFilePath); + +static void stringConcat(char *destinationString, const char *sourceString, + size_t destBufferSize); + +/* Function Definitions */ +/* + * Arguments : const char *unresolvedFilePath + * Return Type : char * + */ +static char *computeFilePathUsingEnvVariable(const char *unresolvedFilePath) +{ + char *resolvedFilePath; + char *stringDuplicate; + size_t filePathLen; + size_t sizeOfChar; + filePathLen = strlen((char *)unresolvedFilePath) + 1; + sizeOfChar = 1; + stringDuplicate = (char *)calloc(filePathLen, sizeOfChar); + stringConcat(stringDuplicate, unresolvedFilePath, filePathLen); +#if defined(MW_RUNTIME_DL_DATA_PATH) != 0 + extern char *mwGetRuntimeDLDataPath(const char *); + resolvedFilePath = mwGetRuntimeDLDataPath((char *)unresolvedFilePath); +#elif defined(MW_DL_DATA_PATH) != 0 + resolvedFilePath = resolveBinaryFilePath(unresolvedFilePath); +#else + char *coderDataPath; + coderDataPath = getenv("CODER_DATA_PATH"); + if (coderDataPath != NULL) { + resolvedFilePath = resolveBinaryFilePath(unresolvedFilePath); + } else { + resolvedFilePath = stringDuplicate; + } +#endif + return resolvedFilePath; +} + +/* + * Arguments : int numerator + * Return Type : int + */ +static int div_nde_s32_floor(int numerator) +{ + int i; + if ((numerator < 0) && (numerator % 28 != 0)) { + i = -1; + } else { + i = 0; + } + return numerator / 28 + i; +} + +/* + * Arguments : int numerator + * int denominator + * Return Type : int + */ +static int div_s32_floor(int numerator, int denominator) +{ + int quotient; + if (denominator == 0) { + if (numerator >= 0) { + quotient = MAX_int32_T; + } else { + quotient = MIN_int32_T; + } + } else { + unsigned int absDenominator; + unsigned int absNumerator; + unsigned int tempAbsQuotient; + boolean_T quotientNeedsNegation; + if (numerator < 0) { + absNumerator = ~(unsigned int)numerator + 1U; + } else { + absNumerator = (unsigned int)numerator; + } + if (denominator < 0) { + absDenominator = ~(unsigned int)denominator + 1U; + } else { + absDenominator = (unsigned int)denominator; + } + quotientNeedsNegation = ((numerator < 0) != (denominator < 0)); + tempAbsQuotient = absNumerator / absDenominator; + if (quotientNeedsNegation) { + absNumerator %= absDenominator; + if (absNumerator > 0U) { + tempAbsQuotient++; + } + quotient = -(int)tempAbsQuotient; + } else { + quotient = (int)tempAbsQuotient; + } + } + return quotient; +} + +/* + * Arguments : const char *unresolvedFilePath + * Return Type : char * + */ +static char *getCustomUserDataPathEnvVar(const char *unresolvedFilePath) +{ + const char *fileName; + char *coderDataPath; + char *resolvedFilePath; + coderDataPath = getenv("CODER_DATA_PATH"); + if (coderDataPath != NULL) { + int posOfLastPathSeparator; + size_t filePathLength; + size_t sizeOfChar; + posOfLastPathSeparator = getPositionOfLastFileSeparator(unresolvedFilePath); + fileName = &unresolvedFilePath[posOfLastPathSeparator]; + filePathLength = (strlen(coderDataPath) + strlen((char *)fileName)) + 1; + sizeOfChar = 1; + resolvedFilePath = (char *)calloc(filePathLength, sizeOfChar); + stringConcat(resolvedFilePath, coderDataPath, filePathLength); + stringConcat(resolvedFilePath, fileName, filePathLength); + } else { + resolvedFilePath = NULL; + } + return resolvedFilePath; +} + +/* + * Arguments : const char *filePath + * Return Type : int + */ +static int getPositionOfLastFileSeparator(const char *filePath) +{ + int lastPathSeparatorUnix; + int posOfLastPathSeparator; + const char *ptrToLastPathSeparator; + lastPathSeparatorUnix = '/'; + ptrToLastPathSeparator = strrchr((char *)filePath, lastPathSeparatorUnix); + if (ptrToLastPathSeparator != NULL) { + posOfLastPathSeparator = (int)(ptrToLastPathSeparator - filePath); + } else { + int lastPathSeparatorWindows; + lastPathSeparatorWindows = '\\'; + ptrToLastPathSeparator = + strrchr((char *)filePath, lastPathSeparatorWindows); + if (ptrToLastPathSeparator != NULL) { + posOfLastPathSeparator = (int)(ptrToLastPathSeparator - filePath); + } else { + posOfLastPathSeparator = -1; + } + } + return posOfLastPathSeparator; +} + +/* + * Arguments : const char *filePath + * Return Type : char * + */ +static char *getRelativePathToParentFolder(const char *filePath) +{ + int posOfLastPathSeparator; + const char *fileName; + const char *parentDir; + char *resolvedFilePath; + size_t filePathLength; + size_t sizeOfChar; + parentDir = ".."; + posOfLastPathSeparator = getPositionOfLastFileSeparator(filePath); + fileName = &filePath[posOfLastPathSeparator]; + filePathLength = (strlen((char *)parentDir) + strlen((char *)fileName)) + 1; + sizeOfChar = 1; + resolvedFilePath = (char *)calloc(filePathLength, sizeOfChar); + stringConcat(resolvedFilePath, parentDir, filePathLength); + stringConcat(resolvedFilePath, fileName, filePathLength); + return resolvedFilePath; +} + +/* + * Arguments : const char *unresolvedFilePath + * Return Type : char * + */ +static char *getResolvedFilePath(const char *unresolvedFilePath) +{ + const char *fileOpenMode; + char *computedPathUsingEnvVars; + char *pathUsingEnvVarAndSanitizedPath; + char *relativePathToParent; + char *resolvedFilePath; + char *sanitizedFilePath; + char *stringDuplicate; + FILE *filePtr; + resolvedFilePath = NULL; + fileOpenMode = "rb"; + filePtr = fopen((char *)unresolvedFilePath, (char *)fileOpenMode); + if (filePtr) { + size_t filePathLen; + size_t sizeOfChar; + filePathLen = strlen((char *)unresolvedFilePath) + 1; + sizeOfChar = 1; + stringDuplicate = (char *)calloc(filePathLen, sizeOfChar); + stringConcat(stringDuplicate, unresolvedFilePath, filePathLen); + resolvedFilePath = stringDuplicate; + fclose(filePtr); + } else { + computedPathUsingEnvVars = + computeFilePathUsingEnvVariable(unresolvedFilePath); + filePtr = fopen(computedPathUsingEnvVars, (char *)fileOpenMode); + if (filePtr) { + resolvedFilePath = computedPathUsingEnvVars; + fclose(filePtr); + } else { + free(computedPathUsingEnvVars); + sanitizedFilePath = sanitizeFilePathForHSP(unresolvedFilePath); + filePtr = fopen(sanitizedFilePath, (char *)fileOpenMode); + if (filePtr) { + resolvedFilePath = sanitizedFilePath; + fclose(filePtr); + } else { + relativePathToParent = + getRelativePathToParentFolder(unresolvedFilePath); + filePtr = fopen(relativePathToParent, (char *)fileOpenMode); + if (filePtr) { + resolvedFilePath = relativePathToParent; + fclose(filePtr); + } else { + free(relativePathToParent); + pathUsingEnvVarAndSanitizedPath = + computeFilePathUsingEnvVariable(sanitizedFilePath); + filePtr = + fopen(pathUsingEnvVarAndSanitizedPath, (char *)fileOpenMode); + if (filePtr) { + resolvedFilePath = pathUsingEnvVarAndSanitizedPath; + fclose(filePtr); + } else { + free(pathUsingEnvVarAndSanitizedPath); + exit(EXIT_FAILURE); + } + } + } + } + } + return resolvedFilePath; +} + +/* + * Arguments : int M + * int K + * int N + * const float *A + * int LDA + * const float *B + * int LDB + * float *C + * int LDC + * Return Type : void + */ +static void macroKernel1(int M, int K, int N, const float *A, int LDA, + const float *B, int LDB, float *C, int LDC) +{ + int idxB; + int j; + j = 0; + idxB = 0; + while (j <= N - 1) { + int i; + int idxA; + int idxC; + idxC = LDC * j; + i = 0; + idxA = 0; + while (i <= M - 28) { + microKernel11(K, &A[idxA], LDA, &B[idxB], &C[idxC]); + idxA += 28; + idxC += 28; + i += 28; + } + while (i <= M - 4) { + microKernel12(K, &A[idxA], LDA, &B[idxB], &C[idxC]); + idxA += 4; + idxC += 4; + i += 4; + } + while (i <= M - 1) { + microKernel13(K, &A[idxA], LDA, &B[idxB], &C[idxC]); + idxA++; + idxC++; + i++; + } + idxB += LDB; + j++; + } +} + +/* + * Arguments : int M + * int K + * int N + * const float *A + * int LDA + * const float *B + * int LDB + * float *C + * int LDC + * Return Type : void + */ +static void macroKernel2(int M, int K, int N, const float *A, int LDA, + const float *B, int LDB, float *C, int LDC) +{ + int idxB; + int j; + j = 0; + idxB = 0; + while (j <= N - 1) { + int i; + int idxA; + int idxC; + idxC = LDC * j; + i = 0; + idxA = 0; + while (i <= M - 4) { + microKernel12(K, &A[idxA], LDA, &B[idxB], &C[idxC]); + idxA += 4; + idxC += 4; + i += 4; + } + while (i <= M - 1) { + microKernel13(K, &A[idxA], LDA, &B[idxB], &C[idxC]); + idxA++; + idxC++; + i++; + } + idxB += LDB; + j++; + } +} + +/* + * Arguments : int M + * int K + * int N + * int blockSizeM + * int blockSizeK + * int blockSizeN + * const float *A + * const float *B + * float *C + * Return Type : void + */ +static void matrixMultiply1(int M, int K, int N, int blockSizeM, int blockSizeK, + int blockSizeN, const float *A, const float *B, + float *C) +{ + const float *ptrB; + int b_i; + int b_j1; + int i; + int i0; + int i0_ub; + int k0; + int k0_ub; + memset(C, 0, (unsigned int)((M * N) << 2)); + if (blockSizeM >= M) { + blockSizeM = M; + } else { + blockSizeM = div_nde_s32_floor(blockSizeM) * 28; + if (blockSizeM <= 0) { + blockSizeM = 1; + } + } + if (blockSizeN >= N) { + blockSizeN = N; + } else if (blockSizeN <= 0) { + blockSizeN = 1; + } + i0_ub = div_s32_floor(M - 1, blockSizeM) + 1; + k0_ub = div_s32_floor(K - 1, blockSizeK) + 1; + for (b_j1 = 0; b_j1 < N; b_j1 += blockSizeN) { + int N2; + if (b_j1 > N - blockSizeN) { + N2 = N - b_j1; + } else { + N2 = blockSizeN; + } + for (k0 = 1; k0 <= k0_ub; k0++) { + int K2; + int k; + k = (k0 - 1) * blockSizeK; + if (k > K - blockSizeK) { + K2 = K - k; + } else { + K2 = blockSizeK; + } + ptrB = &B[k + K * b_j1]; +#pragma omp parallel for num_threads(omp_get_max_threads()) private(i, b_i) + + for (i0 = 1; i0 <= i0_ub; i0++) { + i = (i0 - 1) * blockSizeM; + if (i > M - blockSizeM) { + b_i = M - i; + } else { + b_i = blockSizeM; + } + macroKernel1(b_i, K2, N2, &A[i + M * k], M, ptrB, K, &C[i + M * b_j1], + M); + } + } + } +} + +/* + * Arguments : int M + * int K + * int N + * int blockSizeM + * int blockSizeK + * int blockSizeN + * const float *A + * const float *B + * float *C + * Return Type : void + */ +static void matrixMultiply2(int M, int K, int N, int blockSizeM, int blockSizeK, + int blockSizeN, const float *A, const float *B, + float *C) +{ + const float *ptrB; + int b_i; + int b_j1; + int i; + int i0; + int i0_ub; + int k0; + int k0_ub; + memset(C, 0, (unsigned int)((M * N) << 2)); + if (blockSizeM >= M) { + blockSizeM = M; + } else { + blockSizeM = (blockSizeM >> 2) << 2; + if (blockSizeM <= 0) { + blockSizeM = 1; + } + } + if (blockSizeN >= N) { + blockSizeN = N; + } else if (blockSizeN <= 0) { + blockSizeN = 1; + } + i0_ub = div_s32_floor(M - 1, blockSizeM) + 1; + k0_ub = div_s32_floor(K - 1, blockSizeK) + 1; + for (b_j1 = 0; b_j1 < N; b_j1 += blockSizeN) { + int N2; + if (b_j1 > N - blockSizeN) { + N2 = N - b_j1; + } else { + N2 = blockSizeN; + } + for (k0 = 1; k0 <= k0_ub; k0++) { + int K2; + int k; + k = (k0 - 1) * blockSizeK; + if (k > K - blockSizeK) { + K2 = K - k; + } else { + K2 = blockSizeK; + } + ptrB = &B[k + K * b_j1]; +#pragma omp parallel for num_threads(omp_get_max_threads()) private(i, b_i) + + for (i0 = 1; i0 <= i0_ub; i0++) { + i = (i0 - 1) * blockSizeM; + if (i > M - blockSizeM) { + b_i = M - i; + } else { + b_i = blockSizeM; + } + macroKernel2(b_i, K2, N2, &A[i + M * k], M, ptrB, K, &C[i + M * b_j1], + M); + } + } + } +} + +/* + * Arguments : int K + * const float *A + * int LDA + * const float *B + * float *C + * Return Type : void + */ +static void microKernel11(int K, const float *A, int LDA, const float *B, + float *C) +{ + __m128 b_c; + __m128 c; + __m128 c_c; + __m128 d_c; + __m128 e_c; + __m128 f_c; + __m128 g_c; + int idxA; + int idxB; + int k; + idxA = 0; + idxB = 0; + c = _mm_loadu_ps(&C[0]); + b_c = _mm_loadu_ps(&C[4]); + c_c = _mm_loadu_ps(&C[8]); + d_c = _mm_loadu_ps(&C[12]); + e_c = _mm_loadu_ps(&C[16]); + f_c = _mm_loadu_ps(&C[20]); + g_c = _mm_loadu_ps(&C[24]); + for (k = 0; k < K; k++) { + __m128 aFloat; + __m128 b; + __m128 b_aFloat; + __m128 c_aFloat; + __m128 d_aFloat; + __m128 e_aFloat; + __m128 f_aFloat; + __m128 g_aFloat; + float bFloat; + aFloat = _mm_loadu_ps(&A[idxA]); + b_aFloat = _mm_loadu_ps(&A[idxA + 4]); + c_aFloat = _mm_loadu_ps(&A[idxA + 8]); + d_aFloat = _mm_loadu_ps(&A[idxA + 12]); + e_aFloat = _mm_loadu_ps(&A[idxA + 16]); + f_aFloat = _mm_loadu_ps(&A[idxA + 20]); + g_aFloat = _mm_loadu_ps(&A[idxA + 24]); + bFloat = B[idxB]; + b = _mm_set1_ps(bFloat); + c = _mm_add_ps(c, _mm_mul_ps(aFloat, b)); + b_c = _mm_add_ps(b_c, _mm_mul_ps(b_aFloat, b)); + c_c = _mm_add_ps(c_c, _mm_mul_ps(c_aFloat, b)); + d_c = _mm_add_ps(d_c, _mm_mul_ps(d_aFloat, b)); + e_c = _mm_add_ps(e_c, _mm_mul_ps(e_aFloat, b)); + f_c = _mm_add_ps(f_c, _mm_mul_ps(f_aFloat, b)); + g_c = _mm_add_ps(g_c, _mm_mul_ps(g_aFloat, b)); + idxA += LDA; + idxB++; + } + _mm_storeu_ps(&C[0], c); + _mm_storeu_ps(&C[4], b_c); + _mm_storeu_ps(&C[8], c_c); + _mm_storeu_ps(&C[12], d_c); + _mm_storeu_ps(&C[16], e_c); + _mm_storeu_ps(&C[20], f_c); + _mm_storeu_ps(&C[24], g_c); +} + +/* + * Arguments : int K + * const float *A + * int LDA + * const float *B + * float *C + * Return Type : void + */ +static void microKernel12(int K, const float *A, int LDA, const float *B, + float *C) +{ + __m128 c; + int idxA; + int idxB; + int k; + idxA = 0; + idxB = 0; + c = _mm_loadu_ps(&C[0]); + for (k = 0; k < K; k++) { + __m128 aFloat; + float bFloat; + aFloat = _mm_loadu_ps(&A[idxA]); + bFloat = B[idxB]; + c = _mm_add_ps(c, _mm_mul_ps(aFloat, _mm_set1_ps(bFloat))); + idxA += LDA; + idxB++; + } + _mm_storeu_ps(&C[0], c); +} + +/* + * Arguments : int K + * const float *A + * int LDA + * const float *B + * float *C + * Return Type : void + */ +static void microKernel13(int K, const float *A, int LDA, const float *B, + float *C) +{ + float c; + int idxA; + int idxB; + int k; + idxA = 0; + idxB = 0; + c = C[0]; + for (k = 0; k < K; k++) { + float aFloat; + float b; + aFloat = A[idxA]; + b = B[idxB]; + c += aFloat * b; + idxA += LDA; + idxB++; + } + C[0] = c; +} + +/* + * Arguments : float *inputBufferPtr + * const char *unresolvedFilePath + * int numElementsToRead + * Return Type : void + */ +static void readDnnConstants(float *inputBufferPtr, + const char *unresolvedFilePath, + int numElementsToRead) +{ + int elementSizeInBytes; + const char *fileOpenMode; + char *resolvedFilePath; + FILE *filePtr; + void *dataBufferPtr; + resolvedFilePath = getResolvedFilePath(unresolvedFilePath); + fileOpenMode = "rb"; + filePtr = fopen(resolvedFilePath, (char *)fileOpenMode); + dataBufferPtr = &inputBufferPtr[0]; + elementSizeInBytes = 4; + fread(dataBufferPtr, elementSizeInBytes, numElementsToRead, filePtr); + fclose(filePtr); + free(resolvedFilePath); +} + +/* + * Arguments : const char *unresolvedFilePath + * Return Type : char * + */ +static char *resolveBinaryFilePath(const char *unresolvedFilePath) +{ + const char *c_filePathAfterSlicingRelativeP; + const char *c_leadingPathSeparatorUnixAndWi; + const char *codegenDirStrInMWDLDataPath; + const char *d_filePathAfterSlicingRelativeP; + const char *mwDLDataPath; + char *codegenDir; + char *coderDataPath; + char *resolvedFilePath; + char *updatedStartDir; + size_t sizeOfChar; +#define XSTR(x) #x +#define STR(x) XSTR(x) + coderDataPath = getenv("CODER_DATA_PATH"); + sizeOfChar = 1; + if (coderDataPath != NULL) { + resolvedFilePath = getCustomUserDataPathEnvVar(unresolvedFilePath); + } else { + size_t filePathLen; + size_t posOfCodegenDir; + size_t posOfLeadingPathSeparator; + mwDLDataPath = STR(MW_DL_DATA_PATH); + c_filePathAfterSlicingRelativeP = &unresolvedFilePath[2]; + c_leadingPathSeparatorUnixAndWi = "/\\"; + posOfLeadingPathSeparator = + strcspn((char *)c_filePathAfterSlicingRelativeP, + (char *)c_leadingPathSeparatorUnixAndWi); + filePathLen = posOfLeadingPathSeparator + 1; + codegenDir = (char *)calloc(filePathLen, sizeOfChar); + strncpy(codegenDir, (char *)c_filePathAfterSlicingRelativeP, + posOfLeadingPathSeparator); + codegenDirStrInMWDLDataPath = strstr((char *)mwDLDataPath, codegenDir); + if (codegenDirStrInMWDLDataPath == NULL) { + posOfCodegenDir = strlen((char *)mwDLDataPath); + } else { + posOfCodegenDir = codegenDirStrInMWDLDataPath - mwDLDataPath; + } + if (posOfCodegenDir == strlen((char *)mwDLDataPath)) { + size_t b_filePathLen; + d_filePathAfterSlicingRelativeP = &unresolvedFilePath[1]; + b_filePathLen = (strlen((char *)mwDLDataPath) + + strlen((char *)d_filePathAfterSlicingRelativeP)) + + 1; + resolvedFilePath = (char *)calloc(b_filePathLen, sizeOfChar); + stringConcat(resolvedFilePath, mwDLDataPath, b_filePathLen); + stringConcat(resolvedFilePath, d_filePathAfterSlicingRelativeP, + b_filePathLen); + } else { + size_t c_filePathLen; + c_filePathLen = posOfCodegenDir + 1; + updatedStartDir = (char *)calloc(c_filePathLen, sizeOfChar); + strncpy(updatedStartDir, (char *)mwDLDataPath, posOfCodegenDir); + c_filePathLen = (strlen(updatedStartDir) + + strlen((char *)c_filePathAfterSlicingRelativeP)) + + 1; + resolvedFilePath = (char *)calloc(c_filePathLen, sizeOfChar); + stringConcat(resolvedFilePath, updatedStartDir, c_filePathLen); + stringConcat(resolvedFilePath, c_filePathAfterSlicingRelativeP, + c_filePathLen); + free(updatedStartDir); + } + free(codegenDir); + } +#undef XSTR +#undef STR + return resolvedFilePath; +} + +/* + * Arguments : const char *unSanitizedFilePath + * Return Type : char * + */ +static char *sanitizeFilePathForHSP(const char *unSanitizedFilePath) +{ + char *sanitizedFilePath; + char *stringDuplicate; + size_t charIdx; + size_t filePathLen; + size_t sizeOfChar; + filePathLen = strlen((char *)unSanitizedFilePath) + 1; + sizeOfChar = 1; + stringDuplicate = (char *)calloc(filePathLen, sizeOfChar); + stringConcat(stringDuplicate, unSanitizedFilePath, filePathLen); + sanitizedFilePath = stringDuplicate; + for (charIdx = 0; charIdx < strlen((char *)unSanitizedFilePath); charIdx++) { + char charToCheckFor; + charToCheckFor = unSanitizedFilePath[charIdx]; + if (isspace(charToCheckFor)) { + sanitizedFilePath[charIdx] = '_'; + } + } + return sanitizedFilePath; +} + +/* + * Arguments : char *destinationString + * const char *sourceString + * size_t destBufferSize + * Return Type : void + */ +static void stringConcat(char *destinationString, const char *sourceString, + size_t destBufferSize) +{ + size_t dstStringLen; + size_t srcBuffIdx; + dstStringLen = strlen(destinationString); + srcBuffIdx = 0; + while ((sourceString[srcBuffIdx] != '\x00') && + (dstStringLen < destBufferSize - 1)) { + destinationString[dstStringLen] = sourceString[srcBuffIdx]; + dstStringLen++; + srcBuffIdx++; + } + destinationString[dstStringLen] = '\x00'; +} + +/* + * Arguments : c_coder_internal_ctarget_DeepLe *obj + * const cell_wrap_7 *inputs + * float outputData[3] + * Return Type : void + */ +void c_DeepLearningNetwork_predictFo(c_coder_internal_ctarget_DeepLe *obj, + const cell_wrap_7 *inputs, + float outputData[3]) +{ + static const float inputGateWeights[6000] = { + -0.000811605947F, -0.000403957471F, -0.00243100966F, -0.00382114528F, + -1.61899629E-6F, 8.94312834E-5F, 3.33629373E-8F, -0.00425082352F, + 0.00117815973F, 0.000285012764F, -0.000811230741F, -0.00724314759F, + -0.000264779141F, -0.00258482061F, 0.00162944873F, 8.97908249E-5F, + -0.000722732279F, 6.67564E-5F, -0.000458168564F, -0.00289038289F, + 0.00118018349F, -0.00354100973F, -0.00536254933F, 0.00176362577F, + -0.00750035793F, -0.00060664257F, -0.000997146126F, -0.0116265547F, + -0.00482856948F, -0.00205494091F, -7.65724544E-5F, 0.000909248949F, + -0.00269363518F, -0.00750014372F, 0.00344320945F, -0.00143878628F, + -4.41497E-5F, -2.53833714E-5F, 0.00156619423F, 6.4109925E-5F, + 0.00199011597F, -0.00476080133F, -0.000650383416F, -0.00143824052F, + 0.00153224671F, 0.000200324575F, 0.000473109016F, 0.00872225F, + -0.00109102495F, 0.00278788828F, -0.000165615755F, 0.000912846881F, + -4.58752729E-5F, 0.000656165648F, -8.32701626E-5F, -0.00211699493F, + 3.13232704E-5F, -0.00015071973F, -0.00205210666F, -3.14534554E-5F, + -0.00257907459F, -0.000839801331F, 0.000303567096F, 0.000858099433F, + -0.000419144606F, 0.00110944198F, -0.000466345955F, 0.00601498084F, + -0.00128040288F, -0.0017145155F, -0.00270682387F, -4.08081432E-5F, + 0.000802380615F, 0.00108201848F, 0.00547708385F, 3.56709029E-6F, + 0.000848850817F, 0.000112977606F, 0.0191977564F, -1.78888968E-6F, + 0.001068527F, -0.00191915617F, -0.000542698079F, -0.000778352842F, + -0.00399637595F, -0.000301109743F, -0.000833869795F, -4.78726815E-6F, + 0.000922654697F, -0.000965991348F, 0.00956691802F, -6.71592034E-7F, + 0.00641599111F, 0.00158196315F, -0.00165505824F, -0.00164006534F, + -0.000922036357F, -0.0122742346F, -0.00288693188F, -0.00179624034F, + -0.00144492928F, 0.00200292049F, 0.00038812781F, 0.00243068673F, + -0.000384585699F, -0.00131170952F, -0.0133962277F, -0.000903941866F, + -0.0105738929F, -1.36190774E-5F, -0.00137141324F, -0.00745969266F, + -0.00398253417F, 0.00192800432F, -0.00624481402F, 0.00340897264F, + -0.00877490267F, 0.00107280724F, 8.23896244E-6F, 1.90006795E-5F, + -0.000297067629F, 0.000141839613F, -0.00270557613F, -8.70891818E-5F, + -1.74382512E-5F, 2.75350067E-6F, -0.0216990504F, 8.67056224E-5F, + -0.0078932941F, -0.00243158638F, 0.00200448371F, -0.00421523768F, + 0.00108560862F, 1.69544592E-6F, 0.0149881607F, 0.000174406043F, + -0.00089146645F, -0.029095266F, -0.00348802F, 0.00324869575F, + -0.0134712942F, -0.000393848866F, -0.000382144848F, 0.00499655865F, + -0.00390520808F, -0.0143280849F, -0.0170159284F, 0.00143948745F, + -0.00839268696F, 7.617E-5F, -0.00247039157F, -3.76980388E-5F, + -0.0126846023F, 0.00071061874F, 0.000569965632F, 0.000760204915F, + -8.71344218E-6F, -0.00246503623F, -2.8254788E-5F, 0.00113789295F, + -0.0192671493F, -5.61246566E-7F, -4.27587293E-5F, -5.76605162E-5F, + 0.00314563443F, -0.000292386336F, 0.00187341729F, -0.00175093219F, + -0.00920009706F, 0.00645841891F, -0.00190291763F, -0.00525206327F, + 0.000170764935F, -0.0051871459F, -0.000854811049F, -0.00232053944F, + 0.000217197885F, -0.007993415F, 0.000167308128F, -0.00017179655F, + -0.00069077F, 0.000195302957F, -0.00406250637F, -0.000487260608F, + -0.00466525508F, -0.00457048F, 6.33207455E-5F, -0.0177318417F, + -0.001868158F, -0.0034441324F, 0.011472363F, -0.0108168544F, + 0.00105403725F, -0.000770160696F, 0.00436559506F, 0.000644307933F, + 0.000752061489F, 0.0016595393F, -8.42808458E-6F, -0.00146652537F, + -0.016702015F, 8.31717716E-6F, -0.00506815035F, -0.00175201625F, + -0.000143088153F, -0.00729175285F, 8.3304E-6F, 7.93801E-6F, + 0.00237559131F, 0.00630716048F, -0.00536399335F, 0.00410625711F, + 0.00445362646F, -0.00364957773F, -0.000552527F, -0.000721465272F, + -0.0205494743F, -0.00212246971F, 4.41369593E-6F, -0.011017411F, + -0.00364588737F, 0.00188267208F, -0.00330484216F, 0.000617115758F, + -0.00467597088F, 0.000911520037F, 0.00586306769F, -0.00307324366F, + 0.0010423233F, 0.000501304283F, -0.00309185148F, -0.00420717057F, + 0.000252720696F, -0.00433394825F, 0.0320770554F, -0.000810697966F, + -0.00100285269F, 0.00127381389F, -0.00421597F, -0.0132333869F, + 0.00924789347F, -3.01955042E-5F, -0.0017936381F, -0.00629194966F, + 0.00310924463F, 0.00210362556F, 0.00228453963F, -0.00128047599F, + 0.000490717415F, -0.000878808612F, -0.00242064195F, 9.85230486E-7F, + -0.00412050541F, -0.00421520695F, -0.0108643984F, -2.54645693E-6F, + 0.00265787682F, 0.00266699796F, -0.012327808F, 0.00526723638F, + 0.000719826785F, 0.000910493545F, -0.00204292685F, -0.000629368878F, + 4.45231899E-6F, -0.000880324F, 0.000793417043F, -0.00177949714F, + 0.00126109668F, -0.00467776274F, -0.00124699401F, -0.00387738692F, + -4.50263833E-5F, -0.0021794159F, 0.00236567738F, 0.0402653404F, + 3.16186788E-6F, -0.00423286483F, -0.000512570725F, -0.00147495267F, + 2.60538582E-6F, 0.0002340629F, -0.00420566043F, 0.00110991602F, + -0.000987997F, 0.00204872806F, -0.00046921274F, 0.000477836933F, + -0.00619898969F, -1.32577316E-6F, -0.000911664742F, 0.000740749296F, + 0.00134773948F, 0.000356668519F, -0.00101690216F, -0.00582189392F, + -0.000109753295F, 0.000211407358F, -0.000429577776F, 0.00546530867F, + 0.00132332661F, -0.00350617012F, -0.00282140449F, -0.000563936424F, + 8.49358184E-6F, 0.00376087753F, -0.00164849241F, -9.77022137E-6F, + 9.86206796E-5F, -0.00163003604F, 0.000961513259F, 2.17204324E-5F, + 0.000889442279F, -0.00200066692F, 0.00219748635F, -0.000264933F, + 3.27803682E-5F, 0.000112305403F, -0.00109216128F, 7.83550513E-6F, + -0.00147194078F, -0.000386311905F, -0.0067365896F, -0.00144044787F, + 0.00102290057F, -0.00197097636F, 0.00126772863F, 0.000304743706F, + -0.000149174026F, 0.00581812207F, 0.00347587373F, 0.000638974714F, + 0.00573324598F, -0.000721504621F, 0.00735181663F, 0.00508338353F, + -0.00079733436F, 0.00590155972F, -0.00139975F, 0.000223178053F, + -0.017197445F, 0.00138708483F, 0.00198702631F, -0.000357715908F, + 0.00834593736F, 0.000662176928F, -0.00143365178F, 0.000239587578F, + -0.00252752309F, -0.000405279046F, -0.00196682988F, -0.0526564904F, + 2.09116308E-7F, 1.84966175E-5F, 0.00208460912F, -0.0049990993F, + -0.00153592939F, -0.00217976142F, 0.00137076678F, -0.00504119089F, + -0.00764889177F, -0.00695648836F, 0.00287892297F, -0.00640079333F, + -0.000941274222F, -2.07167141E-5F, 4.51033975E-6F, -6.72665774E-5F, + -0.00554905413F, -0.00759694213F, 1.45602771E-5F, -0.00225794129F, + 5.01600152E-5F, 0.00210504816F, -0.000236742271F, 1.56753395E-5F, + 0.00058416347F, 1.20942204E-5F, 2.6500471E-5F, 1.82370741E-7F, + -0.000187352882F, 0.00033283548F, 1.59073056E-6F, -0.00135960849F, + -0.000113003458F, -0.00062688085F, -0.00190243125F, 0.00105367391F, + 0.000124148515F, 0.00194192713F, 0.000295474136F, -0.000529131328F, + -0.00266979425F, -0.000748379F, -1.00908437E-6F, -0.00230876752F, + 0.00046129516F, 0.00184460951F, 0.00173564104F, -0.000515196298F, + -0.00014261168F, 0.000451887754F, -0.000650619215F, -0.00239279517F, + 3.33026094E-7F, -0.000644662825F, 1.94168464E-7F, -0.00160344341F, + 0.00578579679F, 1.89723651E-5F, -0.000120462428F, -0.00150031981F, + 0.000384779589F, -0.00758471387F, -0.00306786F, 9.10715753E-5F, + 0.000395086652F, 8.08577624E-7F, -0.00165234099F, 0.000297687366F, + -7.7729128E-5F, -0.00158998289F, 0.00111567031F, 0.000756858615F, + -0.00189930841F, 0.000165515579F, 0.000165742254F, -0.000606068643F, + -0.00150391879F, -0.00198520347F, -1.50397636E-6F, 0.000577893399F, + -0.000767694903F, -0.000283680594F, 0.000543883536F, -0.000703565544F, + -8.15253827E-7F, -3.11458223E-7F, 0.000276491832F, 0.000115314906F, + -0.00378054962F, -0.00126468565F, -0.000267570693F, -0.00165691797F, + 0.00428311573F, 0.00136005017F, -0.00193680625F, 0.00331872725F, + 0.000398474251F, 0.0130816931F, 6.77057733E-6F, -0.000400098827F, + -1.56202009E-6F, -0.000719008269F, 7.35082431E-5F, -6.14573873E-5F, + 3.76121679E-5F, -5.11929138E-5F, -0.000980286F, -1.87690148E-7F, + -0.000606924645F, -0.000931074144F, -0.00013314806F, 0.000270338962F, + 8.15370186E-6F, 0.00888133422F, 6.20551145E-5F, 0.00766234659F, + -0.000573340803F, -0.00023898542F, -0.000986089581F, -1.91030199E-6F, + -0.000222552597F, 0.00929437391F, -0.00629347796F, -5.66376315E-8F, + 0.0111953896F, -0.000158965049F, 0.00551053416F, 1.26934268E-8F, + 0.0123075927F, -0.00124351669F, -0.00292155F, -0.000379053119F, + -4.62019416E-5F, -0.000138360847F, -0.000680214085F, -1.89772095E-7F, + 0.0123702716F, -0.00014069106F, -0.0012336747F, -1.48647587E-7F, + 0.00131486F, -0.00022802077F, 0.000190068982F, -0.000668313529F, + 0.000139561715F, -0.0047541284F, -0.000198949245F, 9.53895287E-5F, + -0.000370188529F, -0.000309302297F, 7.29186504E-5F, 0.00331131881F, + 6.27085537E-5F, 5.12397528E-5F, -0.00133802113F, -0.0129850926F, + -0.00232384773F, 7.95079541E-6F, 0.000107047716F, -0.00180797349F, + -0.000651682843F, 0.00257152971F, -0.000841458677F, 0.00596895907F, + -0.00225629727F, -0.00188369118F, 9.5196441E-8F, -1.2867124E-6F, + 2.67723444E-5F, -5.34412975E-5F, -0.000374720839F, 1.91901199E-5F, + -1.55552172E-7F, -2.56239701E-7F, -0.00111451687F, -2.74797385E-5F, + -0.00115484663F, -0.000386414409F, -0.000161124408F, -0.000318843522F, + 0.0125539303F, 4.1508514E-7F, 0.00291154417F, -0.000378979516F, + 6.91920141E-5F, -0.00353199337F, -2.84090802E-5F, -0.002148428F, + -0.0358575881F, 0.000263321592F, 9.35499193E-5F, 0.00251562265F, + -0.00115710613F, -0.000480831979F, -0.00159233692F, 0.000873686164F, + -0.00206386927F, -0.000281714136F, -0.000790852588F, -7.20734647E-7F, + -0.00109115406F, 0.000320314284F, 0.000101897145F, 0.0191060193F, + -1.26713599E-6F, -0.000196462104F, -6.78992456E-6F, -0.00202317326F, + -0.00260305521F, 6.79560372E-8F, -1.30943505E-8F, -3.18288926E-7F, + 0.000292524346F, 3.44303699E-5F, 0.00290977093F, -0.00195633643F, + -0.0047193463F, 0.00731484871F, -0.000117639567F, -0.000554707949F, + 0.000105244195F, -0.00118221925F, -0.00077762123F, 0.000990227913F, + 0.0116961971F, -0.00110797922F, 0.000242607217F, -0.000159077274F, + 0.000154975394F, -0.000126425613F, -0.000364270469F, -0.000879781262F, + -0.000195086497F, -0.000620274164F, -0.00042732872F, -0.00298540411F, + -0.000394841016F, -0.00127542717F, 0.000980596757F, -0.00178104138F, + 0.00068550976F, 0.000129752429F, 0.00111229403F, -2.02965221E-5F, + 0.00295794546F, 0.007908375F, -4.944377E-7F, -0.00119032722F, + -0.00176996214F, 3.3249588E-8F, -0.000405175553F, 0.00127139525F, + -0.000176477901F, -0.000768122612F, -7.41921582E-8F, -9.67997522E-8F, + 0.0167754423F, 0.000491204206F, -0.00231744535F, 0.000554278202F, + 0.00786675513F, -0.00124292052F, 0.0108619565F, 0.000669633388F, + -0.00639148057F, -8.13798324E-5F, -2.96530231E-8F, -0.00120318541F, + -0.000579812622F, 0.00642213924F, -0.00011562679F, 0.00351559953F, + -0.0015330622F, 0.00786566548F, 0.0016404792F, -0.000253595121F, + -0.00419046218F, 0.000165636666F, -0.00176428992F, -0.000851699966F, + -0.000477203837F, -0.000326357549F, 0.00570593774F, -7.82384886E-5F, + -0.000161923861F, 5.02669E-5F, -0.00053282F, -0.00424104603F, + 0.000396475429F, -2.50267271E-6F, 0.000120643635F, -0.00204919977F, + -0.00041275876F, 0.000769685372F, 0.00418855436F, -0.00150115555F, + 5.37781E-5F, 0.000158021794F, -0.000442112039F, 3.69502402E-8F, + -0.000606196816F, -0.00179795758F, -0.00540665537F, -5.75662852E-7F, + 0.00870712F, 0.00148048345F, -0.00277970312F, -0.00397114083F, + 0.00363991084F, 0.000233072918F, 0.000809254299F, 0.000110961344F, + -2.1880453E-10F, -0.00111917499F, -7.99785485E-5F, -0.00110256637F, + 0.0143343061F, -0.0009974F, -0.00189436448F, -0.000437969487F, + 8.30399358E-8F, -0.000884850509F, 0.000687210239F, 0.00505657867F, + -4.42468973E-7F, -0.000901515363F, -0.00177047623F, -0.00097598508F, + 1.50889662E-7F, 0.000165444115F, -0.000719634641F, 0.0129850926F, + -0.000686098123F, 0.000850242272F, 0.00219735201F, -0.000208899117F, + -0.000262733316F, 1.51694876E-5F, 0.000175611203F, 0.0077589117F, + 0.00075067475F, 0.00991781708F, -0.000313583F, -0.0158041436F, + 7.4094889E-5F, 0.000193189175F, -0.000258028274F, -0.000630856259F, + -0.00180789409F, -0.00569119724F, 0.000214955435F, -8.92779499E-5F, + 0.000206874873F, 0.000155327769F, -0.000957209209F, -2.71123383E-7F, + 8.41224755E-5F, -0.000454080058F, 0.00130374578F, -3.28658132E-7F, + 6.77177522E-5F, -0.000290184369F, 0.00196300074F, -0.000132500514F, + -1.04030619E-7F, 4.86098215E-5F, -0.000782931922F, -4.07849683E-7F, + 0.000260191387F, 0.000133648617F, -0.0011504821F, 0.000160504831F, + -0.00230136095F, 0.000340919243F, 0.01486474F, 0.00875595491F, + -0.000733483874F, 0.00347366789F, 0.00249532843F, 0.00979369227F, + 0.0118656624F, 6.23203814E-5F, 0.00125633203F, -0.00270320382F, + -1.39859876E-5F, 0.00249506417F, -0.000368554145F, 2.53509334E-5F, + -0.00258716987F, -0.000624460576F, 0.00152955006F, 3.70989073E-5F, + 0.00114001764F, -0.000720094191F, -0.000843603397F, -0.000453024171F, + -0.000321123196F, -0.000709735614F, 7.37099617E-5F, 0.00668225531F, + 1.31032195E-7F, -1.47728383E-6F, -0.000141604658F, -0.00109070854F, + 0.000120466706F, 0.00140152627F, 0.0108877169F, -0.000963613275F, + -0.00533930119F, -0.00143392663F, 0.000418288895F, -0.000776159519F, + -0.000339441438F, -3.18142526E-7F, -7.64513516E-7F, -4.95546715E-9F, + -0.00187881896F, -0.000128142143F, 1.39529192E-7F, -0.000601065636F, + 1.89759521E-5F, 0.00141948438F, -5.97627586E-5F, 2.38558812E-7F, + 0.0172189251F, -1.69510031E-7F, -7.09732944E-7F, 3.85238792E-7F, + 0.00239633257F, 4.8831138E-5F, -2.04676127E-7F, -8.42860209E-6F, + -6.74265248E-5F, -0.000330363953F, 1.12161806E-5F, 0.00158293906F, + 0.00118106545F, 0.000395420444F, 0.000149852465F, -0.000117827905F, + -0.000451952947F, -1.94844033E-5F, 1.3625332E-5F, -0.000465184741F, + 0.00472352887F, -0.000250676909F, -0.0103198057F, -0.000504570722F, + -0.000859845604F, 0.000237973072F, -0.00227992097F, -0.00708614F, + -1.29671844E-6F, -0.00154623564F, -3.23575193E-7F, -0.0147726163F, + 0.000334113836F, 9.91036941E-5F, -0.000837447529F, -0.00266561774F, + -0.000462967466F, -0.0157461166F, 0.000996652409F, -0.00155728776F, + -0.00861608F, 6.55998883E-5F, -0.00628548255F, -0.000260568748F, + -0.00745093357F, -0.000934191106F, -0.0181049462F, 0.00325698033F, + -0.00658648834F, -0.00119085377F, -0.000581591914F, -0.00251859706F, + -0.00806534F, -0.00619440293F, -7.49534156E-5F, 0.00113818992F, + -0.00563348318F, -0.0157052F, 0.00511393929F, -0.00144257722F, + -4.38337192E-5F, -2.5205E-5F, 0.00223064958F, -0.000349623093F, + -0.0012159053F, -0.00165131467F, -0.000725020596F, -0.000782784889F, + 0.00160143734F, 0.0522256792F, -0.0225508772F, 0.00163438683F, + -0.00210259343F, -0.0321532115F, -0.000169835053F, -0.011985993F, + -4.67040481E-5F, -0.00298216543F, -3.38267528E-5F, -0.00203739316F, + 0.000105981788F, -0.000322094245F, -0.00186713622F, -3.12570119E-5F, + -0.0201219916F, -0.00491749635F, -0.00108589616F, 0.00141438982F, + -0.00146036537F, 0.00178330357F, -0.000177395166F, 0.0175635908F, + -0.00110250921F, -0.00200994103F, -0.00708772149F, -4.17101401E-5F, + 0.000707290834F, 0.00166387495F, 0.000184838049F, 3.54530471E-6F, + 0.000252770522F, 0.0027557807F, 0.0163466223F, -1.96415431E-6F, + 0.00114006863F, -0.00570592098F, -0.0101526417F, -0.00102705F, + -0.00515065482F, -0.000583505491F, 0.00149405119F, -4.83496615E-6F, + 0.00113466661F, -0.00297136325F, -0.00914050639F, -5.1382608E-7F, + -0.000802795286F, -0.00933057349F, -0.0033023071F, -0.011004067F, + -0.000951872906F, -0.00352470274F, -0.000801753253F, -0.00235633552F, + -0.00158252148F, 3.31287301E-5F, 0.000314018835F, 0.00303674466F, + -0.00125113304F, -0.00191067357F, -0.0218420979F, -0.00153042504F, + -0.00685124472F, -2.46036543E-5F, -0.00234800484F, -0.0156736281F, + -0.00785746612F, 0.0037051714F, -0.0030598389F, -0.424786985F, + -0.0129194977F, 0.00396800879F, 8.10907568E-6F, 1.88803551E-5F, + -0.00182471704F, -0.00673355162F, -0.000918688718F, -0.000103112761F, + -1.76887424E-5F, 2.98584018E-6F, -0.00902377442F, 0.000230684906F, + 0.00367539842F, -0.00125393446F, -0.00490391813F, -0.0196456835F, + 0.00136417034F, 1.94845575E-6F, 0.0113431802F, 2.75117654E-5F, + -0.000745880534F, -0.00336119556F, -0.0118103372F, 0.00386944483F, + -0.00907657668F, -0.00234367F, -0.000399059878F, 0.00258899829F, + -0.0066318484F, -0.0210031401F, -0.0224024858F, 0.00998132583F, + -0.00514280051F, -0.000115921968F, -0.0063096839F, -3.79578705E-5F, + -0.0052518039F, 0.00134264608F, 0.000626426539F, 0.000559518579F, + -9.05252818E-6F, -0.0118240081F, -3.19181927E-5F, 0.0011950942F, + -0.00287006074F, -8.46952958E-7F, -4.26690603E-5F, -5.73537582E-5F, + 0.00320769614F, -0.000276077539F, 0.00351903471F, -0.000785001146F, + 0.000252684869F, 0.00101934094F, -0.00253606564F, -0.0191967413F, + 0.00102088484F, -0.010198297F, -0.000736612F, 0.00181817F, + 0.000949966197F, -0.0058380831F, -0.00111708359F, -0.0011710265F, + 0.000694120419F, 0.000108589695F, -0.00317300903F, -0.0121384887F, + -0.00459045079F, -0.0094652269F, 0.000308411429F, -0.00694590248F, + -0.00205804943F, -0.0019556277F, 0.00916089583F, -0.0133883841F, + 0.000256727188F, -0.00288571743F, 0.000869554409F, 0.000634851633F, + 0.00159337022F, 0.0230004154F, -7.15737224E-6F, 0.000648670073F, + -0.0207567625F, 8.53868278E-6F, -0.00657061441F, 0.000338949176F, + -0.000952504459F, -0.00150207349F, 7.96681616E-6F, 7.58805072E-6F, + -0.229451254F, 0.00413796818F, -0.00646067457F, 0.00373793906F, + 0.0842637196F, -0.0196291693F, 0.000431654858F, 0.000870984339F, + -0.00415979186F, -0.0129028875F, 4.38744E-6F, -0.00503046485F, + -0.00696367165F, -0.293174297F, -0.0050171474F, 0.00116933067F, + -0.00951735117F, -0.000712142442F, -0.0060752444F, -0.0118836034F, + 0.000940119906F, 0.000588068389F, -0.00746840285F, -0.0150755178F, + -0.00453179143F, -0.00569637259F, 0.00120737823F, -0.00167322659F, + -0.00123233732F, -0.00932754111F, -0.00138994353F, -0.0149029195F, + 0.0155318426F, -2.91528013E-5F, -0.00279398775F, -0.00797204766F, + 0.000707997708F, 0.00201954949F, 0.00258813193F, -0.00298131537F, + -0.0011777319F, -0.0022795382F, -0.0024240911F, 8.11865448E-7F, + -0.00559594575F, -0.00863348413F, -0.0191905927F, -2.38651478E-6F, + 0.00160833809F, 0.00184033159F, -0.0185900461F, 0.000227240525F, + 0.00151157228F, -0.000521856477F, -0.00843021553F, -0.000384458574F, + 4.2764741E-6F, -0.00114347728F, 0.000683964055F, -0.00181512244F, + 0.00155142089F, -0.00546799228F, -0.00408021966F, -0.00406586565F, + -4.34932081E-5F, -0.00175575342F, 0.00287986593F, 0.00024320402F, + 3.17872968E-6F, -0.011115077F, -0.00113475765F, -0.00303917076F, + 2.63028778E-6F, 0.000618360413F, -0.00731243705F, 0.000986313797F, + -0.00198191986F, 0.00143922854F, 0.000670098292F, -0.0285085402F, + -0.00842475F, 1.14616341E-5F, -0.00126387167F, 0.00136230572F, + 0.00195986498F, -0.000353102543F, -0.00686073396F, -0.00575021887F, + -3.385729E-5F, 0.000194722874F, -0.000180467905F, 0.00268399715F, + 0.00170211075F, -0.037167754F, -0.00500745466F, -0.00286192726F, + 0.000415885472F, 0.000633316464F, -0.00223438162F, -1.00904417E-5F, + -0.000467287202F, -0.0140134403F, 0.000998592586F, 2.13966414E-5F, + 0.00122002803F, -0.00850346312F, 0.00360819721F, -0.000201326358F, + 3.25992733E-5F, 0.000240735535F, -0.000914311735F, 7.78196409E-6F, + -0.0031645475F, 0.00120107387F, 0.00118140143F, 0.000398644072F, + 0.00103147456F, -0.00359596894F, 0.00150569598F, -0.000694301969F, + 0.000439276017F, 0.00293165282F, 0.00402415777F, 0.00101999321F, + 0.00346351764F, 0.000903275853F, 0.000236360458F, -0.00943185F, + -0.00144045951F, 0.00185347721F, -0.0038095566F, -0.000463318982F, + -0.000991646F, -0.00766952103F, 0.00283192983F, -0.00064843538F, + 0.00718120532F, -0.000310957868F, -0.00106281403F, -0.0108272824F, + -0.00244478323F, -0.00157388416F, -0.0036254162F, -0.465218693F, + 2.35750178E-7F, 2.08851543E-5F, -0.00256513059F, -0.0086866105F, + -0.000845739618F, 0.000689039065F, 0.00160949468F, -0.0093180323F, + -0.00286404393F, -0.00773181953F, 0.00236424035F, -0.0143797761F, + -0.00250010891F, -2.03289164E-5F, 4.24339578E-6F, -6.55815384E-5F, + -0.0232975781F, -0.0131051224F, 1.45642916E-5F, -0.00386156607F, + 5.4420052E-5F, 0.00381375942F, 0.000430612417F, 1.56584429E-5F, + 0.000927171495F, 1.21403809E-5F, 2.62203539E-5F, 6.14203782E-6F, + 0.000739936659F, 0.000271304394F, 2.55098666E-6F, -0.000905648F, + -0.0010548993F, -0.00363388937F, -0.00286136661F, 0.00506290747F, + 0.0356920399F, 0.000297347287F, 0.000400027755F, -0.000698350312F, + -0.0016475548F, -0.00194624986F, -7.85311568E-6F, -0.00229220325F, + 0.000890460389F, -0.00840341207F, 0.000661588332F, 8.74464458E-5F, + 0.0156358816F, -0.120300665F, 0.0445312038F, 0.0202315431F, + -0.00621251715F, 0.0089610517F, -0.00558252633F, -0.015076098F, + 0.192519352F, -0.120919868F, 0.0206557773F, -0.0295346882F, + -0.0245486293F, 0.014012374F, 0.189219326F, -0.146334559F, + -0.190424815F, -0.0104626501F, 0.0948371738F, -0.0505331308F, + 0.104474366F, -0.0869478881F, 0.07674326F, 0.019250758F, + -0.0272440333F, -0.0180632584F, 0.0847142488F, -0.0187896695F, + 0.0407559723F, -0.0370429941F, -0.0097754F, -0.158017382F, + -0.154878989F, -0.0621243194F, 0.021553481F, 0.0676778182F, + -0.00974398945F, -0.00862585381F, -0.0910054892F, -0.107235081F, + -0.0314954966F, -0.0437611304F, -0.0198954903F, 0.0781552568F, + 0.397571683F, 0.276344955F, 0.0857517496F, -0.0750907212F, + 0.0675651953F, 0.51270324F, -0.0438874774F, 0.0459572189F, + -0.0082496535F, 0.0531830899F, -0.0305902325F, -0.108082689F, + -0.0284256879F, -0.0859369114F, -0.0453366935F, -0.0119369086F, + -0.146487802F, 0.0337372795F, 0.0842731372F, 0.0131746605F, + -0.0803363F, 0.319330305F, -0.17268087F, 0.107568949F, + 0.0883835703F, 0.0309852548F, -0.125756592F, -0.0124478163F, + 0.0175470226F, 0.310069025F, 0.225708127F, -0.00768979872F, + 0.23495391F, 0.0159210265F, -0.00964548904F, -0.0079640178F, + 0.267619163F, 0.0461737774F, 0.121547379F, -0.0518264547F, + -0.0463084355F, 0.0841503143F, -0.0235264767F, -0.00996197946F, + 0.403045177F, -0.128494039F, -0.0172362253F, -0.00975637604F, + 0.0303903986F, -0.00616691634F, -0.0932951F, -0.017757928F, + 0.0107298205F, 0.0779110491F, -0.0520207658F, -0.150536522F, + 0.0760147423F, -0.236159712F, -0.0418248624F, 0.299678534F, + -0.0754491463F, -0.0660272092F, -0.0314602926F, 0.112541236F, + -0.0371991768F, -0.017344296F, 0.0727705061F, 0.0131254038F, + -0.0739323273F, 0.454170495F, -0.0316375755F, 0.604306F, + -0.0143699637F, 0.248587191F, -0.00648447871F, -0.00702323485F, + -0.073622413F, -0.00592147047F, -0.0510663688F, -0.0499898046F, + -0.00992729608F, -0.0116385715F, -0.0956774727F, -0.00358672952F, + -0.0235641599F, 0.0335619822F, 0.128405809F, 0.0690655261F, + 0.343144774F, -0.0106132934F, -0.278337806F, -0.0927541F, + 0.0115901036F, -0.0209594015F, -0.187636539F, 0.153578445F, + 0.133199066F, -0.0819013938F, -0.148532957F, 0.205214322F, + -0.00502834562F, -0.20333524F, -0.254161179F, -0.0517925769F, + -0.0829561129F, -0.0535426475F, -0.196347773F, -0.00790658407F, + -0.0275397636F, 0.0170407295F, -0.0500803F, 0.328775316F, + -0.0132309347F, 0.0270551797F, -0.0178062674F, 0.442423731F, + -0.0179445427F, -0.0120567521F, -0.00854594167F, -0.0101565281F, + -0.206387043F, 0.0114818905F, 0.404645592F, 0.100600086F, + -0.102011353F, -0.05807532F, -0.148296088F, -0.244718611F, + 0.0156916138F, -0.0976199433F, 0.0693328083F, -0.0634862855F, + 0.366848201F, -0.039595928F, -0.0328488164F, -0.0451899F, + 0.0174252111F, -0.106917828F, -0.0321680419F, 0.0543322489F, + -0.123357564F, -0.103142768F, 0.0318598412F, -0.0211290419F, + -0.100836463F, -0.0195682831F, -0.260177314F, -0.0876769125F, + 0.0546653084F, -0.0809008852F, -0.287584484F, -0.0411743857F, + 0.143359393F, 0.544623673F, -0.0131718591F, 0.132317558F, + -0.223546639F, -0.010054742F, -0.0549867824F, -0.0521799326F, + 0.0203507524F, -0.0881914049F, -0.00808322337F, -0.00862284563F, + 0.627836585F, 0.0156674795F, -0.018634934F, -0.118522644F, + 0.302279145F, 0.0154499123F, 0.411677897F, -0.0283736773F, + 0.0614187419F, -0.194254428F, -0.0109136393F, -0.0204115026F, + -0.061094068F, 0.343773842F, -0.0875794888F, 0.140063345F, + 0.0236265901F, 0.342781276F, 0.0238679219F, 0.0590350442F, + 0.397354305F, 0.0117365904F, 0.0583493598F, 0.0266328F, + -0.14234294F, -0.0578804836F, -0.0770623F, -0.097386308F, + 0.0139115816F, -0.0960146859F, -0.0344771706F, -0.0285359323F, + -0.0637716502F, -0.0099494569F, -0.189204812F, -0.0349811316F, + -0.0089023672F, 0.012863378F, 0.306300581F, 0.0773095265F, + -0.235405937F, -0.0703856498F, 0.0883149132F, -0.0112735005F, + -0.0762585849F, -0.0208872091F, -0.0108019607F, -0.00967807323F, + 0.401371747F, 0.0132294688F, -0.0802314878F, 0.105948962F, + 0.417815596F, -0.180849671F, 0.0236845165F, 0.000344851811F, + -0.0078228889F, 0.0915556699F, -0.041644197F, 0.0829527825F, + 0.41996479F, -0.118456461F, 0.0552982204F, -0.0585849583F, + -0.00636454858F, 0.0740533918F, -0.0233971123F, -0.0790255219F, + -0.00978426542F, 0.00200059451F, 0.0844805688F, -0.0901649222F, + -0.00548229367F, 0.019044742F, -0.0827581F, 0.367288619F, + -0.102074303F, -0.228305891F, 0.0516551509F, 0.214005738F, + 0.0153655028F, -0.021174442F, -0.0601716824F, 0.427391291F, + 0.0300839208F, 0.225331366F, -0.166227639F, 0.0910387486F, + -0.0388795175F, -0.0381186604F, 0.0361924693F, -0.250168592F, + 0.420496643F, 0.136730164F, -0.28646037F, -0.0351749659F, + 0.0270806756F, -0.0614520311F, -0.152119741F, -0.010864988F, + -0.0312970243F, 0.0871922523F, 0.359226376F, -0.00604353752F, + 0.0120121343F, -0.0186188146F, 0.376970947F, -0.0186358988F, + -0.00862731319F, -0.0409256928F, 0.0151986377F, -0.00637789071F, + 0.0621181317F, -0.052649118F, 0.032121826F, -0.0479717441F, + 0.138608918F, -0.0391943939F, 0.448542476F, 0.283807337F, + 0.0803125F, 0.154017314F, 0.341078401F, 0.416369051F, + -0.0101726539F, 0.00862662774F, -0.0788677856F, 0.0719797462F, + 0.0125529123F, -0.0736009F, -0.00796119589F, -0.0698289424F, + -0.018307725F, 0.0997652039F, 0.446916789F, -0.0532275178F, + -0.269560456F, 0.0720769763F, 0.0303690042F, 0.0705022365F, + 0.0507141687F, 0.0623067059F, -0.0500602126F, -0.0246492103F, + -0.0100932047F, -0.00992266F, 0.113085546F, -0.0255877227F, + -0.121299945F, -0.0433101F, 0.23830469F, -0.0770482123F, + -0.0246662F, -0.0327989645F, -0.0971007645F, 0.00622480689F, + 0.0280481316F, -0.00545777334F, -0.00921673235F, -0.0122735025F, + 0.031742F, -0.340941668F, -0.0119912075F, -0.0212843977F, + -0.0304009486F, 0.0307548121F, 0.228673577F, -0.00774139259F, + 0.370676309F, -0.00920305122F, -0.00864098314F, -0.0198391173F, + 0.326521039F, -0.0321539044F, -0.00881213136F, 0.00118429016F, + -0.143021867F, -0.103718162F, -0.0300797913F, 0.0725559741F, + 0.233848765F, 0.011896437F, 0.0155232484F, -0.00411319267F, + -0.115194462F, -0.162447959F, -0.0202823449F, -0.0916206464F, + 0.383730739F, 0.0739927F, 0.166611493F, 0.0388298444F, + 0.00635115802F, -0.000213235471F, -0.0555501767F, -0.0211454928F, + -0.000145654019F, -0.00300268061F, -5.41522641E-5F, -0.0435728319F, + -0.080880329F, -0.0265665222F, 0.0110548884F, -0.0969672278F, + 0.00232045096F, -0.0083966665F, -0.0723532438F, 0.00542015443F, + -0.00524396077F, -7.55404908E-5F, -0.0316300653F, 0.0386507846F, + -0.00516376458F, -0.0221243445F, 0.0805278197F, -0.0362302437F, + -0.0180104F, -0.00239168503F, -0.0706994906F, -0.0522094294F, + -0.0236585755F, 0.0182228349F, -0.000375368545F, 0.0312403869F, + 0.00599418301F, 0.0285570528F, -0.0907101929F, -0.0345298946F, + -0.000105065192F, -2.26368629E-5F, 0.00717271538F, -0.0078999633F, + -0.142090693F, -0.0778052211F, -0.0151367588F, -0.0270840768F, + -0.0861515403F, -0.198288023F, -0.00663411F, 0.0875595063F, + -0.0754767731F, -0.0897610635F, 0.00110274344F, -0.0225990191F, + -2.18402092E-5F, -0.032043F, -0.00103207096F, 0.00815953128F, + -0.000212386469F, 0.00606032414F, 0.0250548907F, -4.7209327E-5F, + -0.00499202032F, -0.0296986941F, -0.0205378812F, 0.0145499613F, + 0.00563175697F, -0.0466866046F, 0.00655869581F, -0.0144442078F, + -0.0536838658F, -0.0362364873F, -0.0212393645F, -0.000262105954F, + -0.0548695847F, -0.0280086324F, -0.0830514804F, -4.06113286E-5F, + -0.00565779954F, -0.0183236804F, -0.0321476981F, 3.85862768E-6F, + 0.0117029715F, -0.0567748509F, -0.071117945F, 0.0125027718F, + 0.00449814461F, -0.00344038662F, -0.0533335023F, -2.87757011E-5F, + -0.0046974523F, -0.0061924113F, -0.0116022732F, -5.74115911E-5F, + -0.000259032182F, -0.0034438842F, 0.000703728176F, -0.0148754921F, + -0.00631415099F, -0.0303297713F, -0.0552081876F, 0.0361452438F, + -0.0285580792F, 0.0119984373F, -0.00213781325F, 0.0636041611F, + 0.00210111309F, -0.00354670966F, -0.0257677846F, -0.0288765766F, + -0.0785514116F, 3.12275915E-6F, 0.0127176233F, -0.0370882042F, + 0.0116858929F, -0.152552992F, -0.0432153456F, 0.0399931781F, + -0.0304008983F, -0.0836773962F, -2.18002715E-5F, -0.000497439061F, + 0.00256904075F, -0.0108590964F, -0.0668707937F, 0.00228711963F, + -5.09769561E-5F, -2.15300906E-6F, 0.0526983067F, -0.00223158882F, + -0.0335922465F, -0.0486717783F, -0.00989935827F, -0.011765752F, + -0.0607998818F, -0.000119347642F, 0.0620973632F, 0.0210839827F, + 0.0112383254F, -0.0323820114F, 0.0152057307F, -0.0265777055F, + -0.0275764354F, 0.00401101727F, 0.00716884574F, 0.0827405304F, + -0.0640587881F, -0.0543829277F, -0.107486859F, 0.0195160769F, + 0.0181852318F, 0.0028181F, -0.104980148F, -6.79438E-6F, + 0.0702239722F, 0.00581584917F, 0.00418959279F, -0.0730842203F, + -7.55977671E-5F, -0.00457642414F, -0.000278160616F, -0.0718260705F, + -0.0797290057F, -9.37727164E-5F, 3.45320659E-5F, -5.07327E-6F, + 0.0336641334F, 0.00902358722F, -0.0851387829F, -0.0237296149F, + 0.00198583584F, -0.0571818277F, 0.0277627613F, -0.0642863289F, + 0.0130572189F, -0.000415618182F, -0.0300351102F, 0.0579015948F, + -0.0783356577F, 0.0170002747F, -0.00364978402F, -0.000784177566F, + -0.0253635235F, 0.00287192012F, 0.0200577378F, -0.0161685627F, + 0.0122554135F, -0.0710278451F, -0.0322019719F, -0.0484185182F, + 0.0266051628F, -0.10575074F, 0.0759705678F, 0.0205606706F, + -0.0456961878F, 0.00429738732F, 0.0487415679F, -0.000673093833F, + 0.00855694246F, -0.0492443219F, -0.000121205558F, -0.0137928119F, + -0.215534583F, -2.82968012E-5F, -0.0474861339F, 0.0110798115F, + -0.00432496844F, 0.0370462462F, -4.90293023E-5F, -6.14608362E-5F, + 0.0467652269F, -0.0591148F, -0.00949929934F, 0.00190093543F, + -0.00942254812F, -0.0324971974F, -0.0794334039F, -0.0220516976F, + -0.0270983092F, 3.36905141E-5F, -0.000367653876F, -0.0713456273F, + -0.0188907553F, -0.0266548414F, 0.00389642F, 0.0069635231F, + -0.066021353F, -0.073382996F, -0.138836384F, 0.00167853769F, + -0.070191741F, 9.2645023E-6F, -0.0368397385F, -0.00570640713F, + -0.00812998228F, -0.00680219708F, -0.148550913F, 0.00777458446F, + 0.00994184799F, -0.022342233F, -0.0736120492F, -0.0279220417F, + -0.15270634F, -9.04201734E-5F, 0.0248623937F, -0.0473640673F, + -0.0138379652F, 0.012622497F, 0.0465248488F, -0.025312908F, + 0.0299531966F, 0.00884186F, -0.0665597618F, -1.51127697E-5F, + -0.0360260718F, -0.0256866924F, -0.00302314712F, -9.06221467E-5F, + -0.0839763358F, 0.0146111446F, 0.00772043178F, -0.0225987341F, + -0.0604838356F, 0.0081674559F, 0.0739108473F, -0.00422944129F, + 5.12173528E-7F, -0.0397033319F, 0.00502928114F, -0.0448821411F, + -0.0405508801F, 0.0115936967F, -0.0225237347F, 0.00644669402F, + 0.000125405888F, -0.0773669928F, 0.0206681304F, -0.156152129F, + -3.32259078E-5F, -0.0366942175F, -0.0196324978F, -0.035888616F, + -7.2415809E-5F, 0.018755326F, -0.0422393568F, -0.0796191916F, + 0.0502114445F, -0.0303351115F, -0.107447408F, 0.0750292242F, + -0.0200724229F, 0.000795939646F, 5.56775885E-5F, -0.0516314916F, + -0.0252503511F, -0.0188633148F, -0.026688315F, -0.0188935883F, + -0.00216096407F, -0.00197518477F, 0.0143949352F, -0.0574767664F, + -0.0866284743F, 0.00352312182F, -0.0436023548F, 0.0172171984F, + 0.024970429F, -0.0801105797F, -0.119313069F, 3.01062573E-6F, + -0.000401673F, -0.0251032077F, -0.0413225107F, -0.000175537134F, + 0.00928535406F, -0.00703683F, -0.00299600442F, -0.00218111044F, + 3.6592437E-6F, -0.00521646626F, -0.0161923058F, -0.000121469107F, + 0.010302241F, 0.0376203F, 0.0335261486F, -0.0453394204F, + -0.0458221436F, -0.0113949422F, -0.0271304715F, -0.0832287371F, + -0.0292690564F, -0.0115214046F, 0.0904996172F, -0.0671069175F, + -0.128664747F, -0.00809220411F, 0.118248969F, -0.0148674082F, + 0.00836195797F, 0.090805009F, -0.00381944608F, 0.00424740789F, + -0.0654850677F, -0.00204463373F, -0.125862598F, 0.0033910519F, + 0.0493750311F, 0.00359896407F, -0.0467774309F, -0.0120652821F, + -0.0247006062F, -0.0227315649F, 0.003363939F, 0.0454593897F, + -1.58740913E-5F, -0.000102603874F, -0.0042887223F, -0.0573766567F, + 0.0390929058F, -0.00562139461F, -0.063695468F, -0.0257034115F, + -0.0129852816F, -0.0556433909F, 0.0114663104F, -0.0105945058F, + 0.00321393088F, -6.44269385E-5F, -7.69509061E-5F, -0.000127168518F, + -0.0457998924F, -0.019606337F, -7.1672308E-5F, -0.0303308F, + -0.00022907056F, -0.0466595702F, -0.0696990043F, 3.93359915E-5F, + -0.0355135389F, 9.39369602E-6F, -9.14997436E-5F, 0.000148543666F, + -0.0695278868F, -0.00234198F, -2.64897062E-6F, -0.00692611467F, + -0.000193786153F, -0.00773071824F, -0.0027026094F, 0.0852008909F, + -0.160452947F, 0.0120855579F, 0.0118633742F, -0.0111197513F, + 0.00803737342F, 0.0345999412F, 9.82778438E-5F, 0.0286855847F, + -0.0738314241F, -0.000319826911F, -0.0906244889F, 0.0152353859F, + 0.0122100497F, -0.0685587153F, 0.0532146804F, 0.0227196049F, + -0.00631499756F, 0.0155053977F, -0.00533545716F, -0.0644893944F, + 0.212158099F, -0.0334987827F, 0.0352170356F, 0.0477775969F, + -0.0589357F, -0.026223246F, 0.195533857F, -0.165626824F, + -0.428328454F, -0.0103451079F, 0.038197808F, 0.0845859423F, + -0.0581872761F, 0.0486425F, -0.0251490101F, 0.0263362955F, + -0.00419124402F, -0.0461379625F, 0.0886044F, 0.0253925398F, + 0.0588818379F, 0.0342758037F, -0.00965406839F, -0.20378311F, + -0.148321524F, -0.126850337F, 0.0408417806F, 0.0625894591F, + -0.00966451876F, -0.00837832876F, -0.0904068202F, -0.0608444475F, + 0.231439859F, 0.0486833043F, -0.0467549115F, 0.0928693339F, + 0.388925493F, -0.07535436F, -0.0195855163F, 0.501822829F, + -0.0903884247F, -0.0352251567F, -0.0141168255F, -0.199645519F, + -0.00832673069F, -0.0419501103F, -0.0369554684F, 0.000323199754F, + -0.0440039672F, -0.0328562073F, 0.0265806764F, -0.011721937F, + -0.396837205F, -0.0427218154F, 0.0892463923F, 0.0172633734F, + -0.100997679F, 0.366015345F, -0.0573327653F, 0.0782054812F, + 0.0989174247F, -0.0218780451F, -0.251846284F, -0.0132232169F, + 0.0192113835F, 0.369668812F, 0.20848377F, -0.00760616036F, + 0.249507785F, -0.113934778F, -0.00771580823F, -0.00798258092F, + 0.274757087F, -0.0464448333F, -0.0428891033F, 0.0174851399F, + -0.0612759106F, 0.0785965398F, 0.0176926218F, -0.0103143975F, + 0.423895866F, -0.136655226F, 0.00433056755F, -0.00987614784F, + 0.00445838785F, -0.425296634F, -0.106992744F, -0.202676311F, + -0.151352733F, 0.11685089F, 0.0151905753F, -0.0382440761F, + 0.0786911696F, -0.0590581819F, -0.0295229945F, 0.278740019F, + -0.0725664422F, -0.0535531677F, -0.0552248619F, 0.103519768F, + 0.024521647F, -0.0178675298F, 0.0471550338F, -0.0218482632F, + -0.0417471714F, 0.494657636F, 0.0229082238F, -0.0113709643F, + -0.0468977317F, 0.217227638F, -0.00644671777F, -0.00701419264F, + -0.0825049356F, -0.202501759F, 0.031184053F, -0.0168172624F, + -0.00989209861F, -0.0116518307F, 0.0670624599F, -0.0552705489F, + 0.0408383347F, -0.0213750172F, -0.115840919F, -0.0233335178F, + 0.333226562F, -0.0102646593F, -0.0820362642F, 0.00795999542F, + 0.0149957417F, 0.0904043242F, -0.274379551F, 0.133289203F, + 0.0781881437F, -0.100619607F, -0.0510360561F, 0.261164874F, + -0.0358819775F, -0.248341084F, -0.275048852F, -0.218417138F, + 0.0237846449F, -0.0664244443F, -0.300778747F, -0.00855548307F, + 0.0796352F, 0.023017304F, -0.0551304854F, 0.365181446F, + -0.0134512223F, -0.0490501113F, -0.0164642036F, 0.456593275F, + 0.0910415F, -0.0133188386F, -0.00850841403F, -0.0100368317F, + -0.142800376F, 0.0129822716F, 0.44139567F, -0.0363783613F, + 0.125792235F, 0.11412587F, -0.0221545715F, -0.444271415F, + 0.018955335F, -0.0784400851F, 0.0756348446F, 0.183961272F, + 0.37708962F, 0.0836915746F, -0.0656416044F, -0.111177929F, + -0.0984497666F, -0.0372203775F, -0.00469301408F, -0.0437098294F, + -0.00156622531F, -0.189774618F, 0.0371136814F, 0.0380729772F, + 0.0278666243F, 0.0723317713F, -0.0762064382F, -0.0252632536F, + -0.0819161758F, -0.112240359F, -0.0743421763F, -0.0218971558F, + 0.139626428F, -0.000638152065F, -0.0128601184F, 0.216307253F, + -0.223684266F, -0.0100939749F, -0.0379333347F, 0.0276659094F, + -0.153472945F, 0.068330504F, -0.00808516052F, -0.00859430339F, + -0.00568165584F, 0.0163984057F, 0.0231793281F, -0.0703228265F, + -0.013821179F, -0.0289726965F, 0.419392765F, -0.0252177678F, + 0.0813333839F, -0.440927148F, -0.0108009344F, 0.0155383786F, + -0.0967788175F, -0.0071179769F, -0.122692935F, 0.133552521F, + -0.0282410923F, 0.402847767F, -0.0210398789F, -0.0288439859F, + 0.411232799F, 0.0116970912F, 0.0550419874F, -0.0220345948F, + -0.263746172F, -0.0482895933F, 0.201818258F, -0.120142974F, + 0.0156068029F, -0.385730654F, 0.0270699635F, -0.0206026081F, + -0.02621953F, -0.00982292835F, -0.061464306F, -0.0218103118F, + -0.0401697233F, 0.0164465159F, 0.285549372F, 0.0828840286F, + -0.0590068065F, -0.117411815F, 0.0994634181F, -0.0116516436F, + -0.0755177662F, -0.0455015339F, -0.0484327488F, -0.00983721483F, + 0.370258182F, 0.0129215F, -0.0231515076F, 0.0566748939F, + 0.45010969F, -0.160208359F, -0.0187660176F, -0.0720971674F, + -0.00766664371F, 0.102645919F, -0.035322845F, 0.0913397521F, + 0.427625239F, -0.0342435651F, 0.0391591676F, -0.0311865266F, + -0.00625828188F, 0.0809864402F, 0.038864065F, 0.249547616F, + -0.0101988399F, -0.0563614815F, 0.082578F, -0.123294152F, + -0.00546018686F, 0.019858351F, -0.0850289688F, 0.419696063F, + 0.0347664505F, -0.0342086479F, -0.0666712672F, 0.0200210158F, + 0.011899217F, -0.0246609785F, -0.0564363226F, 0.441695333F, + 0.0353772491F, 0.270569861F, -0.323727399F, 0.0636938214F, + -0.0391183309F, -0.0406536609F, 0.0357506387F, 0.0153196659F, + 0.452888846F, 0.0483137593F, -0.317688137F, -0.15978162F, + 0.0293045044F, 0.112300038F, 0.0531493798F, -0.0110477805F, + -0.0737797F, -0.00126062077F, 0.385192811F, -0.00600622687F, + 0.014536228F, -0.0917219222F, 0.393331587F, -0.0476891473F, + -0.00854020193F, -0.0657039732F, 0.0164507087F, -0.00636454346F, + 0.0305303279F, 0.0467177294F, 0.0853680447F, 0.0277033933F, + 0.173933968F, -0.0642797872F, 0.461403489F, 0.281231463F, + 0.0940809473F, 0.214337498F, 0.288533509F, 0.441987574F, + 0.535260499F, -0.171780556F, 0.446156412F, -0.0165174827F, + 0.0150784655F, 0.557187617F, -0.0986835733F, -0.0855563805F, + 0.0664859638F, -0.0450743251F, 0.440525442F, -0.0839298F, + -0.0674522892F, 0.0719793886F, 0.0357224643F, -0.0377775058F, + 0.056445282F, 0.0309617259F, -0.103132062F, -0.00390446652F, + -0.0103183752F, -0.00972218253F, -0.12386255F, -0.0380674526F, + 0.0371365212F, 0.0699562356F, 0.238469586F, -0.0989149585F, + 0.062368542F, -0.00999525934F, -0.128712803F, -0.0228541084F, + -0.0559775718F, -0.00547699F, -0.00914524589F, -0.0120327948F, + -0.0298265666F, -0.428830534F, -0.0122575127F, -0.056188941F, + -0.0329085886F, 0.0322112814F, 0.227899268F, -0.00773536414F, + 0.381818444F, -0.00921407901F, -0.00856687874F, -0.0174099449F, + 0.317714632F, -0.0450186059F, -0.00888759736F, -0.123930529F, + -0.129365861F, -0.123661771F, -0.061000593F, -0.165653303F, + -0.0770261511F, 0.0141702015F, 0.0180270132F, -0.100285344F, + 0.032040298F, -0.0394924581F, -0.0224842317F, 0.024350293F, + 0.392343104F, -0.359627694F, 0.170824885F, 0.0431743F, + -0.00104879588F, 0.00122505322F, -0.000398700417F, 0.000126924759F, + -4.91828632E-6F, -0.00162497454F, -1.32124603E-6F, -0.000311106676F, + 0.00318569597F, 0.000895474048F, -0.000698033255F, -0.000572909485F, + -0.00027907535F, -0.000368794601F, 0.00184699474F, 0.00176433416F, + 0.0069358889F, 4.06231084E-5F, -0.0009901023F, 0.00403373595F, + 0.000948386616F, 3.12563061E-5F, 0.00110224017F, 0.000240038411F, + -0.000769922684F, -0.00133787841F, -0.00304876012F, 0.00271599065F, + -0.00101769087F, 0.00208732742F, -5.45834264E-5F, -0.00175762142F, + 0.00358284405F, -0.00088126387F, 0.00136606605F, -0.000413512229F, + -2.82769597E-5F, -2.67427131E-5F, 0.00178644294F, -0.000315875484F, + 0.00499117328F, -0.00112152F, -0.00116505427F, -0.00190259772F, + -0.00309612F, -0.00223297579F, 0.00202301424F, 0.0145351468F, + 0.000451144821F, -0.00100904505F, -0.000541782472F, 0.00375205372F, + -4.6045443E-8F, -0.00316751609F, -0.000539765344F, -0.000180952033F, + -0.000512380502F, 0.000646403234F, -0.00218133698F, -2.73030928E-5F, + 0.00777847273F, -0.00138592604F, 0.00139404612F, -0.00260750344F, + 0.00037840748F, 0.000499652699F, -0.00133662752F, 0.000268684642F, + -0.00180097681F, 0.00110610272F, 0.00538502214F, -1.13555343E-5F, + 0.000611855648F, -0.000542670779F, -0.000148559673F, -8.40650443E-7F, + 0.002185405F, -0.000302537897F, 0.00636084517F, -2.20387278E-6F, + 0.00243463763F, -0.000316448306F, -0.000229730693F, -0.000719608506F, + -0.00110177696F, 0.000122410711F, 0.00471732F, -1.92244479E-5F, + -0.000430384971F, 0.000521854439F, 0.0254353192F, -3.49193124E-6F, + -0.000103668135F, 0.00719236862F, 0.00115215918F, 0.00427249307F, + -0.000521284237F, -0.00764319301F, -0.00121944037F, -0.00429185899F, + -0.00304517243F, 0.000572327175F, -0.000475642795F, 0.000255057035F, + 0.000383799721F, -0.000496108492F, -0.00106719451F, -0.00291779055F, + 0.00015664252F, -9.04038097E-6F, -0.000756725145F, 0.00124762091F, + -0.00322175771F, -0.00369951385F, -0.00310252351F, -0.00610823929F, + -0.00450276025F, 0.000405402243F, 6.10611505E-6F, -6.10171764E-6F, + 0.000442118966F, 0.00372252404F, -0.00311367586F, -0.000295845588F, + -1.43886191E-5F, 2.57110842E-5F, -0.00768435653F, 0.000131112116F, + -0.0103045534F, 0.00115376164F, 0.0016702346F, 0.000475131266F, + 0.0010296586F, 2.5592466E-5F, -0.00585983135F, -0.00131589151F, + -0.000131836277F, 0.00929134246F, -0.000688278058F, -0.00151414704F, + -0.00496745203F, 0.00207575224F, -0.000270612829F, 0.00185639062F, + 0.000989779597F, 0.00588577893F, 0.0086405F, -0.000218421847F, + -0.00298699131F, 0.000272868259F, 0.0066388147F, -3.3407312E-5F, + -0.0012737012F, -0.00150458165F, 0.000475732231F, 0.00168903044F, + 1.77227357E-5F, 0.000379092467F, 8.1069E-6F, -0.00202574022F, + -0.00521624275F, -7.29081876E-7F, 1.19432198E-5F, -3.36367048E-5F, + -0.00410106406F, -0.00186054816F, -0.00354637671F, -0.00152362569F, + -0.0118474439F, 0.0064198887F, -0.00210309681F, 0.00721537F, + -0.00181087479F, -0.00261060172F, -0.00145578757F, 0.00940808561F, + 0.00154968083F, 0.00339201F, 0.000214781496F, 2.47573371E-6F, + 0.0001789526F, 0.000588562631F, 0.0004848073F, 0.000618254067F, + -0.000691086694F, 0.00363202789F, -0.000832942198F, -0.00141269935F, + -0.00161646341F, 0.00164134149F, -0.00200066785F, -0.00399336964F, + 0.00230363128F, 0.000993569498F, -0.0101338588F, 0.000319719606F, + 0.00171477848F, -0.00429724203F, -2.91865017E-5F, 0.00189796F, + 0.0118919192F, 6.50000857E-7F, -0.000620687148F, 0.00663156249F, + -0.000203108502F, -0.00564379F, 1.20214927E-5F, -9.23706466E-6F, + -0.00248157163F, 0.000273964572F, -0.000576939259F, 0.00330283376F, + -0.00285131345F, -0.000375441334F, 9.06682762E-5F, -0.00422670878F, + -0.00101360085F, 0.00641079573F, 1.90990795E-5F, 0.004177914F, + 0.000308713585F, -0.00414241804F, 0.00223308662F, -0.000389215536F, + -0.00094422017F, 0.000955884112F, -0.0106104352F, -0.00142868818F, + -0.0010101425F, -0.000455451838F, -0.00370007614F, -0.000998015283F, + 0.00485840347F, -0.0018297662F, 0.0114736967F, -0.000615280063F, + 0.000520518399F, 0.00790923368F, -0.0019201223F, 0.000834202103F, + 0.00188740727F, -2.16960252E-5F, -0.00686572725F, 0.00149340811F, + -0.000158699797F, -0.00039494611F, 0.000979375676F, -0.00185820018F, + -0.000332072377F, 0.000800371286F, -0.00408341084F, 1.48902291E-5F, + 0.00176885305F, -0.000595376652F, 0.00563839311F, 4.59891316E-6F, + -0.000106595908F, 0.00224087015F, -0.00624096813F, -3.10930227E-6F, + -0.00237845141F, -0.000483203446F, 0.00340924156F, -0.000562378031F, + 2.60543911E-5F, -0.00169735285F, 0.000257855456F, -0.00278747967F, + 0.00202119444F, -0.00454289513F, -0.00197101617F, -0.000850963697F, + -3.0989544E-5F, -0.00378441042F, 0.00386330625F, 0.013040971F, + -2.5194E-6F, 0.00144309876F, 0.00199356489F, -0.000263961294F, + -1.21923449E-9F, -0.00157226459F, 0.00123739673F, 0.00165068405F, + -0.00359358569F, -0.00384409539F, -0.000579100102F, 0.00168589724F, + -0.00304144528F, -4.62716816E-5F, -0.000236924709F, -0.00250286912F, + 0.00149876019F, 0.00248341681F, 0.0066131684F, -0.00329861743F, + -0.000286463124F, -0.000317552622F, -0.000103593258F, -0.00211487897F, + -0.00230940105F, -0.00536245247F, 0.0059840153F, 0.000712878886F, + -0.000581895409F, -0.00010165065F, 0.00336751086F, -8.22307697E-7F, + -1.327273E-5F, 0.00023130374F, -0.00176576083F, 9.39281E-6F, + 0.000150799329F, -0.000127520776F, -0.000530267309F, -0.0011144086F, + 5.14563762E-5F, 0.000326894398F, -0.00330682728F, 1.44141695E-5F, + -0.000782322604F, -0.000975119649F, 0.00109610287F, 0.00110557151F, + 0.0021561156F, -0.000533617858F, -0.00310291769F, 0.000144790014F, + -0.0010256269F, 0.00424530311F, -0.000152450943F, -0.00148287439F, + -0.00207342021F, -0.000849407865F, 0.0119932108F, 0.00454514194F, + -0.000182128861F, 0.0144086163F, 0.00162861531F, -0.000780305942F, + 0.00349279307F, 0.00252406136F, -0.0028676244F, -0.000578143925F, + -0.0054622693F, 0.00231663114F, -0.00194219186F, 0.000592018F, + -0.000766567071F, -0.00358455116F, -0.00136732846F, -0.0174916349F, + 1.46602069E-5F, -1.30600347E-5F, 0.00191745756F, 1.67093131E-5F, + 0.000437316136F, 0.00023415382F, 0.00299473759F, 0.000560754444F, + 0.00060969434F, 5.00386668E-5F, -0.00219711568F, 0.00156658806F, + -0.00116250769F, -3.15053E-5F, -8.80028347E-6F, -2.12953601E-5F, + -0.00998950377F, 0.00565182464F, -1.34087159E-5F, -0.00147542858F, + -9.13184849E-5F, 0.00132937706F, 0.000882414F, 3.32027184E-6F, + 0.00121272192F, 5.92899596E-6F, 5.66179442E-5F, -7.82490497E-6F, + -0.00252069812F, -0.000490448379F, -4.6128057E-6F, -0.000649441208F, + 0.000157590737F, 0.0010792868F, -0.00041455985F, -0.000383277278F, + -0.00249876874F, 0.000855196384F, -0.000702227349F, 0.000769878156F, + -0.000580672291F, -0.00410091504F, -7.42261764E-5F, 0.000525502663F, + -0.0021454927F, 0.00513273524F, -3.70707785E-5F, -0.000453728833F, + -0.000356241595F, 5.29796889E-5F, -0.000650519971F, -0.000225255586F, + 6.05650143E-8F, -0.00185716455F, 2.39891193E-7F, -0.00111545273F, + 0.00102939631F, 2.82283618E-5F, 0.000156881521F, -0.00092172221F, + 0.000482309028F, 0.00131118565F, 0.000297331193F, 0.000552533544F, + 0.00313133118F, 1.62901779E-6F, -0.000557236664F, 0.00058563333F, + 0.000351134571F, -0.000428024767F, -0.00327819749F, -5.66049421E-5F, + -0.000779950176F, 0.000388088025F, -0.000900095445F, -0.00134147168F, + -0.000239813846F, -0.00280024158F, -4.36084156E-6F, 0.000540043111F, + -0.000312036776F, 0.000155777612F, 0.00108219974F, -0.000619637722F, + -1.04016408E-6F, 2.58432351E-6F, 0.000917020137F, 0.00046833232F, + -0.00345716579F, -0.000556990213F, 4.04993334E-5F, -0.000990620931F, + 0.000647964131F, 0.00900976F, -0.00145957F, 0.00037827043F, + -0.00108379603F, -0.00455356063F, 1.95089888E-6F, 0.00100878743F, + 1.18762983E-7F, 0.000169103121F, -2.22167237E-5F, -0.000263246766F, + -6.8342968E-5F, -0.000319360028F, -0.000682825805F, -5.5898164E-7F, + 0.00253772689F, 2.20269594E-5F, -0.000396914722F, -0.000418025185F, + 0.00015029349F, 0.00170558388F, -6.69145957E-5F, 0.00977218896F, + -0.000692162372F, -0.00024337467F, 0.000980372F, -5.88631394E-7F, + -0.000645271095F, -0.000194869135F, 0.0026620077F, 1.91581151E-8F, + 0.0011851833F, 0.000662848062F, 0.00351505657F, -4.85702323E-8F, + 0.00181777705F, -0.000614257413F, 0.00011135314F, 8.32419537E-5F, + -0.000200923736F, -0.00033673193F, 0.00131211197F, -1.81388558E-7F, + 0.00241914275F, -8.60247E-6F, -0.0122067854F, 3.6605266E-7F, + 0.00486872112F, 0.00188065297F, -0.000392324524F, 0.000527759083F, + 0.000128910426F, -0.00918389764F, 0.00112014008F, 0.000252162601F, + -0.000494620181F, 8.98041E-5F, -4.70122141E-5F, 0.00101645233F, + 0.000177395617F, -5.57862659E-5F, -0.000302972767F, -0.0086837355F, + -0.000427602237F, -5.59851833E-6F, -2.3241575E-5F, -0.000850267592F, + -0.000506571785F, 0.000121999728F, -0.000537700078F, -0.0041533364F, + -0.00114617066F, 0.000812396465F, 6.49868809E-7F, -1.44033459E-6F, + 0.00072668877F, 0.000884049281F, -0.000276184961F, -5.89964941E-7F, + 9.24499446E-8F, -2.05685865E-7F, -0.000529556F, 7.3881929E-5F, + 0.00259627705F, -0.000829039665F, 0.00051535F, -2.77228683E-5F, + 0.000849962526F, 5.71458827E-8F, -0.000639315287F, -0.000611476542F, + -0.000241334026F, -0.00400276436F, 0.0016410572F, -0.000132081041F, + -0.0112096956F, 0.000235358559F, -0.000166948332F, 0.00238432642F, + -0.000169535968F, 0.00219109491F, 0.00255403668F, -0.000691943F, + -0.000416015595F, -4.56350936E-5F, 0.00147266767F, -1.02735089E-6F, + -0.00106963771F, -0.00013324579F, 0.000465668F, -0.000226206757F, + -8.18237424E-8F, -2.40063309E-5F, -4.26517499E-6F, 0.000966400723F, + -0.00217168056F, 1.08865549E-7F, 6.57477841E-8F, 6.66861865E-7F, + 7.17131406E-5F, -0.000358786638F, -0.000257942476F, 0.00125974196F, + -0.00264225062F, 0.00317060878F, 0.000321588072F, 0.00351989013F, + -0.000343258464F, -0.000475382636F, -0.000937784789F, 0.00196453347F, + 0.00210295268F, -0.00354318833F, 0.000248211902F, -0.000217025197F, + -0.000259515888F, -0.000162694399F, -0.000483855256F, -0.000830256206F, + 7.232801E-5F, 0.00108488498F, -0.000461800548F, -0.00142866501F, + 0.000190513223F, -0.00238715089F, 0.000384332641F, -0.000686930609F, + -0.00264534145F, -0.000301186665F, 0.00083133881F, -6.7719724E-5F, + 0.00148078182F, -0.00228402275F, 1.25217787E-6F, -0.0014458939F, + 0.00375667773F, 9.28989152E-8F, -7.87453391E-5F, 0.000618499238F, + 0.000666853564F, -0.000723190373F, 9.08144528E-8F, 9.78560593E-7F, + -0.00905068F, 0.00132867217F, -0.00166482909F, 0.000890279713F, + 0.0193887614F, 0.000124661936F, 0.000157294955F, 0.00146732293F, + -0.00610592496F, 0.00346673606F, 3.81952191E-7F, -0.000963421771F, + 1.93799133E-6F, -0.00430528866F, 0.000305529917F, 0.00138899498F, + -0.000893222459F, -0.000107704771F, -0.00160098635F, -0.000356016419F, + -0.000231904691F, -4.63609067E-5F, -0.000662861F, -1.7936225E-5F, + 0.00162277604F, -0.000172902524F, 0.00495565729F, -0.000136772112F, + -0.000441026466F, 0.00223356881F, -2.48727665E-5F, -0.000983665814F, + 0.00508182915F, 1.0843944E-6F, -0.00010617722F, -0.000973979477F, + -0.000154044043F, -9.73853093E-5F, 0.00239368877F, -7.00704768E-5F, + 0.000672406692F, 0.000480921561F, -0.00100308319F, 1.65155356E-7F, + -9.071776E-5F, -0.00131913228F, 0.000368805369F, 5.02834041E-8F, + 0.00161221623F, 0.00124900369F, -0.00136656081F, -0.000978007214F, + 0.00324095902F, 0.000422669778F, -0.00123129296F, 0.000500977272F, + 1.19180044E-7F, -0.000535226543F, -7.06380524E-6F, -0.0010121332F, + 0.00130217418F, -0.000422415964F, -0.00102740317F, -0.00039051153F, + -4.01165437E-7F, -0.00165887643F, 0.000869072159F, 0.00528663397F, + 2.79177948E-6F, 3.44220243E-5F, -0.000352635F, -0.000311243697F, + 1.46634221E-7F, 0.000154146517F, 0.000124932296F, 0.00180438033F, + -0.000326485082F, 0.000453686691F, -0.00210963143F, -0.000929327391F, + -0.000132440982F, -3.77753568E-5F, 0.000268578733F, 0.0007337844F, + 1.69890227E-5F, 0.000309077848F, 0.00223580934F, -0.00602967339F, + 9.17947364E-6F, 0.000231715429F, -0.000363855448F, 0.000255803141F, + -0.0022455235F, -0.0156831667F, 0.00223794556F, -6.88443179E-5F, + -0.00064767868F, 0.000308684277F, -0.000431922643F, -8.91612189E-8F, + 0.000211067687F, -0.000569895317F, 0.000628498732F, -4.08265578E-7F, + -0.000359673169F, -0.000412282359F, -0.0010405652F, -0.000359090016F, + 7.73134047E-7F, -1.0769174E-5F, -7.04462E-5F, -5.14659604E-8F, + -0.000142193327F, -0.000969909073F, -0.00055429F, 0.000598256243F, + -0.00104646734F, 3.59918231E-5F, -0.00128658663F, 0.00149602897F, + -0.000972952112F, 0.00725401053F, 0.00183704752F, 0.00252638222F, + -0.00465418678F, -0.000283771165F, 0.000104799867F, -0.0017065194F, + -0.000412436522F, -0.000332503841F, -0.000551979407F, 0.000350930379F, + 0.00216443976F, -0.000522947F, -0.000301574968F, 0.000241645714F, + -0.000534963969F, -0.000414495473F, -0.00148209766F, -0.000312389457F, + -0.000678326469F, -0.000887024566F, -5.36687439E-5F, -0.00513844425F, + -2.34258607E-7F, -5.05592482E-7F, 0.000793138519F, -0.000495796965F, + 2.44689581E-5F, -0.000415282208F, 0.00209183828F, -5.58289794E-5F, + -0.00321734953F, -0.000987460837F, 3.36667144E-5F, -0.000423887424F, + 0.000112940157F, -1.00013222E-6F, -1.42809745E-6F, 1.37473717E-6F, + -0.000898805854F, 0.00342704984F, -9.94964466E-8F, -0.000386862113F, + -8.97002246E-6F, 0.000990600791F, -0.000792257255F, 2.56307459E-7F, + 0.00149250601F, 3.60995699E-7F, 1.803283E-7F, -2.7594017E-6F, + 0.00142843893F, 5.74976511E-5F, -2.55965098E-8F, -0.000411171059F, + 0.00027668511F, 0.000191464438F, -0.000214549204F, -0.000406398874F, + 0.0041371244F, -0.000259377499F, -0.000512571F, 7.67849124E-5F, + 0.000444031815F, -0.000147597442F, -2.41813427E-6F, 0.000643260777F, + 0.000276057021F, 0.00191366009F, 0.00120859302F, -0.000990478671F, + -0.000905316905F, -0.000270580465F, -0.000554436294F, -0.000697356882F, + -6.50180482E-6F, 0.00175932329F, -1.87074505E-7F, -0.00181808707F, + 0.00177165016F, 0.000704746111F, -0.000609510054F, -0.00103087607F, + -0.00126689381F, -0.0220004339F, 0.00220116763F, 0.000610114424F, + 0.00994851F, 4.44014404E-5F, -0.0050572129F, 0.00307815592F, + -0.000983981881F, -0.000860925706F, -0.00314769591F, 0.00153971231F, + -0.00141894026F, -0.00261958409F, -0.00313783297F, 0.00205085892F, + -0.00449502328F, -0.00329121761F, -5.45460789E-5F, -0.00497362111F, + 0.00316603901F, -0.0020755718F, 0.00144696212F, -0.00227026735F, + -2.7318325E-5F, -2.63893853E-5F, 0.00841834862F, -0.000482959673F, + -0.000135965063F, -0.000306848728F, -0.00204238459F, -0.00121873512F, + -0.0027364695F, 0.0207271278F, -0.00805950165F, -0.000828904856F, + -0.000950173591F, -0.00574493408F, -0.000466708909F, 0.00681707915F, + -7.03526894E-7F, -0.00210177572F, -0.000599672727F, -0.000830670353F, + -0.000713150424F, 0.000148509163F, -0.00346527644F, -2.517346E-5F, + 0.0135116717F, -0.00276829721F, -0.00156729796F, -0.00232079509F, + -5.0501927E-5F, 0.00121280167F, -0.00130546535F, 0.00792968273F, + -0.00196553674F, 0.00127247209F, 0.007454623F, -1.11008676E-5F, + 0.000701395154F, -0.000276232255F, 0.000784944161F, -2.75580305E-7F, + 0.00263328152F, 0.0055037667F, 0.00177942647F, -2.23767825E-6F, + 0.00278757955F, -0.00104876759F, 0.00141231227F, -0.000438002317F, + -0.00208542985F, -0.00109180436F, 0.00112940744F, -1.95823741E-5F, + -0.00036781776F, 0.000503774092F, 0.00571201649F, -2.68506574E-6F, + 0.00352289039F, 0.0125315646F, 0.000455222646F, 0.00520749576F, + 0.000347682653F, -0.0112430537F, 0.00019149654F, -0.00384429214F, + -0.0031567819F, 0.00114962226F, -0.00055224041F, 0.00123782328F, + -0.000658832898F, -0.00111113128F, -0.00173901394F, 0.00167939055F, + -0.000723194156F, -1.94585391E-5F, 0.000679622055F, 0.00310925883F, + -0.00573641527F, -0.00276948907F, -0.00210651592F, -0.0865276307F, + -0.00799148F, 0.0039662919F, 6.70023292E-6F, -8.6989E-6F, + 0.000799075176F, 0.00515406113F, -0.00248437421F, -0.000354347809F, + -1.46105667E-5F, 2.65709714E-5F, -0.00303904759F, 0.000237696091F, + 0.000839697081F, 0.00251528784F, 0.00227491581F, 0.00208421447F, + 0.00185435126F, 2.46844229E-5F, -0.00354624679F, -0.000671897666F, + -3.59030014E-6F, -0.00368319545F, -0.00174005143F, 0.000199998743F, + -0.0121639045F, 0.00152115955F, -0.000751565793F, 0.001288992F, + 0.000678480719F, 0.00850675534F, 0.0108413706F, -0.00361223659F, + -0.00226686569F, 0.000321792846F, 0.00861854851F, -3.48054309E-5F, + -0.00474175531F, -0.000581100117F, -0.000156439972F, 0.00187289726F, + 1.9968471E-5F, 0.000669713307F, 1.72258697E-5F, -0.00236882595F, + -0.00235721073F, 2.32100092E-7F, 1.15750245E-5F, -3.18918756E-5F, + -0.00403148588F, -0.00188854639F, -0.00185669516F, 0.00288299541F, + 0.0008928405F, -0.000108252032F, -0.00185622205F, 0.00992874429F, + -0.000565615948F, -0.00406952901F, -0.00153614988F, 0.00313397F, + 0.00222004F, -0.00451397337F, -0.00135677203F, -0.000929786125F, + 0.000423896738F, 0.000209580539F, -0.00130681659F, 0.00180187763F, + -0.000844739494F, 0.00569560286F, -0.000869892247F, -0.00303014112F, + -0.00194344483F, -0.00158216513F, -0.00312555954F, -0.00678705F, + -0.00108546403F, -0.000296348211F, -0.00511725945F, 0.00051975681F, + 0.00261350069F, 0.00120453618F, -2.95049558E-5F, 0.00195598439F, + 0.0139668304F, 2.716979E-7F, -0.00073891F, 0.00298976339F, + 0.00156981032F, -0.00429279357F, 1.20747745E-5F, -7.05095681E-6F, + -0.0672391877F, -0.00128747954F, -0.00546480389F, 0.00176157837F, + 0.018181067F, -0.000925427303F, -5.91967546E-6F, -0.0043084207F, + -0.00364006124F, 0.00978341F, 1.95708108E-5F, 0.000392989983F, + 0.000629582384F, -0.0435516164F, 0.00178028154F, 0.00089847378F, + -0.00316148507F, 0.00204826915F, -0.0202243179F, -0.000207692385F, + -0.00222496875F, -0.000593348F, -0.00476196222F, -0.00108368939F, + 0.00546776F, -0.00222789403F, -0.00303569017F, -0.00115013262F, + 0.000462797791F, 0.0126115326F, -0.000757590111F, -0.0020811744F, + 0.00730250496F, -1.94641925E-5F, -0.00519294757F, 0.00133368501F, + -0.00291226804F, 0.000368896552F, 0.00106843433F, -0.0019545F, + 0.000174010114F, 0.000122669953F, -0.0042621321F, 1.60827476E-5F, + 0.000617175712F, -0.00302431686F, -0.00670743035F, 4.98964891E-6F, + -0.000264213624F, 0.00312933326F, -0.00732701132F, 0.00219172426F, + -0.00247349427F, -0.00202496257F, 0.00769765908F, -0.000598822488F, + 2.60053876E-5F, -0.00203919061F, 0.00043366375F, -0.00311439531F, + 0.00240932941F, -0.00343307178F, -0.00368479383F, -0.00101666967F, + -3.1405878E-5F, -0.00356597942F, 0.00373284565F, -0.00228113122F, + 5.74445949E-8F, 0.0019404164F, -0.00160106469F, 0.00143149972F, + -9.21497758E-8F, 0.000270294375F, 0.00095987F, 0.00103838416F, + -0.00232775742F, -0.00203328836F, -0.00100378448F, -0.0202542767F, + -0.00288665388F, -6.73033792E-5F, -0.000521369628F, -0.00214108941F, + 0.00126311951F, 0.00130577362F, 0.00921861548F, -0.0053782016F, + -0.000245117786F, -0.000156470021F, 0.00018615053F, 0.00153858203F, + -0.00301476358F, -0.0196457412F, 0.00784728304F, -0.000794535852F, + -0.000626558554F, 0.000302499539F, 0.00223742961F, -9.09492655E-7F, + -0.00080589694F, 0.000331549323F, -0.000646717846F, 9.7569955E-6F, + 0.000512951694F, -0.0007248724F, -0.000475541427F, -0.00145359652F, + 5.13048617E-5F, 8.65181646E-5F, -0.0035223458F, 1.53416986E-5F, + 0.000483318348F, -4.23084457E-5F, -0.000205853037F, 0.000162415672F, + 0.00260469387F, -0.00130364893F, -0.00352760055F, 0.00248485501F, + -0.000331669551F, 0.000861688051F, 0.000735329406F, -0.00116138393F, + -0.00395637052F, 0.000115215618F, 0.00191561587F, 0.00138252298F, + -0.000680791738F, -0.00270125642F, 0.00136553717F, -0.001452761F, + 0.00391785195F, -5.60121116E-5F, -0.00142688933F, -0.000671288697F, + -0.00425610784F, 0.00263032061F, -0.00203758595F, 0.000267575757F, + -0.000753610861F, -0.0013226812F, -0.00224311673F, -0.123240069F, + 1.24001772E-5F, -8.29528108E-6F, 0.000546451833F, -0.000989828492F, + -0.00022107226F, 0.000943021965F, 0.00308996788F, 0.000492428779F, + 0.00154850539F, -0.000267575146F, -0.00153733103F, 0.00228367234F, + -0.00107291178F, -3.0848405E-5F, -9.85276347E-6F, -2.12620489E-5F, + -0.0151785677F, 0.00710098585F, -1.33586645E-5F, -0.00223927503F, + -0.000185353521F, 0.0012356654F, 0.00183174247F, 2.95938071E-6F, + 0.000853509177F, 6.0238217E-6F, 5.91040298E-5F, 5.64618222E-6F, + -0.000809745F, -0.000249823206F, -5.29891895E-6F, 0.000352010073F, + 8.08183813E-6F, 0.0029377467F, -0.000967827509F, -0.00316951703F, + 0.0105116786F, -0.000888024166F, -0.000553193851F, 0.00161534618F, + -0.00111381919F, -0.00217665266F, -7.99514237E-5F, -0.000393206486F, + -0.00123631337F, 0.0146604525F, 0.0014596628F, -0.000443209836F, + -0.00686865207F, -0.00942524F, -0.011525264F, 0.00449397974F, + -0.00156124495F, 0.0147918575F, -0.00197958364F, -0.0320340395F, + 0.0330131203F, 0.028766254F, -0.0123010175F, 0.0326623246F, + -0.00444224523F, -0.119348772F, -0.0138761718F, -0.0167294536F, + -0.0279483721F, -0.00224563736F, 0.0472462587F, 0.0130637363F, + 0.028516354F, -0.023316063F, -0.0321405046F, -0.0175819658F, + -0.0682657808F, -0.00554953283F, 0.0231550224F, -0.0491914116F, + -0.000158374547F, 0.0265680887F, -0.00136397674F, -0.0418447256F, + 0.0801156685F, -0.00298535661F, 0.0036009294F, 0.0471965484F, + -0.00118339865F, -0.00186220452F, 0.152424932F, 0.00807514414F, + -0.153717116F, -0.00256074429F, 0.0290923379F, 0.0236273576F, + 0.0488731787F, -0.0335815214F, 0.0415658168F, -0.0295326393F, + 0.0155699123F, -0.0234109201F, -0.00645803334F, 0.0292472281F, + -0.000512772705F, -0.0531717762F, -0.00462948577F, 0.0192644093F, + -0.00442852592F, -0.0105818277F, 0.0303467605F, -0.00296941912F, + 0.0100204907F, 0.00443351688F, -0.0319474414F, 0.0143002383F, + -0.0173403304F, -0.0104886424F, -0.00781358313F, 0.0105592981F, + 0.0431140698F, -0.0107821589F, -0.0292712562F, -0.00221737521F, + 0.00545813935F, 0.0185759105F, -0.0173867606F, -0.00188694382F, + 0.0359266065F, 0.00880408753F, -0.00703526102F, -0.0018975276F, + 0.0429787748F, 0.020967247F, -0.070534572F, 0.0177585017F, + -0.0271812826F, 0.0512214862F, 0.00785573199F, 0.000144250225F, + 0.0300384369F, -0.0351371206F, 0.458617479F, -0.00275222026F, + 0.0202510562F, 0.104553752F, -0.026489405F, 0.00141967565F, + -0.00158693339F, -0.209635481F, 0.0294696614F, -0.00360614294F, + 0.0231268387F, 0.0139349569F, -0.00626354944F, 0.0623747893F, + -0.000451514177F, 0.000323699758F, -0.0375578403F, -0.01694322F, + 0.0138339316F, -0.00312540517F, 0.0493383184F, 0.0281113759F, + 0.164575264F, 0.0352236107F, 0.12041638F, 0.0260954741F, + -0.123429209F, 0.036980439F, -0.00144131936F, -0.00246315286F, + 0.0123664234F, 0.00397537369F, -0.0106557608F, -0.00697006F, + -0.00296230661F, -0.00187155372F, -0.00453304732F, -0.0025017336F, + 0.183578715F, -0.0144064166F, 0.0298012346F, 0.0110484846F, + -0.045303259F, -0.00132348F, -0.0276319776F, -0.0169388447F, + 0.00697500631F, -0.0936293826F, -0.0137972739F, -0.00558006344F, + -0.0120656956F, -0.0289825778F, -0.00982612465F, 0.10157688F, + 0.0236914791F, -0.0136976838F, -0.0494871736F, 0.0188089833F, + 0.049305059F, 0.0201183092F, -0.0368809849F, -0.000891131407F, + -0.0893468559F, 0.0468174629F, 0.0103646126F, -0.023971932F, + -0.00550787058F, 0.0339302905F, -0.0079084076F, -0.0391223617F, + -0.0600245148F, -0.00214393204F, -0.0018292747F, -0.00262692152F, + -0.0560654551F, 0.00386944762F, 0.00360190962F, 0.0887055472F, + -0.0417188518F, -0.0156072509F, -0.0130255362F, -0.00485743769F, + -0.0310218483F, -0.0458611809F, -0.0646903887F, -0.084483467F, + 0.0164855346F, -0.017776249F, 0.0118639404F, 0.00521624926F, + 0.0165377539F, -0.00535147078F, -0.0649863854F, 0.00287745101F, + -0.0547026582F, -0.0163135976F, -0.00704899197F, -0.0610399432F, + 0.0149369054F, 0.0461114943F, -0.0121291298F, 0.169363946F, + 0.0249304567F, -0.0484328158F, -0.000969537592F, 0.0042802766F, + 0.0122482823F, 0.0635906532F, -0.00574691407F, 0.0971849933F, + -0.0446757711F, -0.00262843771F, -0.00257544871F, -0.0834434405F, + 0.00739394873F, -0.00152714923F, -0.00311892899F, -0.0021380859F, + -0.0551935062F, 0.0125708375F, 0.00332463067F, 0.116671458F, + -0.00245557725F, 0.0437380299F, -0.0394903272F, 0.112166986F, + -0.136568248F, -0.00279223546F, -0.00599852158F, -0.080967389F, + 0.00610055216F, -0.0190902855F, -0.0204526894F, -0.0896021575F, + 0.0134202577F, 0.0449388325F, 0.0965502784F, 0.00056924962F, + 0.0251092613F, -0.0164758246F, 0.015187813F, 0.0325734392F, + 0.0163197313F, -0.00321589271F, -0.012240204F, -0.0104976119F, + -0.0592403561F, 0.119473167F, 0.00747740408F, -0.0607305F, + 0.110857695F, -0.00249154214F, -0.0837121904F, 0.0184110906F, + 0.0486611798F, 0.0407211706F, 0.0707518086F, 0.0180048943F, + 0.0145766009F, -0.019090252F, -0.0280346088F, -0.00113710912F, + -0.0490212105F, 0.0136151342F, -0.0851892382F, -0.00244097295F, + -0.0179456864F, 0.029953761F, -0.0850033313F, -0.012992329F, + 0.0122304326F, -0.0609354377F, 0.22362113F, -0.00513059739F, + -0.00052476913F, 0.0024741462F, -0.00550197111F, -0.0347536542F, + 0.0328168049F, -0.0220565498F, 0.0103854425F, -0.0277583096F, + -0.00173360924F, 0.0215455722F, -0.00347126089F, 0.00321998307F, + -0.00171985407F, -0.00207236968F, 0.00403263792F, 0.0864769F, + -0.00179265009F, -0.011477408F, 0.0120468531F, 0.043847423F, + -0.00569285732F, -0.0558562167F, -0.0508143455F, 0.0154587524F, + 0.0220789593F, -0.00405501807F, -0.00928577222F, -0.0376343094F, + -0.0121626798F, 0.0220762249F, -0.041908F, -0.00694452459F, + -0.00463061407F, -0.00455898745F, -0.0245460514F, -0.00108405598F, + 0.0113417916F, 0.0559490286F, 0.0042371084F, -0.00293709827F, + 0.0273217261F, -0.118767403F, 0.0280825943F, -0.00137310044F, + 0.0042801206F, 0.00475762598F, 0.026177749F, -0.00208459678F, + 0.010057725F, -0.0113659622F, 0.0290140156F, 0.0100100804F, + -0.0012755004F, -0.00131443574F, 0.0413252264F, -0.00130455557F, + 0.00251522055F, 0.0333328918F, -0.0483489931F, 0.0294004865F, + 0.0472123846F, -0.0214729477F, -0.0317377597F, -0.032455571F, + 0.023778934F, 0.0492023863F, 0.0186711326F, 0.0300753564F, + 0.133102462F, 0.00372185837F, -0.032452926F, 0.143474877F, + 0.00274753431F, -0.0415455215F, 0.00192643446F, 0.00305885798F, + -0.0835157186F, 0.0200600009F, -0.0303656049F, -0.00272838236F, + 0.0179258268F, 0.00797419529F, 0.0774647221F, 0.0281909741F, + -0.0250625238F, 0.0149086807F, -0.0242947284F, -0.0252799392F, + -0.00203324133F, -0.00265625166F, 0.0164179336F, 0.0729872659F, + 0.00665205857F, -0.043807812F, 0.0294117108F, 0.0194195062F, + 0.0716371238F, 0.0114522846F, -0.0441396348F, 0.051250644F, + 0.0219993982F, -0.000929543865F, -0.00186388544F, -0.00316384854F, + 0.0714101344F, 0.000205669421F, -0.00603885064F, -0.0195062365F, + -0.00454815757F, -0.0225360561F, -0.00323132193F, -0.00363527914F, + 0.0436791182F, -0.00166003837F, -0.00133614684F, -0.00317442138F, + -0.039589636F, -0.000718942087F, -0.00446849177F, 0.0415370949F, + -0.0246409662F, -0.00205520564F, -0.00513570523F, 0.0223415568F, + 0.0364433601F, 0.0114698093F, -0.0414965339F, 0.0448225066F, + 0.0262142811F, -0.0411966965F, -0.00352199492F, 0.0823013932F, + -0.0375965908F, 0.060425F, -0.043486841F, -0.0537722148F, + -0.00453747F, 8.76551785E-5F, 0.0130886463F, -0.01012938F, + 7.39599818E-6F, 0.00461578136F, -1.66477821E-6F, -0.00435255701F, + 0.00183088647F, 0.000473358668F, 0.012732137F, -0.0115476679F, + -0.00307059358F, -0.184860662F, 0.00987383444F, -0.00257022888F, + 0.0169995707F, 3.15115758E-5F, 0.00210503745F, 0.00943631F, + -0.000395529583F, 0.00241510686F, -0.0169227067F, 0.0323380232F, + -0.0360195562F, 0.000111500463F, 0.00347552286F, -0.0201108065F, + -0.0110844914F, -0.0540666394F, -1.56564456E-5F, 0.00595618226F, + 0.0045998157F, 0.0163887367F, -0.00166674459F, -0.0105201118F, + -2.61783553E-5F, 3.30599505E-5F, 0.00093707745F, -0.00338786957F, + -0.0381998308F, -0.00873891637F, -0.0010980136F, -0.0160167832F, + -0.0119863963F, -0.014075039F, -0.0173068102F, -0.00167570391F, + -0.00166182464F, -0.0458007269F, -0.00026305471F, 0.00667516375F, + -0.000158949028F, -0.00593041489F, -0.000574455713F, -0.00274943095F, + -0.000192253792F, -0.00100315327F, 0.00300726085F, -9.73238366E-6F, + -0.00274772313F, 0.00202520168F, 0.000706491643F, 0.037269827F, + -0.00102657499F, -0.0234860722F, -0.00216104416F, 0.150049284F, + -0.00462159188F, 0.0025742834F, 0.00923787616F, -4.4892171E-5F, + 0.000552231329F, -0.0374358632F, -0.00400787964F, 2.12919349E-5F, + 0.00578467129F, -0.0287171621F, 0.046962589F, -2.1198407E-6F, + 0.04108F, 0.017475903F, -0.0158235077F, -0.00218442664F, + -0.000830664125F, -0.0053672404F, 0.0185054503F, -2.38170196E-5F, + 0.0631411374F, -0.00117324409F, -0.223788589F, 1.66234549E-5F, + 0.0998362675F, 0.0291008428F, -0.00280577294F, 0.00493105082F, + -0.00272661471F, -0.266240716F, 0.0209285617F, 0.000707035651F, + -0.0031808177F, -0.00194149616F, -0.000512734638F, 0.00707431044F, + -0.00304789678F, -0.00454371F, -0.00151070091F, -0.07194525F, + 0.0016758017F, -0.000236274529F, 0.00636288058F, -0.00722349482F, + -0.00757196872F, -0.0311800819F, -0.0259413812F, 0.000392506161F, + -0.0729069859F, 0.0255751852F, 2.83183704E-6F, 5.17932203E-5F, + 0.00213747239F, 0.00842557661F, -0.00137574435F, 0.000303488137F, + 1.12584448E-5F, -4.38827E-7F, 0.0191278663F, 1.64091507E-5F, + 0.0779262409F, 0.00477839867F, -0.00142076658F, -0.00522276107F, + 0.00890669506F, -5.74801834E-6F, 0.0977358446F, -0.000385310152F, + 0.010542999F, -0.0914774612F, 0.0261522569F, 0.0461603217F, + -0.127146363F, -3.58464058E-5F, -0.000962289283F, 0.0193168614F, + -6.32493102E-5F, 0.0284223929F, -0.018996628F, -0.0111982645F, + -0.0435082577F, -0.000640741724F, -0.00265425304F, -1.29499549E-5F, + 0.0417544767F, 0.0102518918F, -0.00377029786F, -0.00884360168F, + 4.5895591E-5F, 7.54644134E-5F, -1.20611967E-5F, 0.0565191358F, + -0.0058779805F, -2.6233256E-6F, -1.22764686E-6F, 1.31822899E-5F, + 0.010716713F, -0.00612985F, -0.0189764854F, 0.00151645031F, + -0.103111558F, 0.0493794195F, -0.00626846636F, 0.0411053F, + 0.00380443549F, 0.00165861275F, -0.00130155287F, 0.000553186F, + 0.00333513506F, -0.0943460763F, 0.00336103304F, -0.00284197275F, + -0.00160505F, -0.000655013893F, -0.014004509F, -0.00848488603F, + -0.000226395889F, 0.00114027131F, -0.000896894489F, -0.0165120419F, + -0.00976843573F, -0.00363050075F, 0.0271431506F, -0.0211667772F, + -0.0192834586F, -0.00111307076F, 0.00677319383F, 0.00119594671F, + 0.0858294293F, 0.035486076F, 6.26683759E-5F, -0.071679391F, + -0.0413738117F, -8.70111E-6F, -0.00469427463F, -0.00533429859F, + -0.0188055094F, 0.000384548941F, 6.39443488E-6F, 2.88473748E-5F, + -0.0188491605F, 0.0031484561F, -0.0554171912F, 0.000420818425F, + 0.252559632F, 0.00178148819F, 0.00343834027F, -0.000333509961F, + -0.127107412F, 0.0284240432F, 3.30653456E-5F, -0.019080922F, + -0.00590422098F, 0.0446648709F, 0.00348512409F, 0.0715444461F, + 0.00620130822F, 0.0050380053F, -0.0335134715F, -0.00191115064F, + 0.0126404418F, 0.00368336192F, -0.014375749F, -0.0015924488F, + -0.000433315086F, -0.0012309663F, 0.046163246F, -0.000954786199F, + -0.00201960607F, 0.0294693168F, 0.00963504F, -0.0348790847F, + 0.125184327F, -6.65909101E-6F, 0.012276805F, 0.00147994445F, + -0.0343494043F, -0.00651057158F, 0.016961F, 0.0051425295F, + 0.00416751718F, -0.00346220261F, -0.00674111536F, -1.28013653E-5F, + -0.00734256394F, -0.0169887207F, -0.0903322175F, -1.8604871E-5F, + 0.0374461263F, 0.00843305327F, -0.066276595F, -0.0893350765F, + 0.0379503779F, 0.00650409237F, -0.00463662855F, -0.00113333773F, + 2.04795306E-5F, -0.0089426646F, 6.6233988E-5F, 0.00619515916F, + -0.0512863658F, -0.0186431129F, 0.00266616791F, -0.0160625484F, + -4.60170259E-6F, -0.00986900367F, 0.00565192243F, 0.0471505821F, + 0.000170877378F, -0.0108535811F, 0.00437774649F, -0.0632747F, + 2.23533038E-6F, -0.0177193545F, 0.00146832701F, -0.00609495491F, + -0.00309435977F, 0.00806932058F, -0.0166497566F, -0.0193406083F, + 0.000853965699F, -0.000646000379F, -0.00193321507F, 0.0300355032F, + 0.0218330529F, -0.0252136383F, 0.0182027612F, -0.123052545F, + -9.6054282E-5F, -0.000764288823F, -0.000746982289F, 0.0231253505F, + 0.0399527F, -0.373940051F, 0.0462000892F, 0.00273191463F, + 0.0308113378F, -0.00812336616F, -0.0226873476F, -1.29780292E-5F, + -0.000534033636F, -0.00717448397F, -0.0368777253F, 1.23707978E-5F, + 0.00562387053F, -0.00653780485F, 0.085629F, 0.000874772493F, + 5.57179519E-5F, 0.00050094584F, -0.00481502339F, 2.7127362E-6F, + 0.00427070353F, 0.0104562985F, -0.0068336362F, 0.00594123779F, + -0.00661524618F, -0.00394165516F, -0.003062431F, 0.05022984F, + 0.00418087514F, 0.21438849F, 0.0120786708F, 0.0737456828F, + -0.091991F, -0.0137403421F, 0.00102413853F, -0.0106307082F, + 0.0374462418F, -0.013818454F, 0.000458038761F, -0.00291326875F, + 0.0223504119F, 0.00756849954F, -0.0823039189F, -0.00147652416F, + -0.00102823647F, 0.00789073855F, -0.00739028F, -0.0107781133F, + -0.0024946325F, -0.00427156407F, -0.00258623878F, -0.0226627942F, + 9.08500283E-7F, 2.99685926E-5F, 0.00306601496F, -0.00158771547F, + 0.0042137336F, -0.0324324779F, 0.0507338978F, -0.00128364202F, + -0.0329697877F, -0.00177360035F, 0.00787202455F, -0.00260705478F, + 0.00119643752F, 6.05915466E-6F, -4.27800842E-5F, 1.44333535E-5F, + -0.0938652083F, 0.0394122563F, -6.39649943E-6F, -0.00592790078F, + -0.000485533499F, 0.0401520208F, -0.00859235693F, 3.63790605E-5F, + 0.0500266887F, -5.58928332E-6F, 8.04520314E-5F, 4.5843226E-5F, + 0.0218254142F, 0.000859198219F, -3.01648015E-5F, 0.00304540317F, + -0.0007424957F, 0.00536153512F, -0.0005044383F, 0.0431798175F, + -0.193358809F, -0.00601687143F, 0.00351903355F, -0.00818584859F, + -0.0144377006F, 0.0108305365F, -0.000372290931F, 0.00150129199F, + 0.060702242F, 0.0235975273F, 0.0830339491F, -0.00161247107F, + -0.00358744152F, -0.00710185943F, -0.00284384494F, 0.00140913879F, + -0.00158492837F, 0.0155509273F, -0.00190361927F, -0.0129980566F, + 0.0915718898F, 0.0130156847F, -0.00739686051F, -0.00557038095F, + -0.00774596957F, 0.419506788F, -0.0230462737F, -0.0428642593F, + 0.0279713608F, -0.00216418761F, 0.00143897743F, 0.0442505702F, + 0.00655937335F, 0.00696173683F, -0.087448F, -0.0155988596F, + 0.105046764F, -0.020983668F, 0.0225097016F, 0.0396928713F, + -0.0979488343F, -0.125353664F, -0.00115656969F, -0.0606693961F, + -0.00834765285F, -0.0267985072F, -0.00957021303F, 0.0258113258F, + -0.00111077807F, -0.00172340812F, 0.151805446F, 0.00665425649F, + -0.0874276236F, 0.00599947199F, -0.0268752333F, 0.0338315964F, + 0.0427368507F, 0.00961930677F, -0.0828220695F, 0.0250961632F, + 0.0292970929F, -0.0162271224F, -0.00474097114F, -0.0328888632F, + -0.000466737751F, -0.027535893F, -0.00557904085F, -0.0469023921F, + -0.00767782331F, -0.0155836679F, 0.000174457833F, -0.00307181361F, + -0.015339952F, -0.0260088407F, 0.00717799552F, 0.030093722F, + -0.0185159743F, 0.00975147448F, -0.0138935894F, -0.050892286F, + 0.0469213948F, 0.0282531586F, -0.0112248743F, -0.00231282623F, + 0.00772784557F, 0.027397804F, 0.0251420941F, -0.00193150307F, + 0.0553981066F, 0.0027663291F, 0.101038046F, -0.00184538797F, + 0.0535100326F, 0.00127890683F, 0.0536441542F, 0.0106909964F, + -0.0579154715F, 0.0280385353F, -0.0314954072F, 0.000281084533F, + 0.0481184088F, -0.013279005F, -0.150751635F, -0.00273538847F, + 0.14890705F, -0.0313222446F, -0.0194536671F, -0.0265731178F, + -0.00514310645F, 0.0016606038F, 0.0558702946F, -0.0422945432F, + 0.0244132504F, 0.013912404F, -0.00792235322F, 0.0719175F, + -0.0250222459F, -0.0263614543F, -0.00626815297F, 0.0252361055F, + 0.0166678596F, -0.00340295909F, 0.0093438318F, -0.0443020463F, + -0.0502445251F, -0.0132489307F, 0.135772064F, -0.0638903156F, + 0.196561977F, -0.0142124547F, -0.00139827468F, -0.00247416808F, + 0.0034279048F, -0.0411467142F, -0.0182666108F, -0.00494772801F, + -0.00288783596F, -0.00178485562F, 0.100442134F, -0.00175492023F, + 0.0244922079F, 0.0214424785F, 0.00794023741F, -0.0331739932F, + 0.0474153981F, -0.00121774094F, -0.0308417976F, -0.00235767383F, + 0.0322102681F, 0.141095981F, 0.0183685664F, -0.070338808F, + -0.0209188964F, -0.00500500528F, -0.0189165939F, 0.0550204292F, + -0.0432117842F, -0.0392608345F, -0.0324128903F, 0.00903544F, + 0.000778355461F, -0.00323533197F, -0.0072015957F, -0.00108600967F, + -0.0815814361F, -0.00476447679F, 0.0182074495F, -0.00316203432F, + -0.00551183941F, -0.0293225814F, -0.00280094775F, 0.0627665892F, + -0.0275012627F, -0.0022131037F, -0.00161108223F, -0.0025760869F, + 0.00864818878F, 0.0189360157F, -0.0208341572F, -0.297763199F, + 0.0557373054F, 0.0267181769F, -0.0511059165F, 0.0138594778F, + -0.0146387154F, 0.032749109F, -0.0601273552F, -0.0437824093F, + 0.062131308F, -0.118492663F, 0.0103622507F, -0.0190732088F, + -0.025762707F, -0.00623017224F, 0.158284739F, 0.0148422038F, + -0.0420675874F, -0.0397501104F, -0.00303176627F, 0.0614507683F, + -0.0512046069F, -0.00712632807F, 0.0743606314F, -0.0975603387F, + -0.100934654F, -0.0121221039F, 0.0128991716F, 0.0299485251F, + 0.0241338313F, 0.203356907F, -0.00569736864F, -0.0286942087F, + -0.00875157211F, -0.00268089F, -0.0346411206F, 0.0183987897F, + 0.0189527217F, 0.0288806316F, -0.00306243473F, -0.00223618955F, + 0.00720873894F, 0.112220518F, -0.00466879131F, 0.131556839F, + -0.00955524761F, -0.0393535495F, 0.0536426306F, 0.12878105F, + 0.105231605F, 0.0108747836F, -0.00604924466F, 0.155762851F, + -0.0514032915F, -0.127869204F, -0.0253902115F, -0.0206353683F, + 0.0267929398F, 0.0817435607F, 0.215282366F, -0.0440404713F, + 0.0428708568F, -0.0264667124F, 0.0106350891F, -0.0458469465F, + -0.0383773968F, -0.0158144329F, 0.0269951709F, -0.0243799407F, + -0.0188230779F, -0.0146228867F, 0.0197180174F, 0.168000549F, + 0.000917923287F, -0.00231873803F, 0.039763011F, -0.0423587188F, + 0.130293712F, 0.0536992177F, 0.075288564F, 0.0221991185F, + -0.0227686726F, -0.0173157342F, -0.0297064222F, -0.00115125382F, + -0.00256854412F, 0.0274870805F, 0.273706585F, -0.00259843469F, + 0.0415415F, 0.0970095769F, 0.133721769F, 0.0311267022F, + -0.0182275604F, 0.00509398524F, -0.0569120981F, -0.020448247F, + -0.000471205072F, 0.00345402909F, 0.00397577742F, -0.0365872085F, + 0.058376193F, 0.00371376239F, -0.00713428948F, -0.0364787653F, + -0.00172459462F, 0.0248198099F, 0.00324366684F, -0.0376552157F, + -0.00155195873F, -0.0288998429F, 0.0162265543F, -0.0125531508F, + -0.00175862317F, 0.0405440591F, -0.038779784F, 0.0569362193F, + -0.0554213859F, 0.00105611992F, 0.0831473619F, -0.343414813F, + -0.0871237367F, -0.00408290653F, -0.00173657958F, 0.034358006F, + -0.0104427114F, -0.0204405095F, -0.00108559243F, -0.049799867F, + -0.00591596F, -0.00777986553F, -0.00933314208F, 0.025457941F, + 0.0534693785F, -0.113824338F, 0.0357518345F, -0.0173416212F, + -0.0575407F, -0.0478240065F, -0.000619981613F, -0.00128848723F, + -0.00187278574F, -0.0154074039F, 0.0839410275F, -0.00201888289F, + 0.0108928969F, 0.019866474F, 0.0716479048F, -0.00765158283F, + -0.00129133381F, -0.0050023F, 0.0493774377F, -0.00130094518F, + 0.0153404642F, 0.0348178446F, 0.163601682F, 0.0186490174F, + 0.0537384488F, -0.0201202966F, 0.0465608165F, 0.106832F, + 0.0261063129F, -0.00194868608F, 0.0602603182F, 0.0562144779F, + 0.103179693F, 0.0230951216F, 0.00443345495F, -0.098668173F, + 0.0250441786F, 0.0388674475F, -0.00899177883F, -0.02125814F, + 0.0757261515F, 0.0289573763F, 0.0402329527F, -0.0158817787F, + 0.00831135735F, 0.011831807F, 0.0852353871F, 0.0206059068F, + -0.0335382074F, -0.0147843519F, 0.00496988557F, 0.00758497696F, + -0.00210844958F, -0.00253903121F, -0.000208573096F, -0.0539728254F, + 0.000160953554F, 0.0123094562F, 0.0403226F, -0.0276894756F, + 0.0989974663F, -0.0546126068F, -0.00844595488F, -0.0532852449F, + -0.00128251838F, -0.000909183407F, -0.001765389F, -0.00313157681F, + 0.171425149F, 0.0147167407F, -0.00592220342F, -0.00697324425F, + -0.00544762F, -0.013354918F, 0.0164084751F, -0.00362881296F, + 0.0533988029F, -0.0015523514F, -0.00128838F, -0.00307122106F, + 0.0327852517F, -0.00129664189F, -0.00437377812F, 0.0744256899F, + -0.0222927723F, 0.0408589318F, -0.0184149072F, 0.0475051962F, + 0.0166320279F, 0.0454322435F, -0.0234557353F, -0.00726727443F, + 0.00133794604F, 0.0101984572F, -0.00405565649F, -0.0975389257F, + 0.0311634243F, -0.0273725335F, -0.0639165491F, -0.0392880328F, + -0.0390160568F, -0.0219234154F, -0.00506899692F, 0.0194818843F, + -0.006276567F, 0.102776393F, -0.00594544597F, 0.01019766F, + 0.0107346429F, -0.0283075F, 0.0272610355F, 0.00811568648F, + -0.0288769305F, -0.133925542F, -0.00932875555F, 0.022728499F, + 0.0495456755F, -0.00829101074F, 0.0247833617F, -0.0393680297F, + 0.0241924915F, 0.00597781595F, -0.0637790114F, -0.0112081748F, + -0.0433425978F, -0.0290499646F, -0.00917339232F, 0.0623163506F, + 0.0140320277F, 0.026519537F, -0.0115691032F, 0.0153951384F, + 0.0445274226F, -0.0573538542F, -0.00900530815F, -0.0262234025F, + -0.00753461476F, -0.00953690149F, 0.0214206558F, 0.00154714554F, + -0.0203068424F, 0.0124172391F, -0.00989702344F, 0.00110173225F, + -0.0104201781F, -0.00641221879F, -0.0287296157F, 0.00274074636F, + -0.0283108708F, 0.00911552366F, -0.0229865629F, 0.0317931436F, + -0.00860681944F, -0.0532010607F, -0.0135800466F, 0.0161096919F, + -0.0140129449F, -0.010634345F, 0.0122489519F, -0.0100681679F, + 0.0375628062F, 0.00971571635F, -0.0423814617F, 0.00555490842F, + -0.0272579044F, 0.00401311042F, -0.0200987756F, -0.0365078412F, + -0.0331012234F, 0.00861770753F, -0.00134792016F, -0.0100050876F, + -0.0108956899F, 0.00718032289F, -0.0619654693F, -0.00770228589F, + 0.00588331744F, 0.0211823732F, -0.0204739701F, -0.00843830872F, + 0.0265243948F, -0.0562994257F, -0.0100176865F, 0.0193365347F, + 0.0129819624F, -0.0489880629F, -0.0407907665F, -0.0105518419F, + 0.0212497842F, 0.0021981441F, -0.03379016F, -0.00869807508F, + -0.083085373F, 0.0339897797F, -0.0164411701F, -0.024920078F, + 0.00278598F, 0.045833949F, -0.0374704786F, -0.0222170856F, + 0.000330847775F, -0.00952580664F, -0.0146491565F, 0.0410982035F, + -0.00942275766F, -0.0252060592F, 0.00634077657F, -0.0166240148F, + -0.00820727181F, -0.0104340138F, -0.0566029213F, 0.0573016591F, + 0.0711948127F, 0.00289416965F, 0.0287663694F, 0.0770852789F, + 0.0409103148F, 0.00183079822F, -0.00689143827F, -0.00776658393F, + -0.00818876829F, 0.0234343335F, -0.0304421F, -0.0219384823F, + -0.0100024706F, -0.0104994345F, -0.018046869F, -0.0177305844F, + -0.0443203412F, 0.0100970203F, 0.0243433919F, -0.0125325043F, + 0.00593960518F, -0.00854167249F, 0.0110948933F, -0.0110646849F, + 0.00717335055F, -0.0444000587F, 0.0399871878F, -0.000281837885F, + -0.0327904671F, -0.00349354418F, -0.0169170145F, -0.0492513105F, + 0.0384470113F, -0.0355682522F, -0.0513380095F, 0.049301751F, + 0.0124234864F, -0.00115889823F, 0.0103381379F, -0.00909674075F, + 0.0245193057F, -0.0157582499F, -0.0280983262F, 0.00685818586F, + -0.013791535F, 0.0176041424F, -0.0154694943F, 0.00189549883F, + 0.0690215081F, -0.0113386214F, -0.0100542977F, -0.00975459442F, + 0.00902961846F, -0.0368471667F, -9.78482694E-6F, -0.0751678497F, + 0.0808041394F, -0.0107695963F, 0.0139331091F, 0.0629705116F, + -0.021434078F, 0.024171466F, 0.009179716F, -0.0271548405F, + -0.00882043596F, 0.10733483F, -0.0342138857F, 0.00801479723F, + -0.00526848854F, -0.0308125522F, -0.0216487702F, 0.0182145F, + -0.031004753F, -0.0107821058F, 0.00484856823F, -0.0310860928F, + 0.0297413785F, 0.0100195101F, -0.0179340411F, -0.00579411071F, + -0.0591498464F, 0.00719102F, 0.01616171F, 0.0213309601F, + -0.00221186271F, -0.0151916742F, -0.0127959102F, -0.0825078487F, + -0.0564374961F, -0.0105190855F, -0.0271570124F, 0.115527011F, + 0.0170003492F, -0.028869709F, -0.00771702407F, -0.00816594809F, + 0.0607834719F, -0.0474133156F, 0.0241863318F, -0.0341028869F, + 0.0624477826F, 0.0294824876F, -0.00644814F, 0.00731728133F, + -0.0485155322F, 0.0543641F, -0.0106657837F, -0.00854472537F, + -0.0353916F, -0.118961364F, -0.0233871881F, -0.0230411254F, + -0.00906670839F, 0.0137941623F, 0.0159291066F, -0.0201004446F, + -0.0135370968F, -0.0225979704F, 0.00325939292F, 0.0282180645F, + 0.0500338227F, -0.0194347221F, -0.00588818593F, -0.0141786011F, + -0.014875168F, 0.0249941275F, -0.00489065889F, -0.0279823449F, + 0.0810302645F, -0.00849893689F, 0.0174962804F, -0.0169789158F, + -0.0575963482F, -0.066181235F, 0.0554747954F, 0.0141629297F, + -0.0170199014F, -0.0254737865F, -2.15807195E-5F, -0.0103351269F, + -0.0217576306F, 0.0113802711F, -0.0370433256F, -0.00920802F, + -0.00871865824F, -0.0711841583F, 0.0461253151F, -0.028935289F, + -0.00353479129F, 0.0181380678F, -0.0106215272F, -0.028111022F, + -0.00749229034F, 0.00122128194F, -0.0344889127F, 0.0121289026F, + -0.0047291317F, -0.0303923152F, 0.012024397F, -0.0349322073F, + -0.00601658132F, -0.00418366212F, -0.0376555361F, -0.00430478854F, + -0.00942463707F, -0.0328148268F, -0.054605905F, -0.042539306F, + -0.00658822479F, -0.0282963254F, 0.0119814938F, 0.0127309384F, + 0.00193207583F, 0.0126223387F, 0.0172443371F, 0.0333592519F, + -0.00452473154F, -0.0126826847F, -0.0192842465F, -0.00527266F, + 0.00257498818F, 0.0113514448F, 0.0128612304F, -0.00940187182F, + -0.0188971851F, -0.0205251556F, -0.00628173677F, -0.0193276F, + 0.00119685626F, 0.0386700705F, -0.00448342226F, 0.0214031506F, + 0.0144488579F, -0.0217231512F, 0.0130189201F, -0.00788075849F, + -0.0250014551F, -0.0101436423F, 0.0181320533F, -0.00507428264F, + -0.0300505236F, -0.0481297597F, 0.0334999599F, -0.0217343867F, + -0.00778858177F, -0.0158458911F, 0.0182139743F, -0.00638542231F, + -0.066762045F, -0.0429260843F, 0.024747422F, -0.0294325743F, + 0.0367734805F, -0.029902203F, -0.00454879459F, 0.00147082133F, + -0.00803617481F, -0.088516213F, -0.000658191799F, -0.000605596113F, + 0.0480240881F, 0.0188802127F, -0.0115462504F, -0.0275351517F, + 0.00610940298F, 0.0139485467F, -0.0310308542F, -0.00292316498F, + 0.0527096875F, 0.0334701911F, 0.0119615616F, -0.0103574013F, + 0.0102620125F, 0.0264285579F, -0.00587664871F, 0.0190599859F, + -0.0669157207F, -0.0214527F, -0.0226543639F, 0.0130819455F, + -0.00974074192F, -0.00880085F, -0.0234066173F, -0.0165743921F, + 0.00885987468F, -0.0558967888F, 0.00511628948F, 0.0238897726F, + 0.00554517F, -0.0378694534F, 0.0766308233F, 0.0397011638F, + 0.0155686559F, -0.00703341421F, -0.00981003698F, -0.0111382669F, + -0.00126180437F, 0.00415448193F, -0.012428347F, -0.00483147381F, + -0.0167075451F, -0.00925983768F, -0.0466434807F, -0.00825073849F, + 0.0252941791F, -0.00967581198F, -0.00841208F, -0.0140585853F, + -0.010195367F, -0.015669208F, -0.0097972434F, 0.00645353645F, + -0.0156124141F, 0.0343501903F, 0.014318943F, -0.0392871313F, + 0.0157704279F, -0.0382945426F, -0.0136974938F, -0.060121987F, + -0.00140025711F, 0.00661256583F, -0.0113543402F, 0.00305811921F, + -0.00922095124F, 0.0367320292F, 0.0209095851F, 0.00441699941F, + -0.00503334729F, -0.0199458059F, 0.0304128453F, -0.0158197377F, + 2.56150597E-5F, 0.0268623643F, 1.48379568E-5F, 0.000902276195F, + 0.0709619746F, -0.0170499384F, -0.00230933516F, -0.0149866836F, + -0.00205297652F, 0.0629917234F, -0.0255185384F, 0.00227710349F, + 0.0375279F, 2.41672678E-5F, -0.00187997217F, 0.0138014648F, + 0.0013459248F, -0.000829339493F, -0.0173542351F, 0.0659461617F, + -0.0425290391F, 0.000917888654F, 0.00165151036F, -0.023235511F, + -0.019782247F, 0.0037292249F, 9.64917199E-5F, 0.0228276607F, + 0.0105787935F, 0.00950662512F, 0.0276393909F, -0.0191652626F, + 3.12894554E-5F, 3.81532809E-5F, -0.0455908962F, -0.0179217942F, + 0.0340310596F, -0.00141925598F, 0.00383092975F, -0.0181895439F, + 0.00341328862F, -0.0875485688F, -0.0481382497F, 0.0337519422F, + 0.0255521908F, -0.0514374673F, -0.000469087914F, 0.019105345F, + -0.00010393461F, 0.0482905544F, -0.000568860327F, -0.00394775392F, + 0.00135250832F, -0.00154879328F, -0.000965173589F, 4.52188669E-6F, + 0.0459278263F, 0.0162536427F, 0.0120572941F, -0.0179130863F, + 0.000906641188F, 0.0570425019F, -0.00216182205F, 0.133576632F, + -0.01012538F, 0.045324482F, -0.0206537955F, -7.4354386E-5F, + -0.0167912263F, 0.0455110669F, 0.00747224083F, 1.55171329E-5F, + 0.041151505F, 0.0410247892F, -0.0392811336F, -8.46469629E-6F, + 0.0230137333F, 0.000892925367F, -0.0102738906F, 0.00173239585F, + -0.00145593926F, 0.0149397086F, -0.0360289253F, 1.11804393E-5F, + 0.053124316F, -0.00678071566F, -0.084990412F, 2.35977659E-5F, + 0.0190591495F, 0.0288674664F, -0.0194924232F, -0.00921005942F, + -0.00114747952F, 0.0189118162F, 0.00437884638F, -0.0034732169F, + -0.0109879309F, -0.0248486102F, -0.000917371246F, -0.0318839699F, + 0.000249909499F, -0.0209735055F, -0.00901185535F, 0.0190297775F, + -0.00230160914F, -0.000647098466F, 0.0171630625F, -0.00590620283F, + 0.000123363658F, -0.00410049828F, -0.0236722138F, 0.0431869179F, + -0.0443415754F, -0.0503056571F, 7.31222553E-6F, 0.000171087086F, + -0.000243300747F, 0.0173275489F, -0.00167825108F, 0.00110085553F, + -3.89841352E-6F, 2.39969322E-5F, 0.00582427159F, -0.00133010512F, + 0.00377520174F, 0.0592311062F, -0.00185450702F, -0.0015280511F, + 0.0502355918F, -0.000105101331F, -0.034689825F, 0.00927379634F, + 0.00953290425F, -0.0499525853F, 0.0336838923F, 0.0336004309F, + -0.0121718151F, -0.00392298633F, -0.00270243804F, -0.0148959188F, + 0.00214157579F, 0.0236298535F, 0.0152786039F, -0.0273004901F, + -0.0571325235F, -0.00148043316F, 0.0103012798F, -8.1996739E-5F, + -0.0253898203F, 0.00479629403F, -0.00177751598F, 0.0512840897F, + 9.35591816E-5F, -0.0069653336F, -1.48293757E-5F, 0.00592407025F, + -0.0102216508F, -6.23707092E-6F, -7.03260885E-5F, -3.06754409E-5F, + 0.0139862075F, 0.0100245168F, 0.00427846052F, 0.0560464412F, + -0.018598279F, 0.0555395372F, -0.0032858171F, 0.041087687F, + 0.00239799F, 0.0180776883F, 0.0253087301F, -0.0393659845F, + 0.0131668597F, -0.0314026475F, 0.000299544161F, 0.00038690868F, + 0.0012863389F, 0.00526041491F, 0.00660000462F, -0.0433290787F, + -0.00184834434F, -0.0147972442F, 0.0276789814F, -0.046267394F, + -0.00300763547F, -0.00747380918F, 0.0178693868F, -0.0513369106F, + -0.0171488971F, -0.000482875272F, 0.0124212271F, 0.00113260304F, + -0.0189440437F, -0.0114956796F, -7.58868846E-5F, 0.00293438439F, + 2.41960042E-5F, -1.453201E-5F, -0.0201415308F, 0.0302154049F, + -0.0161639731F, 0.00340952422F, -9.51585571E-6F, -1.7950988E-5F, + 0.0164113324F, -0.0149687389F, 0.0254097078F, -0.000999248587F, + -0.06792178F, 0.0113164969F, 0.00587866595F, 0.0354857147F, + -0.0140215363F, 0.0400571339F, 3.05843714E-5F, -0.0189771373F, + -0.0213596132F, 0.0616555773F, -0.041547671F, -0.0329392329F, + -0.00865846779F, 0.0499835536F, 0.127388015F, 0.000155783375F, + 0.0101623368F, 0.00444620242F, -0.027420558F, 0.00303560845F, + 0.0262018051F, -0.00902110524F, -0.0148952911F, -0.000345919107F, + -0.0223572012F, 0.0351824462F, -0.0018685722F, -0.0474859364F, + 0.0106536709F, 0.000110685753F, 0.0103681972F, -0.0153932832F, + 0.0285292398F, 0.00198916811F, -0.00383114256F, 0.00253988174F, + -0.00568501139F, -0.00193599914F, -0.00160542713F, -5.30442958E-5F, + -0.0432616584F, -0.0416002572F, -0.0451868027F, -2.88743086E-5F, + -0.00965146255F, 0.00246810517F, -0.0586545244F, 0.00379926572F, + -0.00230379F, 0.0217795763F, 0.020419253F, -0.00361607852F, + -1.91807558E-5F, -0.0138297807F, 0.011895298F, 0.020192517F, + 0.0622759648F, -0.0527633354F, 0.0137765165F, -0.0507362969F, + 2.02151787E-5F, -0.0180200022F, 0.0099460762F, 0.00129704142F, + 0.000121961995F, -0.0102311596F, -0.00327790854F, -0.00614775345F, + 7.73532793E-6F, -0.0399716198F, 0.00357241114F, -0.00303616375F, + 0.00992607139F, 0.0238331538F, 0.071389772F, -0.0411728323F, + 0.0106070871F, -0.00155769952F, 0.000364731415F, 0.00396608468F, + 0.0349264704F, 0.0302193891F, 0.0292348173F, -0.0353335589F, + -0.00273206783F, -0.00301336171F, 0.00415890105F, 0.00366505678F, + -0.00102961611F, -0.0841999F, -0.0537232906F, 0.00864897203F, + -0.0210657492F, -0.030188011F, 0.0228485502F, 4.91587525E-6F, + -0.00424308935F, -0.00145412947F, 0.0299509559F, 0.000167357342F, + -0.00197061268F, -0.0333239473F, 0.0340212584F, -0.0032976279F, + -7.83425203E-5F, 0.00226792041F, -0.00839353725F, 4.15888971E-5F, + 0.0116770109F, 0.020810876F, 0.0323670171F, -0.029765984F, + -0.00239138678F, -0.0142556764F, 0.0472346507F, 0.0539720729F, + 0.00183361524F, 0.0937133133F, -0.030000288F, 0.00155663083F, + 0.00896620285F, -0.0275390409F, 0.0337558836F, -0.0215127151F, + -0.0291665774F, 0.0354518928F, -0.0156729F, 0.00132912584F, + -0.0662753358F, 0.00570930867F, 0.00867140107F, 0.00173700775F, + -0.0546759628F, -0.00227589603F, 0.0471561775F, -0.0285627861F, + 0.00297576701F, 0.000963415834F, -0.0016506355F, 0.0176225789F, + -1.27486792E-5F, 0.000208966885F, 0.00198313221F, -0.00425575394F, + 0.00458215177F, 0.0383296199F, 0.0610946454F, 0.0070612547F, + 0.0326081365F, -0.0255172066F, -0.0175915398F, -0.00390496221F, + 0.00983365066F, -3.02965855E-5F, -4.46496524E-5F, 4.58599607E-5F, + 0.0581062287F, 0.0316390134F, 9.12741143E-6F, -0.0269519612F, + -0.00026497044F, 0.0789519697F, 0.0119877374F, -3.69261397E-6F, + 0.124953069F, -2.71129175E-5F, 2.80642798E-5F, -0.000279291038F, + -0.00942626223F, -0.000850982964F, 6.35804281E-6F, -0.00480838679F, + 0.00407094136F, 0.0102279112F, 0.000612838776F, -0.025860453F, + 0.0537767559F, 0.0112608336F, 0.00797417574F, -0.025133552F, + -0.0482092425F, 0.0122603457F, -0.000670433685F, 0.00433018757F, + -0.00560689857F, 0.0307411794F, -0.00529361749F, 0.0246118419F, + 0.00717390748F, -0.0200502239F, -0.00771401078F, 0.0187316537F, + -0.0062318393F, -0.0357130393F, -0.00574348075F, -0.00547438813F, + -0.0285270493F, 0.0133462353F, 0.0109856203F, -0.00771708973F, + -0.0278962646F, -0.0556492098F, -0.0126486048F, -0.0288003609F, + 0.00088269F, -0.00808373932F, 0.0138148014F, -0.0395192057F, + -0.0607830882F, 0.0216190834F, -0.00708135124F, -0.016153533F, + 0.0446049199F, -0.0282095727F, -0.00120107201F, -0.0231805686F, + -0.00017691929F, -0.0544404797F, -0.0111268098F, 0.00885707419F, + -0.0397710055F, -0.05882385F, -0.0350631587F, 0.0275595952F, + -0.00733120879F, -0.0092581762F, -0.0522061288F, 0.00489043444F, + -0.0369384736F, -0.0339749902F, -0.0409853645F, -0.0186262485F, + 0.0300629269F, -0.00770219648F, 0.0664250851F, -0.00799704809F, + -0.0320677608F, -0.00352215092F, -0.00700242771F, -0.00719992025F, + -0.00843956787F, 0.0592598878F, -0.013699363F, -0.032839004F, + -0.0138980085F, -0.0282559115F, 0.00304872799F, -0.0115039237F, + 0.00457200175F, -0.00893436279F, 0.00147190026F, -0.0045781252F, + -0.02436045F, -0.00251650531F, -0.0367656201F, -0.0513035096F, + -0.0318193808F, 0.0312064085F, -0.0346979462F, -0.0109178731F, + -0.0132610574F, -0.0108438348F, 0.0272642951F, -0.00760443322F, + -0.0103412243F, 0.0391573571F, 0.0713195726F, -0.00826421566F, + 0.0327335782F, 0.0319621935F, -0.00123174756F, -0.044291053F, + -0.0380823389F, -0.00798741821F, 0.115942985F, -0.0105239181F, + 0.0331765935F, -0.0355131924F, 0.0619894899F, -0.00873350352F, + -0.0378015228F, 0.00410274649F, -0.0238186587F, -0.0250653811F, + -0.0489375032F, 0.00377150718F, -0.0940046459F, -0.0367167555F, + 0.0039949487F, -0.0235004742F, -0.0217793323F, 0.0498660132F, + -0.0113417925F, -0.00150737667F, -0.0373770222F, 0.0120726405F, + -0.0812287852F, -0.0106441742F, 0.0529415756F, -0.0297365654F, + -0.046601098F, -0.0104483748F, -0.071615085F, -0.00358015904F, + -0.0144737298F, -0.06018278F, -0.00674917968F, -0.0077018328F, + -0.0312670618F, -0.0133281201F, -0.0478138365F, -0.00749705639F, + -0.00988253F, -0.0101423739F, -0.0630761608F, -0.0159255173F, + -0.0668077F, 0.0447853059F, -0.0426254F, -0.0322438851F, + 0.0279799663F, -0.00808470696F, 0.0689765364F, 0.0132492362F, + -0.0117880534F, 0.0561839975F, -0.0165142864F, 0.0302612484F, + -0.026703706F, -0.0286976658F, -0.0363600738F, 0.0531015098F, + -0.0314430073F, -0.012494619F, 0.0108842989F, -0.003915F, + 0.0105418572F, -0.0467276312F, -0.00168000115F, -0.00948975701F, + 0.0148913255F, -0.0349437781F, -0.0345480815F, -0.00905223F, + -0.0140190944F, -0.011702395F, -0.0253400337F, 0.000470761734F, + -0.028023202F, -0.0116482805F, -0.00983089767F, -0.00960000884F, + 0.0106553603F, 0.0317089148F, -0.00572702056F, 0.0736556724F, + -0.03032979F, 0.0341678448F, -0.052645158F, -0.00122173084F, + -0.0126205441F, 0.00501484144F, 0.0118619734F, 0.0333091095F, + -0.00717527419F, -0.0587735325F, -0.028307613F, -0.0332906768F, + -0.03308044F, 0.00939718075F, -0.00814404245F, 0.020168731F, + -0.0490353703F, -0.0305759218F, 0.00440291176F, 0.0390772298F, + -0.0497349799F, -0.013399573F, -0.00210712501F, 0.0391260497F, + -0.0121949222F, -0.0374400392F, 0.00667709578F, -0.0482878201F, + -0.00357648148F, 0.0630164221F, -0.0126906158F, -0.0219722539F, + 0.00403017784F, -0.0105818389F, -0.016096022F, 0.0275570303F, + 0.00205342914F, 0.0268478226F, -0.00774207758F, -0.00817798078F, + -0.00388732529F, -0.0388730913F, 0.00412518531F, 0.00253406074F, + -0.0309450123F, -0.0355510637F, -0.00389453582F, 0.0103352638F, + 0.0566706099F, 0.0034254645F, -0.0106790513F, -0.0313507542F, + -0.000125321763F, -0.00829311833F, 0.0329030193F, -0.0170280207F, + 0.0071714567F, -0.0299166292F, -0.0153938197F, -0.0339772068F, + 0.0279216319F, -0.00844731F, 0.00421984727F, -0.0398477241F, + -0.00420645298F, -0.0266349576F, 0.0377885178F, -0.0177529063F, + -0.00593080232F, 0.00203218125F, -0.0750116631F, 0.0570460595F, + -0.0220620893F, -0.008336097F, 0.00367104146F, -0.0139197074F, + 0.049220413F, 0.00501138251F, 0.0548327714F, 0.013021417F, + -0.029163124F, -0.0272397064F, -0.00384467584F, -0.0103800753F, + 0.0364386477F, 0.00965568516F, 0.0849544555F, -0.0091971159F, + 0.0225499123F, 0.00977835059F, -0.011230059F, 0.024032034F, + -0.000557830557F, 0.006787939F, -0.0169212036F, -0.0302373469F, + -0.0073574977F, 0.00183938362F, 0.0267850123F, 0.0146743497F, + -0.0103343753F, -0.00160557579F, 0.0117234867F, 0.0551893041F, + -0.00595267024F, -0.00192447193F, 0.00324404845F, 0.00118078F, + -0.00958429463F, -0.00943409838F, 0.00627600634F, 0.0649478734F, + -0.00658918312F, -0.00727240928F, -0.0292203259F, -0.00121375034F, + 0.0121603468F, 0.0171546638F, -0.067914322F, -0.0194232445F, + 0.0243947972F, -0.0130632836F, -0.0335535258F, 0.00715011F, + -0.0108728614F, -0.0181135554F, -0.00365697173F, -0.000531366F, + -0.0181805361F, -0.0206128266F, -0.000510226178F, 0.0243414212F, + -0.011581853F, -0.0402299799F, -0.00264144945F, -0.02425991F, + 0.0134309866F, -0.00170592661F, 0.033539746F, -0.00779508194F, + -0.0230023284F, -0.0434312113F, -0.0236094091F, -0.00504304282F, + -0.0419182852F, -0.012306463F, -0.0165353492F, -0.0387402922F, + -0.007708936F, -0.0125234006F, 0.0268342439F, -0.00636746408F, + -0.0153734535F, 0.00408118451F, -0.0210432801F, 0.0357750282F, + 0.0396066904F, -0.0193430334F, -0.00432342151F, -0.0331865847F, + -0.0167855453F, 0.0535690673F, -0.0100949667F, -0.00378415012F, + -0.015158684F, 0.005531976F, -0.0180341136F, 0.0482169241F, + -0.00467946939F, -0.00927979313F, 0.0126072122F, -0.0106186932F, + -0.111773841F, 0.0277580973F, -0.0180096719F, -0.013940556F, + 0.00942958426F, 0.0272374433F, -0.00828523096F, 0.0206717849F, + -0.0791594312F, -0.0487848818F, -0.0342774764F, -0.00198816066F, + -0.0103528257F, -0.00856939703F, -0.0353162363F, -0.0218529478F, + 0.0216295514F, 0.0179675948F, 0.0156591218F, -0.043010097F, + -0.0483762473F, -0.00413751276F, -0.0176995769F, -0.0300865509F, + -0.0259361F, -0.00701270765F, -0.00955765322F, -0.0107192257F, + -0.0037715747F, 7.26962098E-5F, -0.0127659133F, -0.00264722365F, + -0.0196341909F, -0.0143031655F, 0.00121846702F, -0.00823098328F, + 0.0353800617F, -0.00947012194F, -0.00830474868F, -0.0137861287F, + 0.0153320059F, -0.0151220551F, -0.00975943636F, -0.0300769098F, + -0.0103086196F, -0.0403247885F, -0.0330124386F, 0.0882596821F, + 0.00917501654F, 0.0258501433F, -0.00581257045F, 0.0647055283F, + 0.0189303234F, 0.00881302543F, -0.011624625F, 0.0224221703F, + 0.0124327959F, 0.00386580778F, 0.0342976488F, 0.00888596103F}; + static const float inputStateWeights[2000] = { + 0.00314874668F, -0.00787014514F, -0.0160688609F, 0.00106169598F, + 5.37013148E-6F, -0.0265336763F, -5.25349533E-5F, 0.00105747813F, + -1.23396134F, -0.000590690237F, 0.00721616205F, 0.0247722119F, + -0.00754664233F, 0.00530783553F, -0.864171326F, -0.00265270891F, + 0.00207279762F, -0.000348971429F, 0.00247723935F, -0.180901244F, + -0.00439329306F, -0.000570102478F, -0.0236441698F, -0.0304217655F, + -0.00694960402F, -0.0126075419F, 0.0089141177F, 0.0284314398F, + -0.00197980553F, 0.00980940741F, 0.000652824063F, 0.0037297185F, + 0.00212483131F, 0.000400989229F, -0.0943855271F, -0.018766759F, + 0.000149704108F, 0.000521104608F, -0.000714612659F, -0.00325565482F, + 0.565664172F, 0.020244075F, 0.00936606713F, -0.0170683619F, + 1.97718322F, -0.0200508889F, -0.00161764747F, -2.35757089F, + -0.0318946801F, -2.05218577F, 0.000448196311F, -0.00366514781F, + -0.00050969352F, -0.116347715F, -0.00135769241F, -0.00482169865F, + -0.00290118367F, 0.00195220544F, 0.00347913895F, -5.20110916E-5F, + -0.00330490619F, -0.0154373208F, 0.0187084358F, 0.0100479703F, + -0.00511280028F, -1.89655399F, 0.000470474275F, -0.611541033F, + 0.0274785124F, 0.0406679921F, -0.00274624606F, 0.000214247222F, + -0.000974437513F, 1.7471261F, -1.0899725F, 0.000122972808F, + -1.6185627F, -0.00392514421F, 0.0552157871F, 0.00014054068F, + 1.80896962F, -0.0234160833F, -0.0640470535F, 0.00219722139F, + 0.00557921687F, 0.0142233353F, 0.0532596074F, 0.000301863591F, + -2.26187849F, 0.00049020088F, -0.044443924F, 0.000355279655F, + 0.118296884F, -0.00222709705F, 0.00853458792F, -0.00200375682F, + -0.0052079251F, -0.265616834F, -0.0952408314F, 0.00150596723F, + -0.0081057176F, 0.00441052858F, 0.0013456014F, -1.19141126F, + 0.00453175278F, 0.003145186F, 0.000855901802F, -0.934025109F, + -0.019014325F, 9.18011938E-5F, 0.0107302554F, 0.0193497166F, + -0.00193090446F, -2.15317249F, 0.0198837165F, 2.08740091F, + 0.000972989772F, -1.25609946F, -1.33202811E-5F, -0.000187051846F, + 0.00738360081F, 0.00291070645F, 0.0177826956F, 0.00103478448F, + 0.000336823083F, -0.000176062531F, -6.14874589E-5F, -0.000906702771F, + -0.0129935779F, 0.0448151305F, -0.00466724811F, -0.0098829316F, + -1.97204542F, -0.000439994445F, -0.0143369017F, -0.00308070611F, + 0.00814661197F, 0.132519856F, -0.00290464959F, -0.404010803F, + -0.66887027F, -0.00784713F, -0.000674243493F, 1.14527154F, + -0.0117503088F, -0.0031420372F, 0.00383420289F, -0.00515279919F, + -0.00184909184F, -0.00534129282F, 0.00186458556F, -0.000459458068F, + 0.0821182504F, -0.0084285466F, 0.0136455595F, -2.06126428F, + 0.000630363065F, 8.62760426E-5F, -0.000916643301F, 2.24856782F, + 0.00415883632F, 0.000330363255F, -0.000736651069F, 0.000334648241F, + 0.0042103515F, 5.65930823E-5F, -2.03038263F, -0.0451668687F, + 0.00162343227F, -0.0303141847F, 0.00107299839F, -0.0012400276F, + 0.00322519662F, 0.00168985093F, 0.00938133523F, -0.361380488F, + 2.098773F, -0.0184944365F, -0.00943743158F, -0.00228319643F, + -0.0129082557F, 0.0012409006F, -0.00110732019F, 0.0023427105F, + -0.00598101597F, 0.000703069847F, 0.010200656F, 0.000269045675F, + 0.00241020252F, 0.0883612633F, -0.00612445921F, -0.00102298253F, + -0.0298504177F, 0.0122520123F, 0.00395228341F, -0.00125538011F, + -0.661157072F, 2.28032851F, -0.000853225414F, -0.849594116F, + 0.00261282665F, -0.000147619605F, 0.00666978909F, -0.00169915939F, + 0.00452597626F, 0.00139989262F, 0.00011003259F, -8.19046545E-5F, + 2.30491233F, 0.0184453689F, -0.000628479F, 0.00101093517F, + -0.547155261F, 0.00257795F, 2.20300269F, -0.00171728036F, + -0.29382208F, -0.00145565858F, 0.000385991851F, 0.0248869415F, + 0.00469830679F, 1.49312735F, 0.00969563052F, 0.560694814F, + 0.0258789044F, 2.00685596F, -0.0109965019F, -0.00459041F, + 2.0884223F, -0.00871905778F, -0.00105405319F, 0.00134589686F, + -0.00239628251F, -0.00194465008F, -0.0163770337F, 0.00180788746F, + -0.0107813338F, 0.00248084706F, 0.0171334278F, 7.22190598E-5F, + -0.00219897251F, 0.000299782783F, 0.00304232491F, 0.00905538816F, + 0.0135661513F, 0.00725004543F, -1.05954742F, -0.00156907248F, + 0.00324954232F, 0.00845735241F, 0.0252398793F, -0.00011273905F, + 0.00862967223F, 0.000722300378F, -0.00484135933F, 0.00012051504F, + -1.98108506F, 0.0255138632F, -0.00151296647F, 0.210569724F, + -2.21954751F, -0.00333743822F, -0.025880022F, 0.00567111559F, + -0.000315748825F, 0.016167758F, 0.00421846379F, 0.0240398757F, + 2.24129963F, 0.000301912398F, -0.000677884149F, 0.00363151799F, + -0.000426125276F, 0.0151280509F, 0.0877668932F, 0.0151534127F, + 0.000702293066F, 0.00730168028F, 0.018601317F, -0.0105317282F, + -6.10272082E-6F, 0.0112039475F, 0.00641853828F, -2.198524F, + -0.00332006067F, -0.00419089943F, 0.0707860216F, -0.015182009F, + -0.000407489977F, -0.000109790315F, -0.00430786423F, -2.25603175F, + -0.0128575973F, 1.52074504F, -0.00262070214F, 0.341340542F, + 0.00250137085F, -0.00373360515F, 0.00191095192F, 0.00461659255F, + -2.13173938F, 0.0666869357F, 0.00355771324F, -0.00113288581F, + -0.0131852599F, 0.0851335675F, 0.00845393818F, 0.000270645774F, + 0.00878054835F, -0.0117071364F, 1.8706882F, -0.000286162627F, + -0.00749951415F, -0.00173526676F, -1.86970961F, 0.00971619599F, + -0.000277825282F, -0.00387782045F, 0.00297806924F, -1.69801024E-6F, + 0.00868347939F, -0.0470185131F, -0.127653643F, -0.0164096877F, + 0.00384706515F, -0.0116116172F, -2.37216926F, 1.72298658F, + 0.0112194512F, -0.571332F, 1.35805857F, -2.23222184F, + -2.31718612F, -0.00116825628F, 2.14065289F, -0.0603947788F, + -0.0180576947F, -2.41457057F, -0.00468166173F, 0.00622059777F, + -0.055817049F, -0.00359930145F, 2.02793336F, 0.00542130787F, + -0.00598703744F, 0.000841203961F, 0.00497917132F, -0.00340372277F, + -0.016249001F, 0.028991973F, 0.00139618013F, 2.35152221F, + 0.000555252482F, -0.000133993555F, -0.0048633134F, 0.00530644553F, + -0.000219334135F, -0.0182277169F, -1.65469587F, 0.00226948131F, + -0.0296185985F, -0.0113729415F, -0.00365879107F, 0.0109182009F, + 0.012494334F, -0.000147863131F, 8.38154083E-5F, 0.000304435816F, + 0.0517562032F, -0.0025888849F, -0.000480268296F, 0.00410074461F, + -0.00159565872F, -0.0569580831F, -1.35143399F, -0.000219413734F, + 2.2138288F, -2.82401124E-5F, -0.000328236085F, -0.00091946F, + 1.71955824F, -0.00213139551F, 9.2703347E-5F, -0.0032857398F, + 0.000755992543F, -0.0132150501F, -0.00317613804F, 0.0062529589F, + -0.0236133244F, -0.00102671026F, -0.0026403307F, -0.00750378473F, + -0.00091003417F, 0.00337798265F, 0.000302495784F, 0.00178427773F, + 2.01879168F, 0.00327006285F, -0.759178162F, 0.00357489754F, + -0.00381655921F, -0.00893094577F, 0.0154692261F, -0.23356317F, + -0.000169123567F, -0.00544636045F, 6.75563788E-5F, -0.23691541F, + 0.000864642148F, 0.0206966437F, -0.0285228025F, -0.0193302948F, + 0.0177155063F, 0.292039394F, 0.000358055229F, -0.240775466F, + 0.472415864F, -9.43724372E-5F, 0.27207756F, -0.000904396235F, + -0.312694192F, 0.203077942F, -0.00935666822F, -0.00667019701F, + 0.0408457629F, 0.0225355476F, -0.033748813F, -0.00777953351F, + -0.247596413F, 0.00433470681F, -0.0002636227F, 0.33558926F, + 0.252325773F, 0.400243223F, -0.0062199817F, 0.0270682704F, + -0.000369563495F, 0.000231111364F, 0.0922597423F, 0.0599415712F, + 0.00106071495F, -0.0193646364F, -0.0186275821F, 0.0353815481F, + 0.000230730788F, -0.0742417723F, 0.193724245F, -8.87326678E-5F, + -0.00475794449F, -0.00179402402F, 0.00474830065F, -0.346743673F, + 8.04468E-5F, 0.00445427047F, 0.00733521255F, 0.0771006718F, + 0.00803753454F, -0.0336406119F, 0.0536745749F, -0.00016724439F, + -0.62286979F, 0.0226477142F, -0.0350744389F, 0.00453044893F, + 0.0487474576F, 0.00172606215F, 0.0484898053F, -0.00370464F, + -0.0347283483F, -0.0108105727F, -0.27620396F, -0.000464450801F, + -0.00664520357F, -0.00122941518F, 0.00153526373F, 5.04364725E-5F, + 0.00111592805F, 0.12124674F, 0.0219388586F, -1.71683278E-5F, + -0.00100745517F, 0.0192739293F, 0.0193309244F, -0.00374710234F, + -0.125252619F, -0.0290058609F, -0.0114607131F, -0.000288153475F, + 0.00108892575F, 0.137946725F, -0.00373323588F, -0.000155904316F, + -0.00423072046F, -0.433949202F, -0.0610083379F, -0.245025367F, + 0.0519981571F, -0.00192986848F, 0.00199754653F, 0.214552F, + 0.0352544039F, 0.28454572F, -0.00973717F, -0.00318251201F, + -0.0397126563F, -0.0446944796F, -0.366369516F, 0.00796004292F, + 0.0428335965F, 0.00122456381F, -0.0380760282F, -0.0795356706F, + -0.225847289F, -0.000408564432F, -0.0165695176F, 0.00122393761F, + 0.218054935F, 0.000462346594F, 0.000203814605F, -0.000165886144F, + -0.0427345335F, 0.280971318F, -0.0183905549F, 0.0069271517F, + -9.40488317E-5F, -0.000188976774F, -0.366076887F, 0.00657047238F, + 0.00524042267F, -0.0137694608F, -0.362454474F, 0.11293453F, + 0.000837288564F, -1.2070087E-5F, -0.278915793F, -0.0416631103F, + 0.00466848677F, -0.00680784974F, -0.61334765F, 0.00211783755F, + 0.0184502825F, 0.0559945107F, 0.055399F, 0.00438668F, + 0.0453706682F, -0.723795712F, 0.843705118F, -0.233274639F, + -0.280890554F, 0.0246865209F, 0.394439429F, 5.11934559E-5F, + 0.000858329528F, -0.0075791725F, -0.0129197994F, 0.000886485912F, + 9.56637377E-5F, 0.176858872F, -0.000402158243F, -0.000233488798F, + -0.154569596F, -3.94108138E-5F, 7.46086662E-5F, -0.000135366688F, + 0.298646808F, -0.00736593921F, -0.000707798055F, 0.0265713837F, + -0.208270445F, -0.0584057085F, -0.105831593F, -0.696201921F, + 0.00699091377F, 0.271099061F, -0.0307991486F, 0.000882687804F, + -0.000817586377F, -0.0255920719F, 0.027560113F, 0.0700276F, + -0.00334488018F, -0.0206137206F, 0.0418450311F, 0.201899201F, + 0.121838681F, -0.20483835F, 0.0135532403F, 0.224712834F, + -0.0541509055F, -0.0216867495F, -0.38239646F, -0.275215447F, + -0.0108626783F, -0.0349869579F, 0.452906162F, 0.0105660623F, + -0.00303142611F, 0.000520133F, 5.73302677E-5F, 0.000668372493F, + 0.704923749F, 9.83448263E-5F, -0.0925686136F, 0.0560391694F, + -0.0774831623F, 0.230283886F, -0.000231842205F, 0.00021509784F, + 0.00183128694F, 0.00857338775F, 0.012016193F, 0.110252477F, + -0.00338413566F, 0.261340082F, -0.000228809775F, -0.0237688199F, + 0.00595274195F, -0.551836312F, 6.62863167E-5F, -0.0268080439F, + -0.123874791F, 0.00165127323F, -0.0671545416F, 0.00547763519F, + -0.0185075905F, -0.000740121701F, 0.00529649807F, 0.107087798F, + -0.0011396507F, 0.00495788921F, 0.179709285F, -0.137943313F, + -0.316108763F, 0.169798642F, -0.0802097544F, 0.113342926F, + 0.00680970075F, 0.440126061F, -0.0129490308F, 0.199488163F, + 0.0545490496F, -0.000400881137F, 0.333923459F, -0.0870944932F, + 0.00553947734F, 0.00698705902F, -0.00486489292F, 0.217657849F, + 0.298922122F, -0.057348609F, -0.0363166891F, -2.29220823E-5F, + -0.0741611347F, 0.167478353F, -0.331225902F, -2.86604973E-5F, + 4.64369514E-5F, 0.004873069F, 0.205814824F, -0.00547283096F, + 0.000598929415F, -0.321860284F, 0.00841201097F, -0.0102878548F, + -0.000128256332F, -0.0481821485F, 0.00700079463F, -0.0360869765F, + -0.000502204F, 0.169259265F, -0.0791792497F, -0.108235784F, + -0.000153577086F, -0.0314448625F, 0.00571028283F, 0.0736708865F, + 0.000158556621F, -0.0996549055F, -0.0320827588F, 0.0892332792F, + 0.000154914611F, 0.00716051785F, -0.111196727F, 0.00101557781F, + -0.0796848908F, -0.206619158F, 0.0044677509F, 0.00937444F, + 0.146141335F, 0.00254273228F, 0.00581218116F, 0.000443696714F, + -0.0124219423F, -0.00218953658F, -0.387558311F, -0.016614629F, + -0.00498868152F, 0.0101265525F, 0.0130939102F, 0.344275147F, + 1.97588433E-5F, 0.00419318071F, 0.434338957F, -0.191683963F, + -0.0119603612F, -0.006402181F, -0.115166F, -0.000202633892F, + -0.0203646794F, 0.0601038486F, -0.000200181821F, -7.22859331E-5F, + 0.00543207349F, -0.211255506F, -0.000269725686F, -0.0138152605F, + -0.000505039119F, 0.0190531798F, -0.0310895368F, 0.000281120447F, + -0.053542953F, -0.0138997035F, 0.0112753892F, 0.0150680356F, + 0.458059579F, 0.0332410149F, 0.000386727974F, -0.00104909425F, + -0.0336415805F, 0.000298837433F, 0.00469818711F, 0.00074477552F, + -0.0013002078F, 0.0831075087F, -0.000678756507F, 0.00964783132F, + -0.00509319734F, -9.2561073E-5F, 0.101890489F, -0.0369965248F, + 0.0256403722F, -0.316384554F, 0.000795295811F, -0.0297608059F, + -0.330662817F, -0.13990733F, -0.0177918915F, -0.262164176F, + 0.0221537016F, 0.0209509563F, -0.122528069F, 0.00343359937F, + 6.96575444E-5F, -8.20618588E-5F, -0.335979849F, -0.108464018F, + 0.204122648F, -0.0169068296F, 0.00130720297F, -0.175090328F, + 0.0191006381F, 0.0623088703F, -0.249306664F, -0.0913918316F, + -0.0224927906F, 0.000200999144F, -0.00020956542F, -0.000396768097F, + -0.0194669366F, -0.64970541F, 0.000280443172F, -0.0503520407F, + 0.00403571734F, -0.0071487003F, 0.00184423581F, -2.31634094E-5F, + -0.00041771424F, 0.000185203346F, -0.000385811261F, 0.000321227475F, + -0.000772911764F, 0.0131573128F, -0.000200391398F, 0.0884129852F, + 0.0991241112F, 0.0435242914F, 0.0957473218F, 0.0485167354F, + -0.0728614479F, -0.00664073694F, 0.00697600702F, 0.0491638258F, + 0.192232311F, 0.257060111F, -0.00227578334F, 0.123459667F, + -0.000126005252F, 0.413479924F, 0.0197837129F, 0.0183744654F, + 0.000680345926F, 0.00230351347F, -0.0100025842F, 0.00774193974F, + 0.000392046262F, -0.00594484759F, 0.000284277747F, 0.00810131337F, + -0.198676363F, 0.00362237031F, 0.00969484914F, 0.0163044222F, + 0.00237567187F, -0.0116618518F, 0.0294740442F, 0.00794258434F, + -0.0349789262F, -0.000868049101F, -0.00490528811F, 0.0311872475F, + -0.000640486192F, -0.0032825307F, 0.0848951936F, -0.000949843379F, + -0.0101017756F, 0.00205451902F, 0.00635144487F, 0.0447962582F, + 0.00480035227F, 0.0324775279F, 0.00168666F, -0.0211865772F, + -0.0012417495F, -0.0215262249F, 0.00282091345F, -0.00175741327F, + -0.000418901443F, 0.000273008161F, 0.00986108091F, -0.000193941742F, + -0.0366522111F, -0.0024935361F, 3.5455625E-5F, -0.00944432802F, + -0.0346461162F, -0.0726346746F, -0.0053151329F, 0.0540218F, + 0.0108549157F, 0.105655789F, -0.00137287029F, 0.00265460392F, + -0.00109697075F, 0.0241427477F, -0.000717395102F, -0.00696078641F, + -0.000253994396F, 0.00570952939F, -0.0106065674F, -0.000664773514F, + 0.0677406266F, -0.00294974842F, -0.00502753351F, 0.0096813F, + -0.00268354663F, -0.0160298571F, -0.00415005162F, -0.0925672874F, + -0.000806729659F, 0.0409489162F, 0.00803135F, -9.97148891E-5F, + 0.000109992317F, 0.0843617395F, 0.0761310086F, 0.000158074588F, + -0.157226562F, 0.00963659212F, 0.0545576923F, -0.000224657793F, + 0.109274276F, 0.0079282F, -0.00472148089F, 0.00107064052F, + 0.00831806939F, -0.000680703844F, 0.0145915542F, 0.00119129301F, + 0.00621725F, -0.00396024203F, -0.0991808549F, 2.61711848E-5F, + 0.0288820099F, 0.0247942228F, -0.00447910791F, -0.00300585036F, + -0.00245903432F, -0.0985395F, 0.00741299847F, -0.00758320885F, + -0.00589598948F, -0.00357442815F, 0.00112205616F, -0.160513893F, + 0.00270921574F, 0.00273453933F, 0.0194569565F, -0.112213716F, + -0.00829645F, -0.000750220614F, -0.00122310396F, 0.0142268734F, + 0.00905021653F, 0.103238977F, 0.0130195804F, -0.174182087F, + -0.0117587699F, 0.132393092F, 5.86699607E-5F, 0.000124476821F, + -0.00053076219F, 0.00248901593F, -0.000387881271F, -0.00109869684F, + -0.000567134819F, -0.00109686283F, 0.02387782F, -3.63160871E-5F, + -0.00609645713F, 0.0409346707F, -0.00701291347F, -0.00919855572F, + -0.0956973806F, -0.000855024788F, 0.00290714251F, 0.00176554115F, + 0.0098924879F, 0.13373448F, 0.0502766334F, -0.0688679889F, + -0.125380814F, 0.00121869461F, -0.00274302135F, 0.0522492304F, + -0.00963872F, 0.0610699F, -0.0844984129F, 0.00541153F, + 0.0150168967F, -0.000882919878F, -0.018871272F, -0.000918548671F, + 0.0421002731F, 0.00202887901F, -0.00187768938F, -0.0524490699F, + 0.000330153882F, -0.00201202184F, -0.00150684721F, -0.106714979F, + 0.0111479871F, 0.000864054193F, -0.00107710843F, -0.000304668443F, + -0.0170039926F, -0.00511689F, 0.0938041359F, 0.0381994173F, + 0.00540081644F, -0.0127803078F, 0.00572882732F, 0.0706986338F, + 0.00049541879F, -0.0116030183F, 0.0159163922F, 0.132004857F, + 0.0269345306F, -0.0411693566F, 0.00107141747F, -0.00644039409F, + 0.00347419176F, 0.00373189128F, -0.0140809547F, -0.00648943847F, + -0.00687451335F, 0.00627272716F, -0.0221989229F, -0.00985278562F, + 0.0110013327F, 0.036441125F, 0.014067905F, 0.0185553674F, + -0.0150249293F, -0.00375093613F, -0.0357098356F, 0.000371970877F, + -0.0825389177F, 0.00505056465F, 0.000532988342F, 0.00736738555F, + -0.0635705516F, -3.40382467E-5F, 0.00502072694F, 0.0180624984F, + -0.00570813613F, -0.0134493653F, -0.000114139279F, 0.00017823423F, + -0.0559585877F, 0.0229962524F, -0.020728359F, 0.0143619385F, + -0.0875991955F, -0.0101799071F, -0.024066098F, -0.0179767199F, + -0.0573056377F, 0.044576861F, 0.000181824304F, 0.0189728644F, + 0.00349058351F, -0.217242062F, -0.0058870716F, 0.0405961648F, + 0.0153884571F, -0.0276632383F, -0.0151631404F, -0.00786249712F, + -0.030841561F, 0.00106509204F, -0.00782022346F, 0.0082692029F, + 0.0113058807F, -0.00695260568F, -0.0497051664F, -0.00412077783F, + 0.005991471F, -0.0290992651F, 0.00929375552F, -0.0080729425F, + 0.0275927074F, 0.000338342506F, -0.0166487135F, 0.00963561703F, + -0.0121077988F, 0.00955946092F, -0.180156782F, -0.00214600354F, + -0.0125697562F, -0.00137471443F, 0.0136403674F, -0.0012789655F, + 1.40628144E-5F, -0.00429559778F, 0.0193567164F, -0.000372123788F, + 0.0399229042F, 0.00706020184F, -0.00994324312F, -0.00945355929F, + 0.053805761F, 0.0135746663F, -0.054167334F, -0.00505843665F, + -0.000848945056F, 0.00484906277F, 0.00248761F, 0.0171708744F, + 0.0191855673F, -0.00622265926F, 0.0075661242F, 0.00771086896F, + -0.000474115484F, 0.00718709F, 0.0112716993F, 0.0554932132F, + 0.000180715331F, 0.00425315462F, -0.00183575461F, -3.94854469E-5F, + 3.3788514E-5F, 0.00386808207F, 0.00161695771F, -0.0601852573F, + 0.0129765682F, 0.0033448881F, -0.0209451709F, 0.0131391305F, + -0.00354985381F, -0.00127464125F, 0.00260834815F, -0.0040828404F, + 0.00555834686F, 0.160374478F, 0.0178864673F, 0.0970129743F, + -0.00119459722F, 0.0017075995F, -0.0106811253F, -0.0135023491F, + 0.0718180388F, 0.0396867469F, -0.0380369574F, 0.00395198446F, + 0.00646085292F, -0.0212954618F, -0.00888305157F, -0.000318268401F, + 0.000881629123F, -0.000852009805F, -0.00542392768F, 0.000140928969F, + 0.00938701F, 0.00439199433F, 0.0822964832F, 0.000343250751F, + -0.00082506286F, -0.00274592731F, 0.0018239558F, 0.000370745925F, + 0.00317463418F, 0.0148885949F, -0.0771108046F, 0.0103918966F, + -0.00711305207F, -0.0010198243F, 0.00463588769F, 0.157628864F, + -0.00513939932F, -0.067610234F, 0.195564717F, 0.0407267399F, + 0.0196026918F, 0.00452105049F, -0.0821286663F, -0.0390872806F, + -0.00576363225F, 0.0387735851F, 0.00108715519F, -0.00023271433F, + -0.0391827449F, 0.00365680712F, -0.109896205F, 0.00242763967F, + 0.0215034112F, -0.00141352171F, 0.0271871351F, 0.00613742601F, + -0.00671308814F, 0.00651179068F, 0.00464551337F, -0.0877560154F, + 0.000401016558F, -0.00101045799F, -0.0038594543F, 0.0084049711F, + -0.00355830742F, -0.0274197888F, -0.156455025F, 0.0061225309F, + -0.0303422771F, -0.00872753467F, -0.00296742539F, 0.0105719483F, + 0.00256083021F, -0.000590009557F, 3.2541313E-5F, -0.000315975893F, + 0.0472089723F, 0.0564066544F, 0.000958625227F, 0.00809147488F, + -0.0026891008F, 0.00994159747F, 0.0266902782F, -9.09463633E-5F, + 0.0231766347F, 7.39515672E-5F, -0.000818543485F, -0.000387888344F, + 0.00180229254F, 0.000419004471F, -0.000143691912F, -0.00849154F, + -0.00303285755F, 0.00229802378F, -0.00523008732F, -0.00982593093F, + -0.0634372234F, -0.00966440421F, 0.00390287954F, -0.00393756619F, + -0.00258959248F, -0.00951138884F, 0.00117817323F, -0.0066196057F, + -0.106730245F, -0.0191456955F, -0.0355957039F, -0.0146408761F, + 0.010181075F, 0.0182597954F, 0.00287473435F, 0.00311690872F, + 0.000749245577F, -0.0753863901F, -2.49237655E-6F, 0.0331173316F, + 0.00153616315F, -0.0139333028F, 0.0424549654F, 0.003855824F, + -0.000466364087F, 0.0270436238F, -0.005988135F, 0.0174780842F, + 0.0294550415F, -0.0010467075F, 0.0118141202F, -0.015347518F, + -0.0200422015F, 0.0334838182F, -0.126879334F, -0.00570217567F, + 0.0497274958F, 0.0139471488F, -0.00942287F, -0.185853049F, + -0.00197222456F, -0.135231435F, -0.000508284487F, -0.0315054283F, + -0.0986040384F, 0.0577993169F, -0.00312748179F, 0.0225855745F, + -0.000175076944F, -0.00028970823F, -0.0597486906F, -0.0151358461F, + -0.0610801131F, 6.58598219E-6F, -0.00690713106F, 0.0112176975F, + 0.00128451409F, -0.020741228F, 0.101864658F, 0.00126444024F, + 0.0301863793F, -0.00163323572F, 0.00117655331F, -0.0888636932F, + -5.81458335E-5F, 0.0309854988F, 0.0019981754F, 0.0110544367F, + 0.00280677504F, 0.0261043515F, 0.0126044722F, 0.000110393426F, + 0.0374291353F, -0.0204336531F, -0.00552914804F, -0.0225009359F, + -0.000642686267F, 0.000664175488F, -0.000352519186F, -0.0280420631F, + -0.0148163838F, -0.00085235195F, -0.0651497692F, -0.000274499092F, + 0.0170628354F, -0.00190405187F, 0.00195317343F, 0.000149671294F, + 0.00327512273F, 0.00852747F, 0.0315057822F, 8.73110475E-5F, + -0.000605952344F, 0.0187656134F, -0.0243841652F, -0.000107033942F, + -0.037755996F, 0.0310810488F, 0.076190576F, -0.000634965603F, + 0.000564539456F, 0.00575539889F, 0.248707563F, -0.000308337971F, + 0.0215083472F, -0.0825016722F, -0.0187458489F, -0.0927705318F, + -0.015712304F, 0.14484185F, -0.0115215108F, -0.00170000922F, + 0.0145483492F, 0.000922772451F, -0.00259188819F, 0.00475018797F, + 0.00390146766F, -0.0203045234F, -0.0475396216F, 0.00313332723F, + 0.00369995926F, -0.000729818479F, -0.0167903882F, 0.0273110066F, + 0.00635063089F, -0.00104942F, 0.071261473F, 0.00530780759F, + 0.00731963944F, -0.00331887812F, 0.000256339F, -3.13873315E-5F, + 0.0175880883F, 0.0810402855F, -0.00555240223F, 0.00108502351F, + 0.000125122868F, -3.39730177E-5F, -0.0699553564F, -0.00210734666F, + -0.0525985472F, -0.000107097934F, -0.0342563614F, -0.0157211497F, + 0.00173601473F, -0.00051304989F, 0.0544312485F, 0.00811437797F, + -0.018900929F, -0.135869563F, -0.0571029708F, -0.0437265262F, + 0.00707540847F, -0.00158187188F, -0.00308906077F, 0.00630991766F, + -0.0161475185F, -0.0690191612F, 0.0574202612F, 0.00394807244F, + 0.0495631099F, -0.0157042369F, 0.0249285623F, -0.000105165091F, + -0.120712452F, -0.0247891229F, 0.0168040283F, 0.00164060458F, + -0.000408605672F, 0.00235493411F, -0.00100349297F, 7.07664949E-5F, + 0.0184525754F, -0.000187459402F, -5.26555523E-5F, 0.000140940203F, + -0.0220327433F, -0.00104760681F, -0.00261385157F, 0.108681545F, + -0.110309467F, 7.07585277E-5F, 0.0111334566F, -0.0679689571F, + -0.00500246231F, -0.0124117825F, 0.0327412859F, -0.0835389122F, + -0.000526413962F, 0.159951299F, -0.00752336765F, -0.0208410788F, + 0.00229832157F, 0.0124830678F, 0.0736222044F, -0.0111552682F, + 0.0261130165F, -0.0727323294F, -0.00476233382F, 0.0416221507F, + 0.00396446371F, -0.00164382055F, 0.00371036143F, 0.00885443762F, + 0.105830818F, -0.026345877F, -0.00408091396F, 0.0126476483F, + 0.00267303409F, -0.000917271595F, 0.00120322313F, -0.0162365586F, + 0.0785432905F, 0.000369540765F, -0.035723988F, 0.0732646883F, + 0.00498895394F, 0.0147624193F, -0.00029166587F, 0.000198140973F, + -0.000256419968F, -0.0122586032F, 0.111641854F, -0.0678989366F, + -0.0371649861F, -0.00771801267F, -0.000501040544F, -0.100287527F, + 0.185100451F, -0.0648422241F, 0.000642608094F, -0.100356989F, + -0.0477209501F, 0.00201037317F, -0.0342678651F, -0.0150050428F, + -0.00428009639F, 0.00107277359F, -0.0748442709F, 0.0433729105F, + -0.00119746663F, 0.00266423426F, 0.0264526233F, 0.00490532722F, + 0.0287250578F, 0.0332983769F, -0.0143790245F, 0.00466257939F, + -0.0251652021F, 0.079649277F, -0.00456481287F, 0.0421156846F, + 0.0263974424F, -0.000299460138F, -0.0088561F, 0.0447028428F, + -0.0672218949F, -0.0154211242F, 0.00333628291F, 5.84233203E-5F, + -0.00450219121F, -0.00118868379F, 0.0101462118F, -0.000110024986F, + -0.0170727596F, -0.00330413F, -0.024722483F, -0.000359495811F, + -0.00159286836F, 0.00471497839F, 0.0553272925F, 0.0111930287F, + -0.000884383451F, 0.0263150409F, 0.163908511F, -0.00944588054F, + -0.000171154956F, -0.00454119965F, -0.000499709044F, 0.0134667465F, + -0.000440325559F, 0.0176086798F, -0.0342061594F, -0.00119612133F, + -0.000363196188F, -0.00798483565F, 0.0127690993F, 0.0192808285F, + 0.000219102061F, -0.055264283F, -0.00378783233F, 0.0125577087F, + -0.000178362679F, 0.0216966979F, -0.0667936131F, 0.00152251404F, + 0.0125769526F, 0.027820304F, -0.0377875194F, -0.509855747F, + 0.00299466704F, -0.000849016244F, 0.00360381859F, -0.000661532744F, + -0.000200376715F, 0.000897653168F, -0.0583989434F, -0.00769066811F, + -0.000593957317F, -0.00034414322F, -0.00895662326F, -0.00700473692F, + 0.000643535808F, -0.619575F, 0.0454060473F, 0.00191342761F, + 0.0597218089F, -0.0177612975F, -0.000311494834F, -0.000255559629F, + 0.00616355799F, 0.00312556513F, 0.00221493444F, 0.000314169389F, + -0.0240353718F, -0.0554185808F, 0.000404248422F, 0.00221255864F, + -0.000512506464F, -0.0104709575F, -0.0228308439F, 0.000475795066F, + -0.0174685791F, -0.000364491192F, 0.176135778F, -0.00956498273F, + 0.0962645784F, 0.0189978722F, 0.000419633172F, 0.000951791706F, + -0.0058047343F, -0.0550180934F, -0.00820212811F, -0.00233529694F, + -0.000750485167F, 0.000197994654F, 0.000971945294F, 0.190576449F, + 0.0168904737F, 0.00015177099F, 0.00674569421F, 0.00735155819F, + 0.0216228645F, -0.0508911274F, 0.00305007841F, 0.00736936787F, + 0.0001854617F, 0.00439437525F, 0.0748797208F, 0.0105144801F, + -0.0547153316F, -0.030428037F, 0.00136798015F, -0.000810632482F, + 6.85689811E-5F, -0.000788519334F, -0.0139843104F, -0.0117141912F, + -0.0148905916F, 0.127972901F, 0.000565779104F, 0.0276320968F, + -0.0384831615F, 0.0106597561F, 0.0540800728F, 0.00370144937F, + 0.019245239F, -0.000123381746F, -0.000114747832F, 0.000238741501F, + 0.0776960179F, -0.0654043108F, 0.00128044316F, -0.00813475717F, + 0.00015422047F, -0.00593229895F, -0.000196560795F, 0.000666226842F, + -0.000244986F, 0.00020843184F, -0.000141101278F, -0.000196282781F, + 0.0012501945F, -0.00131098484F, 0.000141836761F, -0.00199860684F, + 0.00928902905F, -0.00152037351F, 0.0123434942F, -0.0029592F, + -0.0384065695F, 0.00741938269F, -0.0327212177F, -0.00169086515F, + -0.00695581222F, -0.0163319428F, 0.000581268454F, 0.00342250895F, + -0.000119021395F, 0.0776363F, -0.0190722421F, -0.0252555907F, + -0.0165664647F, 0.0250557624F, 0.000952373F, 0.00546899F, + -0.000210802216F, 0.0410653949F, 0.000333183183F, 0.0033800106F, + 0.000686915126F, 0.00322990236F, 0.000253222563F, -0.00127998483F, + 0.0174569786F, -0.00230020308F, 0.000166432175F, -0.0040742103F, + -0.00747730397F, -0.000405795785F, 0.00135198585F, 0.0258375332F, + 0.0191968773F, -0.00685103564F, -0.0599452034F, -0.0062314868F, + 0.0342193805F, -0.0242068842F, -0.00328066503F, 0.028658988F, + 0.00549150351F, -0.0532608442F, 0.000489419559F, 0.00177401595F, + -0.0130196009F, -0.00457429187F, -0.00632991036F, -0.00198090728F, + -1.8432851E-5F, 0.000203262389F, 0.0169068538F, -0.00269229035F, + -0.0451242402F, -0.0079566F, 0.0279497504F, -0.00453462964F, + -3.55253433E-5F, -0.000994643779F, -0.0694023594F, -6.46175E-5F, + -0.00639632205F, -0.000671178917F, -0.00105636159F, 0.00550519396F, + -0.00082906679F, -0.0145804547F, 0.000199181144F, -0.0237885956F, + -0.00382464193F, 0.0134124886F, 0.00164319901F, 0.000203237447F, + 0.00233633397F, 0.00351623748F, -0.00483009452F, -0.000728701125F, + -0.011874848F, -0.000693717273F, -0.0298165809F, -0.00519095547F, + 0.000271435856F, -0.00400570454F, -0.0210768972F, 0.000627063389F, + 0.000815495208F, 0.000154721871F, -0.00494252704F, 0.0001594442F, + 0.000897786929F, -0.027819192F, 0.00702390168F, -6.48058631E-5F, + -0.000605302863F, 0.00249067275F, 0.00280356687F, -0.00737546477F, + -0.0320664495F, -0.0603762157F, -0.0691759959F, 0.000554855098F, + -0.000309423398F, 0.0142100835F, -0.0329258032F, -4.92126201E-5F, + 0.165342078F, 0.00619262643F, -0.0264353659F, -0.0233777948F, + -0.0471508652F, -0.00420835335F, -0.00490105944F, -0.0221462045F, + -0.000710495398F, -0.0196131766F, 0.0027684F, -0.000522389368F, + 0.00725211808F, -0.0157533344F, -0.0142330844F, 0.000400500372F, + -0.050233122F, -0.00020735024F, -0.00749767479F, 0.0162866749F, + -0.00359015493F, -0.000286229F, -0.00848473888F, 0.000245987903F, + -0.00116053945F, -0.00131294224F, 0.000136662406F, 3.96386713E-5F, + 0.000545000366F, -0.00407688F, 0.0230317693F, -0.000443035155F, + -0.000179164796F, -0.000448465405F, 0.0110382885F, 0.00240756851F, + -0.0312978774F, -0.00432281801F, 0.029111376F, -0.0239046197F, + 0.000120181314F, -0.000301706576F, 0.000108028202F, 0.00136372168F, + -0.000925521366F, -0.0524285957F, 0.00505313324F, 0.00787255F, + 0.000135985625F, 0.0298998598F, -0.0181634631F, -0.000612892269F, + -0.00470799766F, 0.0136214299F, -0.00842949376F, 0.00661518378F, + 0.000447480968F, -0.0262108445F, -0.0051009953F, -0.000261767826F, + 0.00414674915F, -0.00369807798F, -0.024204772F, 0.00022990501F, + 1.38243877E-6F, -0.00807103F, -0.000481183262F, -0.000498315843F, + 0.0567244925F, 0.000109512737F, -0.000638066907F, 9.97132593E-5F, + 0.00303834141F, -0.021506317F, -0.000236542299F, -0.0691759661F, + 0.0690433607F, -0.00417267252F, -0.0119400453F, 0.0084587913F, + 0.00455519278F, 0.00167028187F, -0.00521173235F, 0.015952399F, + -0.000738578499F, 0.0260974951F, 0.00540008349F, 0.00218918594F, + -0.00784129091F, -0.00357461115F, -0.0326011479F, -0.00883111916F, + 0.019257633F, -0.0309946705F, 0.00554635469F, -0.0405604541F, + -0.00694804033F, -0.00138826785F, 0.0215149373F, -0.00425733393F, + 0.0488502085F, -0.0227380674F, -0.00230037607F, -0.000867218419F, + -0.00251623476F, -0.000201593226F, -0.000263017981F, 0.00748453336F, + 0.0035975303F, -6.35836332E-5F, -0.0170227606F, -0.0820010379F, + 0.00804928F, -0.036916595F, -2.63193178E-5F, 8.49580101E-5F, + -0.000244568451F, 0.189676046F, 0.0564136542F, 0.00913860742F, + -0.00487486972F, 0.00484882295F, -0.000338730228F, 0.0517137684F, + 0.0519011207F, 0.00887640473F, 0.000109827401F, 0.0448451F, + -0.0259796F, 0.0048389812F, -0.0230743F, 0.00432427879F, + 0.00113520084F, -0.000743415556F, 0.0153859342F, 0.0241894331F, + -0.000358915771F, 0.00252561946F, -0.00896606501F, -0.00770540861F, + 0.00229427195F, 0.011491783F, 0.00300636562F, -0.0291112829F, + 0.00471667759F, -0.00740354229F, 0.0411397F, -0.0330031589F, + -0.0059613036F, 1.72313557E-5F, 0.00284899236F, 0.0184357874F, + 0.0169975106F, 0.109620161F, 0.00105592515F, -0.00329352636F, + -0.0146436421F, -0.0144183673F, -0.0031701324F, -1.30080116E-5F, + -0.0228346828F, -0.00584540796F, 0.0266078655F, -0.00044504879F, + 0.000275519735F, 0.11350549F, 0.0204152148F, 0.00258243037F, + -0.000122261423F, 0.00327991019F, -0.0295557361F, -0.0133186551F, + -0.00066202489F, -0.000158070092F, 0.00473620417F, -0.000727552513F, + -0.000464703422F, -0.0194806047F, -0.0215001609F, -0.0269179214F, + -0.000224380245F, -0.00116730283F, -0.000440106814F, -0.00326653593F, + 0.000401564175F, -0.0278664511F, -0.0087978933F, -0.0241048299F, + 0.000186768302F, 0.0084572F, -0.0335189775F, 0.000416661642F, + -0.0064952F, 0.00698973099F, 0.0116506042F, 0.0141201206F, + 0.00648775324F, -0.000332226948F, 0.0266502835F, -0.000135489725F, + -0.00334566436F, -0.000807269593F, 0.00732720317F, 0.00145688164F, + -0.00236210716F, 0.0048403223F, -0.000290717348F, -0.0233775117F, + -0.00019490438F, -0.0424013287F, 0.00365513284F, 0.0126142958F, + -0.00558633683F, -0.0173754077F, 0.0127880126F, 2.58652544E-5F, + 0.00101930974F, -0.00872594491F, -0.000443125959F, 0.000208297613F, + 0.0521670207F, -0.00767835928F, 0.000713706F, 0.0232192744F, + -0.000774113054F, -0.00168361026F, 0.00576139847F, 0.000389983412F, + 0.0114722345F, 0.0447932705F, -0.0347633921F, 0.0310543682F, + -0.00865063537F, -0.0013355118F, 0.000158982715F, -0.000993498834F, + -0.0140050659F, 0.00645087333F, -5.46284828E-5F, -0.000213275664F, + -0.000119558143F, -0.00822392199F, -0.000174074899F, -0.0263162814F, + 0.000818970788F, -0.000422729F, 0.0193791222F, 0.00580308307F, + -0.0531178638F, -0.00363211543F, -0.000171878302F, 0.00856660213F, + 0.00578257721F, 0.00483022397F, -0.0137656042F, 0.000900739338F, + -0.0150311692F, 0.000402260077F, -0.00786450319F, 0.000663833111F, + 0.000345996901F, -0.000137612587F, 0.0125843287F, 0.027283892F, + -0.0083249F, 0.0381750204F, 0.000426513492F, 0.0155400168F, + 0.0242837425F, -0.00019688037F, 0.0761946738F, 0.020138206F, + 0.0177373402F, -0.000109931229F, -0.000126576138F, -6.08700284E-5F, + -0.0228301827F, 0.00891434122F, 0.000273625745F, -0.00669473736F, + -0.00334317866F, -0.00811995473F, 0.00111437973F, -0.000526504591F, + 0.000158716604F, 0.000110757639F, -0.000849792F, -0.000437943847F, + -0.000482622476F, -0.00029238229F, 0.000364155305F, -0.0716130808F, + -0.0160468016F, 0.0262522846F, 0.00984505191F, -0.023198314F, + 0.0133708119F, -0.0426772758F, 0.00974244159F, 0.0130398627F, + -0.0068434421F, -0.005546459F, 0.00033457F, 0.00529577583F, + -0.000136300703F, -0.00652100146F, 0.0076515507F, 0.00853052642F}; + static const float A[1200] = { + -0.0185063314F, -0.0149371522F, 0.00959109422F, 0.00649663433F, + -0.076242514F, 0.0792815089F, -0.00803655572F, 0.0211292263F, + 0.0149814673F, -0.00852664094F, -0.0368006043F, -0.0417494364F, + -0.000242701979F, -3.81596656E-5F, 0.000238602632F, -0.0913784653F, + 0.00527320337F, 0.0686500892F, 0.00033601516F, -0.000225435142F, + -7.67770325E-5F, 0.0576552078F, -0.0060804449F, -0.058956407F, + -0.524561286F, 0.107117243F, 0.287897795F, 0.065357089F, + -0.0416149646F, -0.0414575748F, 0.0688584223F, 0.0625037327F, + 0.0756011382F, 0.116802678F, -0.0304196961F, -0.0726257041F, + 0.00179890066F, -0.0399549119F, 0.0275109652F, -0.226995915F, + 0.128213257F, 0.100191109F, -0.245603427F, -0.0887358487F, + 0.371579915F, 0.160462F, -0.0196233019F, -0.0947477445F, + -0.118664794F, -0.230598763F, 0.326343805F, -0.000300469F, + 0.00103828579F, 0.000319280865F, -0.0485580899F, -0.024990065F, + -0.024126336F, -0.0726294F, -0.178107172F, 0.20375748F, + 0.0763386339F, 0.0675410554F, 0.0381890722F, -0.0758776218F, + -0.0404417962F, -0.0425950959F, 0.287152141F, -0.163394392F, + -0.0572818108F, -0.136681467F, -0.0744578093F, 0.0243694801F, + -0.0381104909F, 0.0180003103F, 0.0299364571F, -0.0390720814F, + -0.0334786363F, 0.0410517417F, 0.0686472207F, 0.033361014F, + 0.0475490913F, 0.156129897F, -0.102854744F, -0.108010955F, + 0.111754365F, 0.0815763772F, 0.0848265216F, 0.137777373F, + -0.054879535F, -0.114213139F, -0.00011136711F, -0.00037642906F, + 0.000499779417F, -0.263773948F, 0.0872296F, 0.100739531F, + -0.0437816679F, -0.0792673677F, 0.134304583F, -0.205342695F, + 0.0285605919F, 0.113808773F, -0.138413221F, -0.0557854362F, + 0.111569241F, -0.0331688747F, -0.0167518035F, -0.0201598573F, + -0.000160955911F, -6.61616359E-5F, 0.000126534695F, 0.000446660473F, + -0.000652738789F, 0.000549886434F, 0.156085387F, -0.114830405F, + -0.0523751602F, -0.0295594577F, -0.0298929457F, 0.00908883847F, + 0.161098942F, 0.311587363F, -0.486503035F, 0.0760901F, + 0.0101279598F, -0.051852826F, 0.0448114388F, 0.0231300127F, + -0.0457665808F, -0.0104811005F, 0.0267677493F, 0.0189444646F, + 0.585180461F, 0.276008636F, -1.04097104F, -0.504882336F, + 0.170029491F, 0.259462684F, -0.0910549909F, 0.047388941F, + 0.0450361818F, -0.45954749F, -1.11887503F, 1.77747846F, + -0.0536975227F, -0.0799393877F, 0.108119488F, -0.318017691F, + -0.821926296F, 1.27830541F, -0.0104194116F, 0.00341624022F, + -0.00301313912F, -0.0271209199F, 0.0774903223F, -0.114261016F, + 0.00122787966F, -0.000620592269F, -0.000325512374F, -0.130317733F, + -0.131210327F, 0.214959085F, -0.018251216F, -0.0070883357F, + 0.000715656F, -0.0880954787F, -0.0318556949F, -0.0179349314F, + -0.0365022905F, -0.0190397501F, -0.0023315635F, 0.0337614939F, + -0.0109152868F, -0.00613890169F, -0.0186525509F, 0.0634597F, + 0.0433536135F, 0.000113212052F, -0.000155173315F, -0.000111268128F, + 0.0865241662F, 0.256456673F, -0.360332131F, -0.0888013F, + 0.000687508495F, 0.051150769F, -0.0620672032F, -0.0666265786F, + -0.0617182925F, 0.0626490712F, -0.0229375F, -0.118592374F, + -0.0627148896F, -0.00885166507F, 0.0614186563F, -0.697208643F, + -0.246962905F, 0.955388546F, -0.0371632464F, 0.0744449869F, + 0.0243972801F, -0.295881093F, 0.106445134F, 0.111857936F, + 0.0406589F, 0.0135262F, 0.0113188177F, 0.147169456F, + -0.0393066816F, -0.0703343749F, 0.0502557047F, 0.161579862F, + -0.127201393F, 0.000110735025F, 0.00030644497F, 0.000638392929F, + -0.0221339874F, 0.0106407674F, 0.0430828705F, 0.726077378F, + 0.163677603F, -0.851761222F, -0.301997155F, -0.142213225F, + 0.475195229F, 0.000373549294F, -0.000269256416F, 9.77893724E-5F, + -0.698015809F, -0.0210949425F, 0.623363435F, 0.119296342F, + -0.0715816319F, -0.0303012282F, 0.288744777F, -0.144549057F, + -0.191340357F, 0.0005547576F, -0.000279696775F, -0.000104532584F, + 0.668244F, 0.160479784F, -0.826386154F, -0.0793811828F, + -0.0195725709F, 0.0546709374F, -0.134957716F, -0.051848609F, + 0.18506211F, 0.036296133F, -0.00853568316F, -0.0173192024F, + 0.0265396666F, -0.028663598F, -0.0286674723F, 0.0081309611F, + 0.00864312053F, 0.0164190196F, 0.0897066742F, 0.0274615586F, + -0.0908611417F, 7.57064772E-5F, 3.15758152E-5F, -0.000128685511F, + -0.742372513F, -0.344099909F, 1.23181593F, -0.0944308862F, + -0.0522959083F, 0.0416614451F, -0.410481095F, 0.158586726F, + 0.138022378F, -0.000303550594F, 0.000181153489F, 2.21591436E-5F, + 0.169230536F, -0.130095437F, -0.0811998F, -0.0414792486F, + 0.272995412F, -0.263415277F, -0.00947134756F, 0.049010057F, + -0.120777763F, 0.0407535024F, 0.130767152F, -0.0220115799F, + 0.0472845286F, 0.0157479532F, 0.00490742829F, -0.26726988F, + 0.112761833F, 0.106083736F, -0.128591314F, -0.104335837F, + 0.21809F, -0.158159971F, 0.0338743739F, 0.0453475863F, + -0.0760464817F, -0.071532093F, -0.0713020563F, -0.173715875F, + 0.0269496683F, 0.0869380832F, 0.0165499467F, -0.00375308702F, + -0.0159374308F, -0.537195623F, 0.180226251F, 0.173726946F, + 0.0327937F, -0.0113618504F, -0.0758859068F, 0.0332014896F, + 0.0115256133F, -0.0154552488F, 0.118279718F, 0.0462243073F, + -0.00394416647F, -0.407246858F, 0.0836311355F, 0.369418085F, + -0.033278212F, 0.0319151282F, 0.0964911878F, -0.00442330586F, + 0.000279037078F, -0.00175968779F, -0.002947F, -0.00441588275F, + 0.0180991702F, 0.0763534606F, 0.0288810395F, -0.026601404F, + 0.0851891115F, -0.0459488928F, -0.057986889F, -0.436191797F, + -0.475663453F, 1.17012966F, 0.0856711417F, -0.0540861338F, + -0.0882113278F, -1.07159853F, 1.3765502F, -0.557946801F, + -0.11464975F, -0.0146697126F, 0.0025291231F, -0.379162371F, + -0.191405594F, 0.526586771F, 0.000421737612F, -0.000615271856F, + 0.000322867592F, 0.000244625466F, 0.000492207415F, -0.000854268F, + 0.0236168168F, 0.0560960434F, -0.0568692312F, 0.0261652134F, + -0.000359477126F, 0.122190945F, 0.0590622686F, -0.0175931342F, + -0.084912695F, 0.00441759545F, 0.0269106533F, 0.0129899364F, + -0.000276617F, 4.43732715E-5F, -0.000142517179F, 0.000740273565F, + 0.000751052226F, 0.000974055554F, 0.109137371F, -0.0671208203F, + -0.0804445744F, 0.0153503F, 0.00177686347F, 0.00918270368F, + -0.215100706F, 0.126886621F, 0.125731409F, 0.133033484F, + -0.0634788871F, -0.0610607229F, 0.023158364F, 0.0601265505F, + -0.019309992F, -0.0345919654F, 0.000833126251F, 0.0265957285F, + -0.783064246F, -0.247396559F, 0.996139944F, -0.00198913203F, + -0.00165932928F, -0.00221476774F, 0.209089234F, -0.235965937F, + 0.0875831321F, 0.0381040275F, -0.00971471F, 0.0179186985F, + 0.020586F, -0.0417273231F, -0.103930086F, 0.445219308F, + -0.178501323F, -0.234423235F, 0.435418725F, -0.0439696386F, + -0.256293327F, -0.199610472F, 0.0850599557F, 0.0678680688F, + -0.584433317F, 0.163783014F, 0.125636145F, -0.024155695F, + -0.0422195382F, 0.0868774876F, -0.084360607F, 0.00719788065F, + 0.000286525901F, 0.410103947F, -0.22317639F, -0.23959817F, + -0.0444748066F, -0.000295772625F, 0.0459589586F, 0.336604297F, + 0.112937838F, -0.305065483F, -0.422415912F, -0.133943811F, + 0.39812392F, 0.0977553353F, -0.138871461F, -0.00881784782F, + 0.025233686F, -0.0582508296F, -0.0735794529F, -0.0323073231F, + -0.0202117F, 0.0321153328F, -0.0362121798F, -0.201739445F, + 0.257355124F, 0.00012426688F, 5.80598789E-5F, -0.000176905131F, + 0.273584545F, -0.0222843178F, -0.152743697F, 0.0147664016F, + 0.0411803648F, 0.0693415329F, 0.0128369611F, 0.0566191636F, + -0.0765666664F, -0.790771365F, -0.28117F, 1.18641543F, + 0.00102483819F, -0.000335995108F, -0.000722596538F, -0.00195459719F, + 0.0313732475F, 0.047658585F, -0.0077119912F, -0.00777185848F, + -0.00633896422F, 0.57221967F, 0.388236851F, -1.19473875F, + 0.0488040969F, -0.0463717878F, -0.0362633765F, 0.000459317816F, + 0.000272250734F, 0.0007665148F, 0.00018143245F, -0.000107768996F, + 1.76696321E-5F, -0.000363005674F, 0.000440601783F, -0.000226537581F, + -0.235064059F, 0.125558734F, 0.08954034F, -0.0184527356F, + 0.00293028983F, 0.0223360639F, -0.54418093F, -0.404378444F, + 1.00959885F, 0.212576345F, -0.137023956F, 0.0148915313F, + 0.142201334F, -0.0684925094F, -0.0678593889F, -0.204713985F, + 0.00454470655F, 0.119008847F, 0.0767824277F, -0.0716513693F, + -0.0787513703F, 0.116506107F, 0.360355765F, -0.465648621F, + 0.0318739079F, -0.014598689F, -0.0583333224F, -0.119416155F, + -0.00743200025F, 0.0435269885F, 0.0190842748F, -0.00661435165F, + 0.0100238696F, 0.166893512F, -0.277739674F, 0.169495687F, + 0.816271722F, 0.322908431F, -1.14659441F, -0.0878818333F, + 0.0533098392F, 0.128648236F, -0.0423653759F, -0.0276637096F, + 0.0590458438F, -0.000248414639F, 0.0432782061F, 0.0630733073F, + -0.0322865061F, -0.0521850623F, 0.0857822224F, 0.0451632626F, + -0.0162474103F, -0.0146965748F, -0.037211556F, 0.0181242153F, + -0.0160861555F, -0.0484956279F, -0.00440467428F, 0.0110566923F, + -0.0565741025F, 0.0355815254F, 0.0602971539F, -0.0346252881F, + 0.147159785F, -0.135528818F, 0.038763091F, 0.0709861442F, + 0.0486921445F, -0.0383530892F, 0.0192163754F, 0.0376171321F, + 0.0613788553F, -0.0599686652F, -0.0439339802F, 0.228982896F, + -0.0175459515F, -0.129245698F, 0.403784603F, -0.187048137F, + -0.0624138974F, 0.0419738516F, -0.0931839645F, -0.12209931F, + -0.148892701F, -0.0327321F, 0.171641439F, 0.0430359058F, + 0.0854147226F, -0.109898254F, -0.417430699F, 0.0479255468F, + 0.016689973F, -0.0216069315F, -0.014878368F, -0.0215174332F, + -0.237952963F, 0.008389147F, 0.248903587F, 0.611206651F, + 0.671706736F, -1.30813873F, -0.00174554344F, 0.0010640343F, + 0.000142838675F, -0.311791271F, 0.0194967873F, 0.359942168F, + -0.128081158F, -0.261490375F, 0.381476551F, -4.86919089E-5F, + -0.000201605653F, 0.000196513152F, 0.0588798523F, 0.0338418782F, + -0.0223606937F, 0.0812725797F, -0.00958260708F, -0.00657183817F, + -0.0850540251F, 0.0454826877F, 0.00527690165F, 0.0214367788F, + 0.103111461F, 0.100884445F, -0.000108704167F, 0.000209772115F, + -0.000228089819F, 3.61512648E-5F, -0.000461667107F, 0.000404061866F, + -0.204728574F, 1.19009578F, -1.18698204F, 0.111308232F, + -0.0422458686F, -0.00206379173F, -0.0623704866F, 0.044391159F, + 0.0573304854F, 0.101131953F, -0.027813198F, -0.058901757F, + -0.647892892F, 0.264845222F, 0.182288527F, -0.0502553359F, + 0.0113283126F, 0.0422547236F, 0.705478907F, 0.331881911F, + -1.21276009F, -0.0735484511F, 0.0735206529F, 0.0857536867F, + -0.187923804F, 0.0875167698F, 0.152866647F, 0.150190949F, + 0.264171481F, -0.30657959F, 0.00188208802F, -0.00139914558F, + 0.000144077538F, 0.113094389F, -0.00261216261F, -0.025781069F, + 0.0305141974F, 0.0673030391F, -0.0179598443F, -0.734919548F, + 1.03924072F, -0.482397616F, 0.0260498915F, 0.0855019316F, + -0.10277652F, 0.278559893F, 0.0681780651F, -0.166207865F, + 0.121414557F, -0.0179571491F, -0.075797461F, 0.571920156F, + 0.278841645F, -1.08576035F, -0.189660937F, 0.222042963F, + -0.03184608F, 0.0142237786F, 0.0473338328F, 0.056984216F, + 0.603169322F, 0.365318596F, -1.04289389F, 0.0176378284F, + 0.00273562851F, -0.000291650416F, 0.0263348222F, 0.0433731601F, + 0.0569455288F, 0.0144555494F, -0.0371674225F, -0.0597714F, + 0.115731552F, 0.0879441649F, -0.155257508F, -0.0618656911F, + -0.0337029211F, -0.0175396465F, -0.32976687F, 0.163599178F, + 0.223501861F, -0.088777937F, 0.013149688F, 0.0384311043F, + -0.0398391932F, -0.0591403805F, -0.0787535235F, -0.0249722619F, + -0.282332361F, 0.260487497F, 0.0938145369F, -0.0433192067F, + -0.0793823898F, -0.0597757585F, 0.0376830287F, 0.0862968564F, + 0.284054786F, -0.160854697F, -0.138043508F, -0.00117521232F, + 0.00046175014F, 0.000210775121F, -0.24404341F, 0.0750361606F, + 0.0983055755F, 0.0550197661F, -0.0461952575F, -0.0795339495F, + -0.0581334718F, 0.0413992107F, -0.00994035136F, 0.0162769705F, + -0.0546957329F, -0.0827825889F, -0.503438592F, 0.222842455F, + 0.229477331F, -0.069400534F, -0.0476446114F, -0.0481714159F, + -0.2167961F, 0.049257271F, 0.0957080945F, 0.0403366275F, + 0.0226387978F, -0.0771635771F, 0.0166972429F, -0.00938277319F, + -0.012227593F, -0.000164745274F, 5.44228933E-5F, -9.67087E-6F, + 0.040314544F, 0.0692793429F, -0.0669015422F, -0.0388383716F, + 0.0556890182F, 0.0743200257F, 0.0514866039F, -0.0928579F, + -0.156887814F, 0.000582668814F, -0.000392655085F, -0.000153240981F, + -0.673658192F, -0.318695515F, 1.01219606F, 0.104245745F, + -0.0163887423F, -0.0986753106F, -0.0965564623F, 0.0271260533F, + 0.0812733695F, 0.168985337F, 0.0384676717F, -0.151781559F, + -0.704460561F, -0.355701506F, 1.22724175F, 0.210338891F, + -0.010440357F, -0.0535013899F, -0.18741332F, 0.0973858535F, + 0.0956284478F, -0.0268621705F, 0.037899591F, -0.00102181989F, + -0.000217149951F, 0.000149656436F, 7.66640296E-5F, 0.0271109454F, + 0.0142492028F, 0.00102584064F, 0.0320955887F, -0.0266867038F, + -0.0646454543F, 0.036111258F, 0.00408272864F, 0.00391116366F, + 0.717572749F, 0.320826054F, -1.23400331F, -0.0784121454F, + 0.0354334153F, 0.0700521693F, 0.0366209298F, -0.000685016101F, + 0.0111233369F, 0.0647566691F, 0.00286021177F, -0.00347586931F, + 0.000371168659F, 1.23869704E-5F, -0.000307855487F, 0.0300111771F, + 0.00374821946F, 0.0130192135F, 0.163204789F, 0.0218390059F, + -0.193344012F, 0.410065F, -0.166317627F, -0.232670605F, + 0.00129024195F, -0.00105626893F, 9.6931908E-5F, 0.0125242984F, + 0.0106748138F, -0.0580485202F, 0.0715380833F, 0.0386607423F, + 0.0506493822F, 0.0485222451F, -0.0729724F, 0.0210845303F, + 8.07656179E-5F, -0.000215206179F, 0.000229169731F, 0.0795771182F, + 0.0344266519F, -0.0211059861F, -0.0131076379F, 0.0457328F, + -0.0566913933F, -0.84305644F, -0.36764431F, 1.22375178F, + 0.0925349072F, -0.0913005248F, -0.0699738115F, 0.100971289F, + -0.101623885F, -0.0257493909F, 0.0308234356F, 0.113807358F, + -0.131112844F, 0.342144221F, -0.0272408444F, -0.191934466F, + -0.0177174732F, -0.0107028056F, -0.0143437479F, -0.0107023222F, + -0.00180856523F, -0.0050410293F, 0.0152977016F, -0.0482494384F, + 0.0263554472F, -0.715217769F, -0.379558414F, 1.25080645F, + -0.066454187F, -0.035986241F, -0.00571531523F, 0.675622165F, + 0.0209170114F, -0.515284598F, 0.0645422265F, 0.180363178F, + -0.224382639F, 0.438318F, -0.12083035F, -0.185375318F, + 0.0122521622F, 0.00708936341F, -0.022736406F, 0.00746905524F, + -0.0244964752F, 0.0174196567F, 0.010602477F, 0.023571698F, + -0.00836411212F, -0.246988356F, 0.0909586176F, 0.0560376F, + -0.50691855F, -0.381806225F, 1.07133389F, 0.290391058F, + -0.052541405F, -0.203004032F, -0.169116259F, -0.147849023F, + 0.319286078F, 0.0883288682F, -0.0145479441F, -0.0541032627F, + -0.00567818619F, -0.0162139665F, 0.0521662049F, -0.0459707975F, + 0.18963775F, -0.132470369F, -0.115600713F, 0.0386183485F, + -0.0495529249F, -0.000463845732F, 7.07569197E-5F, 0.000119566961F, + 0.0275602639F, 0.0179720633F, -0.0505289845F, -0.0420723483F, + -0.0263366718F, -0.0209046528F, 0.476318538F, 0.269101769F, + -0.92183876F, 0.000209588412F, 0.000352240982F, -0.000551821722F, + 0.0430607423F, 0.00390610774F, -0.00705087045F, 0.0302441269F, + 0.000544078881F, -0.0259381272F, -0.396609426F, -0.392353714F, + 0.847975075F, 0.0522582233F, 0.00534800487F, -0.0482308641F, + -0.000172466622F, 0.000430793676F, -0.000244421914F, -0.0397230238F, + -0.00893396F, 0.0382047929F, 0.0749669299F, 0.0573952869F, + 0.0695048273F, 0.00022128511F, -4.26229599E-5F, -7.32342742E-5F, + 0.0698986873F, 0.0655535758F, 0.0846461132F, 0.0474063419F, + -0.114313118F, 0.0757681727F, -0.0911709294F, -0.0202360563F, + 0.0297349989F, -0.0257139374F, -0.0361089706F, 0.0179765578F, + 0.0728144571F, 0.0939310491F, 0.114781089F, -0.0732131451F, + -0.0626562387F, 0.0485F, -0.853588164F, -0.410196275F, + 1.37791836F, 0.686111569F, 0.0440415405F, -0.72017F, + -0.0562374182F, -0.0704142377F, -0.0575962216F, -0.30310604F, + 0.158152819F, 0.16432929F, 0.559832156F, -0.224236578F, + -0.225601092F, -0.68752557F, -0.372567177F, 1.18023872F, + -0.520288467F, -0.618491709F, 1.4398421F, 0.0170276631F, + -0.0223206859F, -0.0371255316F, 0.391462624F, 1.10421729F, + -1.56560814F, -0.246352255F, 0.0327998474F, 0.0919773877F, + -0.103988022F, -0.053406544F, 0.0711082816F, -0.469975293F, + -1.07484F, 1.79736114F, 0.0151338894F, 0.0253107082F, + 0.0723376945F, 0.0137910917F, 0.0186722968F, -0.0475886837F, + -0.250046313F, 0.0876212F, 0.115161665F, 0.137457311F, + 0.0777565613F, 0.0728609636F, 0.341412276F, 0.467387259F, + -0.953884363F, 0.0119764861F, 0.00321631902F, -0.0422189683F, + 0.295392901F, -0.190665796F, -0.0620150864F, -0.0366062298F, + -0.0478814766F, -0.0460813381F, 0.0152617525F, -0.0352801792F, + 0.00479182322F, 0.0263294335F, -0.0417780653F, -0.0384896956F, + -0.0626572818F, -0.0505435355F, -0.0580558442F, -0.0360956639F, + -0.0170971137F, -0.0275967587F, 0.0331380963F, -0.0225325134F, + -0.0585300215F, -1.05620515F, 1.46275258F, -0.692140877F, + 0.0075182179F, 0.00791792758F, 0.00844302215F, -0.00139700982F, + -0.000396846328F, -0.000189000333F, 0.0173354466F, 0.0211281944F, + -0.0426892F, 0.0385014229F, -0.0177992713F, -0.0592359938F, + -0.115884006F, -0.0606935844F, -0.0710758F, -0.105612881F, + 0.039330516F, 0.130406916F, -0.644341826F, -0.0612633415F, + 0.711913F, -0.00150478922F, 0.00602046261F, -0.11093422F, + -0.176470473F, 0.0838371F, 0.0627869889F, -0.0189049393F, + 0.0486989841F, 0.0837780088F, 0.129290417F, -0.0488707162F, + -0.036008466F, 0.0828831F, 0.0281706173F, -0.0185911376F, + 0.0429373793F, 0.00567406323F, -0.0543261506F, 0.000136407732F, + 4.44588586E-5F, -0.000176853486F, 0.000535788829F, -0.000367617118F, + 5.60117915E-5F, -0.000253974576F, 0.000253256876F, -0.000100787809F, + 0.241652131F, -0.140328541F, -0.133708298F, 0.180344105F, + 0.308815122F, -0.413556725F, -0.000305484835F, -5.12668812E-5F, + 0.000237205182F, 0.0380960517F, 0.00541108754F, -0.0340177119F, + -0.0208717156F, -0.00342592061F, 0.0084836632F, -0.0663045198F, + -0.0305126291F, 0.112125F, -0.445950031F, -0.111620493F, + 0.58953011F, -0.000212072686F, 0.0005435606F, -0.000485271128F, + 0.727540731F, 0.313749492F, -1.22549856F, 0.000466902362F, + -0.000679903664F, 0.000373286894F, -0.00059999F, 0.000305893365F, + -1.71834472E-5F, -0.00347050466F, -0.00238134246F, 0.00429680943F, + 0.561529279F, 0.205282032F, -0.830006957F, -0.0115728024F, + -0.0235563926F, -0.000744821737F, -0.000951747177F, -3.06442416E-5F, + 0.000840021879F, -0.0181245934F, -0.0320719257F, -0.0576784723F, + -0.118108042F, -0.00142924837F, 0.0429231785F, -0.0125907455F, + -0.0610669553F, 0.127179638F, -0.0460905656F, -0.0191006754F, + -0.0152855292F, 0.0201769304F, 0.0313777886F, -0.0997237414F, + -0.358287543F, 0.174827367F, 0.224974856F, -0.0630359277F, + -0.00190154067F, 0.0368576795F, 0.00583004626F, -0.02432926F, + -0.0769463554F, 0.0207987726F, 0.0208918341F, 0.03413333F, + -0.0971897691F, -0.045064941F, -0.0497033782F, -0.0967248F, + 0.0838195756F, 0.0733165592F, 0.00578897214F, 0.000160839976F, + -0.000296271843F, -0.0318355076F, 0.0769134164F, 0.068842113F, + 0.613938034F, 0.315026581F, -1.05547535F, 0.0197591223F, + -0.235806271F, 0.201305151F, -0.182288915F, -0.00370216835F, + 0.163586944F, 0.0587238297F, 0.0876326784F, 0.0374986157F}; + static const float gateBias[1200] = { + -0.0790321752F, 0.0141005274F, -0.168436319F, 0.42600888F, + -1.12509298F, -0.202866241F, -1.14119339F, 0.614409745F, + 0.554537177F, -0.00118859462F, -0.025481157F, 0.0731275529F, + 0.089318715F, 0.240239039F, 0.387902975F, 0.203273118F, + 0.423479438F, -0.287737697F, 0.282625914F, 0.256284922F, + 0.593569219F, 0.368146181F, 0.0846514553F, 0.0757937953F, + 0.0450351909F, 0.0590400845F, -0.0360485725F, 0.0438035242F, + 0.265440136F, 0.11768014F, -0.167984411F, 0.608572483F, + 0.20700106F, 0.343822896F, 0.132332936F, -0.0867883712F, + -0.501745403F, -0.641356349F, -0.079237543F, 0.0619565956F, + 0.471312553F, 0.0809629F, 0.0432426967F, -0.0582616925F, + 0.25622F, -0.0210454315F, 0.41972959F, 0.98646F, + 0.149820119F, 0.231268063F, -0.137458131F, 0.927105248F, + -0.552180529F, 0.252653331F, -0.234470218F, 0.0199261978F, + -0.123127334F, -0.0605359934F, 0.044449538F, -0.207410291F, + 0.807678223F, 0.060520798F, 0.0251374412F, -0.217038423F, + 0.0672033057F, 1.09128702F, -0.0162570737F, 0.18959108F, + -0.0274123885F, -0.17459254F, 0.310041904F, -0.123127118F, + -0.360046029F, 1.03480518F, 0.300535F, -0.887191534F, + 1.21458721F, 0.0322799683F, 0.0423767082F, -0.653758764F, + 1.27191389F, 0.0541249588F, -0.315187484F, -0.206606403F, + 0.0538008846F, -0.0582740121F, 0.0980005786F, -0.287911594F, + 0.611212075F, 0.163904727F, -0.000685226F, -0.551142514F, + 0.0423555449F, 0.624259889F, 0.108532041F, 0.666205585F, + 0.139417261F, 0.174536929F, 0.292212F, 0.144097105F, + -0.0585080571F, 0.115652993F, -0.148829892F, 0.458797097F, + 0.0247824676F, 0.00786283705F, 0.184117272F, 0.254439592F, + 0.041556567F, -0.28951925F, 0.0275634304F, 0.0528764911F, + 0.201193184F, 0.28944388F, -0.0719915628F, -0.292362154F, + 0.213642985F, 0.531683803F, -1.21947765F, -0.873364925F, + 0.0227244068F, 0.780486643F, 0.0651040673F, -0.127787054F, + -0.443174481F, -0.273549706F, 0.195082143F, -0.0675825477F, + -0.159140661F, -0.172833189F, 0.799283862F, 0.176939428F, + 0.907233715F, -0.301915675F, 0.113045186F, -0.0621651337F, + -0.236542046F, 0.296142399F, 0.615756869F, 0.133467883F, + 0.207525149F, 0.117558591F, -0.0110919531F, 0.426760495F, + 0.0190624204F, 0.29264459F, 0.357200086F, 0.344687223F, + 0.323282033F, -0.00492559699F, 0.281639457F, -0.23315005F, + 0.240047127F, -0.250667483F, 0.0068882457F, 1.42002773F, + -0.260693282F, 0.443476886F, 0.236076891F, 0.273177058F, + 0.0220468231F, -0.104886211F, -0.43490544F, -0.481044054F, + 0.320485026F, -0.0260774083F, 0.278478831F, 0.0499890447F, + 0.0524972714F, 0.189473912F, -0.00536097F, 0.506318867F, + -0.18701452F, 0.327275217F, -0.096524775F, 0.181827068F, + 0.883208513F, 0.179616362F, 0.148421556F, 0.572085381F, + 0.269627035F, -0.0410539247F, 0.025895793F, 0.542962372F, + 0.0446818732F, 0.213866308F, -0.117382325F, 0.110360608F, + -0.0342725553F, 0.181487009F, 0.1902031F, 0.364336282F, + 0.23796618F, 0.169547185F, 0.410188884F, -0.128759235F, + 0.27187711F, -0.0673881322F, -0.745250106F, 0.479578435F, + 0.265242726F, -0.668425143F, 0.03577701F, 0.0470794216F, + 0.106663905F, 0.193006918F, -1.00490487F, -0.756424069F, + 0.0196593162F, 0.00369984098F, 0.0298457574F, 0.0307789035F, + 0.239761755F, 0.816684544F, 0.571181178F, -0.129732236F, + 0.131058231F, 0.593863308F, -0.749651194F, 0.0512646809F, + 0.102341473F, 0.313887447F, 0.106204689F, 0.185676977F, + 0.00627188291F, 0.965909898F, -0.191527039F, 0.201669902F, + 0.464972973F, -0.0721799F, 0.301421672F, 0.157233551F, + 0.38152048F, 0.113625847F, 0.383909732F, 0.186366409F, + -0.1181679F, 0.536965251F, 0.0159919336F, 0.104253471F, + 0.150566086F, -0.539137244F, 0.196617365F, 0.0410451144F, + 0.0678505525F, -0.0123571688F, 0.237185046F, 0.533912361F, + 0.215003639F, 0.263886422F, -0.0776872262F, -0.212334603F, + 0.00919762347F, 0.224880889F, 0.430611134F, -0.478675336F, + 0.324978173F, -0.0377874821F, 0.129552335F, 0.0887583F, + 0.476260036F, 0.394958436F, -0.169663414F, 0.0538865887F, + -0.699017525F, 0.0162888747F, -0.00726912636F, -0.0247627869F, + 0.517477632F, 0.162742212F, 0.0872455239F, 0.0337559208F, + -0.843918264F, -0.117661439F, 0.154303789F, 0.20260407F, + -0.335387F, 0.155367181F, -0.00546656549F, 0.0303015765F, + -1.01600599F, -0.233078092F, 0.0712637305F, 0.97761184F, + 0.0239913557F, 0.0438982509F, 0.307702303F, 0.101171777F, + 0.121292956F, -0.180446208F, -0.0305901449F, 0.391886979F, + -0.076988481F, 1.0480305F, 0.468116F, 0.113771506F, + -0.0411241539F, -0.112057067F, -0.143320605F, 0.182067946F, + 0.245718613F, 0.0300512668F, 0.351083666F, 0.431001F, + -0.171561241F, 0.14660953F, 0.105844803F, -0.380426F, + 0.408160567F, 0.0572711229F, 0.383335799F, -1.04496217F, + -0.0723926798F, 1.09851718F, 0.448274285F, 0.0814931616F, + -0.638614297F, -0.0334848873F, -0.100831456F, -0.929008603F, + 0.0316732079F, 0.0701776296F, 0.0787612721F, 0.0272244737F, + 1.57695043F, 0.0954825357F, 0.450734764F, 0.755732596F, + -0.122160353F, 0.317746639F, 0.47026062F, 0.46159181F, + 0.870429397F, 0.198976234F, 1.09287667F, 0.0687557608F, + -0.143724337F, 0.939091206F, 0.244067773F, 0.12680535F, + 0.19328472F, 0.614573777F, 0.2628F, 0.0826464593F, + 0.170520276F, 0.121072993F, -0.122422703F, 0.758471847F, + -0.00324818282F, -0.0144281397F, 0.233541638F, 0.667597055F, + -0.298393726F, -0.294388026F, 0.647620618F, 0.0876321122F, + 0.261276782F, 0.109275676F, 1.34051156F, 0.136613116F, + 0.0551797F, 0.0516299792F, 0.092758365F, 0.074312523F, + -0.0423643477F, -0.833191276F, -0.726633251F, -0.280544251F, + -0.0454872735F, 0.462711304F, -0.892533302F, 0.0755794272F, + -0.116437323F, 0.0388766192F, 0.761632144F, -1.03178656F, + 0.895898879F, -0.843708813F, -0.580566347F, -0.0448042825F, + 0.402565092F, -0.080034F, -1.35243F, 0.18723543F, + 0.212126791F, 0.172991082F, 0.10638196F, -0.0416163318F, + -0.0177275334F, -0.0629761145F, -0.339087427F, 0.111292377F, + 0.150141731F, 0.2212843F, -0.241489694F, 0.0697369948F, + 0.432065278F, 0.902476668F, 0.45992893F, -0.091967456F, + 0.960106432F, 0.95705086F, 0.906095564F, 0.862216532F, + 0.838277578F, 0.838413179F, 0.841836154F, 0.90588F, + 0.951579332F, 0.928959608F, 0.866790235F, 0.961853147F, + 1.01845801F, 1.16119075F, 0.932738423F, 0.948005855F, + 1.10169208F, 0.885723829F, 0.857056499F, 1.00312078F, + 0.886824727F, 0.932410061F, 0.955854595F, 0.932296634F, + 1.01833761F, 1.04283249F, 0.921210527F, 1.02764297F, + 0.874603093F, 0.981151938F, 0.984685659F, 0.611126304F, + 1.15482044F, 0.825549066F, 0.861283183F, 0.852577F, + 0.995672047F, 0.92314297F, 1.0191257F, 0.90457195F, + 0.949436665F, 0.886380613F, 1.05650854F, 0.895279288F, + 0.93153F, 0.886161625F, 0.747809887F, 1.11702275F, + 0.947779F, 0.902131617F, 0.944754481F, 1.31214964F, + 0.837353408F, 0.941805482F, 0.955858111F, 1.02226329F, + 1.04616916F, 0.988247335F, 0.892672181F, 0.909467518F, + 1.12927473F, 0.951045F, 0.939490795F, 0.894724309F, + 0.988688827F, 0.935397923F, 0.951995075F, 0.914486885F, + 0.900701463F, 0.977878034F, 1.0779953F, 0.816423237F, + 0.882923484F, 0.946516395F, 0.95207274F, 0.816074967F, + 0.974269688F, 1.02908039F, 0.911354661F, 0.897592962F, + 0.791170895F, 0.938192666F, 1.0192275F, 0.838884652F, + 0.821765661F, 0.921384513F, 1.078933F, 0.932317436F, + 0.812781096F, 0.956124067F, 1.09867978F, 0.993680894F, + 0.88465637F, 1.14997542F, 1.00909936F, 1.11557245F, + 1.07398605F, 1.0068115F, 0.888974F, 0.943429828F, + 0.807707F, 1.02125907F, 0.876318932F, 1.23647618F, + 1.01773083F, 0.902329266F, 0.904016614F, 1.17850256F, + 0.997405946F, 0.90304F, 0.988996148F, 0.914558589F, + 0.934586883F, 1.0528729F, 1.09696317F, 0.936310649F, + 0.987189531F, 0.870045F, 0.806435823F, 0.76756984F, + 1.07333F, 0.959156394F, 0.961848497F, 0.958821F, + 0.874361575F, 0.825384F, 0.863994539F, 1.03957558F, + 1.00066757F, 0.915043116F, 1.34348786F, 0.863556087F, + 0.896915F, 0.887526035F, 0.851264894F, 0.891592205F, + 0.89653486F, 1.03889F, 0.792457104F, 0.880553365F, + 1.2232542F, 0.994815528F, 0.937377751F, 1.11965537F, + 0.894897044F, 0.962495446F, 0.952475429F, 0.58386606F, + 0.922640204F, 0.975831389F, 0.941857517F, 0.878302872F, + 0.940841496F, 0.884394348F, 1.04053366F, 1.03731406F, + 0.880948305F, 0.91936481F, 0.904538393F, 0.862465441F, + 0.958227694F, 0.909650862F, 0.885100424F, 0.977844298F, + 0.792992413F, 0.945910573F, 0.957345247F, 0.957394063F, + 0.975794435F, 0.85384357F, 0.861218333F, 1.10162437F, + 0.923621595F, 0.910913348F, 0.790857136F, 1.04447424F, + 1.10293114F, 0.842267F, 1.07985198F, 0.832337081F, + 0.935829401F, 0.851196289F, 0.974302471F, 0.794970095F, + 1.00791264F, 0.9198066F, 0.919773638F, 0.848312438F, + 0.910352F, 1.03683543F, 0.937734485F, 0.822969556F, + 1.00051F, 1.08976102F, 0.952739716F, 0.943589389F, + 0.870387733F, 0.983715236F, 0.825886607F, 0.888743222F, + 0.993087947F, 0.863982856F, 0.886427104F, 0.931790948F, + 0.889108F, 0.932529867F, 0.823124349F, 0.874493718F, + 0.981136F, 1.01564848F, 0.922092617F, 0.96847558F, + 0.875515759F, 0.743196309F, 0.988799036F, 0.790688753F, + 1.18602753F, 1.11198342F, 0.796592236F, 0.941343248F, + 0.946298182F, 0.976827502F, 1.07966626F, 0.934223413F, + 0.928446651F, 0.946527183F, 0.897596717F, 0.802042663F, + 0.873630047F, 0.91239506F, 0.816420317F, 0.788462102F, + 1.12612069F, 0.914227843F, 0.929764628F, 0.916368842F, + 0.973728597F, 1.06681824F, 0.975928366F, 0.955243707F, + 0.859362125F, 0.879903376F, 0.961439133F, 0.946296275F, + 0.939440846F, 0.997548878F, 1.11342943F, 0.890396416F, + 1.01475048F, 1.03219914F, 0.860998809F, 1.00736594F, + 0.918809056F, 0.799307346F, 1.04100585F, 0.862045169F, + 0.97694695F, 0.938678324F, 0.912828505F, 1.10996091F, + 0.895494401F, 0.948866785F, 1.02391601F, 1.04304898F, + 0.900392771F, 0.887809396F, 0.911795676F, 0.883735061F, + 0.818106115F, 0.950095296F, 0.844420612F, 0.951589763F, + 0.837153F, 0.923431933F, 0.96109575F, 0.968134582F, + 0.901893318F, 0.942753553F, 0.902131F, 1.06391358F, + 0.84443748F, 0.915730059F, 0.913780749F, 1.19514847F, + 0.876676142F, 0.903627276F, 0.833706379F, 1.02244067F, + 0.833423316F, 0.99124974F, 0.946102142F, 0.829581738F, + 0.889579713F, 0.984988868F, 1.05351472F, 1.09377897F, + 0.972744703F, 0.982434332F, 0.976970196F, 0.938302517F, + 0.908320069F, 0.859108F, 1.03429747F, 0.711908102F, + 0.888820171F, 1.01242685F, 1.02280891F, 0.956657708F, + 0.927860498F, 0.94312048F, 0.894460857F, 0.87084806F, + 1.10599053F, 0.736487269F, 1.01162398F, 1.08566368F, + 0.805399597F, 0.973915339F, 0.927041888F, 0.814889133F, + 0.975278676F, 0.985330045F, 0.931632459F, 0.965500355F, + 0.787575662F, 0.949271202F, 0.912249506F, 1.0062815F, + 0.781042695F, 0.919925F, 1.34912336F, 0.868786216F, + 0.807931423F, 0.872944534F, 1.19928968F, 1.0907F, + 0.945064723F, 1.04022622F, 0.932594061F, 1.0306921F, + 0.991927266F, 0.88299942F, 1.03824246F, 0.946053922F, + 0.919889271F, 0.92087F, 0.910266817F, 0.716958523F, + 0.898022F, 0.937896967F, 0.809169233F, 0.948136151F, + 0.927504539F, 0.912947118F, 1.12790394F, 0.931124091F, + 0.918827534F, 0.989981115F, 0.971396923F, 1.05399966F, + 0.801212907F, 0.904776156F, 0.896874726F, 0.94449842F, + 1.03472149F, 0.845925093F, 0.899981499F, 0.93438983F, + 1.09838152F, 1.1159848F, 0.82390964F, 0.852247834F, + 0.85578835F, 0.945648372F, 0.90151608F, 0.835381925F, + 0.822595716F, 0.833830357F, 0.890754282F, 0.924410284F, + 0.898759425F, 0.92266947F, 0.8172068F, 0.90121007F, + 0.896629691F, 1.07547271F, 0.838228285F, 0.983668447F, + 0.824096799F, 0.95225656F, 0.949434519F, 0.711838961F, + 0.844419837F, 0.859657466F, 1.01489687F, 0.89432621F, + 0.887916386F, 1.27266765F, 1.05784082F, 0.990758657F, + -0.167772755F, 0.050235074F, -0.182471573F, 0.255905837F, + -1.14730823F, -0.0842738822F, -1.03656602F, 0.123318754F, + 0.339924723F, -0.0026557215F, -0.070375F, -0.0920568332F, + -0.0654447824F, -0.131522834F, 0.260476351F, 0.126228407F, + 0.339513779F, -0.300448F, 0.158196121F, 0.382495522F, + 0.193165556F, 0.806875587F, 0.178576082F, 0.0144095067F, + -0.037641231F, 0.0218072813F, -0.00868367683F, 0.0364467278F, + 0.238487408F, 0.087493211F, -0.161503449F, 0.343386382F, + 0.126014203F, 0.191358849F, 0.176195055F, -0.0542749129F, + -0.54238385F, -0.592496514F, 0.0254813917F, 0.188626423F, + 0.397057682F, -0.00666273F, -0.00556852063F, -0.0171657205F, + 0.223989606F, 0.219359845F, 0.0154556334F, 0.362697124F, + 0.0952301F, 0.740374923F, -0.141456574F, 0.144229382F, + -0.607324183F, 0.286981434F, -0.247633547F, 0.0438861884F, + -0.13466759F, -0.0433421545F, 0.0522859842F, -0.23907198F, + 0.316515237F, -0.0154936984F, -0.0414051376F, -0.27192995F, + 0.0350574441F, 0.510870039F, 0.109756567F, 0.0922761038F, + -0.0134260729F, 0.0174043346F, 0.164631903F, -0.243160501F, + -0.312000573F, 0.605097473F, 0.455679864F, -0.882435322F, + 0.934483886F, -0.00816096086F, -0.0772722214F, -0.674862146F, + 1.06302917F, 0.0447643846F, 0.00883842073F, -0.22373125F, + 0.0165478699F, -0.0734626874F, 0.0711589903F, -0.396961391F, + 0.318187267F, 0.0899260193F, 0.144247219F, -0.629972637F, + -0.025148673F, 0.275706649F, 0.0790922716F, 0.183798552F, + -0.0472177081F, -0.0893307552F, 0.406946838F, 0.257619649F, + -0.0207007807F, 0.305288017F, -0.211484686F, 0.410077691F, + 0.0472648665F, -0.00231603067F, 0.103438996F, 0.189004093F, + 0.0370718911F, -0.341873139F, 0.0161695685F, 0.021563299F, + 0.199952647F, 0.0232190508F, -0.119898282F, 0.424328893F, + 0.0492243022F, 0.498944342F, -1.23189604F, -0.877648532F, + -0.0152666904F, 0.166068301F, 0.0438912846F, -0.147943079F, + -0.476065606F, -0.292126954F, 0.325056404F, -0.168407544F, + 0.115267567F, 0.0397179723F, 0.22261934F, 0.049247805F, + 0.783859909F, -0.251935422F, 0.212176427F, 0.00393313775F, + -0.299771816F, 0.0272866692F, 0.343088835F, 0.164154038F, + 0.087906979F, 0.0126287155F, 0.175418049F, 0.298124939F, + -0.00495501701F, 0.239099145F, 0.366405696F, 0.155251339F, + 0.448239356F, -0.052816458F, 0.217681095F, -0.442730039F, + 0.0837830752F, -0.213978693F, 0.00548931351F, 0.992679298F, + -0.388364226F, 0.111932345F, -0.0757898465F, 0.0973213464F, + 0.0992756486F, -0.208624184F, -0.432575375F, -0.464167267F, + 0.292214692F, -0.0629993156F, 0.001853019F, 0.0242606178F, + 0.311009735F, -0.0235452596F, 0.104749836F, 0.375994235F, + -0.17243439F, 0.298072755F, -0.108441971F, 0.214614198F, + 0.700758398F, 0.0454863869F, 0.0224057715F, 0.0829284117F, + 0.0996522382F, 0.0405012853F, -0.0600756891F, 0.146571219F, + 0.0901494101F, 0.035325937F, -0.118204825F, 0.375635564F, + -0.0814069733F, -0.00332949078F, 0.308853209F, 0.302655548F, + 0.160925552F, 0.121465862F, 1.00559294F, -0.137891531F, + 0.298918128F, 0.669958293F, -0.636432052F, 0.295713603F, + 0.271575153F, -0.759487391F, 0.00763507467F, -0.0135729909F, + 0.0766565874F, 0.603044629F, -1.02650011F, -0.754618883F, + 0.424126506F, -0.174037144F, -0.0565970764F, -0.0607551113F, + 0.190213293F, 0.135043904F, 0.410972089F, -0.221425638F, + 0.146402657F, 0.420819491F, -0.795169413F, 0.00960396696F, + 0.0299989935F, 0.369756758F, 0.112863168F, 0.307549208F, + 0.00269142888F, 0.342275977F, -0.154358774F, 0.0416299403F, + 0.131328806F, -0.0654349551F, 0.0817687437F, 0.0188052822F, + 0.143744573F, 0.0651056617F, 0.0413832739F, 0.125345707F, + -0.137600631F, 0.220464647F, -0.014726745F, 0.0250087F, + 0.265958875F, -0.515117764F, 0.249486431F, 0.0198834818F, + -0.110331178F, -0.17954427F, 0.24717088F, 0.242833853F, + 0.348093867F, 0.133874446F, -0.114583679F, -0.269770443F, + 0.038708698F, 0.0348364376F, 0.177008674F, -0.526227355F, + 0.416508347F, -0.180069461F, 0.084044151F, 0.0836647898F, + 0.160341933F, 0.40371111F, 0.165471241F, -0.0505398698F, + -0.658738792F, 0.0645545721F, -0.0946731716F, -0.0326265432F, + 0.36973983F, 0.294985473F, -0.00370010664F, 0.0246887114F, + -0.838050127F, -0.0516633913F, 0.149742395F, -0.056687396F, + -0.495754272F, -0.0100054611F, -0.0424069F, 0.00323242205F, + -1.02988625F, -0.28956449F, 0.00470431335F, 0.449456394F, + 0.0561158694F, 0.278410912F, 0.21559003F, 0.0871143565F, + 0.0107088769F, -0.27044785F, -0.0373626947F, 0.243187696F, + -0.144917339F, 0.697903275F, 0.199041575F, 0.0571259558F, + -0.0248904899F, -0.0796185434F, -0.179429024F, 1.14135873F, + -0.00845696777F, 0.035143882F, 0.379369944F, 0.100087948F, + -0.186802208F, -0.0167249795F, 0.0877677798F, -0.433974057F, + -0.0216692053F, 0.0153705031F, 0.109474711F, -1.06668437F, + -0.100437112F, 0.237491429F, 0.0619618334F, 0.0467277579F, + -0.629076183F, -0.0784472078F, -0.113414116F, -0.943143189F, + -0.0082419645F, 0.034004733F, 0.0352855213F, -0.0158829484F, + 1.58103681F, -0.0279034413F, 0.2684834F, 0.689715683F, + -0.112793848F, 0.237669602F, 0.7017501F, 0.203925282F, + -0.132763132F, -0.055551976F, 0.619030952F, 0.19201827F, + -0.0371397696F, 0.0821021497F, 0.102402188F, 0.0453967378F, + -0.0895129144F, 0.331370622F, 0.0451294556F, -0.0976474434F, + 0.368125647F, 0.0430431142F, -0.0913531706F, 0.237670392F, + -0.0114337066F, 0.00852338411F, 0.0274815056F, 0.392632097F, + -0.373556346F, -0.286817968F, 0.201574415F, 0.0470800735F, + 0.885477245F, -0.000748385617F, 1.19005048F, 0.0609361678F, + -0.124743387F, 0.0505551286F, 0.0660053492F, 0.0200117268F, + -0.00299887802F, -0.900257945F, -0.71710217F, -0.269961715F, + -0.0234408565F, 0.501320124F, -0.992201328F, -0.00535441097F, + -0.108619191F, 0.104421228F, 0.680802524F, -1.04835451F, + 0.702401638F, -0.875879943F, -0.578085601F, -0.0372556187F, + 0.430793166F, -0.184866309F, -1.37217891F, 0.00999766868F, + 0.136564702F, 0.0779872462F, 0.00922749098F, -0.138511553F, + 0.188112214F, -0.239430279F, -0.371088415F, -0.03123625F, + 0.526792347F, 0.76443857F, -0.250765204F, 0.103226878F, + 0.236611277F, 0.22589241F, 0.169456646F, -0.120205782F}; + static const float stateBias[400] = { + 0.104048461F, -0.0761412829F, -0.232239112F, 0.342873931F, + -0.000975009636F, 0.0688102916F, 6.49523718E-5F, 0.235507011F, + 0.00195251068F, -0.0467984937F, 0.114465274F, 0.198269293F, + -0.176635459F, -0.045360323F, 0.0619256981F, 0.138484374F, + -0.204644069F, -0.000131502631F, -0.169491932F, 0.024638949F, + 0.31261465F, -0.409777433F, 0.0474973693F, 0.0883291364F, + -0.0524479039F, -0.241572052F, 0.166343912F, 0.108027F, + 0.281149328F, 0.00193988939F, 0.00192181347F, -0.104164347F, + -0.260359794F, -0.125209764F, 0.060414806F, -0.295993328F, + 0.000788049889F, 0.0015770559F, -0.0121091167F, -0.341339886F, + 0.0106629916F, 0.2090092F, 0.1998339F, -0.348827511F, + -0.0582826361F, 0.0810302496F, -0.0843943879F, 0.0365539938F, + 0.002454784F, 0.0334644243F, -0.046164535F, 0.362081F, + -0.00186490617F, -0.0360834487F, -0.0780937895F, -0.0807999894F, + -0.100676239F, 0.0278875977F, -0.0544118211F, -0.000133354653F, + 0.195994377F, -0.195237935F, 0.289029479F, -0.0315730609F, + -0.200734362F, 0.0255534314F, -0.010702976F, -0.00735088F, + 0.366673321F, 0.156369165F, 0.215092152F, 0.00175695273F, + 0.100393809F, -0.0264283083F, 0.0529408716F, 0.00145998783F, + 0.0107766083F, -0.0484384596F, -0.0503902175F, 0.000333679782F, + -0.0186391026F, -0.253929257F, -0.130302072F, 0.0592749901F, + 0.0387604497F, 0.199462876F, 0.0733283609F, 0.00145081338F, + 0.0446812324F, -0.191940784F, -0.107470654F, -0.00021448062F, + -0.030237183F, 0.228780866F, 0.28475666F, 0.309271425F, + 0.0225542765F, -0.0156757757F, -0.00951651763F, -0.0805095807F, + -0.164557561F, -0.181319311F, 0.0974652916F, -0.00448253378F, + 0.224103391F, 0.139196739F, 0.0586323F, 0.0308150351F, + -0.0810154751F, -0.0140792085F, 0.0592546F, 0.0574058518F, + 0.136019513F, 0.0508504435F, -0.0296914335F, -0.0477596335F, + -0.141964048F, 0.0503985882F, 0.000686414714F, -0.000302809261F, + 0.185021147F, -0.366702795F, 0.235790506F, -0.0678399056F, + 7.06804567E-5F, -0.000634692493F, 0.00937621854F, -0.0586204F, + 0.0935753658F, 0.174699157F, 0.365818262F, -0.0249194298F, + 0.0223717056F, -0.000792799F, 0.0630756393F, 0.262100905F, + -0.0698117241F, 0.0429682136F, 0.137910321F, 0.0368783809F, + -0.0138219493F, -0.296291232F, -0.068014361F, -0.0309682F, + -0.101011641F, 0.135358408F, -0.154723376F, 0.176287726F, + 0.204112947F, -0.17271997F, -0.19276154F, -0.000440017058F, + 0.0241195504F, 0.179854557F, 0.191054314F, 0.0077241594F, + 0.00120672875F, -0.241553053F, -0.000165931255F, -0.0569644123F, + 0.0066308328F, 0.00136826257F, -0.00188742043F, 0.000355802884F, + -0.101741552F, 0.198630944F, 0.0573820919F, -0.121685639F, + 0.0195783861F, 0.138951018F, 0.1036103F, 0.18656221F, + -0.105236866F, -0.167946443F, 0.210929945F, 0.0347344205F, + -0.0302785169F, 0.0626201108F, -0.221739829F, -0.191136792F, + 0.00916037802F, 0.107348733F, -0.0398608483F, -0.266649395F, + -0.0781506747F, 0.208947822F, -0.0718607903F, -0.0786139518F, + 0.0223614536F, 0.141084194F, 0.0985953063F, 0.180785432F, + -0.0424256F, 0.247841164F, -0.122325569F, -0.137574449F, + 0.030968355F, -0.0478197F, -0.00167171541F, 0.0422613F, + -0.164235353F, -0.000563430309F, 0.139033452F, -0.0461723544F, + 0.124062292F, -0.0812684372F, -0.000609176699F, -7.73743232E-5F, + -0.0145842396F, -0.101897255F, -0.0906750187F, 0.00557193579F, + 0.0440317802F, -0.13561365F, -0.0371860564F, 0.0713308454F, + -0.0245366655F, 0.21939148F, 0.000366997352F, 0.0704934821F, + 0.161902457F, -0.0489316285F, 0.276109338F, -0.0361038037F, + 0.12856473F, -0.0331462063F, 0.0518835634F, -0.00816147588F, + -0.0544778369F, -0.130084008F, -0.122095011F, 0.0455697514F, + 0.219196469F, -0.0915518478F, 0.113890693F, -0.125071719F, + -0.209175214F, -0.218215629F, 0.0545807108F, -0.0998134688F, + -0.0598984696F, 0.00135708868F, -0.0995640382F, 0.0616916902F, + 0.096117489F, -0.0947800279F, 0.00764789525F, -0.288739026F, + -0.123744018F, 0.324823141F, 0.359524429F, 0.000430202286F, + 0.234553903F, -0.149082959F, 0.163982853F, 0.000249010365F, + 0.03981198F, -0.0781321F, -0.0566770025F, -0.0312611461F, + 0.0571559295F, 0.184633493F, -0.145166546F, 0.122505181F, + -0.00142252783F, 0.282994241F, -0.057230588F, 0.385203928F, + -0.0372500829F, -0.107206799F, 0.0726640224F, 0.0457907617F, + -0.000274225575F, 0.178014472F, -0.056240689F, -0.0533011444F, + 0.00135842164F, 0.173348725F, 0.216118991F, -0.174579456F, + 0.000114926414F, -0.153867871F, 0.161101028F, 0.0271121077F, + 0.00130190828F, 0.154399157F, -0.00131946919F, 0.0746037439F, + -0.0783764422F, -0.0276896507F, -0.031335596F, 0.0517627F, + 0.135367036F, 0.000667774584F, 0.236381888F, 0.0342263095F, + 0.0501087606F, -0.0973698646F, -0.190459833F, -0.0699870586F, + 0.0578431934F, 0.0457646586F, -0.1441935F, 0.193921879F, + 0.144730419F, 0.0533681251F, 0.137984842F, 0.000931386254F, + 0.189412966F, -0.084781073F, -0.057004258F, -0.000604897563F, + -0.116203539F, 0.159025744F, 0.0410725176F, 0.172092915F, + -0.00123649836F, -0.152446479F, 0.105236925F, 0.000702245045F, + 0.0856303349F, 0.0351231359F, -0.080520153F, -0.136352956F, + -0.482311F, -0.24442701F, 0.043281626F, -0.0112866974F, + 0.251540661F, 0.0585129447F, -0.00857528672F, 0.0491058417F, + 0.0387075879F, -0.114040785F, -0.0337748788F, -0.192918226F, + 0.0856347084F, 0.05089847F, -0.353909433F, 0.257296473F, + -0.0841496065F, 0.359268785F, -0.0676469728F, 0.20263581F, + 0.063291207F, 0.283381134F, 0.0293648187F, 0.235825032F, + -0.113269709F, 0.0133708827F, 0.208997488F, -0.0274674408F, + 0.00102248474F, -2.43457489E-5F, 0.344379902F, 0.0865588859F, + -0.323001564F, 0.0542085841F, 0.00613147626F, 0.128314748F, + -0.0895234272F, -0.060851F, 0.0960444808F, 0.0788563266F, + 0.162114114F, -0.000168587198F, -0.000408729771F, 0.000698294258F, + -0.0176401082F, 0.186227351F, -0.00131730398F, 0.10283114F, + -0.0495281853F, 0.0829151273F, 0.0297670513F, -0.00196181657F, + -0.0324171335F, 0.000884046138F, -0.00122172933F, -0.00350201572F, + -0.0484138317F, -0.114702232F, 0.00188085821F, 0.0035473255F, + -0.157313228F, -0.270324826F, -0.0369702801F, 0.0464711413F, + 0.0736103281F, 0.127652794F, -0.132167846F, -0.0840467215F, + -0.251417875F, -0.0973516926F, 0.0263930149F, -0.126744121F, + -0.0497680455F, -0.256805599F, 0.0114933755F, -0.091192767F}; + static float recurrentGateWeights[480000]; + static float recurrentStateWeights[160000]; + static boolean_T bufferInitialized; + __m128 r; + __m128 r1; + __m128 r2; + __m128 r3; + float Z[1200]; + float gateValues[1200]; + float CS[400]; + float YT[400]; + float d_B[400]; + float stateValues[400]; + float inMinibatch_0_f1_data[10]; + float B[5]; + float b_B[5]; + float c_B[5]; + float e_B[5]; + float layerOutput[3]; + int i; + if (!bufferInitialized) { + readDnnConstants( + &recurrentGateWeights[0], + "../scripts/largeDnnConstants_1551436.bin", 480000); + readDnnConstants( + &recurrentStateWeights[0], + "../scripts/largeDnnConstants_1551441.bin", 160000); + } + bufferInitialized = true; + for (i = 0; i < 10; i++) { + inMinibatch_0_f1_data[i] = (float)inputs->f1[0].f1[i]; + } + if (!obj->IsNetworkInitialized) { + memset(&obj->InternalState[0].f1[0].f1[0], 0, 400U * sizeof(float)); + memset(&obj->InternalState[0].f1[1].f1[0], 0, 400U * sizeof(float)); + obj->IsNetworkInitialized = true; + } + matrixMultiply1(1200, 400, 1, 128, 128, 128, &recurrentGateWeights[0], + &obj->InternalState[0].f1[0].f1[0], &Z[0]); + for (i = 0; i <= 1196; i += 4) { + r = _mm_loadu_ps(&Z[i]); + _mm_storeu_ps(&Z[i], _mm_add_ps(r, _mm_loadu_ps(&gateBias[i]))); + } + for (i = 0; i < 5; i++) { + B[i] = inMinibatch_0_f1_data[i]; + } + matrixMultiply1(1200, 5, 1, 128, 128, 128, &inputGateWeights[0], &B[0], + &gateValues[0]); + for (i = 0; i <= 1196; i += 4) { + r = _mm_loadu_ps(&gateValues[i]); + r1 = _mm_loadu_ps(&Z[i]); + _mm_storeu_ps(&gateValues[i], _mm_add_ps(r, r1)); + } + lambdaForColumnMajorGeneric(gateValues); + matrixMultiply1(400, 400, 1, 128, 128, 128, &recurrentStateWeights[0], + &obj->InternalState[0].f1[0].f1[0], &YT[0]); + for (i = 0; i <= 396; i += 4) { + r = _mm_loadu_ps(&YT[i]); + _mm_storeu_ps(&YT[i], _mm_add_ps(r, _mm_loadu_ps(&stateBias[i]))); + } + for (i = 0; i < 5; i++) { + b_B[i] = inMinibatch_0_f1_data[i]; + } + matrixMultiply1(400, 5, 1, 128, 128, 128, &inputStateWeights[0], &b_B[0], + &stateValues[0]); + for (i = 0; i <= 396; i += 4) { + r = _mm_loadu_ps(&stateValues[i]); + r1 = _mm_loadu_ps(&YT[i]); + _mm_storeu_ps(&stateValues[i], _mm_add_ps(r, r1)); + } + c_lambdaForColumnMajorGeneric(stateValues); + for (i = 0; i <= 396; i += 4) { + r = _mm_loadu_ps(&stateValues[i]); + r1 = _mm_loadu_ps(&gateValues[i]); + r2 = _mm_loadu_ps(&gateValues[i + 400]); + r3 = _mm_loadu_ps(&obj->InternalState[0].f1[1].f1[i]); + r = _mm_add_ps(_mm_mul_ps(r, r1), _mm_mul_ps(r2, r3)); + _mm_storeu_ps(&CS[i], r); + _mm_storeu_ps(&stateValues[i], r); + } + e_lambdaForColumnMajorGeneric(stateValues); + for (i = 0; i <= 396; i += 4) { + r = _mm_loadu_ps(&stateValues[i]); + r1 = _mm_loadu_ps(&gateValues[i + 800]); + _mm_storeu_ps(&YT[i], _mm_mul_ps(r, r1)); + } + matrixMultiply1(1200, 400, 1, 128, 128, 128, &recurrentGateWeights[0], &YT[0], + &Z[0]); + for (i = 0; i <= 1196; i += 4) { + r = _mm_loadu_ps(&Z[i]); + _mm_storeu_ps(&Z[i], _mm_add_ps(r, _mm_loadu_ps(&gateBias[i]))); + } + for (i = 0; i < 5; i++) { + c_B[i] = inMinibatch_0_f1_data[i + 5]; + } + matrixMultiply1(1200, 5, 1, 128, 128, 128, &inputGateWeights[0], &c_B[0], + &gateValues[0]); + for (i = 0; i <= 1196; i += 4) { + r = _mm_loadu_ps(&gateValues[i]); + r1 = _mm_loadu_ps(&Z[i]); + _mm_storeu_ps(&gateValues[i], _mm_add_ps(r, r1)); + } + lambdaForColumnMajorGeneric(gateValues); + memcpy(&d_B[0], &YT[0], 400U * sizeof(float)); + matrixMultiply1(400, 400, 1, 128, 128, 128, &recurrentStateWeights[0], + &d_B[0], &YT[0]); + for (i = 0; i <= 396; i += 4) { + r = _mm_loadu_ps(&YT[i]); + _mm_storeu_ps(&YT[i], _mm_add_ps(r, _mm_loadu_ps(&stateBias[i]))); + } + for (i = 0; i < 5; i++) { + e_B[i] = inMinibatch_0_f1_data[i + 5]; + } + matrixMultiply1(400, 5, 1, 128, 128, 128, &inputStateWeights[0], &e_B[0], + &stateValues[0]); + for (i = 0; i <= 396; i += 4) { + r = _mm_loadu_ps(&stateValues[i]); + r1 = _mm_loadu_ps(&YT[i]); + _mm_storeu_ps(&stateValues[i], _mm_add_ps(r, r1)); + } + c_lambdaForColumnMajorGeneric(stateValues); + for (i = 0; i <= 396; i += 4) { + r = _mm_loadu_ps(&stateValues[i]); + r1 = _mm_loadu_ps(&gateValues[i]); + r2 = _mm_loadu_ps(&gateValues[i + 400]); + r3 = _mm_loadu_ps(&CS[i]); + r = _mm_add_ps(_mm_mul_ps(r, r1), _mm_mul_ps(r2, r3)); + _mm_storeu_ps(&CS[i], r); + _mm_storeu_ps(&YT[i], r); + } + e_lambdaForColumnMajorGeneric(YT); + for (i = 0; i <= 396; i += 4) { + r = _mm_loadu_ps(&YT[i]); + r1 = _mm_loadu_ps(&gateValues[i + 800]); + _mm_storeu_ps(&YT[i], _mm_mul_ps(r, r1)); + } + matrixMultiply2(3, 400, 1, 128, 128, 128, &A[0], &YT[0], &layerOutput[0]); + layerOutput[0] -= 0.000501449395F; + layerOutput[1] += 0.0780053213F; + layerOutput[2] -= 0.0883610174F; + SoftmaxLayer_predict(layerOutput, outputData); +} + +/* + * File trailer for predictForRNN.c + * + * [EOF] + */ diff --git a/src/rtGetInf.c b/src/rtGetInf.c new file mode 100644 index 0000000..5205607 --- /dev/null +++ b/src/rtGetInf.c @@ -0,0 +1,61 @@ +/* + * File: rtGetInf.c + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +/* + * Abstract: + * MATLAB for code generation function to initialize non-finite, Inf and + * MinusInf + */ +/* Include Files */ +#include "rtGetInf.h" +#include "rt_nonfinite.h" + +/* + * Function: rtGetInf + * ================================================================== Abstract: + * Initialize rtInf needed by the generated code. + */ +real_T rtGetInf(void) +{ + return rtInf; +} + +/* + * Function: rtGetInfF + * ================================================================= Abstract: + * Initialize rtInfF needed by the generated code. + */ +real32_T rtGetInfF(void) +{ + return rtInfF; +} + +/* + * Function: rtGetMinusInf + * ============================================================= Abstract: + * Initialize rtMinusInf needed by the generated code. + */ +real_T rtGetMinusInf(void) +{ + return rtMinusInf; +} + +/* + * Function: rtGetMinusInfF + * ============================================================ Abstract: + * Initialize rtMinusInfF needed by the generated code. + */ +real32_T rtGetMinusInfF(void) +{ + return rtMinusInfF; +} + +/* + * File trailer for rtGetInf.c + * + * [EOF] + */ diff --git a/src/rtGetNaN.c b/src/rtGetNaN.c new file mode 100644 index 0000000..19e70dd --- /dev/null +++ b/src/rtGetNaN.c @@ -0,0 +1,44 @@ +/* + * File: rtGetNaN.c + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +/* + * Abstract: + * MATLAB for code generation function to initialize non-finite, NaN + */ +/* Include Files */ +#include "rtGetNaN.h" +#include "rt_nonfinite.h" + +/* + * Function: rtGetNaN + * ====================================================================== + * Abstract: + * Initialize rtNaN needed by the generated code. + * NaN is initialized as non-signaling. Assumes IEEE. + */ +real_T rtGetNaN(void) +{ + return rtNaN; +} + +/* + * Function: rtGetNaNF + * ===================================================================== + * Abstract: + * Initialize rtNaNF needed by the generated code. + * NaN is initialized as non-signaling. Assumes IEEE + */ +real32_T rtGetNaNF(void) +{ + return rtNaNF; +} + +/* + * File trailer for rtGetNaN.c + * + * [EOF] + */ diff --git a/src/rt_nonfinite.c b/src/rt_nonfinite.c new file mode 100644 index 0000000..434d4ce --- /dev/null +++ b/src/rt_nonfinite.c @@ -0,0 +1,76 @@ +/* + * File: rt_nonfinite.c + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +/* + * Abstract: + * MATLAB for code generation function to initialize non-finites, + * (Inf, NaN and -Inf). + */ +/* Include Files */ +#include "rt_nonfinite.h" +#include + +#if defined(__ICL) && __ICL == 1700 +#pragma warning(disable : 264) +#endif + +real_T rtNaN = (real_T)NAN; +real_T rtInf = (real_T)INFINITY; +real_T rtMinusInf = -(real_T)INFINITY; +real32_T rtNaNF = (real32_T)NAN; +real32_T rtInfF = (real32_T)INFINITY; +real32_T rtMinusInfF = -(real32_T)INFINITY; + +#if defined(__ICL) && __ICL == 1700 +#pragma warning(default : 264) +#endif + +/* + * Function: rtIsInf ================================================== + * Abstract: + * Test if value is infinite + */ +boolean_T rtIsInf(real_T value) +{ + return (isinf(value) != 0U); +} + +/* + * Function: rtIsInfF ================================================= + * Abstract: + * Test if single-precision value is infinite + */ +boolean_T rtIsInfF(real32_T value) +{ + return (isinf((real_T)value) != 0U); +} + +/* + * Function: rtIsNaN ================================================== + * Abstract: + * Test if value is not a number + */ +boolean_T rtIsNaN(real_T value) +{ + return (isnan(value) != 0U); +} + +/* + * Function: rtIsNaNF ================================================= + * Abstract: + * Test if single-precision value is not a number + */ +boolean_T rtIsNaNF(real32_T value) +{ + return (isnan((real_T)value) != 0U); +} + +/* + * File trailer for rt_nonfinite.c + * + * [EOF] + */ diff --git a/src/runPrediction.c b/src/runPrediction.c new file mode 100644 index 0000000..25aeed5 --- /dev/null +++ b/src/runPrediction.c @@ -0,0 +1,55 @@ +/* + * File: runPrediction.c + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +/* Include Files */ +#include "runPrediction.h" +#include "getCategoryNames.h" +#include "postProcessOutputToReturnCategorical.h" +#include "predict.h" +#include "rt_nonfinite.h" +#include "runPrediction_data.h" +#include "runPrediction_initialize.h" +#include "runPrediction_internal_types.h" +#include "runPrediction_types.h" + +/* Function Definitions */ +/* + * Fazer a previsão + * + * Arguments : const cell_wrap_0 A[1] + * categorical *pred + * Return Type : void + */ +void runPrediction(const cell_wrap_0 A[1], categorical *pred) +{ + c_coder_internal_ctarget_DeepLe net; + cell_wrap_32 r; + emxArray_cell_wrap_1_3 idx_categoryNames; + unsigned int idx_codes; + if (!isInitialized_runPrediction) { + runPrediction_initialize(); + } + net.IsNetworkInitialized = false; + net.matlabCodegenIsDeleted = false; + DeepLearningNetwork_predict(&net, &A[0], r.f1); + idx_codes = c_DeepLearningNetwork_postProce(r, idx_categoryNames.data, + &idx_categoryNames.size[0]); + /* Converter a previsão para rótulos */ + pred->categoryNames.size[0] = categorical_getCategoryNames( + idx_categoryNames.data, idx_categoryNames.size[0], + pred->categoryNames.data); + if (idx_codes > 255U) { + idx_codes = 255U; + } + pred->codes = (unsigned char)idx_codes; +} + +/* + * File trailer for runPrediction.c + * + * [EOF] + */ diff --git a/src/runPrediction_data.c b/src/runPrediction_data.c new file mode 100644 index 0000000..67eb0ec --- /dev/null +++ b/src/runPrediction_data.c @@ -0,0 +1,21 @@ +/* + * File: runPrediction_data.c + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +/* Include Files */ +#include "runPrediction_data.h" +#include "rt_nonfinite.h" + +/* Variable Definitions */ +omp_nest_lock_t runPrediction_nestLockGlobal; + +boolean_T isInitialized_runPrediction = false; + +/* + * File trailer for runPrediction_data.c + * + * [EOF] + */ diff --git a/src/runPrediction_initialize.c b/src/runPrediction_initialize.c new file mode 100644 index 0000000..4294617 --- /dev/null +++ b/src/runPrediction_initialize.c @@ -0,0 +1,29 @@ +/* + * File: runPrediction_initialize.c + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +/* Include Files */ +#include "runPrediction_initialize.h" +#include "rt_nonfinite.h" +#include "runPrediction_data.h" +#include "omp.h" + +/* Function Definitions */ +/* + * Arguments : void + * Return Type : void + */ +void runPrediction_initialize(void) +{ + omp_init_nest_lock(&runPrediction_nestLockGlobal); + isInitialized_runPrediction = true; +} + +/* + * File trailer for runPrediction_initialize.c + * + * [EOF] + */ diff --git a/src/runPrediction_terminate.c b/src/runPrediction_terminate.c new file mode 100644 index 0000000..a8f2e10 --- /dev/null +++ b/src/runPrediction_terminate.c @@ -0,0 +1,29 @@ +/* + * File: runPrediction_terminate.c + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +/* Include Files */ +#include "runPrediction_terminate.h" +#include "rt_nonfinite.h" +#include "runPrediction_data.h" +#include "omp.h" + +/* Function Definitions */ +/* + * Arguments : void + * Return Type : void + */ +void runPrediction_terminate(void) +{ + omp_destroy_nest_lock(&runPrediction_nestLockGlobal); + isInitialized_runPrediction = false; +} + +/* + * File trailer for runPrediction_terminate.c + * + * [EOF] + */ diff --git a/src/strcmp.c b/src/strcmp.c new file mode 100644 index 0000000..e59cd9d --- /dev/null +++ b/src/strcmp.c @@ -0,0 +1,54 @@ +/* + * File: strcmp.c + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +/* Include Files */ +#include "strcmp.h" +#include "rt_nonfinite.h" + +/* Function Definitions */ +/* + * Arguments : const char a_data[] + * const int a_size[2] + * const char b_data[] + * const int b_size[2] + * Return Type : boolean_T + */ +boolean_T b_strcmp(const char a_data[], const int a_size[2], + const char b_data[], const int b_size[2]) +{ + boolean_T b; + boolean_T b_bool; + b_bool = false; + b = (a_size[1] == 0); + if (b && (b_size[1] == 0)) { + b_bool = true; + } else if (a_size[1] == b_size[1]) { + int kstr; + kstr = 0; + int exitg1; + do { + exitg1 = 0; + if (kstr <= b_size[1] - 1) { + if (a_data[0] != b_data[0]) { + exitg1 = 1; + } else { + kstr = 1; + } + } else { + b_bool = true; + exitg1 = 1; + } + } while (exitg1 == 0); + } + return b_bool; +} + +/* + * File trailer for strcmp.c + * + * [EOF] + */ diff --git a/src/strtrim.c b/src/strtrim.c new file mode 100644 index 0000000..5c75509 --- /dev/null +++ b/src/strtrim.c @@ -0,0 +1,61 @@ +/* + * File: strtrim.c + * + * MATLAB Coder version : 24.1 + * C/C++ source code generated on : 12-Dec-2024 16:04:45 + */ + +/* Include Files */ +#include "strtrim.h" +#include "rt_nonfinite.h" + +/* Function Definitions */ +/* + * Arguments : const char x_data[] + * const int x_size[2] + * char y_data[] + * int y_size[2] + * Return Type : void + */ +void strtrim(const char x_data[], const int x_size[2], char y_data[], + int y_size[2]) +{ + static const boolean_T bv[128] = { + false, false, false, false, false, false, false, false, false, true, + true, true, true, true, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, true, true, + true, true, true, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false}; + int b_j1; + int j2; + b_j1 = 1; + while ((b_j1 <= x_size[1]) && bv[(unsigned char)x_data[0] & 127] && + (x_data[0] != '\x00')) { + b_j1 = 2; + } + j2 = x_size[1]; + while ((j2 > 0) && bv[(unsigned char)x_data[0] & 127] && + (x_data[0] != '\x00')) { + j2 = 0; + } + b_j1 = (b_j1 <= j2); + y_size[0] = 1; + y_size[1] = b_j1; + if (b_j1 - 1 >= 0) { + y_data[0] = x_data[0]; + } +} + +/* + * File trailer for strtrim.c + * + * [EOF] + */