'encoding UTF-8 Do not remove or change this line! '************************************************************************** '* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. '* '* Copyright 2008 by Sun Microsystems, Inc. '* '* OpenOffice.org - a multi-platform office productivity suite '* '* $RCSfile: t_key_tools.inc,v $ '* '* $Revision: 1.1 $ '* '* last change: $Author: jsk $ $Date: 2008-06-20 07:58:19 $ '* '* This file is part of OpenOffice.org. '* '* OpenOffice.org is free software: you can redistribute it and/or modify '* it under the terms of the GNU Lesser General Public License version 3 '* only, as published by the Free Software Foundation. '* '* OpenOffice.org is distributed in the hope that it will be useful, '* but WITHOUT ANY WARRANTY; without even the implied warranty of '* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the '* GNU Lesser General Public License version 3 for more details '* (a copy is included in the LICENSE file that accompanied this code). '* '* You should have received a copy of the GNU Lesser General Public License '* version 3 along with OpenOffice.org. If not, see '* '* for a copy of the LGPLv3 License. '* '/************************************************************************ '* '* owner : joerg.skottke@sun.com '* '* short description : tools for evaluation of key=value datalists '* '******************************************************************************* ' ** ' #1 hGetDataPairAsString ' retrieve key=value from a list ' #1 hGetValueForPairAsString ' retrieve value from a key=value as string ' #1 hGetValueForPairAsLong ' retrieve value from a key=value as long integer ' #1 hGetValueForKeyAsInt ' retrieve value for a specified key as integer ' #1 hGetValueForKeyAsLong ' retrieve value for a specified key as long integer ' #1 hGetKeyForPairAsString ' retrieve key from key=value as string ' #1 hGetKeyForValueAsString ' retrieve key for a specified value as string ' #1 hGetKeyForValueAsInt ' retrieve key for a specified value as int ' #1 hGetIndexForKeyAsInt ' retrieve the index for a key in a list ' #1 KeyCompare ' compare two keys ' ** '\****************************************************************************** ' Some variables explained: ' ' cComp is the KEY belonging to the VALUE above for reverse test ' ' NOTE: Other related functions can be found in global/tools/inc/t_filters.inc '******************************************************************************* function hGetDataPairAsString( sKey as string, sVal as long ) as string '///

Concatenate two strings and insert an = sign

'///About "KEY"-functions:
'///These functions are used whenever '///+ data is to be processed that is stored in a key=value format.
'///+ They handle a single string or a list of strings '///+ to e.g. isolate a key, a value or to just retrieve the pair.


'///Input: '///
    '///+
  1. KEY (string)
  2. '/// '///+
  3. VALUE (string)
  4. '/// '///
'///Returns: '///
    '///+
  1. KEY=VALUE pair (string)
  2. '///
'///Description: '/// end function '******************************************************************************* function hGetValueForPairAsString( cLine as string ) as string '///

Retrieve value from a key=value string

'///About "KEY"-functions:
'///These functions are used whenever '///+ data is to be processed that is stored in a key=value format.
'///+ They handle a single string or a list of strings '///+ to e.g. isolate a key, a value or to just retrieve the pair.


'///Input: '///
    '///+
  1. KEY=VALUE pair (string)
  2. '///
'///Returns: '///
    '///+
  1. VALUE (string)
  2. '/// '///
'///Description: '/// end function '******************************************************************************* function hGetValueForPairAsLong( cLine as string ) as long '///

Retrieve the value from a key=value pair as long

'///About "KEY"-functions:
'///These functions are used whenever '///+ data is to be processed that is stored in a key=value format.
'///+ They handle a single string or a list of strings '///+ to e.g. isolate a key, a value or to just retrieve the pair.


'///Input: '///
    '///+
  1. KEY=VALUE pair (string)
  2. '///
'///Returns: '///
    '///+
  1. VALUE (long)
  2. '/// '///
'///Description: '/// end function '******************************************************************************* function hGetValueForKeyAsInt( lsList() as string, sKey as string ) as integer '///

Retrieve the value of a key=value pair as integer

'///About "KEY"-functions:
'///These functions are used whenever '///+ data is to be processed that is stored in a key=value format.
'///+ They handle a single string or a list of strings '///+ to e.g. isolate a key, a value or to just retrieve the pair.


'///Prerequisite: Array compatible to listfuncs, known, valid key

'///Input: '///
    '///+
  1. List of KEY=VALUE pairs (string)
  2. '/// '///+
  3. Key to be searched for within the list (string)
  4. '/// '///
'///Returns: '///
    '///+
  1. VALUE (integer)
  2. '/// '///
'///Description: '/// end function '******************************************************************************* function hGetValueForKeyAsLong( lsList() as string, sKey as string ) as long '///

Retrieve the value of a key=value pair as integer

'///About "KEY"-functions:
'///These functions are used whenever '///+ data is to be processed that is stored in a key=value format.
'///+ They handle a single string or a list of strings '///+ to e.g. isolate a key, a value or to just retrieve the pair.


'///Prerequisite: Array compatible to listfuncs, known, valid key

'///Input: '///
    '///+
  1. List of KEY=VALUE pairs (string)
  2. '/// '///+
  3. Key to be searched for within the list (string)
  4. '/// '///
'///Returns: '///
    '///+
  1. VALUE (long integer)
  2. '/// '///
'///Description: '/// end function '******************************************************************************* function hGetKeyForPairAsString( cLine as string ) as string '///

Retrieve the KEY from a key=value pair

'///About "KEY"-functions:
'///These functions are used whenever '///+ data is to be processed that is stored in a key=value format.
'///+ They handle a single string or a list of strings '///+ to e.g. isolate a key, a value or to just retrieve the pair.


'///Input: '///
    '///+
  1. KEY=VALUE pair (string)
  2. '///
'///Returns: '///
    '///+
  1. KEY (string)
  2. '/// '///
'///Description: '/// end function '******************************************************************************* function hGetKeyForValueAsString( lsList() as string, sVal as string ) as string '///

Retrieve the KEY for a known VALUE from a key=value pair

'///About "KEY"-functions:
'///These functions are used whenever '///+ data is to be processed that is stored in a key=value format.
'///+ They handle a single string or a list of strings '///+ to e.g. isolate a key, a value or to just retrieve the pair.


'///Prerequisite: List compatible to listfuncs, known VALUE for pair

'///Input: '///
    '///+
  1. List of KEY=VALUE pairs (string)
  2. '/// '///+
  3. VALUE (string)
  4. '/// '///
'///Returns: '///
    '///+
  1. KEY (string)
  2. '///
'///Description: '/// end function '******************************************************************************* function hGetKeyForValueAsInt( lsList() as string, sVal as string ) as integer '///

Retrieve the KEY for a known VALUE from a key=value pair

'///About "KEY"-functions:
'///These functions are used whenever '///+ data is to be processed that is stored in a key=value format.
'///+ They handle a single string or a list of strings '///+ to e.g. isolate a key, a value or to just retrieve the pair.


'///Prerequisite: List compatible to listfuncs, known VALUE for pair

'///Input: '///
    '///+
  1. List of KEY=VALUE pairs (string)
  2. '///+
  3. VALUE (string)
  4. '/// '///
'///Returns: '///
    '///+
  1. KEY (integer)
  2. '///
'///Description: '/// end function '******************************************************************************* function hGetIndexForKeyAsInt( lsList() as string, sKey as string ) as integer '///

Search a list of key=value pairs for a key and return its index

'///About "KEY"-functions:
'///These functions are used whenever '///+ data is to be processed that is stored in a key=value format.
'///+ They handle a single string or a list of strings '///+ to e.g. isolate a key, a value or to just retrieve the pair.


'///Prerequisite: List compatible to listfuncs, known VALUE for pair

'///Input: '///
    '///+
  1. List of KEY=VALUE pairs (string)
  2. '///+
  3. KEY to search for (string)
  4. '///
'///Returns: '///
    '///+
  1. Index of the KEY in the list (integer)
  2. '/// '///
'///Description: '/// end function '******************************************************************************* function keycompare( found as string, expected as string, sKey as string, optional cBugID as string) as boolean '///

Function to compare two keys with each other

'///Deprecated, do not use if ( isMissing( cBugID ) ) then cBugID = "" endif if ( lcase(found) = lcase(expected) ) then printlog( " * '" & sKey & "': ok" ) keycompare = true else warnlog( "#" + cBugID + "# Control has incorrect value: '" & sKey & "'") printlog( " > Found...: '" & found & "'" ) printlog( " > Expected: '" & expected & "'" ) keycompare = false endif end function