diff --git a/.clang-format b/.clang-format
index 4ee2ef3..2aff157 100644
--- a/.clang-format
+++ b/.clang-format
@@ -100,7 +100,7 @@ PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 10000
PenaltyReturnTypeOnItsOwnLine: 60
-PointerAlignment: Right
+PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: false
diff --git a/doc/main.md b/doc/main.md
index 23521a0..6935565 100644
--- a/doc/main.md
+++ b/doc/main.md
@@ -54,8 +54,8 @@ Consider a simple application that splits a big file into chunks, such that
they can be sent by e-mail. It requires doing a few very simple tasks:
- Access command line arguments: int main(int argc,char **argv)
-- Open an input file, open several output files: std::fstream::open(char const *,std::ios::openmode m)
-- Remove the files in case of fault: std::remove(char const *file)
+- Open an input file, open several output files: std::fstream::open(const char*,std::ios::openmode m)
+- Remove the files in case of fault: std::remove(const char* file)
- Print a progress report onto the console: std::cout << file_name
Unfortunately it is impossible to implement this simple task in plain C++
@@ -122,7 +122,7 @@ Several reasons:
- \c wchar_t is not really portable, it can be 2 bytes, 4 bytes or even 1 byte making Unicode aware programming harder
- The C and C++ standard libraries use narrow strings for OS interactions. This library follows the same general rule. There is
- no such thing as fopen(wchar_t const *, wchar_t const *) in the standard library, so it is better
+ no such thing as fopen(const wchar_t*, const wchar_t*) in the standard library, so it is better
to stick to the standards rather than re-implement Wide API in "Microsoft Windows Style"
@@ -276,7 +276,7 @@ Under POSIX platforms, the functions in boost::nowide are aliases of their stand
namespace boost {
namespace nowide {
#ifdef BOOST_WINDOWS
-inline FILE *fopen(char const *name,char const *mode)
+inline FILE *fopen(const char* name, const char* mode)
{
...
}
diff --git a/include/boost/nowide/args.hpp b/include/boost/nowide/args.hpp
index a1cbdc3..9673f98 100644
--- a/include/boost/nowide/args.hpp
+++ b/include/boost/nowide/args.hpp
@@ -22,9 +22,9 @@ namespace nowide {
class args
{
public:
- args(int &, char **&)
+ args(int&, char**&)
{}
- args(int &, char **&, char **&)
+ args(int&, char**&, char**&)
{}
~args()
{}
@@ -53,7 +53,7 @@ namespace nowide {
///
/// Fix command line arguments
///
- args(int &argc, char **&argv) :
+ args(int& argc, char**& argv) :
old_argc_(argc), old_argv_(argv), old_env_(0), old_argc_ptr_(&argc), old_argv_ptr_(&argv), old_env_ptr_(0)
{
fix_args(argc, argv);
@@ -61,7 +61,7 @@ namespace nowide {
///
/// Fix command line arguments and environment
///
- args(int &argc, char **&argv, char **&env) :
+ args(int& argc, char**& argv, char**& env) :
old_argc_(argc), old_argv_(argv), old_env_(env), old_argc_ptr_(&argc), old_argv_ptr_(&argv), old_env_ptr_(&env)
{
fix_args(argc, argv);
@@ -83,11 +83,11 @@ namespace nowide {
private:
class wargv_ptr
{
- wchar_t **p;
+ wchar_t** p;
int argc;
// Non-copyable
- wargv_ptr(const wargv_ptr &);
- wargv_ptr &operator=(const wargv_ptr &);
+ wargv_ptr(const wargv_ptr&);
+ wargv_ptr& operator=(const wargv_ptr&);
public:
wargv_ptr() : p(CommandLineToArgvW(GetCommandLineW(), &argc))
@@ -105,17 +105,17 @@ namespace nowide {
{
return p != NULL;
}
- const wchar_t *operator[](size_t i) const
+ const wchar_t* operator[](size_t i) const
{
return p[i];
}
};
class wenv_ptr
{
- wchar_t *p;
+ wchar_t* p;
// Non-copyable
- wenv_ptr(const wenv_ptr &);
- wenv_ptr &operator=(const wenv_ptr &);
+ wenv_ptr(const wenv_ptr&);
+ wenv_ptr& operator=(const wenv_ptr&);
public:
wenv_ptr() : p(GetEnvironmentStringsW())
@@ -125,13 +125,13 @@ namespace nowide {
if(p)
FreeEnvironmentStringsW(p);
}
- operator const wchar_t *() const
+ operator const wchar_t*() const
{
return p;
}
};
- void fix_args(int &argc, char **&argv)
+ void fix_args(int& argc, char**& argv)
{
const wargv_ptr wargv;
if(!wargv)
@@ -143,18 +143,18 @@ namespace nowide {
argc = wargv.size();
argv = &args_[0];
}
- void fix_env(char **&env)
+ void fix_env(char**& env)
{
const wenv_ptr wstrings;
if(!wstrings)
throw std::runtime_error("Could not get environment strings!");
- const wchar_t *wstrings_end = 0;
+ const wchar_t* wstrings_end = 0;
int count = 0;
for(wstrings_end = wstrings; *wstrings_end; wstrings_end += wcslen(wstrings_end) + 1)
count++;
env_.convert(wstrings, wstrings_end);
envp_.resize(count + 1, 0);
- char *p = env_.get();
+ char* p = env_.get();
int pos = 0;
for(int i = 0; i < count; i++)
{
@@ -165,18 +165,18 @@ namespace nowide {
env = &envp_[0];
}
- std::vector args_;
+ std::vector args_;
std::vector arg_values_;
stackstring env_;
- std::vector envp_;
+ std::vector envp_;
int old_argc_;
- char **old_argv_;
- char **old_env_;
+ char** old_argv_;
+ char** old_env_;
- int *old_argc_ptr_;
- char ***old_argv_ptr_;
- char ***old_env_ptr_;
+ int* old_argc_ptr_;
+ char*** old_argv_ptr_;
+ char*** old_env_ptr_;
};
#endif
@@ -184,6 +184,3 @@ namespace nowide {
} // namespace nowide
} // namespace boost
#endif
-
-///
-// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
diff --git a/include/boost/nowide/config.hpp b/include/boost/nowide/config.hpp
index 63de44d..db49fb0 100644
--- a/include/boost/nowide/config.hpp
+++ b/include/boost/nowide/config.hpp
@@ -71,4 +71,3 @@
#endif
#endif // boost/nowide/config.hpp
-// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
diff --git a/include/boost/nowide/convert.hpp b/include/boost/nowide/convert.hpp
index 43e5030..1855504 100644
--- a/include/boost/nowide/convert.hpp
+++ b/include/boost/nowide/convert.hpp
@@ -5,8 +5,8 @@
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
-#ifndef BOOST_NOWIDE_CONVERT_H_INCLUDED
-#define BOOST_NOWIDE_CONVERT_H_INCLUDED
+#ifndef BOOST_NOWIDE_CONVERT_HPP_INCLUDED
+#define BOOST_NOWIDE_CONVERT_HPP_INCLUDED
#include
#include
@@ -25,16 +25,16 @@ namespace nowide {
/// Any illegal sequences are replaced with the replacement character, see #BOOST_NOWIDE_REPLACEMENT_CHARACTER
///
template
- CharOut *basic_convert(CharOut *buffer, size_t buffer_size, CharIn const *source_begin, CharIn const *source_end)
+ CharOut* basic_convert(CharOut* buffer, size_t buffer_size, const CharIn* source_begin, const CharIn* source_end)
{
- CharOut *rv = buffer;
+ CharOut* rv = buffer;
if(buffer_size == 0)
return 0;
buffer_size--;
while(source_begin != source_end)
{
using namespace detail::utf;
- code_point c = utf_traits::template decode(source_begin, source_end);
+ code_point c = utf_traits::template decode(source_begin, source_end);
if(c == illegal || c == incomplete)
{
c = BOOST_NOWIDE_REPLACEMENT_CHARACTER;
@@ -45,7 +45,7 @@ namespace nowide {
rv = NULL;
break;
}
- buffer = utf_traits::template encode(c, buffer);
+ buffer = utf_traits::template encode(c, buffer);
buffer_size -= width;
}
*buffer++ = 0;
@@ -59,7 +59,7 @@ namespace nowide {
/// Any illegal sequences are replaced with the replacement character, see #BOOST_NOWIDE_REPLACEMENT_CHARACTER
///
template
- std::basic_string basic_convert(CharIn const *begin, CharIn const *end)
+ std::basic_string basic_convert(const CharIn* begin, const CharIn* end)
{
std::basic_string result;
result.reserve(end - begin);
@@ -69,7 +69,7 @@ namespace nowide {
code_point c;
while(begin != end)
{
- c = utf_traits::template decode(begin, end);
+ c = utf_traits::template decode(begin, end);
if(c == illegal || c == incomplete)
{
c = BOOST_NOWIDE_REPLACEMENT_CHARACTER;
@@ -80,18 +80,18 @@ namespace nowide {
}
/// \cond INTERNAL
- namespace details {
+ namespace detail {
//
// wcslen defined only in C99... So we will not use it
//
template
- Char const *basic_strend(Char const *s)
+ const Char* basic_strend(const Char* s)
{
while(*s)
s++;
return s;
}
- } // namespace details
+ } // namespace detail
/// \endcond
///
@@ -101,7 +101,7 @@ namespace nowide {
/// Any illegal sequences are replaced with the replacement character, see #BOOST_NOWIDE_REPLACEMENT_CHARACTER
///
template
- std::basic_string basic_convert(std::basic_string const &s)
+ std::basic_string basic_convert(std::basic_string const& s)
{
return basic_convert(s.c_str(), s.c_str() + s.size());
}
@@ -112,9 +112,9 @@ namespace nowide {
/// Any illegal sequences are replaced with the replacement character, see #BOOST_NOWIDE_REPLACEMENT_CHARACTER
///
template
- std::basic_string basic_convert(CharIn const *s)
+ std::basic_string basic_convert(const CharIn* s)
{
- return basic_convert(s, details::basic_strend(s));
+ return basic_convert(s, detail::basic_strend(s));
}
///
@@ -124,9 +124,9 @@ namespace nowide {
/// In case of success output is returned, if there is not enough room NULL is returned.
/// Any illegal sequences are replaced with the replacement character, see #BOOST_NOWIDE_REPLACEMENT_CHARACTER
///
- inline char *narrow(char *output, size_t output_size, wchar_t const *source)
+ inline char* narrow(char* output, size_t output_size, const wchar_t* source)
{
- return basic_convert(output, output_size, source, details::basic_strend(source));
+ return basic_convert(output, output_size, source, detail::basic_strend(source));
}
///
/// Convert UTF text in range [begin,end) to NULL terminated \a output string of size at
@@ -135,7 +135,7 @@ namespace nowide {
/// In case of success output is returned, if there is not enough room NULL is returned.
/// Any illegal sequences are replaced with the replacement character, see #BOOST_NOWIDE_REPLACEMENT_CHARACTER
///
- inline char *narrow(char *output, size_t output_size, wchar_t const *begin, wchar_t const *end)
+ inline char* narrow(char* output, size_t output_size, const wchar_t* begin, const wchar_t* end)
{
return basic_convert(output, output_size, begin, end);
}
@@ -146,9 +146,9 @@ namespace nowide {
/// In case of success output is returned, if there is not enough room NULL is returned.
/// Any illegal sequences are replaced with the replacement character, see #BOOST_NOWIDE_REPLACEMENT_CHARACTER
///
- inline wchar_t *widen(wchar_t *output, size_t output_size, char const *source)
+ inline wchar_t* widen(wchar_t* output, size_t output_size, const char* source)
{
- return basic_convert(output, output_size, source, details::basic_strend(source));
+ return basic_convert(output, output_size, source, detail::basic_strend(source));
}
///
/// Convert UTF text in range [begin,end) to NULL terminated \a output string of size at
@@ -157,7 +157,7 @@ namespace nowide {
/// In case of success output is returned, if there is not enough room NULL is returned.
/// Any illegal sequences are replaced with the replacement character, see #BOOST_NOWIDE_REPLACEMENT_CHARACTER
///
- inline wchar_t *widen(wchar_t *output, size_t output_size, char const *begin, char const *end)
+ inline wchar_t* widen(wchar_t* output, size_t output_size, const char* begin, const char* end)
{
return basic_convert(output, output_size, begin, end);
}
@@ -167,7 +167,7 @@ namespace nowide {
///
/// Any illegal sequences are replaced with the replacement character, see #BOOST_NOWIDE_REPLACEMENT_CHARACTER
///
- inline std::string narrow(wchar_t const *s)
+ inline std::string narrow(const wchar_t* s)
{
return basic_convert(s);
}
@@ -176,7 +176,7 @@ namespace nowide {
///
/// Any illegal sequences are replaced with the replacement character, see #BOOST_NOWIDE_REPLACEMENT_CHARACTER
///
- inline std::wstring widen(char const *s)
+ inline std::wstring widen(const char* s)
{
return basic_convert(s);
}
@@ -185,7 +185,7 @@ namespace nowide {
///
/// Any illegal sequences are replaced with the replacement character, see #BOOST_NOWIDE_REPLACEMENT_CHARACTER
///
- inline std::string narrow(std::wstring const &s)
+ inline std::string narrow(const std::wstring& s)
{
return basic_convert(s);
}
@@ -194,7 +194,7 @@ namespace nowide {
///
/// Any illegal sequences are replaced with the replacement character, see #BOOST_NOWIDE_REPLACEMENT_CHARACTER
///
- inline std::wstring widen(std::string const &s)
+ inline std::wstring widen(const std::string& s)
{
return basic_convert(s);
}
@@ -203,5 +203,3 @@ namespace nowide {
} // namespace boost
#endif
-///
-// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
diff --git a/include/boost/nowide/cstdio.hpp b/include/boost/nowide/cstdio.hpp
index af5c9aa..7a313ad 100644
--- a/include/boost/nowide/cstdio.hpp
+++ b/include/boost/nowide/cstdio.hpp
@@ -5,8 +5,8 @@
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
-#ifndef BOOST_NOWIDE_CSTDIO_H_INCLUDED
-#define BOOST_NOWIDE_CSTDIO_H_INCLUDED
+#ifndef BOOST_NOWIDE_CSTDIO_HPP_INCLUDED
+#define BOOST_NOWIDE_CSTDIO_HPP_INCLUDED
#include
@@ -32,35 +32,35 @@ namespace nowide {
///
/// \brief Same as freopen but file_name and mode are UTF-8 strings
///
- inline FILE *freopen(char const *file_name, char const *mode, FILE *stream)
+ inline FILE* freopen(const char* file_name, const char* mode, FILE* stream)
{
- wstackstring const wname(file_name);
- wshort_stackstring const wmode(mode);
+ const wstackstring wname(file_name);
+ const wshort_stackstring wmode(mode);
return _wfreopen(wname.get(), wmode.get(), stream);
}
///
/// \brief Same as fopen but file_name and mode are UTF-8 strings
///
- inline FILE *fopen(char const *file_name, char const *mode)
+ inline FILE* fopen(const char* file_name, const char* mode)
{
- wstackstring const wname(file_name);
- wshort_stackstring const wmode(mode);
+ const wstackstring wname(file_name);
+ const wshort_stackstring wmode(mode);
return _wfopen(wname.get(), wmode.get());
}
///
/// \brief Same as rename but old_name and new_name are UTF-8 strings
///
- inline int rename(char const *old_name, char const *new_name)
+ inline int rename(const char* old_name, const char* new_name)
{
- wstackstring const wold(old_name), wnew(new_name);
+ const wstackstring wold(old_name), wnew(new_name);
return _wrename(wold.get(), wnew.get());
}
///
/// \brief Same as rename but name is UTF-8 string
///
- inline int remove(char const *name)
+ inline int remove(const char* name)
{
- wstackstring const wname(name);
+ const wstackstring wname(name);
return _wremove(wname.get());
}
#endif
@@ -72,5 +72,3 @@ namespace nowide {
#endif
#endif
-///
-// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
diff --git a/include/boost/nowide/cstdlib.hpp b/include/boost/nowide/cstdlib.hpp
index 4d6d9fc..9fb226e 100644
--- a/include/boost/nowide/cstdlib.hpp
+++ b/include/boost/nowide/cstdlib.hpp
@@ -31,16 +31,16 @@ namespace nowide {
///
/// This function is not thread safe or reenterable as defined by the standard library
///
- inline char *getenv(char const *key)
+ inline char* getenv(const char* key)
{
static stackstring value;
- wshort_stackstring const name(key);
+ const wshort_stackstring name(key);
static const size_t buf_size = 64;
wchar_t buf[buf_size];
std::vector tmp;
- wchar_t *ptr = buf;
+ wchar_t* ptr = buf;
size_t n = GetEnvironmentVariableW(name.get(), buf, buf_size);
if(n == 0 && GetLastError() == 203) // ERROR_ENVVAR_NOT_FOUND
return 0;
@@ -62,16 +62,16 @@ namespace nowide {
/// if overwrite is not 0, that the old value is always overwritten, otherwise,
/// if the variable exists it remains unchanged
///
- inline int setenv(char const *key, char const *value, int overwrite)
+ inline int setenv(const char* key, const char* value, int overwrite)
{
- wshort_stackstring const name(key);
+ const wshort_stackstring name(key);
if(!overwrite)
{
wchar_t unused[2];
if(!(GetEnvironmentVariableW(name.get(), unused, 2) == 0 && GetLastError() == 203)) // ERROR_ENVVAR_NOT_FOUND
return 0;
}
- wstackstring const wval(value);
+ const wstackstring wval(value);
if(SetEnvironmentVariableW(name.get(), wval.get()))
return 0;
return -1;
@@ -79,9 +79,9 @@ namespace nowide {
///
/// \brief Remove environment variable \a key
///
- inline int unsetenv(char const *key)
+ inline int unsetenv(const char* key)
{
- wshort_stackstring const name(key);
+ const wshort_stackstring name(key);
if(SetEnvironmentVariableW(name.get(), 0))
return 0;
return -1;
@@ -89,16 +89,16 @@ namespace nowide {
///
/// \brief UTF-8 aware putenv implementation, expects string in format KEY=VALUE
///
- inline int putenv(char *string)
+ inline int putenv(char* string)
{
- char const *key = string;
- char const *key_end = string;
+ const char* key = string;
+ const char* key_end = string;
while(*key_end != '=' && *key_end != '\0')
key_end++;
if(*key_end == '\0')
return -1;
- wshort_stackstring const wkey(key, key_end);
- wstackstring const wvalue(key_end + 1);
+ const wshort_stackstring wkey(key, key_end);
+ const wstackstring wvalue(key_end + 1);
if(SetEnvironmentVariableW(wkey.get(), wvalue.get()))
return 0;
@@ -108,11 +108,11 @@ namespace nowide {
///
/// Same as std::system but cmd is UTF-8.
///
- inline int system(char const *cmd)
+ inline int system(const char* cmd)
{
if(!cmd)
return _wsystem(0);
- wstackstring const wcmd(cmd);
+ const wstackstring wcmd(cmd);
return _wsystem(wcmd.get());
}
#endif
@@ -120,5 +120,3 @@ namespace nowide {
} // namespace boost
#endif
-///
-// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
diff --git a/include/boost/nowide/detail/utf.hpp b/include/boost/nowide/detail/utf.hpp
index ed43980..cd24522 100644
--- a/include/boost/nowide/detail/utf.hpp
+++ b/include/boost/nowide/detail/utf.hpp
@@ -75,7 +75,7 @@ namespace nowide {
/// - p points to the last consumed character
///
template
- static code_point decode(Iterator &p, Iterator e);
+ static code_point decode(Iterator& p, Iterator e);
///
/// Maximal width of valid sequence in the code units:
@@ -126,7 +126,7 @@ namespace nowide {
/// If the sequence is invalid or points to end the behavior is undefined
///
template
- static code_point decode_valid(Iterator &p);
+ static code_point decode_valid(Iterator& p);
};
#else
@@ -186,7 +186,7 @@ namespace nowide {
}
template
- static code_point decode(Iterator &p, Iterator e)
+ static code_point decode(Iterator& p, Iterator e)
{
if(BOOST_UNLIKELY(p == e))
return incomplete;
@@ -250,7 +250,7 @@ namespace nowide {
}
template
- static code_point decode_valid(Iterator &p)
+ static code_point decode_valid(Iterator& p)
{
unsigned char lead = *p++;
if(lead < 192)
@@ -345,7 +345,7 @@ namespace nowide {
}
template
- static code_point decode(It ¤t, It last)
+ static code_point decode(It& current, It last)
{
if(BOOST_UNLIKELY(current == last))
return incomplete;
@@ -364,7 +364,7 @@ namespace nowide {
return combine_surrogate(w1, w2);
}
template
- static code_point decode_valid(It ¤t)
+ static code_point decode_valid(It& current)
{
uint16_t w1 = *current++;
if(BOOST_LIKELY(w1 < 0xD800 || 0xDFFF < w1))
@@ -416,13 +416,13 @@ namespace nowide {
}
template
- static code_point decode_valid(It ¤t)
+ static code_point decode_valid(It& current)
{
return *current++;
}
template
- static code_point decode(It ¤t, It last)
+ static code_point decode(It& current, It last)
{
if(BOOST_UNLIKELY(current == last))
return incomplete;
diff --git a/include/boost/nowide/filebuf.hpp b/include/boost/nowide/filebuf.hpp
index a175078..fafc863 100644
--- a/include/boost/nowide/filebuf.hpp
+++ b/include/boost/nowide/filebuf.hpp
@@ -6,8 +6,8 @@
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
-#ifndef BOOST_NOWIDE_FILEBUF_HPP
-#define BOOST_NOWIDE_FILEBUF_HPP
+#ifndef BOOST_NOWIDE_FILEBUF_HPP_INCLUDED
+#define BOOST_NOWIDE_FILEBUF_HPP_INCLUDED
#include
#if BOOST_NOWIDE_USE_FSTREAM_REPLACEMENTS
@@ -54,8 +54,8 @@ namespace nowide {
class basic_filebuf : public std::basic_streambuf
{
// Non-copyable
- basic_filebuf(const basic_filebuf &);
- basic_filebuf &operator=(const basic_filebuf &);
+ basic_filebuf(const basic_filebuf&);
+ basic_filebuf& operator=(const basic_filebuf&);
typedef std::char_traits Traits;
@@ -77,26 +77,26 @@ namespace nowide {
///
/// Same as std::filebuf::open but s is UTF-8 string
///
- basic_filebuf *open(std::string const &s, std::ios_base::openmode mode)
+ basic_filebuf* open(const std::string& s, std::ios_base::openmode mode)
{
return open(s.c_str(), mode);
}
///
/// Same as std::filebuf::open but s is UTF-8 string
///
- basic_filebuf *open(char const *s, std::ios_base::openmode mode)
+ basic_filebuf* open(const char* s, std::ios_base::openmode mode)
{
if(is_open())
return NULL;
validate_cvt(this->getloc());
- bool const ate = bool(mode & std::ios_base::ate);
+ const bool ate = bool(mode & std::ios_base::ate);
if(ate)
mode = mode ^ std::ios_base::ate;
- wchar_t const *smode = get_mode(mode);
+ const wchar_t* smode = get_mode(mode);
if(!smode)
return 0;
#ifdef BOOST_WINDOWS
- wstackstring const name(s);
+ const wstackstring name(s);
file_ = ::_wfopen(name.get(), smode);
#else
short_stackstring smode2(smode);
@@ -116,7 +116,7 @@ namespace nowide {
///
/// Same as std::filebuf::close()
///
- basic_filebuf *close()
+ basic_filebuf* close()
{
if(!is_open())
return NULL;
@@ -152,14 +152,14 @@ namespace nowide {
owns_buffer_ = true;
}
}
- void validate_cvt(const std::locale &loc)
+ void validate_cvt(const std::locale& loc)
{
if(!std::use_facet >(loc).always_noconv())
throw std::runtime_error("Converting codecvts are not supported");
}
protected:
- virtual std::streambuf *setbuf(char *s, std::streamsize n)
+ virtual std::streambuf* setbuf(char* s, std::streamsize n)
{
assert(n >= 0);
// Maximum compatibility: Discard all local buffers and use user-provided values
@@ -236,7 +236,7 @@ namespace nowide {
return EOF;
if(buffer_size_ == 0)
{
- int const c = std::fgetc(file_);
+ const int c = std::fgetc(file_);
if(c == EOF)
return EOF;
last_char_ = c;
@@ -244,7 +244,7 @@ namespace nowide {
} else
{
make_buffer();
- size_t const n = std::fread(buffer_, 1, buffer_size_, file_);
+ const size_t n = std::fread(buffer_, 1, buffer_size_, file_);
setg(buffer_, buffer_, buffer_ + n);
if(n == 0)
return EOF;
@@ -305,7 +305,7 @@ namespace nowide {
// Standard mandates "as-if fsetpos", but assume the effect is the same as fseek
return seekoff(pos, std::ios_base::beg, m);
}
- virtual void imbue(const std::locale &loc)
+ virtual void imbue(const std::locale& loc)
{
validate_cvt(loc);
}
@@ -317,7 +317,7 @@ namespace nowide {
{
if(gptr())
{
- std::streamsize const off = gptr() - egptr();
+ const std::streamsize off = gptr() - egptr();
setg(0, 0, 0);
assert(off <= std::numeric_limits::max());
if(off && std::fseek(file_, off, SEEK_CUR) != 0)
@@ -332,8 +332,8 @@ namespace nowide {
{
if(pptr())
{
- const char *const base = pbase();
- size_t const n = pptr() - base;
+ const char* const base = pbase();
+ const size_t n = pptr() - base;
setp(0, 0);
if(n && std::fwrite(base, 1, n, file_) != n)
return false;
@@ -341,7 +341,7 @@ namespace nowide {
return true;
}
- void reset(FILE *f = 0)
+ void reset(FILE* f = 0)
{
sync();
if(file_)
@@ -352,7 +352,7 @@ namespace nowide {
file_ = f;
}
- static wchar_t const *get_mode(std::ios_base::openmode mode)
+ static const wchar_t* get_mode(std::ios_base::openmode mode)
{
//
// done according to n2914 table 106 27.9.1.4
@@ -400,8 +400,8 @@ namespace nowide {
}
size_t buffer_size_;
- char *buffer_;
- FILE *file_;
+ char* buffer_;
+ FILE* file_;
bool owns_buffer_;
char last_char_;
std::ios::openmode mode_;
@@ -422,5 +422,3 @@ namespace nowide {
#endif
#endif
-
-// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
diff --git a/include/boost/nowide/fstream.hpp b/include/boost/nowide/fstream.hpp
index ff90fd3..679a91b 100644
--- a/include/boost/nowide/fstream.hpp
+++ b/include/boost/nowide/fstream.hpp
@@ -5,8 +5,8 @@
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
-#ifndef BOOST_NOWIDE_FSTREAM_INCLUDED_HPP
-#define BOOST_NOWIDE_FSTREAM_INCLUDED_HPP
+#ifndef BOOST_NOWIDE_FSTREAM_HPP_INCLUDED
+#define BOOST_NOWIDE_FSTREAM_HPP_INCLUDED
#include
#include
@@ -49,23 +49,23 @@ namespace nowide {
this->init(&buf_);
}
- explicit basic_ifstream(char const *file_name, std::ios_base::openmode mode = std::ios_base::in) : internal_stream_type(NULL)
+ explicit basic_ifstream(const char* file_name, std::ios_base::openmode mode = std::ios_base::in) : internal_stream_type(NULL)
{
this->init(&buf_);
open(file_name, mode);
}
- explicit basic_ifstream(std::string const &file_name, std::ios_base::openmode mode = std::ios_base::in) : internal_stream_type(NULL)
+ explicit basic_ifstream(const std::string& file_name, std::ios_base::openmode mode = std::ios_base::in) : internal_stream_type(NULL)
{
this->init(&buf_);
open(file_name, mode);
}
- void open(std::string const &file_name, std::ios_base::openmode mode = std::ios_base::in)
+ void open(const std::string& file_name, std::ios_base::openmode mode = std::ios_base::in)
{
open(file_name.c_str(), mode);
}
- void open(char const *file_name, std::ios_base::openmode mode = std::ios_base::in)
+ void open(const char* file_name, std::ios_base::openmode mode = std::ios_base::in)
{
if(!buf_.open(file_name, mode | std::ios_base::in))
this->setstate(std::ios_base::failbit);
@@ -86,9 +86,9 @@ namespace nowide {
this->setstate(std::ios_base::failbit);
}
- internal_buffer_type *rdbuf() const
+ internal_buffer_type* rdbuf() const
{
- return const_cast(&buf_);
+ return const_cast(&buf_);
}
private:
@@ -110,22 +110,22 @@ namespace nowide {
{
this->init(&buf_);
}
- explicit basic_ofstream(char const *file_name, std::ios_base::openmode mode = std::ios_base::out) : internal_stream_type(NULL)
+ explicit basic_ofstream(const char* file_name, std::ios_base::openmode mode = std::ios_base::out) : internal_stream_type(NULL)
{
this->init(&buf_);
open(file_name, mode);
}
- explicit basic_ofstream(std::string const &file_name, std::ios_base::openmode mode = std::ios_base::out) :
+ explicit basic_ofstream(const std::string& file_name, std::ios_base::openmode mode = std::ios_base::out) :
internal_stream_type(NULL)
{
this->init(&buf_);
open(file_name, mode);
}
- void open(std::string const &file_name, std::ios_base::openmode mode = std::ios_base::out)
+ void open(const std::string& file_name, std::ios_base::openmode mode = std::ios_base::out)
{
open(file_name.c_str(), mode);
}
- void open(char const *file_name, std::ios_base::openmode mode = std::ios_base::out)
+ void open(const char* file_name, std::ios_base::openmode mode = std::ios_base::out)
{
if(!buf_.open(file_name, mode | std::ios_base::out))
this->setstate(std::ios_base::failbit);
@@ -146,9 +146,9 @@ namespace nowide {
this->setstate(std::ios_base::failbit);
}
- internal_buffer_type *rdbuf() const
+ internal_buffer_type* rdbuf() const
{
- return const_cast(&buf_);
+ return const_cast(&buf_);
}
private:
@@ -173,23 +173,23 @@ namespace nowide {
{
this->init(&buf_);
}
- explicit basic_fstream(char const *file_name, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out) :
+ explicit basic_fstream(const char* file_name, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out) :
internal_stream_type(NULL)
{
this->init(&buf_);
open(file_name, mode);
}
- explicit basic_fstream(std::string const &file_name, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out) :
+ explicit basic_fstream(const std::string& file_name, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out) :
internal_stream_type(NULL)
{
this->init(&buf_);
open(file_name, mode);
}
- void open(std::string const &file_name, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out)
+ void open(const std::string& file_name, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out)
{
open(file_name.c_str(), mode);
}
- void open(char const *file_name, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out)
+ void open(const char* file_name, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out)
{
if(!buf_.open(file_name, mode))
this->setstate(std::ios_base::failbit);
@@ -210,9 +210,9 @@ namespace nowide {
this->setstate(std::ios_base::failbit);
}
- internal_buffer_type *rdbuf() const
+ internal_buffer_type* rdbuf() const
{
- return const_cast(&buf_);
+ return const_cast(&buf_);
}
private:
@@ -244,4 +244,3 @@ namespace nowide {
} // namespace boost
#endif
-// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
diff --git a/include/boost/nowide/integration/filesystem.hpp b/include/boost/nowide/integration/filesystem.hpp
index 51448da..e06c688 100644
--- a/include/boost/nowide/integration/filesystem.hpp
+++ b/include/boost/nowide/integration/filesystem.hpp
@@ -27,5 +27,3 @@ namespace nowide {
} // namespace boost
#endif
-///
-// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
diff --git a/include/boost/nowide/iostream.hpp b/include/boost/nowide/iostream.hpp
index d2f6a35..135d9a0 100644
--- a/include/boost/nowide/iostream.hpp
+++ b/include/boost/nowide/iostream.hpp
@@ -34,17 +34,17 @@ namespace nowide {
#else
/// \cond INTERNAL
- namespace details {
+ namespace detail {
class console_output_buffer;
class console_input_buffer;
class BOOST_NOWIDE_DECL winconsole_ostream : public std::ostream
{
- winconsole_ostream(winconsole_ostream const &);
- void operator=(winconsole_ostream const &);
+ winconsole_ostream(const winconsole_ostream&);
+ void operator=(const winconsole_ostream&);
public:
- winconsole_ostream(int fd, winconsole_ostream *tieStream);
+ winconsole_ostream(int fd, winconsole_ostream* tieStream);
~winconsole_ostream();
private:
@@ -53,17 +53,17 @@ namespace nowide {
class BOOST_NOWIDE_DECL winconsole_istream : public std::istream
{
- winconsole_istream(winconsole_istream const &);
- void operator=(winconsole_istream const &);
+ winconsole_istream(const winconsole_istream&);
+ void operator=(const winconsole_istream&);
public:
- explicit winconsole_istream(winconsole_ostream *tieStream);
+ explicit winconsole_istream(winconsole_ostream* tieStream);
~winconsole_istream();
private:
boost::scoped_ptr d;
};
- } // namespace details
+ } // namespace detail
/// \endcond
@@ -72,25 +72,25 @@ namespace nowide {
///
/// Note, the stream is not synchronized with stdio and not affected by std::ios::sync_with_stdio
///
- extern BOOST_NOWIDE_DECL details::winconsole_istream cin;
+ extern BOOST_NOWIDE_DECL detail::winconsole_istream cin;
///
/// \brief Same as std::cout, but uses UTF-8
///
/// Note, the stream is not synchronized with stdio and not affected by std::ios::sync_with_stdio
///
- extern BOOST_NOWIDE_DECL details::winconsole_ostream cout;
+ extern BOOST_NOWIDE_DECL detail::winconsole_ostream cout;
///
/// \brief Same as std::cerr, but uses UTF-8
///
/// Note, the stream is not synchronized with stdio and not affected by std::ios::sync_with_stdio
///
- extern BOOST_NOWIDE_DECL details::winconsole_ostream cerr;
+ extern BOOST_NOWIDE_DECL detail::winconsole_ostream cerr;
///
/// \brief Same as std::clog, but uses UTF-8
///
/// Note, the stream is not synchronized with stdio and not affected by std::ios::sync_with_stdio
///
- extern BOOST_NOWIDE_DECL details::winconsole_ostream clog;
+ extern BOOST_NOWIDE_DECL detail::winconsole_ostream clog;
#endif
@@ -106,5 +106,3 @@ namespace nowide {
#endif
#endif
-///
-// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
diff --git a/include/boost/nowide/replacement.hpp b/include/boost/nowide/replacement.hpp
index 82d2fbf..c8e2468 100644
--- a/include/boost/nowide/replacement.hpp
+++ b/include/boost/nowide/replacement.hpp
@@ -17,4 +17,3 @@
#endif
#endif // boost/nowide/replacement.hpp
-// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
diff --git a/include/boost/nowide/stackstring.hpp b/include/boost/nowide/stackstring.hpp
index 228b34e..9fcfed9 100644
--- a/include/boost/nowide/stackstring.hpp
+++ b/include/boost/nowide/stackstring.hpp
@@ -5,8 +5,8 @@
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
-#ifndef BOOST_NOWIDE_DETAILS_WIDESTR_H_INCLUDED
-#define BOOST_NOWIDE_DETAILS_WIDESTR_H_INCLUDED
+#ifndef BOOST_NOWIDE_STACKSTRING_HPP_INCLUDED
+#define BOOST_NOWIDE_STACKSTRING_HPP_INCLUDED
#include
#include
@@ -34,12 +34,12 @@ namespace nowide {
typedef CharOut output_char;
typedef CharIn input_char;
- basic_stackstring(basic_stackstring const &other) : data_(NULL)
+ basic_stackstring(const basic_stackstring& other) : data_(NULL)
{
*this = other;
}
- friend void swap(basic_stackstring &lhs, basic_stackstring &rhs)
+ friend void swap(basic_stackstring& lhs, basic_stackstring& rhs)
{
if(lhs.uses_stack_memory())
{
@@ -63,7 +63,7 @@ namespace nowide {
} else
std::swap(lhs.data_, rhs.data_);
}
- basic_stackstring &operator=(basic_stackstring const &other)
+ basic_stackstring& operator=(const basic_stackstring& other)
{
if(this != &other)
{
@@ -82,22 +82,22 @@ namespace nowide {
{
buffer_[0] = 0;
}
- explicit basic_stackstring(input_char const *input) : data_(NULL)
+ explicit basic_stackstring(const input_char* input) : data_(NULL)
{
convert(input);
}
- basic_stackstring(input_char const *begin, input_char const *end) : data_(NULL)
+ basic_stackstring(const input_char* begin, const input_char* end) : data_(NULL)
{
convert(begin, end);
}
- output_char *convert(input_char const *input)
+ output_char* convert(const input_char* input)
{
if(input)
- return convert(input, details::basic_strend(input));
+ return convert(input, detail::basic_strend(input));
clear();
return get();
}
- output_char *convert(input_char const *begin, input_char const *end)
+ output_char* convert(const input_char* begin, const input_char* end)
{
clear();
@@ -117,12 +117,12 @@ namespace nowide {
return get();
}
/// Return the converted, NULL-terminated string or NULL if no string was converted
- output_char *get()
+ output_char* get()
{
return data_;
}
/// Return the converted, NULL-terminated string or NULL if no string was converted
- output_char const *get() const
+ const output_char* get() const
{
return data_;
}
@@ -164,23 +164,23 @@ namespace nowide {
return 2 * in;
}
output_char buffer_[buffer_size];
- output_char *data_;
+ output_char* data_;
}; // basic_stackstring
///
- /// Convinience typedef
+ /// Convenience typedef
///
typedef basic_stackstring wstackstring;
///
- /// Convinience typedef
+ /// Convenience typedef
///
typedef basic_stackstring stackstring;
///
- /// Convinience typedef
+ /// Convenience typedef
///
typedef basic_stackstring wshort_stackstring;
///
- /// Convinience typedef
+ /// Convenience typedef
///
typedef basic_stackstring short_stackstring;
@@ -188,5 +188,3 @@ namespace nowide {
} // namespace boost
#endif
-///
-// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
diff --git a/include/boost/nowide/utf8_codecvt.hpp b/include/boost/nowide/utf8_codecvt.hpp
index 9104e30..ff90684 100644
--- a/include/boost/nowide/utf8_codecvt.hpp
+++ b/include/boost/nowide/utf8_codecvt.hpp
@@ -5,8 +5,8 @@
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
-#ifndef BOOST_NOWIDE_UTF8_CODECVT_HPP
-#define BOOST_NOWIDE_UTF8_CODECVT_HPP
+#ifndef BOOST_NOWIDE_UTF8_CODECVT_HPP_INCLUDED
+#define BOOST_NOWIDE_UTF8_CODECVT_HPP_INCLUDED
#include
#include
@@ -21,12 +21,38 @@ namespace nowide {
// Make sure that mbstate can keep 16 bit of UTF-16 sequence
//
BOOST_STATIC_ASSERT(sizeof(std::mbstate_t) >= 2);
+ namespace detail {
+ // Avoid including cstring for std::memcpy
+ inline void copy_uint16_t(void* dst, const void* src)
+ {
+ unsigned char* cdst = static_cast(dst);
+ const unsigned char* csrc = static_cast(src);
+ cdst[0] = csrc[0];
+ cdst[1] = csrc[1];
+ }
+ inline boost::uint16_t read_state(const std::mbstate_t& src)
+ {
+ boost::uint16_t dst;
+ copy_uint16_t(&dst, &src);
+ return dst;
+ }
+ inline void write_state(std::mbstate_t& dst, const boost::uint16_t src)
+ {
+ copy_uint16_t(&dst, &src);
+ }
+ } // namespace detail
#if defined _MSC_VER && _MSC_VER < 1700
// MSVC do_length is non-standard it counts wide characters instead of narrow and does not change mbstate
#define BOOST_NOWIDE_DO_LENGTH_MBSTATE_CONST
#endif
+ /// std::codecvt implementation that converts between UTF-8 and UTF-16 or UTF-32
+ ///
+ /// @tparam CharSize Determines the encoding: 2 for UTF-16, 4 for UTF-32
+ ///
+ /// Invalid sequences are replaced by #BOOST_NOWIDE_REPLACEMENT_CHARACTER
+ /// A trailing incomplete sequence will result in a return value of std::codecvt::partial
template
class utf8_codecvt;
@@ -42,10 +68,9 @@ namespace nowide {
protected:
typedef CharType uchar;
- virtual std::codecvt_base::result do_unshift(std::mbstate_t &s, char *from, char * /*to*/, char *&next) const
+ virtual std::codecvt_base::result do_unshift(std::mbstate_t& s, char* from, char* /*to*/, char*& next) const
{
- boost::uint16_t &state = *reinterpret_cast(&s);
- if(state != 0)
+ if(detail::read_state(s) != 0)
return std::codecvt_base::error;
next = from;
return std::codecvt_base::ok;
@@ -67,21 +92,20 @@ namespace nowide {
#ifdef BOOST_NOWIDE_DO_LENGTH_MBSTATE_CONST
const
#endif
- &std_state,
- char const *from,
- char const *from_end,
+ & std_state,
+ const char* from,
+ const char* from_end,
size_t max) const
{
+ boost::uint16_t state = detail::read_state(std_state);
#ifndef BOOST_NOWIDE_DO_LENGTH_MBSTATE_CONST
- char const *save_from = from;
- boost::uint16_t &state = *reinterpret_cast(&std_state);
+ const char* save_from = from;
#else
size_t save_max = max;
- boost::uint16_t state = *reinterpret_cast(&std_state);
#endif
while(max > 0 && from < from_end)
{
- char const *prev_from = from;
+ const char* prev_from = from;
boost::uint32_t ch = detail::utf::utf_traits::decode(from, from_end);
if(ch == detail::utf::illegal)
{
@@ -105,19 +129,20 @@ namespace nowide {
}
}
#ifndef BOOST_NOWIDE_DO_LENGTH_MBSTATE_CONST
+ detail::write_state(std_state, state);
return static_cast(from - save_from);
#else
return static_cast(save_max - max);
#endif
}
- virtual std::codecvt_base::result do_in(std::mbstate_t &std_state,
- char const *from,
- char const *from_end,
- char const *&from_next,
- uchar *to,
- uchar *to_end,
- uchar *&to_next) const
+ virtual std::codecvt_base::result do_in(std::mbstate_t& std_state,
+ const char* from,
+ const char* from_end,
+ const char*& from_next,
+ uchar* to,
+ uchar* to_end,
+ uchar*& to_next) const
{
std::codecvt_base::result r = std::codecvt_base::ok;
@@ -126,10 +151,10 @@ namespace nowide {
//
// if 0 no code above >0xFFFF observed, of 1 a code above 0xFFFF observed
// and first pair is written, but no input consumed
- boost::uint16_t &state = *reinterpret_cast(&std_state);
+ boost::uint16_t state = detail::read_state(std_state);
while(to < to_end && from < from_end)
{
- char const *from_saved = from;
+ const char* from_saved = from;
uint32_t ch = detail::utf::utf_traits::decode(from, from_end);
@@ -178,16 +203,17 @@ namespace nowide {
to_next = to;
if(r == std::codecvt_base::ok && (from != from_end || state != 0))
r = std::codecvt_base::partial;
+ detail::write_state(std_state, state);
return r;
}
- virtual std::codecvt_base::result do_out(std::mbstate_t &std_state,
- uchar const *from,
- uchar const *from_end,
- uchar const *&from_next,
- char *to,
- char *to_end,
- char *&to_next) const
+ virtual std::codecvt_base::result do_out(std::mbstate_t& std_state,
+ const uchar* from,
+ const uchar* from_end,
+ const uchar*& from_next,
+ char* to,
+ char* to_end,
+ char*& to_next) const
{
std::codecvt_base::result r = std::codecvt_base::ok;
// mbstate_t is POD type and should be initialized to 0 (i.a. state = stateT())
@@ -197,7 +223,7 @@ namespace nowide {
// State: state!=0 - a first surrogate pair was observed (state = first pair),
// we expect the second one to come and then zero the state
///
- boost::uint16_t &state = *reinterpret_cast(&std_state);
+ boost::uint16_t state = detail::read_state(std_state);
while(to < to_end && from < from_end)
{
boost::uint32_t ch = 0;
@@ -258,6 +284,7 @@ namespace nowide {
to_next = to;
if(r == std::codecvt_base::ok && from != from_end)
r = std::codecvt_base::partial;
+ detail::write_state(std_state, state);
return r;
}
};
@@ -272,7 +299,7 @@ namespace nowide {
protected:
typedef CharType uchar;
- virtual std::codecvt_base::result do_unshift(std::mbstate_t & /*s*/, char *from, char * /*to*/, char *&next) const
+ virtual std::codecvt_base::result do_unshift(std::mbstate_t& /*s*/, char* from, char* /*to*/, char*& next) const
{
next = from;
return std::codecvt_base::ok;
@@ -295,19 +322,19 @@ namespace nowide {
const
#endif
& /*state*/,
- char const *from,
- char const *from_end,
+ const char* from,
+ const char* from_end,
size_t max) const
{
#ifndef BOOST_NOWIDE_DO_LENGTH_MBSTATE_CONST
- char const *start_from = from;
+ const char* start_from = from;
#else
size_t save_max = max;
#endif
while(max > 0 && from < from_end)
{
- char const *save_from = from;
+ const char* save_from = from;
boost::uint32_t ch = detail::utf::utf_traits::decode(from, from_end);
if(ch == detail::utf::incomplete)
{
@@ -326,24 +353,19 @@ namespace nowide {
#endif
}
- virtual std::codecvt_base::result do_in(std::mbstate_t & /*state*/,
- char const *from,
- char const *from_end,
- char const *&from_next,
- uchar *to,
- uchar *to_end,
- uchar *&to_next) const
+ virtual std::codecvt_base::result do_in(std::mbstate_t& /*state*/,
+ const char* from,
+ const char* from_end,
+ const char*& from_next,
+ uchar* to,
+ uchar* to_end,
+ uchar*& to_next) const
{
std::codecvt_base::result r = std::codecvt_base::ok;
- // mbstate_t is POD type and should be initialized to 0 (i.a. state = stateT())
- // according to standard. We use it to keep a flag 0/1 for surrogate pair writing
- //
- // if 0 no code above >0xFFFF observed, of 1 a code above 0xFFFF observed
- // and first pair is written, but no input consumed
while(to < to_end && from < from_end)
{
- char const *from_saved = from;
+ const char* from_saved = from;
uint32_t ch = detail::utf::utf_traits::decode(from, from_end);
@@ -365,13 +387,13 @@ namespace nowide {
return r;
}
- virtual std::codecvt_base::result do_out(std::mbstate_t & /*std_state*/,
- uchar const *from,
- uchar const *from_end,
- uchar const *&from_next,
- char *to,
- char *to_end,
- char *&to_next) const
+ virtual std::codecvt_base::result do_out(std::mbstate_t& /*std_state*/,
+ const uchar* from,
+ const uchar* from_end,
+ const uchar*& from_next,
+ char* to,
+ char* to_end,
+ char*& to_next) const
{
std::codecvt_base::result r = std::codecvt_base::ok;
while(to < to_end && from < from_end)
@@ -403,5 +425,3 @@ namespace nowide {
} // namespace boost
#endif
-///
-// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
diff --git a/include/boost/nowide/windows.hpp b/include/boost/nowide/windows.hpp
index fb7e26d..63fad3f 100644
--- a/include/boost/nowide/windows.hpp
+++ b/include/boost/nowide/windows.hpp
@@ -17,18 +17,16 @@
//
extern "C" {
-__declspec(dllimport) wchar_t *__stdcall GetEnvironmentStringsW(void);
-__declspec(dllimport) int __stdcall FreeEnvironmentStringsW(wchar_t *);
-__declspec(dllimport) wchar_t *__stdcall GetCommandLineW(void);
-__declspec(dllimport) wchar_t **__stdcall CommandLineToArgvW(wchar_t const *, int *);
+__declspec(dllimport) wchar_t* __stdcall GetEnvironmentStringsW(void);
+__declspec(dllimport) int __stdcall FreeEnvironmentStringsW(wchar_t*);
+__declspec(dllimport) wchar_t* __stdcall GetCommandLineW(void);
+__declspec(dllimport) wchar_t** __stdcall CommandLineToArgvW(const wchar_t*, int*);
__declspec(dllimport) unsigned long __stdcall GetLastError();
-__declspec(dllimport) void *__stdcall LocalFree(void *);
-__declspec(dllimport) int __stdcall SetEnvironmentVariableW(wchar_t const *, wchar_t const *);
-__declspec(dllimport) unsigned long __stdcall GetEnvironmentVariableW(wchar_t const *, wchar_t *, unsigned long);
+__declspec(dllimport) void* __stdcall LocalFree(void*);
+__declspec(dllimport) int __stdcall SetEnvironmentVariableW(const wchar_t*, const wchar_t*);
+__declspec(dllimport) unsigned long __stdcall GetEnvironmentVariableW(const wchar_t*, wchar_t*, unsigned long);
}
#endif
#endif
-///
-// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
diff --git a/src/iostream.cpp b/src/iostream.cpp
index 499dcd3..a46bc4a 100644
--- a/src/iostream.cpp
+++ b/src/iostream.cpp
@@ -32,7 +32,7 @@ namespace nowide {
namespace boost {
namespace nowide {
- namespace details {
+ namespace detail {
namespace {
bool is_atty_handle(HANDLE h)
@@ -78,15 +78,15 @@ namespace nowide {
}
private:
- int write(char const *p, int n)
+ int write(const char* p, int n)
{
namespace uf = detail::utf;
- char const *b = p;
- char const *e = p + n;
+ const char* b = p;
+ const char* e = p + n;
DWORD size = 0;
if(n > buffer_size)
return -1;
- wchar_t *out = wbuffer_;
+ wchar_t* out = wbuffer_;
uf::code_point c;
size_t decoded = 0;
while(p < e && (c = uf::utf_traits::decode(p, e)) != uf::incomplete)
@@ -129,8 +129,8 @@ namespace nowide {
if(pback_buffer_.empty())
{
pback_buffer_.resize(4);
- char *b = &pback_buffer_[0];
- char *e = b + pback_buffer_.size();
+ char* b = &pback_buffer_[0];
+ char* e = b + pback_buffer_.size();
setg(b, e - 1, e);
*gptr() = traits_type::to_char_type(c);
} else
@@ -140,9 +140,9 @@ namespace nowide {
tmp.resize(n * 2);
memcpy(&tmp[n], &pback_buffer_[0], n);
tmp.swap(pback_buffer_);
- char *b = &pback_buffer_[0];
- char *e = b + n * 2;
- char *p = b + n - 1;
+ char* b = &pback_buffer_[0];
+ char* e = b + n * 2;
+ char* p = b + n - 1;
*p = traits_type::to_char_type(c);
setg(b, p, e);
}
@@ -173,10 +173,10 @@ namespace nowide {
if(!ReadConsoleW(handle_, wbuffer_, static_cast(n), &read_wchars, 0))
return 0;
wsize_ += read_wchars;
- char *out = buffer_;
- wchar_t *b = wbuffer_;
- wchar_t *e = b + wsize_;
- wchar_t *p = b;
+ char* out = buffer_;
+ wchar_t* b = wbuffer_;
+ wchar_t* e = b + wsize_;
+ wchar_t* p = b;
uf::code_point c = 0;
wsize_ = e - p;
while(p < e && (c = uf::utf_traits::decode(p, e)) != uf::illegal && c != uf::incomplete)
@@ -205,7 +205,7 @@ namespace nowide {
std::vector pback_buffer_;
};
- winconsole_ostream::winconsole_ostream(int fd, winconsole_ostream *tieStream) : std::ostream(0)
+ winconsole_ostream::winconsole_ostream(int fd, winconsole_ostream* tieStream) : std::ostream(0)
{
HANDLE h = 0;
switch(fd)
@@ -233,7 +233,7 @@ namespace nowide {
{}
}
- winconsole_istream::winconsole_istream(winconsole_ostream *tieStream) : std::istream(0)
+ winconsole_istream::winconsole_istream(winconsole_ostream* tieStream) : std::istream(0)
{
HANDLE h = GetStdHandle(STD_INPUT_HANDLE);
if(is_atty_handle(h))
@@ -251,15 +251,13 @@ namespace nowide {
winconsole_istream::~winconsole_istream()
{}
- } // namespace details
+ } // namespace detail
- details::winconsole_ostream cout(1, NULL);
- details::winconsole_istream cin(&cout);
- details::winconsole_ostream cerr(2, &cout);
- details::winconsole_ostream clog(2, &cout);
+ detail::winconsole_ostream cout(1, NULL);
+ detail::winconsole_istream cin(&cout);
+ detail::winconsole_ostream cerr(2, &cout);
+ detail::winconsole_ostream clog(2, &cout);
} // namespace nowide
} // namespace boost
#endif
-///
-// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
diff --git a/standalone/config.hpp b/standalone/config.hpp
index 57d3936..ec438ae 100644
--- a/standalone/config.hpp
+++ b/standalone/config.hpp
@@ -40,5 +40,3 @@
#endif
#endif
-///
-// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
diff --git a/standalone/scoped_ptr.hpp b/standalone/scoped_ptr.hpp
index cde55ab..37761a9 100644
--- a/standalone/scoped_ptr.hpp
+++ b/standalone/scoped_ptr.hpp
@@ -25,20 +25,20 @@ template
class scoped_ptr // noncopyable
{
private:
- T *px;
+ T* px;
- scoped_ptr(scoped_ptr const &);
- scoped_ptr &operator=(scoped_ptr const &);
+ scoped_ptr(scoped_ptr const&);
+ scoped_ptr& operator=(scoped_ptr const&);
typedef scoped_ptr this_type;
- void operator==(scoped_ptr const &) const;
- void operator!=(scoped_ptr const &) const;
+ void operator==(scoped_ptr const&) const;
+ void operator!=(scoped_ptr const&) const;
public:
typedef T element_type;
- explicit scoped_ptr(T *p = 0) : px(p) // never throws
+ explicit scoped_ptr(T* p = 0) : px(p) // never throws
{}
~scoped_ptr() // never throws
@@ -46,25 +46,25 @@ public:
delete px;
}
- void reset(T *p = 0) // never throws
+ void reset(T* p = 0) // never throws
{
assert(p == 0 || p != px); // catch self-reset errors
this_type(p).swap(*this);
}
- T &operator*() const // never throws
+ T& operator*() const // never throws
{
assert(px != 0);
return *px;
}
- T *operator->() const // never throws
+ T* operator->() const // never throws
{
assert(px != 0);
return px;
}
- T *get() const // never throws
+ T* get() const // never throws
{
return px;
}
@@ -74,9 +74,9 @@ public:
return px != 0;
}
- void swap(scoped_ptr &b) // never throws
+ void swap(scoped_ptr& b) // never throws
{
- T *tmp = b.px;
+ T* tmp = b.px;
b.px = px;
px = tmp;
}
@@ -85,4 +85,3 @@ public:
} // namespace nowide
#endif
-// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index af17246..9d5d4e1 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -22,10 +22,10 @@ boost_nowide_add_test(test_fstream)
boost_nowide_add_test(test_iostream)
boost_nowide_add_test(test_stackstring)
boost_nowide_add_test(test_stdio)
-boost_nowide_add_test(test_system_n SRC test_system.cpp ARGS -n)
+boost_nowide_add_test(test_system_n SRC test_system.cpp DEFINITIONS BOOST_NOWIDE_TEST_USE_NARROW=1)
if(WIN32)
- boost_nowide_add_test(test_system_w SRC test_system.cpp ARGS -w)
+ boost_nowide_add_test(test_system_w SRC test_system.cpp DEFINITIONS BOOST_NOWIDE_TEST_USE_NARROW=0)
else()
boost_nowide_add_test(test_internal_fstream SRC test_fstream.cpp DEFINITIONS BOOST_NOWIDE_USE_FSTREAM_REPLACEMENTS=1)
endif()
diff --git a/test/Jamfile.v2 b/test/Jamfile.v2
index 5aa498e..e14a636 100644
--- a/test/Jamfile.v2
+++ b/test/Jamfile.v2
@@ -31,7 +31,7 @@ run test_iostream.cpp : : : /boost/nowide//boost_nowide static :
run test_iostream.cpp : : : /boost/nowide//boost_nowide shared : test_iostream_shared ;
run test_stackstring.cpp ;
run test_stdio.cpp ;
-run test_system.cpp : "-n" : : windows:shell32 : test_system_n ;
-run test_system.cpp : "-w" : : windows:shell32 no windows:yes: test_system_w ;
+run test_system.cpp : : : BOOST_NOWIDE_TEST_USE_NARROW=1 windows:shell32 : test_system_n ;
+run test_system.cpp : : : BOOST_NOWIDE_TEST_USE_NARROW=0 windows:shell32 no windows:yes: test_system_w ;
compile benchmark_fstream.cpp : BOOST_NOWIDE_USE_WIN_FSTREAM=1 /boost/chrono//boost_chrono/;
diff --git a/test/benchmark_fstream.cpp b/test/benchmark_fstream.cpp
index 9e985a4..4ddd0f7 100644
--- a/test/benchmark_fstream.cpp
+++ b/test/benchmark_fstream.cpp
@@ -27,16 +27,16 @@ template
class io_fstream
{
public:
- void open(char const *file)
+ void open(const char* file)
{
f_.open(file, std::fstream::out | std::fstream::in | std::fstream::trunc);
TEST(f_);
}
- void write(char *buf, int size)
+ void write(char* buf, int size)
{
f_.write(buf, size);
}
- void read(char *buf, int size)
+ void read(char* buf, int size)
{
f_.read(buf, size);
}
@@ -61,16 +61,16 @@ private:
class io_stdio
{
public:
- void open(char const *file)
+ void open(const char* file)
{
f_ = fopen(file, "w+");
TEST(f_);
}
- void write(char *buf, int size)
+ void write(char* buf, int size)
{
fwrite(buf, 1, size, f_);
}
- void read(char *buf, int size)
+ void read(char* buf, int size)
{
size_t res = fread(buf, 1, size, f_);
(void)res;
@@ -90,11 +90,11 @@ public:
}
private:
- FILE *f_;
+ FILE* f_;
};
template
-void test_io(const char *file, char const *type)
+void test_io(const char* file, const char* type)
{
std::cout << "Testing I/O performance " << type << std::endl;
FStream tmp;
@@ -139,14 +139,14 @@ void test_io(const char *file, char const *type)
std::remove(file);
}
-void test_perf(const char *file)
+void test_perf(const char* file)
{
test_io(file, "stdio");
test_io >(file, "std::fstream");
test_io >(file, "nowide::fstream");
}
-int main(int argc, char **argv)
+int main(int argc, char** argv)
{
std::string filename = "perf_test_file.dat";
if(argc == 2)
diff --git a/test/exampleProject/example_main.cpp b/test/exampleProject/example_main.cpp
index 1c246c7..9124598 100644
--- a/test/exampleProject/example_main.cpp
+++ b/test/exampleProject/example_main.cpp
@@ -9,7 +9,7 @@
#include
#include
-int main(int argc, char **argv, char **env)
+int main(int argc, char** argv, char** env)
{
boost::nowide::args _(argc, argv, env);
if(argc < 1)
diff --git a/test/test.hpp b/test/test.hpp
index d1f046e..c7faeea 100644
--- a/test/test.hpp
+++ b/test/test.hpp
@@ -13,7 +13,7 @@
#include
/// Function called when a test failed to be able set a breakpoint for debugging
-inline void test_failed(const std::string &msg)
+inline void test_failed(const std::string& msg)
{
throw std::runtime_error(msg);
}
@@ -29,5 +29,3 @@ inline void test_failed(const std::string &msg)
} while(0)
#endif // #ifndef BOOST_NOWIDE_LIB_TEST_H_INCLUDED
-///
-// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
diff --git a/test/test_codecvt.cpp b/test/test_codecvt.cpp
index 25312db..29f48fa 100644
--- a/test/test_codecvt.cpp
+++ b/test/test_codecvt.cpp
@@ -16,11 +16,11 @@
#include
#include
-static char const *utf8_name = "\xf0\x9d\x92\x9e-\xD0\xBF\xD1\x80\xD0\xB8\xD0\xB2\xD0\xB5\xD1\x82-\xE3\x82\x84\xE3\x81\x82.txt";
+static const char* utf8_name = "\xf0\x9d\x92\x9e-\xD0\xBF\xD1\x80\xD0\xB8\xD0\xB2\xD0\xB5\xD1\x82-\xE3\x82\x84\xE3\x81\x82.txt";
static const std::wstring wide_name_str = boost::nowide::widen(utf8_name);
-static wchar_t const *wide_name = wide_name_str.c_str();
+static const wchar_t* wide_name = wide_name_str.c_str();
-char const *res(std::codecvt_base::result r)
+const char* res(std::codecvt_base::result r)
{
switch(r)
{
@@ -34,15 +34,15 @@ char const *res(std::codecvt_base::result r)
typedef std::codecvt cvt_type;
-void test_codecvt_in_n_m(cvt_type const &cvt, int n, int m)
+void test_codecvt_in_n_m(const cvt_type& cvt, int n, int m)
{
- wchar_t const *wptr = wide_name;
+ const wchar_t* wptr = wide_name;
size_t wlen = std::wcslen(wide_name);
size_t u8len = std::strlen(utf8_name);
- char const *from = utf8_name;
- char const *end = from;
- char const *real_end = utf8_name + u8len;
- char const *from_next = from;
+ const char* from = utf8_name;
+ const char* end = from;
+ const char* real_end = utf8_name + u8len;
+ const char* from_next = from;
std::mbstate_t mb = std::mbstate_t();
while(from_next < real_end)
{
@@ -54,9 +54,9 @@ void test_codecvt_in_n_m(cvt_type const &cvt, int n, int m)
}
wchar_t buf[128];
- wchar_t *to = buf;
- wchar_t *to_end = to + m;
- wchar_t *to_next = to;
+ wchar_t* to = buf;
+ wchar_t* to_end = to + m;
+ wchar_t* to_next = to;
std::mbstate_t mb2 = mb;
std::codecvt_base::result r = cvt.in(mb, from, end, from_next, to, to_end, to_next);
@@ -95,27 +95,27 @@ void test_codecvt_in_n_m(cvt_type const &cvt, int n, int m)
TEST(from == real_end);
}
-void test_codecvt_out_n_m(cvt_type const &cvt, int n, int m)
+void test_codecvt_out_n_m(const cvt_type& cvt, int n, int m)
{
- char const *nptr = utf8_name;
+ const char* nptr = utf8_name;
size_t wlen = std::wcslen(wide_name);
size_t u8len = std::strlen(utf8_name);
std::mbstate_t mb = std::mbstate_t();
- wchar_t const *from_next = wide_name;
- wchar_t const *real_from_end = wide_name + wlen;
+ const wchar_t* from_next = wide_name;
+ const wchar_t* real_from_end = wide_name + wlen;
char buf[256];
- char *to = buf;
- char *to_next = to;
- char *to_end = to + n;
- char *real_to_end = buf + sizeof(buf);
+ char* to = buf;
+ char* to_next = to;
+ char* to_end = to + n;
+ char* real_to_end = buf + sizeof(buf);
while(from_next < real_from_end)
{
- wchar_t const *from = from_next;
- wchar_t const *from_end = from + m;
+ const wchar_t* from = from_next;
+ const wchar_t* from_end = from + m;
if(from_end > real_from_end)
from_end = real_from_end;
if(to_end == to)
@@ -156,7 +156,7 @@ void test_codecvt_conv()
std::cout << "Conversions " << std::endl;
std::locale l(std::locale::classic(), new boost::nowide::utf8_codecvt());
- cvt_type const &cvt = std::use_facet(l);
+ const cvt_type& cvt = std::use_facet(l);
for(int i = 1; i <= (int)std::strlen(utf8_name) + 1; i++)
{
@@ -180,20 +180,20 @@ void test_codecvt_err()
std::cout << "Errors " << std::endl;
std::locale l(std::locale::classic(), new boost::nowide::utf8_codecvt());
- cvt_type const &cvt = std::use_facet(l);
+ const cvt_type& cvt = std::use_facet(l);
std::cout << "- UTF-8" << std::endl;
{
wchar_t buf[4];
- wchar_t *const to = buf;
- wchar_t *const to_end = buf + 4;
- char const *err_utf = "1\xFF\xFF\xd7\xa9";
+ wchar_t* const to = buf;
+ wchar_t* const to_end = buf + 4;
+ const char* err_utf = "1\xFF\xFF\xd7\xa9";
{
std::mbstate_t mb = std::mbstate_t();
- char const *from = err_utf;
- char const *from_end = from + std::strlen(from);
- char const *from_next = from;
- wchar_t *to_next = to;
+ const char* from = err_utf;
+ const char* from_end = from + std::strlen(from);
+ const char* from_next = from;
+ wchar_t* to_next = to;
TEST(cvt.in(mb, from, from_end, from_next, to, to_end, to_next) == cvt_type::ok);
TEST(from_next == from + 5);
TEST(to_next == to + 4);
@@ -204,16 +204,16 @@ void test_codecvt_err()
std::cout << "- UTF-16/32" << std::endl;
{
char buf[32];
- char *to = buf;
- char *to_end = buf + 32;
- char *to_next = to;
+ char* to = buf;
+ char* to_end = buf + 32;
+ char* to_next = to;
wchar_t err_buf[3] = {'1', 0xDC9E, 0}; // second surrogate not works both for UTF-16 and 32
- wchar_t const *err_utf = err_buf;
+ const wchar_t* err_utf = err_buf;
{
std::mbstate_t mb = std::mbstate_t();
- wchar_t const *from = err_utf;
- wchar_t const *from_end = from + std::wcslen(from);
- wchar_t const *from_next = from;
+ const wchar_t* from = err_utf;
+ const wchar_t* from_end = from + std::wcslen(from);
+ const wchar_t* from_next = from;
TEST(cvt.out(mb, from, from_end, from_next, to, to_end, to_next) == cvt_type::ok);
TEST(from_next == from + 2);
TEST(to_next == to + 4);
@@ -222,21 +222,21 @@ void test_codecvt_err()
}
}
-std::wstring codecvt_to_wide(std::string const &s)
+std::wstring codecvt_to_wide(const std::string& s)
{
std::locale l(std::locale::classic(), new boost::nowide::utf8_codecvt());
- cvt_type const &cvt = std::use_facet(l);
+ const cvt_type& cvt = std::use_facet(l);
std::mbstate_t mb = std::mbstate_t();
- char const *from = s.c_str();
- char const *from_end = from + s.size();
- char const *from_next = from;
+ const char* from = s.c_str();
+ const char* from_end = from + s.size();
+ const char* from_next = from;
std::vector buf(s.size() + 1);
- wchar_t *to = &buf[0];
- wchar_t *to_end = to + buf.size();
- wchar_t *to_next = to;
+ wchar_t* to = &buf[0];
+ wchar_t* to_end = to + buf.size();
+ wchar_t* to_next = to;
TEST(cvt.in(mb, from, from_end, from_next, to, to_end, to_next) == cvt_type::ok);
@@ -244,21 +244,21 @@ std::wstring codecvt_to_wide(std::string const &s)
return res;
}
-std::string codecvt_to_narrow(std::wstring const &s)
+std::string codecvt_to_narrow(const std::wstring& s)
{
std::locale l(std::locale::classic(), new boost::nowide::utf8_codecvt());
- cvt_type const &cvt = std::use_facet(l);
+ const cvt_type& cvt = std::use_facet(l);
std::mbstate_t mb = std::mbstate_t();
- wchar_t const *from = s.c_str();
- wchar_t const *from_end = from + s.size();
- wchar_t const *from_next = from;
+ const wchar_t* from = s.c_str();
+ const wchar_t* from_end = from + s.size();
+ const wchar_t* from_next = from;
std::vector buf(s.size() * 4 + 1);
- char *to = &buf[0];
- char *to_end = to + buf.size();
- char *to_next = to;
+ char* to = &buf[0];
+ char* to_end = to + buf.size();
+ char* to_next = to;
TEST(cvt.out(mb, from, from_end, from_next, to, to_end, to_next) == cvt_type::ok);
@@ -280,7 +280,7 @@ int main()
test_codecvt_err();
test_codecvt_subst();
- } catch(std::exception const &e)
+ } catch(const std::exception& e)
{
std::cerr << "Failed : " << e.what() << std::endl;
return 1;
@@ -288,5 +288,3 @@ int main()
return 0;
}
-///
-// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
diff --git a/test/test_convert.cpp b/test/test_convert.cpp
index a4c9667..dcb3d10 100644
--- a/test/test_convert.cpp
+++ b/test/test_convert.cpp
@@ -29,8 +29,8 @@ int main()
std::cout << "- boost::nowide::widen" << std::endl;
{
- char const *b = hello.c_str();
- char const *e = b + 8;
+ const char* b = hello.c_str();
+ const char* e = b + 8;
wchar_t buf[6] = {0, 0, 0, 0, 0, 1};
TEST(boost::nowide::widen(buf, 5, b, e) == buf);
TEST(buf == whello);
@@ -60,8 +60,8 @@ int main()
}
std::cout << "- boost::nowide::narrow" << std::endl;
{
- wchar_t const *b = whello.c_str();
- wchar_t const *e = b + 4;
+ const wchar_t* b = whello.c_str();
+ const wchar_t* e = b + 4;
char buf[10] = {0};
buf[9] = 1;
TEST(boost::nowide::narrow(buf, 9, b, e) == buf);
@@ -88,7 +88,7 @@ int main()
}
std::cout << "- Substitutions" << std::endl;
run_all(boost::nowide::widen, boost::nowide::narrow);
- } catch(std::exception const &e)
+ } catch(const std::exception& e)
{
std::cerr << "Failed :" << e.what() << std::endl;
return 1;
@@ -96,6 +96,3 @@ int main()
return 0;
}
-
-///
-// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
diff --git a/test/test_env.cpp b/test/test_env.cpp
index bb49612..1fa9629 100644
--- a/test/test_env.cpp
+++ b/test/test_env.cpp
@@ -41,7 +41,7 @@ int main()
// Passing a variable without an equals sign (before \0) is an error
// But GLIBC has an extension that unsets the env var instead
char penv2[256] = {0};
- const char *sPenv2 = "BOOST_TEST1SOMEGARBAGE=";
+ const char* sPenv2 = "BOOST_TEST1SOMEGARBAGE=";
strncpy(penv2, sPenv2, sizeof(penv2) - 1);
// End the string before the equals sign -> Expect fail
penv2[strlen("BOOST_TEST1")] = '\0';
@@ -49,7 +49,7 @@ int main()
TEST(boost::nowide::getenv("BOOST_TEST1"));
TEST(boost::nowide::getenv("BOOST_TEST1") == example);
#endif
- } catch(std::exception const &e)
+ } catch(const std::exception& e)
{
std::cerr << "Failed " << e.what() << std::endl;
return 1;
@@ -57,6 +57,3 @@ int main()
return 0;
}
-
-///
-// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
diff --git a/test/test_fs.cpp b/test/test_fs.cpp
index ad9ac4a..ea801a9 100644
--- a/test/test_fs.cpp
+++ b/test/test_fs.cpp
@@ -37,7 +37,7 @@ int main()
TEST(!boost::filesystem::is_regular_file(boost::nowide::widen(utf8_name)));
TEST(!boost::filesystem::is_regular_file(utf8_name));
- } catch(std::exception const &e)
+ } catch(const std::exception& e)
{
std::cerr << "Failed : " << e.what() << std::endl;
return 1;
@@ -45,6 +45,3 @@ int main()
return 0;
}
-
-///
-// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
diff --git a/test/test_fstream.cpp b/test/test_fstream.cpp
index eb5e291..7b4c8a1 100644
--- a/test/test_fstream.cpp
+++ b/test/test_fstream.cpp
@@ -16,15 +16,15 @@
namespace nw = boost::nowide;
-void make_empty_file(const char *filepath)
+void make_empty_file(const char* filepath)
{
nw::ofstream f(filepath, std::ios_base::out | std::ios::trunc);
TEST(f);
}
-bool file_exists(const char *filepath)
+bool file_exists(const char* filepath)
{
- FILE *f = nw::fopen(filepath, "r");
+ FILE* f = nw::fopen(filepath, "r");
if(f)
{
std::fclose(f);
@@ -34,9 +34,9 @@ bool file_exists(const char *filepath)
}
template
-bool file_contents_equal(const char *filepath, const char (&contents)[N], bool binary_mode = false)
+bool file_contents_equal(const char* filepath, const char (&contents)[N], bool binary_mode = false)
{
- FILE *f = nw::fopen(filepath, binary_mode ? "rb" : "r");
+ FILE* f = nw::fopen(filepath, binary_mode ? "rb" : "r");
if(!f)
return false;
for(size_t i = 0; i + 1 < N; i++)
@@ -51,7 +51,7 @@ bool file_contents_equal(const char *filepath, const char (&contents)[N], bool b
}
template
-void test_with_different_buffer_sizes(const char *filepath)
+void test_with_different_buffer_sizes(const char* filepath)
{
/* Important part of the standard for mixing input with output:
However, output shall not be directly followed by input without an intervening call to the fflush function
@@ -131,7 +131,7 @@ void test_with_different_buffer_sizes(const char *filepath)
}
template
-void test_close(const char *filepath)
+void test_close(const char* filepath)
{
const std::string filepath2 = std::string(filepath) + ".2";
// Make sure file does not exist yet
@@ -156,7 +156,7 @@ void test_close(const char *filepath)
}
template
-void test_flush(const char *filepath)
+void test_flush(const char* filepath)
{
OFStream fo(filepath, std::ios_base::out | std::ios::trunc);
TEST(fo);
@@ -179,7 +179,7 @@ void test_flush(const char *filepath)
}
}
-void test_ofstream_creates_file(const char *filename)
+void test_ofstream_creates_file(const char* filename)
{
nw::remove(filename);
TEST(!file_exists(filename));
@@ -203,7 +203,7 @@ void test_ofstream_creates_file(const char *filename)
}
// Create filename file with content "test\n"
-void test_ofstream_write(const char *filename)
+void test_ofstream_write(const char* filename)
{
// char* ctor
{
@@ -259,7 +259,7 @@ void test_ofstream_write(const char *filename)
TEST(nw::remove(filename) == 0);
}
-void test_ifstream_open_read(const char *filename)
+void test_ifstream_open_read(const char* filename)
{
// Create test file
{
@@ -336,7 +336,7 @@ void test_ifstream_open_read(const char *filename)
}
}
-void test_fstream(const char *filename)
+void test_fstream(const char* filename)
{
nw::remove(filename);
TEST(!file_exists(filename));
@@ -436,16 +436,16 @@ void test_fstream(const char *filename)
}
template
-bool is_open(T &stream)
+bool is_open(T& stream)
{
- // There are const and non const versions of is_open
+ // There const are and const non versions of is_open
// Test both
- TEST(stream.is_open() == const_cast(stream).is_open());
+ TEST(stream.is_open() == const_cast(stream).is_open());
return stream.is_open();
}
template
-void do_test_is_open(const char *filename)
+void do_test_is_open(const char* filename)
{
T f;
TEST(!is_open(f));
@@ -457,7 +457,7 @@ void do_test_is_open(const char *filename)
TEST(!is_open(f));
}
-void test_is_open(const char *filename)
+void test_is_open(const char* filename)
{
// Note the order: Output before input so file exists
do_test_is_open(filename);
@@ -466,7 +466,7 @@ void test_is_open(const char *filename)
TEST(nw::remove(filename) == 0);
}
-int main(int, char **argv)
+int main(int, char** argv)
{
const std::string exampleFilename = std::string(argv[0]) + "-\xd7\xa9-\xd0\xbc-\xce\xbd.txt";
try
@@ -494,7 +494,7 @@ int main(int, char **argv)
test_flush(exampleFilename.c_str());
std::cout << "Flush - Test" << std::endl;
test_flush(exampleFilename.c_str());
- } catch(std::exception const &e)
+ } catch(const std::exception& e)
{
std::cerr << e.what() << std::endl;
return 1;
diff --git a/test/test_iostream.cpp b/test/test_iostream.cpp
index 350035b..d241184 100644
--- a/test/test_iostream.cpp
+++ b/test/test_iostream.cpp
@@ -13,7 +13,7 @@
#include "test.hpp"
-bool isValidUTF8(const std::string &s)
+bool isValidUTF8(const std::string& s)
{
using namespace boost::nowide::detail::utf;
for(std::string::const_iterator it = s.begin(); it != s.end();)
@@ -25,9 +25,9 @@ bool isValidUTF8(const std::string &s)
return true;
}
-int main(int argc, char **argv)
+int main(int argc, char** argv)
{
- char const *example = "Basic letters: \xd7\xa9-\xd0\xbc-\xce\xbd\n"
+ const char* example = "Basic letters: \xd7\xa9-\xd0\xbc-\xce\xbd\n"
"East Asian Letters: \xe5\x92\x8c\xe5\xb9\xb3\n"
"Non-BMP letters: \xf0\x9d\x84\x9e\n"
"Invalid UTF-8: `\xFF' `\xd7\xFF' `\xe5\xFF\x8c' `\xf0\x9d\x84\xFF' \n"
@@ -67,7 +67,7 @@ int main(int argc, char **argv)
boost::nowide::cout << "Flushing each character:" << std::endl;
- for(char const *s = example; *s; s++)
+ for(const char* s = example; *s; s++)
{
boost::nowide::cout << *s << std::flush;
TEST(boost::nowide::cout);
@@ -86,7 +86,7 @@ int main(int argc, char **argv)
boost::nowide::cout << "Second: " << v2 << std::endl;
TEST(boost::nowide::cout);
}
- } catch(std::exception const &e)
+ } catch(const std::exception& e)
{
std::cerr << "Fail: " << e.what() << std::endl;
return 1;
diff --git a/test/test_sets.hpp b/test/test_sets.hpp
index 9e17448..559e699 100644
--- a/test/test_sets.hpp
+++ b/test/test_sets.hpp
@@ -14,14 +14,14 @@
struct utf8_to_wide
{
- char const *utf8;
- wchar_t const *wide;
+ const char* utf8;
+ const wchar_t* wide;
};
struct wide_to_utf8
{
- wchar_t const *wide;
- char const *utf8;
+ const wchar_t* wide;
+ const char* utf8;
};
#if defined(BOOST_MSVC) && BOOST_MSVC < 1700
@@ -35,13 +35,6 @@ utf8_to_wide n2w_tests[] = {{"\xf0\x9d\x92\x9e-\xD0\xBF\xD1\x80\xD0\xB8\xD0\xB2\
{"\xE3\x82\xFF\xE3\x81\x82", L"\ufffd\u3042"},
{"\xE3\xFF\x84\xE3\x81\x82", L"\ufffd\ufffd\u3042"}};
-utf8_to_wide u2w_tests[] = {{"\xf0\x9d\x92\x9e-\xD0\xBF\xD1\x80\xD0\xB8\xD0\xB2\xD0\xB5\xD1\x82-\xE3\x82\x84\xE3\x81\x82.txt",
- L"\U0001D49E-\u043F\u0440\u0438\u0432\u0435\u0442-\u3084\u3042.txt"},
- {"\xFF\xD0\xBF\xD1\x80\xD0\xB8\xD0\xB2\xD0\xB5\xD1\x82", L"\uFFFD\u043F\u0440\u0438\u0432\u0435\u0442"},
- {"\xD0\xBF\xD1\x80\xD0\xB8\xD0\xB2\xD0\xB5\xD1\x82\xFF", L"\u043F\u0440\u0438\u0432\u0435\u0442\uFFFD"},
- {"\xE3\x82\xFF\xE3\x81\x82", L"\ufffd\u3042"},
- {"\xE3\xFF\x84\xE3\x81\x82", L"\ufffd\ufffd\u3042"}};
-
wide_to_utf8 w2n_tests_utf16[] = {
{
L"\U0001D49E-\u043F\u0440\u0438\u0432\u0435\u0442-\u3084\u3042.txt",
@@ -75,15 +68,15 @@ wide_to_utf8 w2n_tests_utf32[] = {
#pragma warning(disable : 4127) // Constant expression detected
#endif
-void run_all(std::wstring (*to_wide)(std::string const &), std::string (*to_narrow)(std::wstring const &))
+void run_all(std::wstring (*to_wide)(const std::string&), std::string (*to_narrow)(const std::wstring&))
{
for(size_t i = 0; i < sizeof(n2w_tests) / sizeof(n2w_tests[0]); i++)
{
std::cout << " N2W " << i << std::endl;
TEST(to_wide(n2w_tests[i].utf8) == n2w_tests[i].wide);
}
- int total = 0;
- wide_to_utf8 const *ptr = 0;
+ size_t total = 0;
+ const wide_to_utf8* ptr = 0;
if(sizeof(wchar_t) == 2)
{
ptr = w2n_tests_utf16;
@@ -93,7 +86,7 @@ void run_all(std::wstring (*to_wide)(std::string const &), std::string (*to_narr
ptr = w2n_tests_utf32;
total = sizeof(w2n_tests_utf32) / sizeof(w2n_tests_utf32[0]);
}
- for(int i = 0; i < total; i++)
+ for(size_t i = 0; i < total; i++)
{
std::cout << " W2N " << i << std::endl;
TEST(to_narrow(ptr[i].wide) == ptr[i].utf8);
@@ -105,6 +98,3 @@ void run_all(std::wstring (*to_wide)(std::string const &), std::string (*to_narr
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
-
-///
-// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
diff --git a/test/test_stackstring.cpp b/test/test_stackstring.cpp
index 9f3c2d7..6d1c4ee 100644
--- a/test/test_stackstring.cpp
+++ b/test/test_stackstring.cpp
@@ -15,13 +15,13 @@
#pragma warning(disable : 4428) // universal-character-name encountered in source
#endif
-std::wstring stackstring_to_wide(std::string const &s)
+std::wstring stackstring_to_wide(const std::string& s)
{
const boost::nowide::wstackstring ss(s.c_str());
return ss.get();
}
-std::string stackstring_to_narrow(std::wstring const &s)
+std::string stackstring_to_narrow(const std::wstring& s)
{
const boost::nowide::stackstring ss(s.c_str());
return ss.get();
@@ -33,18 +33,18 @@ int main()
{
std::string hello = "\xd7\xa9\xd7\x9c\xd7\x95\xd7\x9d";
std::wstring whello = L"\u05e9\u05dc\u05d5\u05dd";
- const wchar_t *wempty = L"";
+ const wchar_t* wempty = L"";
{
// Default constructed string is NULL
- boost::nowide::short_stackstring const s;
+ const boost::nowide::short_stackstring s;
TEST(s.get() == NULL);
}
{
// NULL ptr passed to ctor results in NULL
- boost::nowide::short_stackstring const s(NULL);
+ const boost::nowide::short_stackstring s(NULL);
TEST(s.get() == NULL);
- boost::nowide::short_stackstring const s2(NULL, NULL);
+ const boost::nowide::short_stackstring s2(NULL, NULL);
TEST(s2.get() == NULL);
}
{
@@ -60,10 +60,10 @@ int main()
}
{
// An empty string is accepted
- boost::nowide::short_stackstring const s(wempty);
+ const boost::nowide::short_stackstring s(wempty);
TEST(s.get());
TEST(s.get() == std::string());
- boost::nowide::short_stackstring const s2(wempty, wempty);
+ const boost::nowide::short_stackstring s2(wempty, wempty);
TEST(s2.get());
TEST(s2.get() == std::string());
}
@@ -114,8 +114,8 @@ int main()
const std::wstring wtest = L"test";
const std::string stackVal = "test";
TEST(stackVal.size() < 5); // Will be put on stack
- stackstring const heap(whello.c_str());
- stackstring const stack(wtest.c_str());
+ const stackstring heap(whello.c_str());
+ const stackstring stack(wtest.c_str());
{
stackstring sw2(heap), sw3;
@@ -170,7 +170,7 @@ int main()
}
std::cout << "- Substitutions" << std::endl;
run_all(stackstring_to_wide, stackstring_to_narrow);
- } catch(std::exception const &e)
+ } catch(const std::exception& e)
{
std::cerr << "Failed :" << e.what() << std::endl;
return 1;
@@ -178,6 +178,3 @@ int main()
return 0;
}
-
-///
-// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
diff --git a/test/test_stdio.cpp b/test/test_stdio.cpp
index 06ecafe..92c6efa 100644
--- a/test/test_stdio.cpp
+++ b/test/test_stdio.cpp
@@ -17,12 +17,12 @@
#pragma warning(disable : 4996) // function unsafe/deprecated
#endif
-bool file_exists(const std::string &filename)
+bool file_exists(const std::string& filename)
{
#ifdef BOOST_WINDOWS
- FILE *f = _wfopen(boost::nowide::widen(filename).c_str(), L"r");
+ FILE* f = _wfopen(boost::nowide::widen(filename).c_str(), L"r");
#else
- FILE *f = std::fopen(filename.c_str(), "r");
+ FILE* f = std::fopen(filename.c_str(), "r");
#endif
bool result = false;
if(f)
@@ -33,19 +33,19 @@ bool file_exists(const std::string &filename)
return result;
}
-void create_test_file(const std::string &filename)
+void create_test_file(const std::string& filename)
{
#ifdef BOOST_WINDOWS
- FILE *f = _wfopen(boost::nowide::widen(filename).c_str(), L"w");
+ FILE* f = _wfopen(boost::nowide::widen(filename).c_str(), L"w");
#else
- FILE *f = std::fopen(filename.c_str(), "w");
+ FILE* f = std::fopen(filename.c_str(), "w");
#endif
TEST(f);
TEST(std::fputs("test\n", f) >= 0);
std::fclose(f);
}
-int main(int, char **argv)
+int main(int, char** argv)
{
const std::string prefix = argv[0];
const std::string filename = prefix + "\xd7\xa9-\xd0\xbc-\xce\xbd.txt";
@@ -55,7 +55,7 @@ int main(int, char **argv)
// fopen - existing file
{
create_test_file(filename);
- FILE *f = boost::nowide::fopen(filename.c_str(), "r");
+ FILE* f = boost::nowide::fopen(filename.c_str(), "r");
TEST(f);
char buf[16];
TEST(std::fgets(buf, 16, f) != 0);
@@ -79,7 +79,7 @@ int main(int, char **argv)
// freopen
{
create_test_file(filename);
- FILE *f = boost::nowide::fopen(filename.c_str(), "r+");
+ FILE* f = boost::nowide::fopen(filename.c_str(), "r+");
TEST(f);
// Can read & write
{
@@ -92,7 +92,7 @@ int main(int, char **argv)
// Reopen in read mode
// Note that changing the mode is not possibly on all implementations
// E.g. MSVC disallows NULL completely as the file parameter
- FILE *f2 = boost::nowide::freopen(NULL, "r", f);
+ FILE* f2 = boost::nowide::freopen(NULL, "r", f);
if(!f2)
f2 = boost::nowide::freopen(filename.c_str(), "r", f);
// no write possible
@@ -134,7 +134,7 @@ int main(int, char **argv)
TEST(boost::nowide::remove(filename.c_str()) < 0);
TEST(boost::nowide::remove(filename2.c_str()) == 0);
}
- } catch(std::exception const &e)
+ } catch(const std::exception& e)
{
std::cerr << "Failed " << e.what() << std::endl;
return 1;
@@ -142,6 +142,3 @@ int main(int, char **argv)
return 0;
}
-
-///
-// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
diff --git a/test/test_system.cpp b/test/test_system.cpp
index e156a24..76aecec 100644
--- a/test/test_system.cpp
+++ b/test/test_system.cpp
@@ -12,7 +12,7 @@
#include
#include
-int main(int argc, char **argv, char **env)
+int main(int argc, char** argv, char** env)
{
try
{
@@ -27,11 +27,11 @@ int main(int argc, char **argv, char **env)
TEST(boost::nowide::getenv("BOOST_NOWIDE_TEST") == example);
std::string sample = "BOOST_NOWIDE_TEST=" + example;
bool found = false;
- for(char **e = env; *e != 0; e++)
+ for(char** e = env; *e != 0; e++)
{
- char *eptr = *e;
+ char* eptr = *e;
// printf("%s\n",eptr);
- char *key_end = strchr(eptr, '=');
+ char* key_end = strchr(eptr, '=');
TEST(key_end);
std::string key = std::string(eptr, key_end);
std::string value = key_end + 1;
@@ -42,44 +42,27 @@ int main(int argc, char **argv, char **env)
}
TEST(found);
std::cout << "Subprocess ok" << std::endl;
- } else if(argc == 2 && argv[1][0] == '-')
+ } else if(argc == 1)
{
- switch(argv[1][1])
- {
- case 'w': {
-#ifdef BOOST_WINDOWS
- std::wstring env_var = L"BOOST_NOWIDE_TEST=" + boost::nowide::widen(example);
- TEST(_wputenv(env_var.c_str()) == 0);
- std::wstring wcommand = boost::nowide::widen(argv[0]);
- wcommand += L" ";
- wcommand += boost::nowide::widen(example);
- TEST(_wsystem(wcommand.c_str()) == 0);
- std::cout << "Wide Parent ok" << std::endl;
+#if BOOST_NOWIDE_TEST_USE_NARROW
+ TEST(boost::nowide::setenv("BOOST_NOWIDE_TEST", example.c_str(), 1) == 0);
+ TEST(boost::nowide::setenv("BOOST_NOWIDE_TEST_NONE", example.c_str(), 1) == 0);
+ TEST(boost::nowide::unsetenv("BOOST_NOWIDE_TEST_NONE") == 0);
+ std::string command = "\"";
+ command += argv[0];
+ command += "\" ";
+ command += example;
+ TEST(boost::nowide::system(command.c_str()) == 0);
+ std::cout << "Parent ok" << std::endl;
#else
- std::cout << "Wide API is irrelevant" << std::endl;
+ std::wstring envVar = L"BOOST_NOWIDE_TEST=" + boost::nowide::widen(example);
+ TEST(_wputenv(envVar.c_str()) == 0);
+ std::wstring wcommand = boost::nowide::widen(argv[0]) + L" " + boost::nowide::widen(example);
+ TEST(_wsystem(wcommand.c_str()) == 0);
+ std::cout << "Wide Parent ok" << std::endl;
#endif
- }
- break;
- case 'n': {
- TEST(boost::nowide::setenv("BOOST_NOWIDE_TEST", example.c_str(), 1) == 0);
- TEST(boost::nowide::setenv("BOOST_NOWIDE_TEST_NONE", example.c_str(), 1) == 0);
- TEST(boost::nowide::unsetenv("BOOST_NOWIDE_TEST_NONE") == 0);
- std::string command = "\"";
- command += argv[0];
- command += "\" ";
- command += example;
- TEST(boost::nowide::system(command.c_str()) == 0);
- std::cout << "Parent ok" << std::endl;
- }
- break;
- default: std::cout << "Invalid parameters expected '-n/-w'" << std::endl; return 1;
- }
- } else
- {
- std::cerr << "Invalid parameters" << std::endl;
- return 1;
}
- } catch(std::exception const &e)
+ } catch(const std::exception& e)
{
std::cerr << "Failed " << e.what() << std::endl;
return 1;
@@ -87,6 +70,3 @@ int main(int argc, char **argv, char **env)
return 0;
}
-
-///
-// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4