pf2: skeleton str api

This commit is contained in:
Michael Scire
2021-02-03 14:28:01 -08:00
parent 60ea1dade2
commit 3107ec0127
6 changed files with 318 additions and 0 deletions

View File

@@ -22,6 +22,7 @@
#include <vapours/svc.hpp>
#include <vapours/prfile2/prfile2_common.hpp>
#include <vapours/prfile2/prfile2_str.hpp>
#include <vapours/prfile2/prfile2_system.hpp>
#include <vapours/prfile2/pdm/prfile2_pdm_api.hpp>
#include <vapours/prfile2/pdm/prfile2_pdm_disk_management.hpp>

View File

@@ -17,6 +17,7 @@
#include <vapours/prfile2/prfile2_build_config.hpp>
#include <vapours/prfile2/pf/prfile2_pf_config.hpp>
#include <vapours/prfile2/pf/prfile2_pf_api_common.hpp>
#include <vapours/prfile2/prfile2_wide_string.hpp>
namespace ams::prfile2 {

View File

@@ -0,0 +1,65 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours/prfile2/prfile2_common.hpp>
namespace ams::prfile2::str {
enum CodeMode {
CodeMode_Invalid = 0,
CodeMode_Local = 1,
CodeMode_Unicode = 2,
};
enum TargetString {
TargetString_Head = 1,
TargetString_Tail = 2,
};
struct String {
const char *head;
const char *tail;
CodeMode code_mode;
};
pf::Error Initialize(String *str, const char *s, CodeMode code_mode);
void SetCodeMode(String *str, CodeMode code_mode);
CodeMode GetCodeMode(const String *str);
char *GetPos(String *str, TargetString target);
void MovePos(String *str, s16 num_char);
u16 GetLength(String *str);
u16 GetNumChar(String *str, TargetString target);
int Compare(const String *str, const char *rhs);
int Compare(const String *str, const WideChar *rhs);
/* TODO: StrNCmp */
/* TODO: ToUpperNStr */
constexpr bool IsNull(const String *str) {
return str->head == nullptr;
}
}
namespace ams::prfile2 {
using String = str::String;
}

View File

@@ -0,0 +1,32 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours/prfile2/prfile2_common.hpp>
namespace ams::prfile2 {
using WideChar = u16;
size_t w_strlen(const WideChar *s);
size_t w_strnlen(const WideChar *s, size_t length);
WideChar *w_strcpy(WideChar *dst, const WideChar *src);
WideChar *w_strncpy(WideChar *dst, const WideChar *src, size_t length);
int w_strcmp(const WideChar *lhs, const WideChar *rhs);
int w_strncmp(const WideChar *lhs, const WideChar *rhs, size_t length);
}