Skip to content

Commit

Permalink
Move non-constexpr function to .cpp file
Browse files Browse the repository at this point in the history
  • Loading branch information
calcmogul committed Dec 1, 2023
1 parent 8f68b66 commit f2e5019
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
13 changes: 13 additions & 0 deletions wpilibc/src/main/native/cpp/util/Color.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.

#include "frc/util/Color.h"

using namespace frc;

std::string Color::HexString() const {
return fmt::format("#{:02X}{:02X}{:02X}", static_cast<int>(255.0 * red),
static_cast<int>(255.0 * green),
static_cast<int>(255.0 * blue));
}
11 changes: 11 additions & 0 deletions wpilibc/src/main/native/cpp/util/Color8Bit.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.

#include "frc/util/Color8Bit.h"

using namespace frc;

std::string Color8Bit::HexString() const {
return fmt::format("#{:02X}{:02X}{:02X}", red, green, blue);
}
6 changes: 1 addition & 5 deletions wpilibc/src/main/native/include/frc/util/Color.h
Original file line number Diff line number Diff line change
Expand Up @@ -851,11 +851,7 @@ class Color {
*
* @return a string of the format <tt>\#RRGGBB</tt>
*/
std::string HexString() const {
return fmt::format("#{:02X}{:02X}{:02X}", static_cast<int>(255.0 * red),
static_cast<int>(255.0 * green),
static_cast<int>(255.0 * blue));
}
std::string HexString() const;

double red = 0.0;
double green = 0.0;
Expand Down
4 changes: 1 addition & 3 deletions wpilibc/src/main/native/include/frc/util/Color8Bit.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ class Color8Bit {
*
* @return a string of the format <tt>\#RRGGBB</tt>
*/
std::string HexString() const {
return fmt::format("#{:02X}{:02X}{:02X}", red, green, blue);
}
std::string HexString() const;

int red = 0;
int green = 0;
Expand Down

0 comments on commit f2e5019

Please sign in to comment.