You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
105 lines
5.4 KiB
105 lines
5.4 KiB
/* ——————————————————————————————————————————————————————————————————————————
|
|
Proyecto WIAWAIW
|
|
—————————————————————————————————————————————————————————————————————————————
|
|
Fichero cstate.go
|
|
Package cval
|
|
Autor Juan V. Navarro juanvnl@activething.com
|
|
Creado 05/09/2025
|
|
—————————————————————————————————————————————————————————————————————————————
|
|
|
|
LICENSES AND TERMS OF USE
|
|
-------------------------
|
|
|
|
This software is licensed under the Elastic License v2.0 (the "License").
|
|
For full terms and additional information regarding permitted and prohibited
|
|
uses, please visit:
|
|
https://activething.com/wiawiaw/licenses
|
|
|
|
You may use, copy, modify, and redistribute this software internally within
|
|
your organization for any purpose, including research, development, and
|
|
testing, subject to the terms of this License.
|
|
|
|
You may NOT, however, use, provide, distribute, or make this software
|
|
available to any third party as part of a hosted service, SaaS offering, or
|
|
commercial product without first obtaining a commercial license from
|
|
Active Thing.
|
|
|
|
You may combine this software with other code, provided that such
|
|
combination does not circumvent the restrictions of this License.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. In no event shall
|
|
the authors or copyright holders be liable for any claim, damages, or other
|
|
liability arising from the use of this software.
|
|
|
|
—————————————————————————————————————————————————————————————————————————————
|
|
|
|
Web : activething.com | wiawiaw.com
|
|
git : g.activething.com | github.com/activething
|
|
Correo : dev@activething.com
|
|
|
|
—————————————————————————————————————————————————————————————————————————————
|
|
No deseo caminar sobre el agua", dijo Siddhartha.
|
|
Que los antiguos chamanes se contenten con tales habilidades.
|
|
—— Hermann Hesse, Siddhartha
|
|
—————————————————————————————————————————————————————————————————————————————
|
|
Copyright (c) 2025 Active Thing
|
|
————————————————————————————————————————————————————————————————————————————— */
|
|
|
|
package cval
|
|
|
|
|
|
|
|
|
|
const (
|
|
StateInvalid State = 1 << iota // Valor inválido o corrupto (inconsistente)
|
|
StateError // Hubo un error al construir el valor
|
|
StateNil // Valor explícitamente nulo
|
|
StateZero // Valor es cero (valor por defecto)
|
|
StateVersion // Contiene metadatos de versión
|
|
StateReflected // Valor obtenido mediante reflexión
|
|
StateSensitive // Valor sensible (requiere tratamiento especial)
|
|
StateEncoded // Valor fue codificado (ej. serializado)
|
|
|
|
StateNone State = 0 // Sin banderas activas
|
|
StateOps = StateSensitive | StateEncoded // Banderas operativas especiales
|
|
)
|
|
|
|
// State define un conjunto de banderas para el tipo CValue (compact value) indicando el
|
|
// estado del mismo
|
|
type State uint8
|
|
|
|
|
|
|
|
|
|
// HasInvalid indica que el estado es inválido o inconsistente.
|
|
func (s State) HasInvalid() bool { return s&StateInvalid != 0 }
|
|
|
|
// HasError indica que hubo un error al construir el valor.
|
|
func (s State) HasError() bool { return s&StateError != 0 }
|
|
|
|
// HasNil indica que el valor es nulo explícitamente.
|
|
func (s State) HasNil() bool { return s&StateNil != 0 }
|
|
|
|
// HasZero indica que el valor es igual AType cero (valor por defecto).
|
|
func (s State) HasZero() bool { return s&StateZero != 0 }
|
|
|
|
// HasNilOrZero indica si el valor es nulo o cero.
|
|
func (s State) HasNilOrZero() bool { return s&(StateZero|StateNil) != 0 }
|
|
|
|
// HasVersion indica que el valor contiene metainformación de versión.
|
|
func (s State) HasVersion() bool { return s&StateVersion != 0 }
|
|
|
|
// HasReflected indica que el valor fue obtenido mediante reflexión.
|
|
func (s State) HasReflected() bool { return s&StateReflected != 0 }
|
|
|
|
// HasSensitive indica que el valor contiene información sensible.
|
|
func (s State) HasSensitive() bool { return s&StateSensitive != 0 }
|
|
|
|
// HasEncoded indica que el valor ha sido codificado.
|
|
func (s State) HasEncoded() bool { return s&StateEncoded != 0 }
|
|
|
|
// HasAny verifica si alguna de las banderas especificadas está activa.
|
|
func (s State) HasAny(flags State) bool { return s&flags != 0 }
|