/*  Copyright (C) 2015  Povilas Kanapickas <povilas@radix.lt>

    This file is part of cppreference-doc

    This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
    Unported License. To view a copy of this license, visit
    http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative
    Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.

    Permission is granted to copy, distribute and/or modify this document
    under the terms of the GNU Free Documentation License, Version 1.3 or
    any later version published by the Free Software Foundation; with no
    Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
*/

#ifndef CPPREFERENCE_CWCHAR_H
#define CPPREFERENCE_CWCHAR_H

namespace std {

// wide strings
std::size_t wcslen(const wchar_t* str);
int wcscmp(const wchar_t* lhs, const wchar_t* rhs);
int wcsncmp(const wchar_t* lhs, const wchar_t* rhs, std::size_t count);
int wcscoll(const wchar_t* lhs, const wchar_t* rhs);
const wchar_t* wcschr(const wchar_t* str, wchar_t ch);
wchar_t* wcschr(wchar_t* str, wchar_t ch);
const wchar_t* wcsrchr(const wchar_t* str, wchar_t ch);
wchar_t* wcsrchr(wchar_t* str, wchar_t ch);
size_t wcsspn(const wchar_t* dest, const wchar_t* src);
std::size_t wcscspn(const wchar_t* dest, const wchar_t* src);
const wchar_t* wcspbrk(const wchar_t* dest, const wchar_t* str);
wchar_t* wcspbrk(wchar_t* dest, const wchar_t* str);
const wchar_t* wcsstr(const wchar_t* dest, const wchar_t* src);
wchar_t* wcsstr(wchar_t* dest, const wchar_t* src);
wchar_t* wcstok(wchar_t* str, const wchar_t* delim, wchar_t** ptr);

wchar_t* wmemcpy(wchar_t* dest, const wchar_t* src, std::size_t count);
wchar_t* wmemmove(wchar_t* dest, const wchar_t* src, std::size_t count);
int wmemcmp(const wchar_t* lhs, const wchar_t* rhs, std::size_t count);
const wchar_t* wmemchr(const wchar_t* ptr, wchar_t ch, std::size_t count);
wchar_t* wmemchr(wchar_t* ptr, wchar_t ch, std::size_t count);
wchar_t* wmemset(wchar_t* dest, wchar_t ch, std::size_t count);

wchar_t* wcscpy(wchar_t* dest, const wchar_t* src);
wchar_t* wcsncpy(wchar_t* dest, const wchar_t* src, std::size_t count);
wchar_t* wcscat(wchar_t* dest, const wchar_t* src);
wchar_t* wcsncat(wchar_t* dest, const wchar_t* src, std::size_t count);
std::size_t strxfrm(wchar_t* dest, const wchar_t* src, std::size_t count);

// string conversions
long      wcstol(const wchar_t* str, wchar_t** str_end, int base);
unsigned long      wcstoul(const wchar_t* str, wchar_t** str_end, int base);
double      wcstod(const wchar_t* str, wchar_t** str_end);
#if CPPREFERENCE_STDVER> 2011
long long wcstoll(const wchar_t* str, wchar_t** str_end, int base);
unsigned long long wcstoull(const wchar_t* str, wchar_t** str_end, int base);
float       wcstof(const wchar_t* str, wchar_t** str_end);
long double wcstold(const wchar_t* str, wchar_t** str_end);
#endif

// multibyte strings
struct mbstate_t;
int mbsinit(const std::mbstate_t* ps);
std::size_t mbrtowc(wchar_t* pwc,
                    const char* s,
                    std::size_t n,
                    std::mbstate_t* ps);
std::wint_t btowc(int c);
std::size_t mbsrtowcs(wchar_t* dst,
                      const char** src,
                      std::size_t len,
                      std::mbstate_t* ps);
int wctob(std::wint_t c);
std::size_t wcrtomb(char* s, wchar_t wc, std::mbstate_t* ps);
std::size_t wcsrtombs(char* dst,
                      const wchar_t** src,
                      std::size_t len,
                      std::mbstate_t* ps);
std::size_t mbrlen(const char* s, std::size_t n, std::mbstate_t* ps);

// input/output

wint_t fgetwc(std::FILE* stream);
wint_t getwc(std::FILE* stream);
wchar_t* fgetws(wchar_t* str, int count, std::FILE* stream);
wint_t fputwc(wchar_t ch, std::FILE* stream);
wint_t putwc(wchar_t ch, std::FILE* stream);
int fputws(const wchar_t* str, std::FILE* stream);
wint_t getwchar();
wint_t putwchar(wchar_t ch);
wint_t ungetwc(wint_t ch, std::FILE* stream);

#if CPPREFERENCE_STDVER> 2011
int wscanf(const wchar_t* format, ...);
int fwscanf(std::FILE* stream, const wchar_t* format, ...);
int swscanf(const wchar_t* buffer, const wchar_t* format, ...);
int vwscanf(const wchar_t* format, va_list vlist);
int vfwscanf(std::FILE* stream, const wchar_t* format, va_list vlist);
int vswscanf(const wchar_t* buffer, const wchar_t* format, va_list vlist);
#endif
int wprintf(const wchar_t* format, ...);
int fwprintf(std::FILE* stream, const wchar_t* format, ...);
int swprintf(wchar_t* buffer, std::size_t size, const wchar_t* format, ...);
int vwprintf(const wchar_t* format, va_list vlist);
int vfwprintf(std::FILE* stream, const wchar_t* format, va_list vlist);
int vswprintf(const wchar_t* buffer, std::size_t size, const wchar_t* format, va_list vlist);

} // namespace std

#endif // CPPREFERENCE_CWCHAR_H
