mirror of
https://github.com/ETLCPP/etl.git
synced 2026-11-09 22:59:47 +08:00
Added data_end() and renamed trim() to trim_to_terminator()
This commit is contained in:
parent
da4e7f33ec
commit
99c3bead5a
@ -582,6 +582,24 @@ namespace etl
|
||||
return p_buffer;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a pointer to the beginning of the string data.
|
||||
///\return A pointer to the beginning of the string data.
|
||||
//*********************************************************************
|
||||
pointer data_end()
|
||||
{
|
||||
return p_buffer + current_size;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Returns a const pointer to the beginning of the string data.
|
||||
///\return A const pointer to the beginning of the string data.
|
||||
//*********************************************************************
|
||||
const_pointer data_end() const
|
||||
{
|
||||
return p_buffer + current_size;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Assigns values to the string.
|
||||
/// Truncates if the string does not have enough free space.
|
||||
@ -2200,7 +2218,7 @@ namespace etl
|
||||
/// If the last buffer position has a non-null value then the truncated
|
||||
/// flag will be set.
|
||||
//*********************************************************************
|
||||
void trim()
|
||||
void trim_to_terminator()
|
||||
{
|
||||
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
|
||||
set_truncated(p_buffer[CAPACITY] != T(0));
|
||||
|
||||
@ -874,7 +874,7 @@ namespace
|
||||
Text text(compare_text.begin(), compare_text.end());
|
||||
|
||||
bool is_equal = std::equal(text.data(),
|
||||
text.data() + text.size(),
|
||||
text.data_end(),
|
||||
compare_text.begin());
|
||||
|
||||
CHECK(is_equal);
|
||||
@ -891,7 +891,7 @@ namespace
|
||||
const Text text(compare_text.begin(), compare_text.end());
|
||||
|
||||
bool is_equal = std::equal(text.data(),
|
||||
text.data() + text.size(),
|
||||
text.data_end(),
|
||||
compare_text.begin());
|
||||
|
||||
CHECK(is_equal);
|
||||
@ -4200,7 +4200,7 @@ namespace
|
||||
|
||||
text.initialize_free_space();
|
||||
std::fill(text.data(), text.data() + text.max_size(), STR('A'));
|
||||
text.trim();
|
||||
text.trim_to_terminator();
|
||||
|
||||
CHECK(!text.is_truncated());
|
||||
CHECK_EQUAL(text.max_size(), text.size());
|
||||
@ -4213,7 +4213,7 @@ namespace
|
||||
|
||||
text.initialize_free_space();
|
||||
std::fill(text.data(), text.data() + text.max_size() - 1, STR('A'));
|
||||
text.trim();
|
||||
text.trim_to_terminator();
|
||||
|
||||
CHECK(!text.is_truncated());
|
||||
CHECK_EQUAL(text.max_size() - 1, text.size());
|
||||
@ -4226,7 +4226,7 @@ namespace
|
||||
|
||||
text.initialize_free_space();
|
||||
std::fill(text.data(), text.data() + text.max_size() + 1, STR('A')); // Overwrites to terminating null.
|
||||
text.trim();
|
||||
text.trim_to_terminator();
|
||||
|
||||
CHECK(text.is_truncated());
|
||||
CHECK_EQUAL(text.max_size(), text.size());
|
||||
|
||||
@ -4567,7 +4567,7 @@ namespace
|
||||
|
||||
text.initialize_free_space();
|
||||
std::fill(text.data(), text.data() + text.max_size(), STR('A'));
|
||||
text.trim();
|
||||
text.trim_to_terminator();
|
||||
|
||||
CHECK(!text.is_truncated());
|
||||
CHECK_EQUAL(text.max_size(), text.size());
|
||||
@ -4581,7 +4581,7 @@ namespace
|
||||
|
||||
text.initialize_free_space();
|
||||
std::fill(text.data(), text.data() + text.max_size() - 1, STR('A'));
|
||||
text.trim();
|
||||
text.trim_to_terminator();
|
||||
|
||||
CHECK(!text.is_truncated());
|
||||
CHECK_EQUAL(text.max_size() - 1, text.size());
|
||||
@ -4595,7 +4595,7 @@ namespace
|
||||
|
||||
text.initialize_free_space();
|
||||
std::fill(text.data(), text.data() + text.max_size() + 1, STR('A')); // Overwrites to terminating null.
|
||||
text.trim();
|
||||
text.trim_to_terminator();
|
||||
|
||||
CHECK(text.is_truncated());
|
||||
CHECK_EQUAL(text.max_size(), text.size());
|
||||
|
||||
@ -4200,7 +4200,7 @@ namespace
|
||||
|
||||
text.initialize_free_space();
|
||||
std::fill(text.data(), text.data() + text.max_size(), STR('A'));
|
||||
text.trim();
|
||||
text.trim_to_terminator();
|
||||
|
||||
CHECK(!text.is_truncated());
|
||||
CHECK_EQUAL(text.max_size(), text.size());
|
||||
@ -4213,7 +4213,7 @@ namespace
|
||||
|
||||
text.initialize_free_space();
|
||||
std::fill(text.data(), text.data() + text.max_size() - 1, STR('A'));
|
||||
text.trim();
|
||||
text.trim_to_terminator();
|
||||
|
||||
CHECK(!text.is_truncated());
|
||||
CHECK_EQUAL(text.max_size() - 1, text.size());
|
||||
@ -4226,7 +4226,7 @@ namespace
|
||||
|
||||
text.initialize_free_space();
|
||||
std::fill(text.data(), text.data() + text.max_size() + 1, STR('A')); // Overwrites to terminating null.
|
||||
text.trim();
|
||||
text.trim_to_terminator();
|
||||
|
||||
CHECK(text.is_truncated());
|
||||
CHECK_EQUAL(text.max_size(), text.size());
|
||||
|
||||
@ -4567,7 +4567,7 @@ namespace
|
||||
|
||||
text.initialize_free_space();
|
||||
std::fill(text.data(), text.data() + text.max_size(), STR('A'));
|
||||
text.trim();
|
||||
text.trim_to_terminator();
|
||||
|
||||
CHECK(!text.is_truncated());
|
||||
CHECK_EQUAL(text.max_size(), text.size());
|
||||
@ -4581,7 +4581,7 @@ namespace
|
||||
|
||||
text.initialize_free_space();
|
||||
std::fill(text.data(), text.data() + text.max_size() - 1, STR('A'));
|
||||
text.trim();
|
||||
text.trim_to_terminator();
|
||||
|
||||
CHECK(!text.is_truncated());
|
||||
CHECK_EQUAL(text.max_size() - 1, text.size());
|
||||
@ -4595,7 +4595,7 @@ namespace
|
||||
|
||||
text.initialize_free_space();
|
||||
std::fill(text.data(), text.data() + text.max_size() + 1, STR('A')); // Overwrites to terminating null.
|
||||
text.trim();
|
||||
text.trim_to_terminator();
|
||||
|
||||
CHECK(text.is_truncated());
|
||||
CHECK_EQUAL(text.max_size(), text.size());
|
||||
|
||||
@ -4200,7 +4200,7 @@ namespace
|
||||
|
||||
text.initialize_free_space();
|
||||
std::fill(text.data(), text.data() + text.max_size(), STR('A'));
|
||||
text.trim();
|
||||
text.trim_to_terminator();
|
||||
|
||||
CHECK(!text.is_truncated());
|
||||
CHECK_EQUAL(text.max_size(), text.size());
|
||||
@ -4213,7 +4213,7 @@ namespace
|
||||
|
||||
text.initialize_free_space();
|
||||
std::fill(text.data(), text.data() + text.max_size() - 1, STR('A'));
|
||||
text.trim();
|
||||
text.trim_to_terminator();
|
||||
|
||||
CHECK(!text.is_truncated());
|
||||
CHECK_EQUAL(text.max_size() - 1, text.size());
|
||||
@ -4226,7 +4226,7 @@ namespace
|
||||
|
||||
text.initialize_free_space();
|
||||
std::fill(text.data(), text.data() + text.max_size() + 1, STR('A')); // Overwrites to terminating null.
|
||||
text.trim();
|
||||
text.trim_to_terminator();
|
||||
|
||||
CHECK(text.is_truncated());
|
||||
CHECK_EQUAL(text.max_size(), text.size());
|
||||
|
||||
@ -4550,7 +4550,7 @@ namespace
|
||||
|
||||
text.initialize_free_space();
|
||||
std::fill(text.data(), text.data() + text.max_size(), STR('A'));
|
||||
text.trim();
|
||||
text.trim_to_terminator();
|
||||
|
||||
CHECK(!text.is_truncated());
|
||||
CHECK_EQUAL(text.max_size(), text.size());
|
||||
@ -4564,7 +4564,7 @@ namespace
|
||||
|
||||
text.initialize_free_space();
|
||||
std::fill(text.data(), text.data() + text.max_size() - 1, STR('A'));
|
||||
text.trim();
|
||||
text.trim_to_terminator();
|
||||
|
||||
CHECK(!text.is_truncated());
|
||||
CHECK_EQUAL(text.max_size() - 1, text.size());
|
||||
@ -4578,7 +4578,7 @@ namespace
|
||||
|
||||
text.initialize_free_space();
|
||||
std::fill(text.data(), text.data() + text.max_size() + 1, STR('A')); // Overwrites to terminating null.
|
||||
text.trim();
|
||||
text.trim_to_terminator();
|
||||
|
||||
CHECK(text.is_truncated());
|
||||
CHECK_EQUAL(text.max_size(), text.size());
|
||||
|
||||
@ -4200,7 +4200,7 @@ namespace
|
||||
|
||||
text.initialize_free_space();
|
||||
std::fill(text.data(), text.data() + text.max_size(), STR('A'));
|
||||
text.trim();
|
||||
text.trim_to_terminator();
|
||||
|
||||
CHECK(!text.is_truncated());
|
||||
CHECK_EQUAL(text.max_size(), text.size());
|
||||
@ -4213,7 +4213,7 @@ namespace
|
||||
|
||||
text.initialize_free_space();
|
||||
std::fill(text.data(), text.data() + text.max_size() - 1, STR('A'));
|
||||
text.trim();
|
||||
text.trim_to_terminator();
|
||||
|
||||
CHECK(!text.is_truncated());
|
||||
CHECK_EQUAL(text.max_size() - 1, text.size());
|
||||
@ -4226,7 +4226,7 @@ namespace
|
||||
|
||||
text.initialize_free_space();
|
||||
std::fill(text.data(), text.data() + text.max_size() + 1, STR('A')); // Overwrites to terminating null.
|
||||
text.trim();
|
||||
text.trim_to_terminator();
|
||||
|
||||
CHECK(text.is_truncated());
|
||||
CHECK_EQUAL(text.max_size(), text.size());
|
||||
|
||||
@ -4550,7 +4550,7 @@ namespace
|
||||
|
||||
text.initialize_free_space();
|
||||
std::fill(text.data(), text.data() + text.max_size(), STR('A'));
|
||||
text.trim();
|
||||
text.trim_to_terminator();
|
||||
|
||||
CHECK(!text.is_truncated());
|
||||
CHECK_EQUAL(text.max_size(), text.size());
|
||||
@ -4564,7 +4564,7 @@ namespace
|
||||
|
||||
text.initialize_free_space();
|
||||
std::fill(text.data(), text.data() + text.max_size() - 1, STR('A'));
|
||||
text.trim();
|
||||
text.trim_to_terminator();
|
||||
|
||||
CHECK(!text.is_truncated());
|
||||
CHECK_EQUAL(text.max_size() - 1, text.size());
|
||||
@ -4578,7 +4578,7 @@ namespace
|
||||
|
||||
text.initialize_free_space();
|
||||
std::fill(text.data(), text.data() + text.max_size() + 1, STR('A')); // Overwrites to terminating null.
|
||||
text.trim();
|
||||
text.trim_to_terminator();
|
||||
|
||||
CHECK(text.is_truncated());
|
||||
CHECK_EQUAL(text.max_size(), text.size());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user