Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace boost::lexical_cast with pxr/base/tf/stringUtils.h in UsdStageCache #2496

Merged
merged 1 commit into from
Jul 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions pxr/usd/usd/stageCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
#include "pxr/usd/usd/api.h"
#include "pxr/usd/sdf/declareHandles.h"
#include "pxr/base/tf/declarePtrs.h"

#include <boost/lexical_cast.hpp>
#include "pxr/base/tf/stringUtils.h"

#include <string>
#include <memory>
Expand Down Expand Up @@ -107,15 +106,23 @@ class UsdStageCache
/// Create an Id from a string value. The supplied \p val must have
/// been obtained by calling ToString() previously.
static Id FromString(const std::string &s) {
return FromLongInt(boost::lexical_cast<long int>(s));
bool overflow = false;
const long int result = TfStringToLong(s, &overflow);
if (overflow) {
TF_CODING_ERROR(
"'%s' overflowed during conversion to int64_t.",
s.c_str()
);
}
return FromLongInt(result);
}

/// Convert this Id to an integral representation.
long int ToLongInt() const { return _value; }

/// Convert this Id to a string representation.
std::string ToString() const {
return boost::lexical_cast<std::string>(ToLongInt());
return TfStringify(ToLongInt());
}

/// Return true if this Id is valid.
Expand Down