// SPDX-License-Identifier: MIT
#pragma once
#include <string>
#include <vector>
namespace fedem
{
namespace fson
{
// ─────────────────────────────────────────────────────────────────────
// Comment
//
// A single FSON comment, stored without its delimiters.
// SingleLine : text between "//" and the line break
// MultiLine : text between "/*" and "*/" (may span lines, may
// contain nested "/* … */" pairs verbatim)
//
// Comments are trivia: they carry no semantic meaning but MUST be
// preserved on write-back (project hard requirement).
// ─────────────────────────────────────────────────────────────────────
class Comment final
{
public:
enum class Kind
{
SingleLine,
MultiLine
};
Comment( Kind kind, std::string text );
Kind getKind( ) const noexcept;
std::string const& getText( ) const noexcept;
void setText( std::string text );
private:
Kind kind;
std::string text;
};
// Ordered list of comments attached to one point of the document.
using CommentList = std::vector< Comment >;
inline Comment::Comment( Kind kind, std::string text )
: kind( kind )
, text( std::move( text ) )
{
}
inline Comment::Kind Comment::getKind( ) const noexcept
{
return kind;
}
inline std::string const& Comment::getText( ) const noexcept
{
return text;
}
inline void Comment::setText( std::string text )
{
this->text = std::move( text );
}
} // end namespace fson
} // end namespace fedem