// Copyright (c) 2021-2023, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once

//! @file
//!
//! @brief TODO

#include <omni/fabric/IToken.h>

#include <string>

namespace usdrt
{

class TfToken
{
public:
    TfToken();
    TfToken(const omni::fabric::Token& token);
    TfToken(const std::string& token);
    TfToken(const char* token);

    const std::string GetString() const;
    const char* GetText() const;

    void pyUpdate(const char* fromPython);
    // TODO: other TfToken APIs
    bool IsEmpty() const;

    bool operator==(const TfToken& other) const;
    bool operator!=(const TfToken& other) const;
    bool operator<(const TfToken& other) const;
    operator omni::fabric::TokenC() const;

private:
    omni::fabric::Token m_token;
};

inline TfToken::TfToken()
{
    // m_token constructs uninitialized by default
}

inline TfToken::TfToken(const omni::fabric::Token& token) : m_token(token)
{
}

inline TfToken::TfToken(const std::string& token) : m_token(token.c_str())
{
}

inline TfToken::TfToken(const char* token) : m_token(token)
{
}

inline bool TfToken::operator==(const TfToken& other) const
{
    return m_token == other.m_token;
}

inline bool TfToken::operator!=(const TfToken& other) const
{
    return !(m_token == other.m_token);
}

inline bool TfToken::operator<(const TfToken& other) const
{
    return m_token < other.m_token;
}

inline TfToken::operator omni::fabric::TokenC() const
{
    return omni::fabric::TokenC(m_token);
}

inline const std::string TfToken::GetString() const
{
    return m_token.getString();
}

inline const char* TfToken::GetText() const
{
    return m_token.getText();
}

inline void TfToken::pyUpdate(const char* fromPython)
{
    m_token = omni::fabric::Token(fromPython);
}

inline bool TfToken::IsEmpty() const
{
    return m_token == omni::fabric::kUninitializedToken;
}

typedef std::vector<TfToken> TfTokenVector;

}
