Victor Mezrin
Victor Mezrin

Reputation: 2847

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.

Upvotes: 6

Views: 3139

Answers (1)

Jonathon Ogden
Jonathon Ogden

Reputation: 1582

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()

Upvotes: 5

Related Questions