dvparser

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 16, 2020 License: MIT Imports: 12 Imported by: 4

Documentation

Overview

********************************************************************** MicroCore Copyright 2020-2020 by Danyil Dobryvechir (dobrivecher@yahoo.com ddobryvechir@gmail.com) ***********************************************************************

********************************************************************** MicroCore Copyright 2017 - 2020 by Danyil Dobryvechir (dobrivecher@yahoo.com ddobryvechir@gmail.com) ***********************************************************************

********************************************************************** MicroCore Copyright 2020 -2020 by Danyil Dobryvechir (dobrivecher@yahoo.com ddobryvechir@gmail.com) ***********************************************************************

********************************************************************** MicroCore Copyright 2017 - 2020 by Danyil Dobryvechir (dobrivecher@yahoo.com ddobryvechir@gmail.com) ***********************************************************************

********************************************************************** MicroCore Copyright 2020 - 2020 by Danyil Dobryvechir (dobrivecher@yahoo.com ddobryvechir@gmail.com) ***********************************************************************

Index

Constants

View Source
const (
	CONFIG_RESULT_NOT_CONTAINING_PREMAP         = 1 << iota
	CONFIG_REPLACEMENT_NOT_MANDATORY            = 1 << iota
	CONFIG_IS_NOT_ESCAPED                       = 1 << iota
	CONFIG_IS_NOT_VARIABLES                     = 1 << iota
	CONFIG_DISABLE_INITIAL_MAP_FROM_ENVIRONMENT = 1 << iota
	CONFIG_PRESERVE_SPACE                       = 1 << iota
)
View Source
const (
	IFELSE_ELSE_NOTRUN = 0
	IFELSE_ELSE_RUN    = 1
	IFELSE_ELSE_NOMORE = 2
	IFELSE_ELSE_ERROR  = 3
	IFELSE_LOW_MASK    = 7
	IFELSE_CONSUMED    = 16
	IFELSE_NONEWIF     = 8
)

Variables

View Source
var DvParserLog bool = false
View Source
var GeneralFilePaths []string
View Source
var GeneralMicroCoreFolderIndex int = -1
View Source
var GeneralNamespaceFolderIndex int = -1
View Source
var GlobalProperties map[string]string
View Source
var GlobalPropertiesAsDvObject *dvevaluation.DvObject
View Source
var MicroCorePathSuffix = "PATH"
View Source
var MicroCorePrexix = "MICROCORE_"
View Source
var MicroCorePropertiesInCurrentFolderFileName = "MicroCore.properties"

MicroCorePropertiesInCurrentFolderFileName is a main property file name, which can be customized

View Source
var NumberOfBracketsInConfigParsing = 3
View Source
var SubstitutionEndParameter = []byte{'}'}
View Source
var SubstitutionStartParameter = []byte{'$', '{'}

Functions

func AddNonRepeatingWords

func AddNonRepeatingWords(s string, oldList, newList []string, imap map[string]int, plain, joiner string) string

func AddStringListWithoutRepeats

func AddStringListWithoutRepeats(src []string, newList []string) []string

func ByteArrayEvaluatorAsInterface

func ByteArrayEvaluatorAsInterface(data []byte, extraParams *dvevaluation.DvObject, source string) (interface{}, error)

func CallInitBySettingFunc

func CallInitBySettingFunc(parameters map[string]string, functionPool map[string]interface{})

func CallInitBySettingFuncDefault

func CallInitBySettingFuncDefault()

func CleanLogByteArray

func CleanLogByteArray(data []byte) string

func CleanLogString

func CleanLogString(data string) string

func CloneGlobalProperties

func CloneGlobalProperties() map[string]string

func ComposeParametersInTemplate

func ComposeParametersInTemplate(template string, brackets int, value string) (res map[string]string, ok bool)

func ConvertByteArrayByGlobalProperties

func ConvertByteArrayByGlobalProperties(data []byte, sourceName string) (res string, err error)

func ConvertByteArrayByGlobalPropertiesInByteLines

func ConvertByteArrayByGlobalPropertiesInByteLines(data []byte, sourceName string) (res [][]byte, err error)

func ConvertByteArrayByGlobalPropertiesInStringLines

func ConvertByteArrayByGlobalPropertiesInStringLines(data []byte, sourceName string) (res []string, err error)

func ConvertByteArrayByGlobalPropertiesRuntime

func ConvertByteArrayByGlobalPropertiesRuntime(data []byte, sourceName string) (res string, err error)

func ConvertByteArrayBySpecificProperties

func ConvertByteArrayBySpecificProperties(data []byte, sourceName string, properties map[string]string, numberOfBrackets int, configOptions int) ([]byte, error)

func ConvertByteArrayBySpecificPropertiesInLines

func ConvertByteArrayBySpecificPropertiesInLines(data []byte, sourceName string, properties map[string]string, numberOfBrackets int, configOptions int) ([][]byte, error)

func ConvertFileByGlobalProperties

func ConvertFileByGlobalProperties(fileName string) ([]byte, error)

func ConvertStringArrayByGlobalProperties

func ConvertStringArrayByGlobalProperties(data []string, sourceName string) (res []string, err error)

func ConvertStringByGlobalProperties

func ConvertStringByGlobalProperties(data string, sourceName string) (string, error)

func ConvertToList

func ConvertToList(lst string) []string

func ConvertToNonEmptyList

func ConvertToNonEmptyList(lst string) []string

func ConvertToNonEmptySemicolonList

func ConvertToNonEmptySemicolonList(lst string) []string

func ConvertURLToList

func ConvertURLToList(url string) []string

func CopyStringMap

func CopyStringMap(src map[string]string) map[string]string

func EvaluateDifferenceRate

func EvaluateDifferenceRate(model string, pattern string) int

func ExtractFromBufByBeforeAfterKeys

func ExtractFromBufByBeforeAfterKeys(data []byte, before []byte, after []byte) (res []byte, status int)

func FindEol

func FindEol(data []byte) int

func FindInGeneralPaths

func FindInGeneralPaths(name string) string

func FindSubStringSmartInByteArray

func FindSubStringSmartInByteArray(data []byte, needle []byte) (int, int)

func GetByGlobalPropertiesOrDefault

func GetByGlobalPropertiesOrDefault(propName, defValue string) string

func GetCanonicalVersion

func GetCanonicalVersion(version int64) string

func GetCanonicalVersionFromHexName

func GetCanonicalVersionFromHexName(version string) string

func GetCommandLine

func GetCommandLine() []string

func GetGlobalPropertiesAsDvObject

func GetGlobalPropertiesAsDvObject() *dvevaluation.DvObject

func GetNextNonEmptyPartInYaml

func GetNextNonEmptyPartInYaml(s string) string

func GetNextWordBySpaceTable

func GetNextWordBySpaceTable(s string, spaceTable map[byte]bool, allRest bool) string

func GetNextWordExceptYamlControls

func GetNextWordExceptYamlControls(s string) string

func GetNextWordInText

func GetNextWordInText(s string) string

func GetProptertiesPrototypedToGlobalProperties

func GetProptertiesPrototypedToGlobalProperties(localMap map[string]interface{}) *dvevaluation.DvObject

func GetStringArrayWithDefaults

func GetStringArrayWithDefaults(src []string, defs []string) []string

func GetUnquotedString

func GetUnquotedString(data string) string

func GetVersionIndex

func GetVersionIndex(version string) int64

func InitAndReadCommandLine

func InitAndReadCommandLine() []string

func InsertTextIntoBuffer

func InsertTextIntoBuffer(src []byte, posStart int, posEnd int, buf ...[]byte) (dst []byte, dif int)

func Int64ToFullHex

func Int64ToFullHex(v int64) string

func IsAlphabeticalLowCase

func IsAlphabeticalLowCase(s string) bool

func IsDigitOnly

func IsDigitOnly(s string) bool

func JoinStringsWithClean

func JoinStringsWithClean(data []string) []byte

func LinearSmartConfigFromEnvironment

func LinearSmartConfigFromEnvironment() map[string]string

func LinearSmartConfigFromFile

func LinearSmartConfigFromFile(fileName string, configInfo *ConfigInfo, level int)

************************************************************************* level = -1 if even missing the file is not a problem

>= 0 start looking the file from paths configInfo.FilePaths[level] and up

**************************************************************************

func LinearSmartConfigParse

func LinearSmartConfigParse(data []byte, configInfo *ConfigInfo, sourceName string)

func LoadSimpleMapFromByteArray

func LoadSimpleMapFromByteArray(data []byte, separator byte) map[string]string

func LoadSimpleMapFromFile

func LoadSimpleMapFromFile(fileName string, separator byte) (res map[string]string, err error)

func LogVariables

func LogVariables(name string, vars map[string]string)

func LookInDescriptionByteArray

func LookInDescriptionByteArray(data []byte, lookNames map[string]string, mustPresent bool) (res map[string]string, err error)

func LookInDescriptionFile

func LookInDescriptionFile(fileName string, lookNames map[string]string, mustPresent bool) (res map[string]string, err error)

func MakeUniqueStringList

func MakeUniqueStringList(lists ...[]string) []string

func MatchParametersByVariableSubstitution

func MatchParametersByVariableSubstitution(model string, list []string, rest []string, occurrence int, strict bool) (params map[string]string, doubt bool, ok bool)

func PrepareAndMayQuoteParams

func PrepareAndMayQuoteParams(src []string) (string, int)

func PresentMapAsProperties

func PresentMapAsProperties(pool map[string]string, outputFileName string) error

func PrintInt64ToByteBuffer

func PrintInt64ToByteBuffer(n int64, b []byte) int

func PutDescribedAttributesToMapFromCommaSeparatedList

func PutDescribedAttributesToMapFromCommaSeparatedList(params map[string]string, pool map[string]string, list string) error

func PutDescribedAttributesToMapFromList

func PutDescribedAttributesToMapFromList(params map[string]string, pool map[string]string, list []string) error

func QuickLookJsonOption

func QuickLookJsonOption(s string, option string) string

func ReadHexValue

func ReadHexValue(v string) int64

func ReadInsideBrackets

func ReadInsideBrackets(str string, pos int) (endPos int, err error)

func ReadPropertiesFileWithEnvironmentVariables

func ReadPropertiesFileWithEnvironmentVariables(currentDir string, propertiesName string, setFilePaths func() error) error

func ReadPropertiesFileWithEnvironmentVariablesInCurrentDirectory

func ReadPropertiesFileWithEnvironmentVariablesInCurrentDirectory(propertiesName string) error

func ReadPropertiesInEnvironment

func ReadPropertiesInEnvironment(name string) map[string]string

func ReadPropertiesOrPanic

func ReadPropertiesOrPanic(name string) map[string]string

func ReduceListRestByKnownValueAtIndex

func ReduceListRestByKnownValueAtIndex(list []string, rest []string, index int, value string) ([]string, []string, int)

func ReduceListToNonEmptyList

func ReduceListToNonEmptyList(res []string) []string

func ReduceSpaceAndCountWords

func ReduceSpaceAndCountWords(str string) (string, int)

func RegisterInitBySettingFunc

func RegisterInitBySettingFunc(initializer InitBySettingFunc) bool

func RemoveGlobalPropertiesValue

func RemoveGlobalPropertiesValue(key string)

func ReplaceTextInsideByteArray

func ReplaceTextInsideByteArray(data []byte, start int, end int, replacement []byte) []byte

func SeparateToKeyValue

func SeparateToKeyValue(line string) (key string, value string)

func SetGlobalPropertiesValue

func SetGlobalPropertiesValue(key string, value string)

func SetMicroCorePrefix

func SetMicroCorePrefix(prefix string)

func SetNumberOfBracketsInConfigParsing

func SetNumberOfBracketsInConfigParsing(n int)

func SetPrefixesByApplicationName

func SetPrefixesByApplicationName(name string)

SetPrefixesByApplicationName must be called at start of the application to customize prefixes and property file names

func SmartReadFileAsString

func SmartReadFileAsString(fileName string, properties map[string]string) (string, error)

func SmartReadTemplate

func SmartReadTemplate(filename string, numberOfBrackets int, joiner byte) ([]byte, error)

func SmartReadTemplateLines

func SmartReadTemplateLines(fileName string, numberOfBrackets int, properties map[string]string) (lines [][]byte, err error, lastOutputMap map[string]string)

func StringEvaluatorAsBoolean

func StringEvaluatorAsBoolean(data string, extraParams *dvevaluation.DvObject) (bool, error)

func StringEvaluatorAsBooleanWithErrorLoggedAsWarning

func StringEvaluatorAsBooleanWithErrorLoggedAsWarning(data string, extraParams *dvevaluation.DvObject, defaultIfError bool) bool

func StringEvaluatorAsString

func StringEvaluatorAsString(data string, extraParams *dvevaluation.DvObject) (string, error)

func StringEvaluatorAsStringWithErrorLoggedAsWarning

func StringEvaluatorAsStringWithErrorLoggedAsWarning(data string, extraParams *dvevaluation.DvObject, defaultIfError string) string

func SubstitutionGetList

func SubstitutionGetList(data []byte) (list []string, rest []string, ok bool)

func SubstitutionMatchModelByPattern

func SubstitutionMatchModelByPattern(model string, pattern string, hintOccurrence int, hintStrict bool) (params map[string]string, doubt bool, ok bool)

func SubstitutionsGetNextPosition

func SubstitutionsGetNextPosition(list []string, rest []string, positions []int, model string) bool

func SubstitutionsGetNextPositionFromLast

func SubstitutionsGetNextPositionFromLast(list []string, rest []string, positions []int, model string) bool

func SubstitutionsGetParamsByPositions

func SubstitutionsGetParamsByPositions(list []string, rest []string, positions []int, model string) map[string]string

func TryReadInteger

func TryReadInteger(str string, def int) int

func UpdateModelByListRestParams

func UpdateModelByListRestParams(pattern string, list []string, rest []string, paramMap map[string]string, silent bool) (string, error)

func UpdateModelByParamGetter

func UpdateModelByParamGetter(pattern string, paramGetter func(string) (string, bool)) (string, []string)

func UpdateModelByParams

func UpdateModelByParams(pattern string, paramMap map[string]string) (string, error)

func UpdateModelByParamsSilent

func UpdateModelByParamsSilent(pattern string, paramMap map[string]string) (string, error)

Types

type ConfigInfo

type ConfigInfo struct {
	NumberOfBrackets int
	InputMap         map[string]string
	Options          int
	OutputMap        map[string]string
	OutputLines      [][]byte
	Err              error
	FilePaths        []string
	// contains filtered or unexported fields
}

type InitBySettingFunc

type InitBySettingFunc func(parameters map[string]string, functionPool map[string]interface{})

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL