Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

boost::filesystem::path vs boost::filesystem::wpath

Boost lib has a class to deal with file path: boost::filesystem::path. Also Boos has this class boost::filesystem::wpath

Each class has methods string(), wstring(), c_str(), native()

I develop Windows app and I completely do not understand what should I use ))

What is the difference between these two classes from the practical point of view? What is the difference between these methods?

What class and what methods should I use for Windows app? ::wpath and wstring() everywhere?

Part of sources (several statically linked libs) will be compiled for Ubuntu. In this situation ::wpath still good?


Also I use SQLite and it needs path to the database file. sqlite3_open.

I should use sqlite3_open_v2 (UTF-8 encoding for the file path) or sqlite3_open16 (UTF-16 encoding for the file path) ?


P.S. After reading this article link seems that ::path and ::wpath have no difference at all. Is it right?

Method native() seems preferable for the source code that compiled for different platforms.

like image 219
Victor Mezrin Avatar asked Feb 20 '16 16:02

Victor Mezrin


People also ask

What is boost :: filesystem :: path?

boost::filesystem::path is the central class in Boost. Filesystem for representing and processing paths. Definitions can be found in the namespace boost::filesystem and in the header file boost/filesystem. hpp . Paths can be built by passing a string to the constructor of boost::filesystem::path (see Example 35.1).

What is Boost Filesystem?

The Boost Filesystem Library provides portable facilities to query and manipulate paths, files, and directories. The motivation for the library is the need to be able to perform portable script-like operations from within C++ programs.


1 Answers

What is the difference between these two classes from the practical point of view? What is the difference between these methods?

What class and what methods should I use for Windows app? ::wpath and wstring() everywhere?

Worth mentioning that for several releases now, Boost has deprecated wpath and class path should be used instead. See Boost Deprecated Features (current release)

"Under the hood", Boost represents path and wpath using std::string and std::wstring where wstring is used to represent wide character strings, i.e. supports larger character sets.

These questions for the most part are answered here: std::wstring VS std::string

Method native() seems preferable for the source code that compiled for different platforms

That is correct. If it's solely a Windows app you are developing, then wstring() can be used over native()

like image 154
Jonathon Ogden Avatar answered Sep 29 '22 23:09

Jonathon Ogden