common_util
Loading...
Searching...
No Matches
Functions
verutil.h File Reference

Version utilities. More...

#include <string>

Go to the source code of this file.

Functions

bool cutl::is_version (const std::string &text)
 Check if a string is a valid version.
 
std::string cutl::get_version (const std::string &text)
 Parse a version string from a text.
 
int cutl::compare_version (const std::string &v1, const std::string &v2)
 Compare two version strings.
 

Detailed Description

Version utilities.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations.

Author
spencer.luo
Date
2024-05-13

Function Documentation

◆ compare_version()

int cutl::compare_version ( const std::string & v1,
const std::string & v2 )

Compare two version strings.

Parameters
v1version string 1.
v2version string 2.
Returns
int The result of the comparison. -1 if v1 < v2, 0 if v1 == v2, 1 if v1 > v2.

◆ get_version()

std::string cutl::get_version ( const std::string & text)

Parse a version string from a text.

Parameters
textThe text to parse.
Returns
std::string The parsed version string.

◆ is_version()

bool cutl::is_version ( const std::string & text)

Check if a string is a valid version.

Parameters
textThe string to check.
Returns
true if the string is a valid version, false otherwise.