Skip to content

Commit

Permalink
Add support for std::filesystem::path
Browse files Browse the repository at this point in the history
  • Loading branch information
Elyas El Idrissi committed Apr 6, 2023
1 parent be9362f commit d218bc4
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions include/soci/std-path.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// Copyright (C) 2023 Elyas El Idrissi
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//

#ifndef SOCI_STD_PATH_H_INCLUDED
#define SOCI_STD_PATH_H_INCLUDED

#include "soci/type-conversion-traits.h"

#include <filesystem>
#include <string>

namespace soci
{

// simple fall-back for std::filesystem::path
template <>
struct type_conversion<std::filesystem::path>
{
typedef std::string base_type;

static void from_base(base_type in, indicator ind, std::filesystem::path & out)
{
out = ind != i_null ? std::filesystem::path{in} : std::filesystem::path{};
}

static void to_base(std::filesystem::path in, base_type & out, indicator & ind)
{
out = in.string();
ind = i_ok;
}
};

} // namespace soci

#endif // SOCI_STD_PATH_H_INCLUDED

0 comments on commit d218bc4

Please sign in to comment.