Browse Source

Cleaned up API

master
Sasko Usinov 1 month ago
parent
commit
66c4ad47ed
3 changed files with 28 additions and 3 deletions
  1. +1
    -1
      dm4l.pro.user
  2. +1
    -0
      lib/libsources/api.h
  3. +26
    -2
      lib/libsources/str.cpp

+ 1
- 1
dm4l.pro.user View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.9.1, 2020-03-29T11:30:02. -->
<!-- Written by QtCreator 4.9.1, 2020-03-30T18:45:31. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>


+ 1
- 0
lib/libsources/api.h View File

@@ -74,6 +74,7 @@

bool left_string_compare (const std::string & src, const std::string & target);
bool right_string_compare (const std::string & src, const std::string & target);
bool mid_string_compare (size_t index, const std::string & src, const std::string & target);

std::string to_upper_case (std::string);
std::string to_upper_case (std::string &);


+ 26
- 2
lib/libsources/str.cpp View File

@@ -233,8 +233,6 @@ bool api::str::right_string_compare(const std::string & src, const std::string &

for (size_t i = start; i < src.size(); i++)
{
std::cout << (char) target[i - start] << std::endl;

if (target[i - start] != src[i])
return false;
}
@@ -242,6 +240,32 @@ bool api::str::right_string_compare(const std::string & src, const std::string &
return true;
}

//-------------------------------------------------------------------------------//
// Type: namespace
//-------------------------------------------------------------------------------//
//
// ToDo: n/a
//
// Notes: It checks whether target exists in src
//
// Returns: True if so otherwise false
//
//-------------------------------------------------------------------------------//
bool api::str::mid_string_compare(size_t index, const std::string & src, const std::string & target)
{
if (target.size() > src.size()) return false;

if (index >= src.length()) return false;

for (size_t i = 0; i < target.size(); i++)
{
if (src[i + index] != target[i])
return false;
}

return true;
}

//-------------------------------------------------------------------------------//
// Type: class
//-------------------------------------------------------------------------------//


Loading…
Cancel
Save