<commit_before>// Copyright 2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef FPLBASE_UTILITIES_H
#define FPLBASE_UTILITIES_H

#include <string>
#include "fplbase/config.h"  // Must come first.

#include "mathfu/utilities.h"

#if defined(__ANDROID__)
#include <jni.h>
#if defined(FPL_BASE_BACKEND_STDLIB)
#include <android/asset_manager.h>
#include <android/asset_manager_jni.h>
#endif  // defined(FPL_BASE_BACKEND_STDLIB)
#endif

namespace fplbase {

/// @file
/// @brief General utility functions, used by FPLBase, and that might be of use
/// to people using the library:
/// @addtogroup fplbase_utilities
/// @{

/// @brief Constants for use with LogInfo, LogError, etc.
#ifdef FPL_BASE_BACKEND_SDL
enum LogCategory {
  kApplication = 0,  // SDL_LOG_CATEGORY_APPLICATION
  kError = 1,        // SDL_LOG_CATEGORY_ERROR
  kSystem = 3,       // SDL_LOG_CATEGORY_SYSTEM
  kAudio = 4,        // SDL_LOG_CATEGORY_AUDIO
  kVideo = 5,        // SDL_LOG_CATEGORY_VIDEO
  kRender = 6,       // SDL_LOG_CATEGORY_RENDER
  kInput = 7,        // SDL_LOG_CATEGORY_INPUT
  kCustom = 19,      // SDL_LOG_CATEGORY_CUSTOM
};
#else
enum LogCategory {
  kApplication = 0,
  kError,
  kSystem,
  kAudio,
  kVideo,
  kRender,
  kInput,
  kCustom
};
#endif

/// @brief Called by `LoadFile()`.
typedef bool (*LoadFileFunction)(const char *filename, std::string *dest);

/// @brief Enum for use with the `Set/GetPerformanceMode()` functions.
enum PerformanceMode {
  // Normal mode.  No special actions taken.
  kNormalPerformance = 0,

  // High performance mode.  Attempt to keep the CPU frequency up.
  kHighPerformance<commit_msg>Change the fpl LoadFileFunction to an std::function. This would enable the use of member functions or lambdas as needed. PiperOrigin-RevId: 145803054 Change-Id: Id579fc87e76de0e7e23708f35d5ae43d8aa2c318<commit_after>// Copyright 2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef FPLBASE_UTILITIES_H
#define FPLBASE_UTILITIES_H

#include <functional>
#include <string>
#include "fplbase/config.h"  // Must come first.

#include "mathfu/utilities.h"

#if defined(__ANDROID__)
#include <jni.h>
#if defined(FPL_BASE_BACKEND_STDLIB)
#include <android/asset_manager.h>
#include <android/asset_manager_jni.h>
#endif  // defined(FPL_BASE_BACKEND_STDLIB)
#endif

namespace fplbase {

/// @file
/// @brief General utility functions, used by FPLBase, and that might be of use
/// to people using the library:
/// @addtogroup fplbase_utilities
/// @{

/// @brief Constants for use with LogInfo, LogError, etc.
#ifdef FPL_BASE_BACKEND_SDL
enum LogCategory {
  kApplication = 0,  // SDL_LOG_CATEGORY_APPLICATION
  kError = 1,        // SDL_LOG_CATEGORY_ERROR
  kSystem = 3,       // SDL_LOG_CATEGORY_SYSTEM
  kAudio = 4,        // SDL_LOG_CATEGORY_AUDIO
  kVideo = 5,        // SDL_LOG_CATEGORY_VIDEO
  kRender = 6,       // SDL_LOG_CATEGORY_RENDER
  kInput = 7,        // SDL_LOG_CATEGORY_INPUT
  kCustom = 19,      // SDL_LOG_CATEGORY_CUSTOM
};
#else
enum LogCategory {
  kApplication = 0,
  kError,
  kSystem,
  kAudio,
  kVideo,
  kRender,
  kInput,
  kCustom
};
#endif

/// @brief Called by `LoadFile()`.
using LoadFileFunction =
    std::function<bool(const char *filename, std::string *dest)>;

/// @brief Enum for use with the `Set/GetPerformanceMode()` functions.
enum PerformanceMode {
  // Normal mode.  No special actions taken.
  kNormalPerformance = 0,

  // High performance mode.  Attempt to keep the CPU frequency up.
  kHighPerformance
{'fraction_non_alphanumeric': 0.09932032449024336, 'fraction_numerical': 0.015566761675071256, 'mean_word_length': 3.571142284569138, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4709844', 'n_tokens_mistral': 1569, 'n_tokens_neox': 1484, 'n_words': 471}