Hoyt's FORK of DemoIccMAX 2.1.17.hoyt
Documentation for Hoyt's FORK of DemoIccMAX
Loading...
Searching...
No Matches
CIccFuncTokenizer Class Reference

#include <IccMpeCalc.h>

+ Collaboration diagram for CIccFuncTokenizer:

Public Member Functions

 CIccFuncTokenizer (const char *szText, bool bAllowReferences=false)
 
bool GetEnvSig (icSigCmmEnvVar &envSig)
 
bool GetIndex (icUInt16Number &v1, icUInt16Number &v2, icUInt16Number initV1=0, icUInt16Number initV2=0)
 
std::string & GetLast ()
 
std::string GetName () const
 
bool GetNext (bool bForceNoRefs=false)
 
const char * GetPos ()
 
std::string GetReference () const
 
icSigCalcOp GetSig ()
 
icFloat32Number GetValue ()
 
void SetPos (const char *szText)
 
virtual ~CIccFuncTokenizer ()
 

Protected Member Functions

bool IsComment ()
 
bool IsWhiteSpace ()
 
void SkipComment ()
 

Protected Attributes

bool m_bUseRefs
 
const char * m_text
 
std::string * m_token
 

Detailed Description

Definition at line 322 of file IccMpeCalc.h.

Constructor & Destructor Documentation

◆ CIccFuncTokenizer()

CIccFuncTokenizer::CIccFuncTokenizer ( const char * szText,
bool bAllowReferences = false )

Definition at line 2482 of file IccMpeCalc.cpp.

2483{
2484 m_token = new std::string();
2485 m_text = szText;
2486 m_bUseRefs = bAllowNamedReferences;
2487}
const char * m_text
Definition IccMpeCalc.h:348
std::string * m_token
Definition IccMpeCalc.h:349

References m_bUseRefs, m_text, and m_token.

◆ ~CIccFuncTokenizer()

CIccFuncTokenizer::~CIccFuncTokenizer ( )
virtual

Definition at line 2489 of file IccMpeCalc.cpp.

2490{
2491 delete m_token;
2492}

References m_token.

Member Function Documentation

◆ GetEnvSig()

bool CIccFuncTokenizer::GetEnvSig ( icSigCmmEnvVar & envSig)

Definition at line 2673 of file IccMpeCalc.cpp.

2674{
2675 const char *pos = GetPos();
2676
2677 if (!GetNext())
2678 return false;
2679 const char *szToken = m_token->c_str();
2680 int l=(int)strlen(szToken);
2681 if ((*szToken=='[' && szToken[l-1]==']') ||
2682 (*szToken=='(' && szToken[l-1]==')')) {
2683
2684 int i;
2685
2686 icUInt32Number sig = 0;
2687 if (l==10) {
2688 sscanf(szToken+1, "%x", &sig);
2689
2690 envSig = (icSigCmmEnvVar)sig;
2691 return true;
2692 }
2693
2694 for (i=1; i<=4 && i<l-1; i++) {
2695 sig <<= 8;
2696 sig |= szToken[i];
2697 }
2698
2699 for (;i<=4; i++) {
2700 sig <<= 8;
2701 sig |= 0x20;
2702 }
2703
2704 envSig = (icSigCmmEnvVar)sig;
2705 }
2706 else {
2707 SetPos(pos); //Undo get token
2708 envSig = (icSigCmmEnvVar)0;
2709 return false;
2710 }
2711
2712 return true;
2713}
icArraySignature sig
unsigned int icUInt32Number
void SetPos(const char *szText)
Definition IccMpeCalc.h:330
const char * GetPos()
Definition IccMpeCalc.h:329
bool GetNext(bool bForceNoRefs=false)
icSigCmmEnvVar

References GetNext(), GetPos(), m_token, SetPos(), and sig.

Referenced by CIccCalculatorFunc::ParseFuncDef().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetIndex()

bool CIccFuncTokenizer::GetIndex ( icUInt16Number & v1,
icUInt16Number & v2,
icUInt16Number initV1 = 0,
icUInt16Number initV2 = 0 )

Definition at line 2630 of file IccMpeCalc.cpp.

2631{
2632 unsigned int iv1, iv2;
2633 const char *pos = GetPos();
2634
2635 if (!GetNext(true))
2636 return false;
2637 iv1=initV1;
2638 iv2=initV2;
2639 const char *szToken = m_token->c_str();
2640 if (*szToken=='[' || *szToken=='(') {
2641 if (strchr(szToken, ',')) {
2642 if (*szToken=='(')
2643 sscanf(m_token->c_str(), "(%u,%u)", &iv1, &iv2);
2644 else
2645 sscanf(m_token->c_str(), "[%u,%u]", &iv1, &iv2);
2646 }
2647 else {
2648 if (*szToken=='(')
2649 sscanf(m_token->c_str(), "(%u)", &iv1);
2650 else
2651 sscanf(m_token->c_str(), "[%u]", &iv1);
2652 }
2653 }
2654 else {
2655 SetPos(pos); //Undo get token
2656 }
2657 v1 = (icUInt16Number)iv1 - initV1;
2658 v2 = (icUInt16Number)iv2 - initV2;
2659
2660 return true;
2661}
unsigned short icUInt16Number

References GetNext(), GetPos(), m_token, and SetPos().

Referenced by CIccMpeXmlCalculator::Flatten(), CIccCalculatorFunc::ParseFuncDef(), CIccMpeXmlCalculator::ParseImport(), and CIccMpeXmlCalculator::UpdateLocals().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetLast()

std::string & CIccFuncTokenizer::GetLast ( )
inline

Definition at line 341 of file IccMpeCalc.h.

341{ return *m_token; }

Referenced by CIccMpeXmlCalculator::Flatten(), and CIccMpeXmlCalculator::UpdateLocals().

+ Here is the caller graph for this function:

◆ GetName()

std::string CIccFuncTokenizer::GetName ( ) const

Definition at line 2601 of file IccMpeCalc.cpp.

2602{
2603 std::string rv;
2604 const char *pos = m_token->c_str();
2605
2606 while (*pos && *pos != '{' && *pos != '[' && *pos != '(') {
2607 rv += *pos;
2608 pos++;
2609 }
2610
2611 return rv;
2612}

References m_token.

Referenced by CIccMpeXmlCalculator::Flatten(), CIccMpeXmlCalculator::ParseImport(), and CIccMpeXmlCalculator::UpdateLocals().

+ Here is the caller graph for this function:

◆ GetNext()

bool CIccFuncTokenizer::GetNext ( bool bForceNoRefs = false)

Definition at line 2495 of file IccMpeCalc.cpp.

2496{
2497 m_token->clear();
2498
2499try_again:
2500
2501 while (*m_text && IsWhiteSpace())
2502 m_text++;
2503
2504 if (!*m_text) {
2505 return false;
2506 }
2507
2508 if (!m_bUseRefs || bForceNoRefs) {
2509 if (*m_text == '{') {
2510 m_text++;
2511 *m_token = "{";
2512 return true;
2513 }
2514
2515 if (*m_text == '}') {
2516 m_text++;
2517 *m_token = "}";
2518 return true;
2519 }
2520
2521 if (*m_text == '[') {
2522 m_text++;
2523 *m_token = "[";
2524 while (*m_text && *m_text != ']') {
2525 *m_token += *m_text;
2526 m_text++;
2527 }
2528 }
2529
2530 if (*m_text == '(') {
2531 m_text++;
2532 *m_token = "(";
2533 while (*m_text && *m_text != ')') {
2534 *m_token += *m_text;
2535 m_text++;
2536 }
2537 if (!*m_text) {
2538 return false;
2539 }
2540 }
2541 }
2542
2543 if (!*m_text) {
2544 return false;
2545 }
2546
2547 if (IsComment()) {
2548 SkipComment();
2549 goto try_again;
2550 }
2551
2552 if (m_bUseRefs && !bForceNoRefs) {
2553 while (!IsWhiteSpace() && *m_text && !IsComment()) {
2554 *m_token += *m_text;
2555 m_text++;
2556 }
2557 }
2558 else {
2559 while (!IsWhiteSpace() && *m_text && *m_text != '{' && *m_text != '[' &&
2560 *m_text != '(' && *m_text != '}' && !IsComment()) {
2561 *m_token += *m_text;
2562 m_text++;
2563 }
2564 }
2565 return true;
2566}

References IsComment(), IsWhiteSpace(), m_bUseRefs, m_text, m_token, and SkipComment().

Referenced by CIccMpeXmlCalculator::Flatten(), GetEnvSig(), GetIndex(), CIccCalculatorFunc::ParseFuncDef(), CIccMpeXmlCalculator::ParseImport(), CIccMpeXmlCalculator::UpdateLocals(), and CIccMpeXmlCalculator::ValidMacroCalls().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetPos()

const char * CIccFuncTokenizer::GetPos ( )
inline

Definition at line 329 of file IccMpeCalc.h.

329{ return m_text; }

Referenced by GetEnvSig(), GetIndex(), and CIccCalculatorFunc::ParseFuncDef().

+ Here is the caller graph for this function:

◆ GetReference()

std::string CIccFuncTokenizer::GetReference ( ) const

Definition at line 2614 of file IccMpeCalc.cpp.

2615{
2616 const char *pos = strchr(m_token->c_str(), '{');
2617 if (!m_bUseRefs || !pos)
2618 return "";
2619
2620 std::string rv;
2621 pos++;
2622 while (*pos && *pos != '}') {
2623 rv += *pos;
2624 pos++;
2625 }
2626
2627 return rv;
2628}

References m_bUseRefs, and m_token.

Referenced by CIccMpeXmlCalculator::Flatten(), and CIccMpeXmlCalculator::ValidMacroCalls().

+ Here is the caller graph for this function:

◆ GetSig()

icSigCalcOp CIccFuncTokenizer::GetSig ( )

Definition at line 2569 of file IccMpeCalc.cpp.

2570{
2571 const unsigned char *szToken = (unsigned char*) m_token->c_str();
2572 int i;
2573
2574 if ((szToken[0]>='0' && szToken[0]<='9') || szToken[0]=='.' || (szToken[0]=='-' && szToken[1]!='I')) {
2575 return icSigDataOp;
2576 }
2577
2578 if (szToken[0]=='{')
2579 return icSigBeginBlockOp;
2580
2581 if (szToken[0]=='}')
2582 return icSigEndBlockOp;
2583
2584 if (szToken[0]=='[')
2585 return icSigBadOp;
2586
2587 icUInt32Number sig = 0;
2588 for (i=0; i<4 && szToken[i]; i++) {
2589 sig <<= 8;
2590 sig |= szToken[i];
2591 }
2592
2593 for (;i<4; i++) {
2594 sig <<= 8;
2595 sig |= 0x20;
2596 }
2597
2598 return (icSigCalcOp)sig;
2599}
icSigCalcOp
Definition IccMpeCalc.h:110
@ icSigDataOp
Definition IccMpeCalc.h:112
#define icSigEndBlockOp
Definition IccMpeCalc.h:319
#define icSigBadOp
Definition IccMpeCalc.h:320
#define icSigBeginBlockOp
Definition IccMpeCalc.h:318

References icSigBadOp, icSigBeginBlockOp, icSigDataOp, icSigEndBlockOp, m_token, and sig.

Referenced by CIccCalculatorFunc::ParseFuncDef().

+ Here is the caller graph for this function:

◆ GetValue()

icFloat32Number CIccFuncTokenizer::GetValue ( )

Definition at line 2664 of file IccMpeCalc.cpp.

2665{
2666 const char * ascii = m_token->c_str();
2667 char * p = NULL;
2668 double d = strtod( ascii, &p );
2669 return (icFloat32Number)d;
2670}
float icFloat32Number

References m_token.

Referenced by CIccCalculatorFunc::ParseFuncDef().

+ Here is the caller graph for this function:

◆ IsComment()

bool CIccFuncTokenizer::IsComment ( )
protected

Definition at line 2723 of file IccMpeCalc.cpp.

2724{
2725 if (*m_text=='%' || *m_text==';' || *m_text=='/')
2726 return true;
2727 return false;
2728}

References m_text.

Referenced by GetNext().

+ Here is the caller graph for this function:

◆ IsWhiteSpace()

bool CIccFuncTokenizer::IsWhiteSpace ( )
protected

Definition at line 2716 of file IccMpeCalc.cpp.

2717{
2718 if (*m_text==' ' || *m_text=='\n' || *m_text=='\r' || *m_text=='\t')
2719 return true;
2720 return false;
2721}

References m_text.

Referenced by GetNext().

+ Here is the caller graph for this function:

◆ SetPos()

void CIccFuncTokenizer::SetPos ( const char * szText)
inline

Definition at line 330 of file IccMpeCalc.h.

330{ m_text = szText; }

Referenced by GetEnvSig(), GetIndex(), and CIccCalculatorFunc::ParseFuncDef().

+ Here is the caller graph for this function:

◆ SkipComment()

void CIccFuncTokenizer::SkipComment ( )
protected

Definition at line 2730 of file IccMpeCalc.cpp.

2731{
2732 while(*m_text && !(*m_text=='\n' || *m_text=='\r')) {
2733 m_text++;
2734 }
2735}

References m_text.

Referenced by GetNext().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_bUseRefs

bool CIccFuncTokenizer::m_bUseRefs
protected

Definition at line 351 of file IccMpeCalc.h.

Referenced by CIccFuncTokenizer(), GetNext(), and GetReference().

◆ m_text

const char* CIccFuncTokenizer::m_text
protected

Definition at line 348 of file IccMpeCalc.h.

Referenced by CIccFuncTokenizer(), GetNext(), IsComment(), IsWhiteSpace(), and SkipComment().

◆ m_token

std::string* CIccFuncTokenizer::m_token
protected

The documentation for this class was generated from the following files: