2.11 The class PlAtom - Supporting Prolog constants (version 2)
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
    • Packages
      • A C++ interface to SWI-Prolog
        • A C++ interface to SWI-Prolog (Version 2)
          • The class PlAtom - Supporting Prolog constants (version 2)
            • Direct comparision to char *
            • Direct comparision to PlAtom
            • Extraction of the atom and comparison to PlAtom
            • Extraction of the atom and comparison to char *

2.11.1 Direct comparision to char *

Example:

PREDICATE(test, 1)
{ if ( A1 == "read" )
    ...;
}

This writes easily and is the preferred method is performance is not critical and only a few comparisons have to be made. It validates A1 to be a term-reference representing text (atom, string, integer or float) extracts the represented text and uses strcmp() to match the strings.