Skip to content

Commit

Permalink
parsing functions
Browse files Browse the repository at this point in the history
  • Loading branch information
M. Fatih Cırıt committed Jul 14, 2023
1 parent cef89cf commit 517ee08
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 2 deletions.
1 change: 1 addition & 0 deletions autoware_version_manager/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<depend>autoware_system_msgs</depend>
<depend>rclcpp</depend>
<depend>rclcpp_components</depend>
<depend>yaml_cpp_vendor</depend>

<test_depend>ament_cmake_ros</test_depend>
<test_depend>ament_lint_auto</test_depend>
Expand Down
14 changes: 12 additions & 2 deletions autoware_version_manager/src/include/parse_version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,22 @@

#include "include/version_types.hpp"

#include <yaml-cpp/yaml.h>

#include <filesystem>

namespace autoware_version_manager
{
class ParseVersion
namespace parse_version
{
};

VersionAutoware parse_autoware_version(const YAML::Node & yaml_node);
VersionAutoware parse_autoware_version(const std::filesystem::path & path);

VersionInterface parse_interface_version(const YAML::Node & yaml_node);
VersionInterface parse_interface_version(const std::filesystem::path & path);

} // namespace parse_version
} // namespace autoware_version_manager

#endif // PARSE_VERSION_HPP_
59 changes: 59 additions & 0 deletions autoware_version_manager/src/parse_version.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright 2023 The Autoware Foundation
//
// 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 under the License.

#include "include/parse_version.hpp"

#include "include/version_types.hpp"

#include <yaml-cpp/yaml.h>

#include <filesystem>

namespace autoware_version_manager
{
namespace parse_version
{

VersionAutoware parse_autoware_version(const YAML::Node & yaml_node)
{
VersionAutoware version;
version.year = yaml_node["year"].as<int>();
version.minor = yaml_node["minor"].as<int>();
version.micro = yaml_node["micro"].as<int>();
return version;
}

VersionAutoware parse_autoware_version(const std::filesystem::path & path)
{
YAML::Node yaml_node = YAML::LoadFile(path.string());
return parse_autoware_version(yaml_node);
}

VersionInterface parse_interface_version(const YAML::Node & yaml_node)
{
VersionInterface version;
version.major = yaml_node["major"].as<int>();
version.minor = yaml_node["minor"].as<int>();
version.patch = yaml_node["patch"].as<int>();
return version;
}

VersionInterface parse_interface_version(const std::filesystem::path & path)
{
YAML::Node yaml_node = YAML::LoadFile(path.string());
return parse_interface_version(yaml_node);
}

} // namespace parse_version
} // namespace autoware_version_manager

0 comments on commit 517ee08

Please sign in to comment.