PosIntMacro

class Object
trait Matchable
class Any

Value members

Concrete methods

def apply(value: Expr[Int])(using Quotes): Expr[PosInt]
def isValid(i: Int): Boolean

Inherited methods

def ensureValidCharLiteral(value: Expr[Char], notValidMsg: String, notLiteralMsg: String)(isValid: Char => Boolean)(using Quotes): Unit

Ensures a given expression of type Char is a literal with a valid value according to a given validation function.

Ensures a given expression of type Char is a literal with a valid value according to a given validation function.

If the given Char expression is a literal whose value satisfies the given validation function, this method will return normally. Otherwise, if the given Char expression is not a literal, this method will complete abruptly with an exception whose detail message includes the String passed as notLiteralMsg. Otherwise, the given Char expression is a literal that does not satisfy the given validation function, so this method will complete abruptly with an exception whose detail message includes the String passed as notValidMsg.

This method is intended to be invoked at compile time from macros. When called from a macro, exceptions thrown by this method will result in compiler errors. The detail message of the thrown exception will appear as the compiler error message.

Value parameters:
c

the compiler context for this assertion

isValid

a function used to validate a literal value parsed from the given expression

notLiteralMsg

a String message to include in the exception thrown if the expression is not a literal

notValidMsg

a String message to include in the exception thrown if the expression is a literal, but not valid

value

the Char expression to validate

Inherited from:
CompileTimeAssertions
Source:
CompileTimeAssertions.scala
def ensureValidDoubleLiteral(value: Expr[Double], notValidMsg: String, notLiteralMsg: String)(isValid: Double => Boolean)(using Quotes): Unit

Ensures a given expression of type Double is a literal with a valid value according to a given validation function.

Ensures a given expression of type Double is a literal with a valid value according to a given validation function.

If the given Double expression is a literal whose value satisfies the given validation function, this method will return normally. Otherwise, if the given Double expression is not a literal, this method will complete abruptly with an exception whose detail message includes the String passed as notLiteralMsg. Otherwise, the given Double expression is a literal that does not satisfy the given validation function, so this method will complete abruptly with an exception whose detail message includes the String passed as notValidMsg.

This method is intended to be invoked at compile time from macros. When called from a macro, exceptions thrown by this method will result in compiler errors. The detail message of the thrown exception will appear as the compiler error message.

Value parameters:
c

the compiler context for this assertion

isValid

a function used to validate a literal value parsed from the given expression

notLiteralMsg

a String message to include in the exception thrown if the expression is not a literal

notValidMsg

a String message to include in the exception thrown if the expression is a literal, but not valid

value

the Double expression to validate

Inherited from:
CompileTimeAssertions
Source:
CompileTimeAssertions.scala
def ensureValidFloatLiteral(value: Expr[Float], notValidMsg: String, notLiteralMsg: String)(isValid: Float => Boolean)(using Quotes): Unit

Ensures a given expression of type Float is a literal with a valid value according to a given validation function.

Ensures a given expression of type Float is a literal with a valid value according to a given validation function.

If the given Float expression is a literal whose value satisfies the given validation function, this method will return normally. Otherwise, if the given Float expression is not a literal, this method will complete abruptly with an exception whose detail message includes the String passed as notLiteralMsg. Otherwise, the given Float expression is a literal that does not satisfy the given validation function, so this method will complete abruptly with an exception whose detail message includes the String passed as notValidMsg.

This method is intended to be invoked at compile time from macros. When called from a macro, exceptions thrown by this method will result in compiler errors. The detail message of the thrown exception will appear as the compiler error message.

Value parameters:
c

the compiler context for this assertion

isValid

a function used to validate a literal value parsed from the given expression

notLiteralMsg

a String message to include in the exception thrown if the expression is not a literal

notValidMsg

a String message to include in the exception thrown if the expression is a literal, but not valid

value

the Float expression to validate

Inherited from:
CompileTimeAssertions
Source:
CompileTimeAssertions.scala
def ensureValidIntLiteral(value: Expr[Int], notValidMsg: String, notLiteralMsg: String)(isValid: Int => Boolean)(using Quotes): Unit

Ensures a given expression of type Int is a literal with a valid value according to a given validation function.

Ensures a given expression of type Int is a literal with a valid value according to a given validation function.

If the given Int expression is a literal whose value satisfies the given validation function, this method will return normally. Otherwise, if the given Int expression is not a literal, this method will complete abruptly with an exception whose detail message includes the String passed as notLiteralMsg. Otherwise, the given Int expression is a literal that does not satisfy the given validation function, so this method will complete abruptly with an exception whose detail message includes the String passed as notValidMsg.

This method is intended to be invoked at compile time from macros. When called from a macro, exceptions thrown by this method will result in compiler errors. The detail message of the thrown exception will appear as the compiler error message.

Value parameters:
c

the compiler context for this assertion

isValid

a function used to validate a literal value parsed from the given expression

notLiteralMsg

a String message to include in the exception thrown if the expression is not a literal

notValidMsg

a String message to include in the exception thrown if the expression is a literal, but not valid

value

the Int expression to validate

Inherited from:
CompileTimeAssertions
Source:
CompileTimeAssertions.scala
def ensureValidLongLiteral(value: Expr[Long], notValidMsg: String, notLiteralMsg: String)(isValid: Long => Boolean)(using Quotes): Unit

Ensures a given expression of type Long is a literal with a valid value according to a given validation function.

Ensures a given expression of type Long is a literal with a valid value according to a given validation function.

If the given Long expression is a literal whose value satisfies the given validation function, this method will return normally. Otherwise, if the given Long expression is not a literal, this method will complete abruptly with an exception whose detail message includes the String passed as notLiteralMsg. Otherwise, the given Long expression is a literal that does not satisfy the given validation function, so this method will complete abruptly with an exception whose detail message includes the String passed as notValidMsg.

This method is intended to be invoked at compile time from macros. When called from a macro, exceptions thrown by this method will result in compiler errors. The detail message of the thrown exception will appear as the compiler error message.

Value parameters:
c

the compiler context for this assertion

isValid

a function used to validate a literal value parsed from the given expression

notLiteralMsg

a String message to include in the exception thrown if the expression is not a literal

notValidMsg

a String message to include in the exception thrown if the expression is a literal, but not valid

value

the Long expression to validate

Inherited from:
CompileTimeAssertions
Source:
CompileTimeAssertions.scala
def ensureValidStringLiteral(value: Expr[String], notValidMsg: String, notLiteralMsg: String)(isValid: String => Boolean)(using Quotes): Unit

Ensures a given expression of type String is a literal with a valid value according to a given validation function.

Ensures a given expression of type String is a literal with a valid value according to a given validation function.

If the given String expression is a literal whose value satisfies the given validation function, this method will return normally. Otherwise, if the given String expression is not a literal, this method will complete abruptly with an exception whose detail message includes the String passed as notLiteralMsg. Otherwise, the given String expression is a literal that does not satisfy the given validation function, so this method will complete abruptly with an exception whose detail message includes the String passed as notValidMsg.

This method is intended to be invoked at compile time from macros. When called from a macro, exceptions thrown by this method will result in compiler errors. The detail message of the thrown exception will appear as the compiler error message.

Value parameters:
c

the compiler context for this assertion

isValid

a function used to validate a literal value parsed from the given expression

notLiteralMsg

a String message to include in the exception thrown if the expression is not a literal

notValidMsg

a String message to include in the exception thrown if the expression is a literal, but not valid

value

the String expression to validate

Inherited from:
CompileTimeAssertions
Source:
CompileTimeAssertions.scala