示例#1
0
文件: main.cpp 项目: avakar/gh
static void checkout_tree(gitdb & db, string_view dir, gitdb::tree_t const & t)
{
	for (auto && te: t)
	{
		std::string name = dir.to_string() + "/" + te.name;

		if ((te.mode & 0xe000) == 0xe000)
		{
			// XXX gitlink
		}
		else if (te.mode & 0x4000)
		{
			make_directory(name);
			checkout_tree(db, name, db.get_tree(te.oid));
		}
		else
		{
			file ff(name, /*readonly=*/false);

			std::vector<uint8_t> v = db.get_blob(te.oid);

			file::ofile fo = ff.seekp(0);
			write_all(fo, v.data(), v.size());
		}
	}
}
示例#2
0
std::string normalize_path(string_view path, uri_comparison_level level) {
  auto result = path.to_string();

  if (uri_comparison_level::syntax_based == level) {
    // case normalization
    detail::for_each(result, percent_encoded_to_upper<std::string>());

    // % encoding normalization
    result.erase(
        detail::decode_encoded_unreserved_chars(std::begin(result),
                                                std::end(result)),
        std::end(result));

    // % path segment normalization
    result = normalize_path_segments(result);
  }

  return result;
}
示例#3
0
Win32Exception::Win32Exception(ErrorCode ec, string_view msg, const char* fn,
	RecordLevel lv)
	: Win32Exception(ec, msg.to_string() + " @ " + Nonnull(fn), lv)
{}
示例#4
0
			typename base::const_iterator find(const string_view& key) const
			{
				return this->base::find(key.to_string());
			}
示例#5
-1
void test_strview_compare(const string_view& a, const string_view& b) {

    std::string as = a.to_string();
    std::string bs = b.to_string();

    auto sg = [](int x) { return x == 0 ? 0 : (x < 0 ? -1 : 1); };
    int c = as.compare(bs);

    ASSERT_EQ(sg(c), sg(a.compare(b)));
    ASSERT_EQ(sg(c), sg(a.compare(bs.c_str())));

    ASSERT_EQ(c == 0, a == b);
    ASSERT_EQ(c != 0, a != b);
    ASSERT_EQ(c <  0, a <  b);
    ASSERT_EQ(c <= 0, a <= b);
    ASSERT_EQ(c >  0, a >  b);
    ASSERT_EQ(c >= 0, a >= b);

    ASSERT_EQ((-c) == 0, b == a);
    ASSERT_EQ((-c) != 0, b != a);
    ASSERT_EQ((-c) <  0, b <  a);
    ASSERT_EQ((-c) <= 0, b <= a);
    ASSERT_EQ((-c) >  0, b >  a);
    ASSERT_EQ((-c) >= 0, b >= a);
}