Skip to content

Commit ce97f29

Browse files
committed
Drop now-unused basAnc findRecByNmXX() member functions
1 parent 57ce223 commit ce97f29

File tree

2 files changed

+6
-260
lines changed

2 files changed

+6
-260
lines changed

src/ancrec.cpp

Lines changed: 4 additions & 247 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,254 +1203,9 @@ RC basAnc::ba_Validate( // validate an anchor: check self-consistency of anchor
12031203

12041204
return RCOK; // if here, all OK
12051205
} // basAnc::ba_Validate
1206-
1207-
1208-
//---------------------------------------------------------------------------------------------------------------------------
1209-
RC basAnc::findRecByNm1( // find record by name and owner subscript (first match). No msg here.
1210-
// see also findRecByNmDefO().
1211-
const char* _name, // name to look for
1212-
TI* _i, // NULL or receives subscript of entry if found
1213-
record** _r) // NULL or receives entry ptr if found
1214-
{
1215-
1216-
record* r1Old = nullptr;
1217-
1218-
int iRec = 0;
1219-
1220-
RC rcOld = findRecByNm1X(_name, &iRec, &r1Old);
1221-
1222-
1223-
RC rcNew = FindRecByName(this, _name, 0, _r, _i);
1224-
1225-
bool rGood = !_r || (_r && *_r == r1Old);
1226-
1227-
if (rcOld != rcNew || !rGood || (_i && iRec != *_i))
1228-
{
1229-
record* r1NewX;
1230-
RC rcX = FindRecByName(this, _name, 0, &r1NewX);
1231-
err(PABT, "findRecByNm1 mismatch");
1232-
}
1233-
1234-
return rcNew;
1235-
1236-
}
1237-
1238-
1239-
//---------------------------------------------------------------------------------------------------------------------------
1240-
RC basAnc::findRecByNm1X( // find record by 1st match on name, RCOK if found, no msg here.
1241-
// can and should all uses be changed to findRecByNmU ?? <<<<
1242-
const char* _name, // record name to look for
1243-
TI *_i, // NULL or receives subscript of entry if found
1244-
record **_r ) // NULL or receives entry ptr if found
1245-
{
1246-
if (this==nullptr) // test for 0 'this' pointer
1247-
return RCBAD; // return NOT FOUND if called for NULL anc pointer (occurs re types if .tyB 0)
1248-
record *r;
1249-
RLUPTHIS(r) // loop over records, setting r to point to each good one
1250-
if (r->IsNameMatch( _name)) // if matches
1251-
{
1252-
if (_i) *_i = r->ss; // found. return info
1253-
if (_r) *_r = r; // ..
1254-
return RCOK; // good return
1255-
}
1256-
return RCBAD; // not found return
1257-
} // basAnc::findRecByNm1
1258-
1259-
//---------------------------------------------------------------------------------------------------------------------------
1260-
RC basAnc::findRecByNmU( // find record by name and owner subscript (first match). No msg here.
1261-
// see also findRecByNmDefO().
1262-
const char* _name, // name to look for
1263-
TI* _i, // NULL or receives subscript of entry if found
1264-
record** _r) // NULL or receives entry ptr if found
1265-
{
1266-
record* r1Old = nullptr;
1267-
1268-
int iRec = 0;
1269-
1270-
RC rcOld = findRecByNmUX(_name, &iRec, &r1Old);
1271-
1272-
RC rcNew = FindRecByName(this, _name, frnUNIQUE, _r, _i);
1273-
1274-
bool rGood = !_r || (_r && *_r == r1Old);
1275-
1276-
if (rcOld != rcNew || !rGood || (_i && (*_i != iRec)))
1277-
err(PABT, "findRecByNmU mismatch");
1278-
1279-
return rcNew;
1280-
1281-
}
1282-
//---------------------------------------------------------------------------------------------------------------------------
1283-
RC basAnc::findRecByNmUX( // find record by unique name match. RCBAD not found, RCBAD2 ambiguous, no msgs here.
1284-
const char* _name, // record name to look for
1285-
TI *_i, // NULL or receives subscript of entry if found
1286-
record **_r ) // NULL or receives entry ptr if found
1287-
{
1288-
if (this==nullptr)
1289-
return RCBAD; // return NOT FOUND if called for NULL anc pointer (ocurs re types if .tyB 0)
1290-
record *r, *r1 = nullptr;
1291-
int nHits = 0;
1292-
RLUPTHIS(r) // loop over records, setting r to point to each good one
1293-
{ if (r->IsNameMatch(_name)) // if matches
1294-
{ if (nHits++)
1295-
return RCBAD2; // if seen before, bad (ambigous) return
1296-
else
1297-
r1 = r; // else save record addr, continue search to be sure unique
1298-
}
1299-
}
1300-
1301-
if (!nHits)
1302-
return RCBAD; // no matches, give bad (not found) return
1303-
if (_i) // exactly 1 match if here. return info.
1304-
*_i = r1->ss;
1305-
if (_r)
1306-
*_r = r1; // ..
1307-
return RCOK; // good return
1308-
} // basAnc::findRecByNmU
1309-
1310-
//---------------------------------------------------------------------------------------------------------------------------
1311-
RC basAnc::findRecByNmOX( // find record by name and owner subscript (first match). No msg here.
1312-
// see also findRecByNmDefO().
1313-
const char* _name, // name to look for
1314-
TI ownTi, // required owner subscript (should be non-0)
1315-
TI *_i, // NULL or receives subscript of entry if found
1316-
record **_r ) // NULL or receives entry ptr if found
1317-
{
1318-
if (this==nullptr)
1319-
return RCBAD; // return NOT FOUND if called for NULL anc pointer (occurs re types if .tyB 0)
1320-
1321-
// add isOwnable check if it is possible for anchor to be non-ownAble, 2-92.
1322-
record *r;
1323-
RLUPTHIS(r) // loop over records, setting r to point to each good one
1324-
{ if (r->ownTi==ownTi // if owning object subscript matches
1325-
&& r->IsNameMatch(_name)) // if name matches
1326-
{ if (_i) *_i = r->ss; // found. return info
1327-
if (_r) *_r = r; // ..
1328-
return RCOK; // good return
1329-
}
1330-
}
1331-
return RCBAD; // not found return
1332-
} // basAnc::findRecByNmO
1333-
1334-
//---------------------------------------------------------------------------------------------------------------------------
1335-
RC basAnc::findRecByNmO( // find record by name and owner subscript (first match). No msg here.
1336-
// see also findRecByNmDefO().
1337-
const char* _name, // name to look for
1338-
TI ownTi, // required owner subscript (should be non-0)
1339-
TI* _i, // NULL or receives subscript of entry if found
1340-
record** _r) // NULL or receives entry ptr if found
1341-
{
1342-
record* r1Old = nullptr;
1343-
1344-
int iRec = 0;
1345-
1346-
RC rcOld = findRecByNmOX(_name, ownTi, &iRec, &r1Old);
1347-
1348-
RC rcNew = FindRecByName(this, _name, ownTi, _r);
1349-
1350-
if (rcOld != rcNew || (_r != nullptr && (r1Old != *_r || (*_r != nullptr && iRec != (*_r)->ss))))
1351-
err(PABT, "findRecByNmO mismatch");
1352-
1353-
return rcNew;
1354-
1355-
}
1356-
//----------------------------------------------------------------------------------------
1357-
RC basAnc::findRecByNmDefO( // find record by name, and owner if ambiguous
1358-
1359-
// Accepts unambiguous match with another owner;
1360-
// returns info for caller to do detailed err msg if ambiguous; no msg here.
1361-
// DOUBLE CAUTION: following recoded 3-92 without specific test:
1362-
//// CAUTION: currently 1-92 does not check for multiple entries with same owner TI.
1363-
1364-
const char* _name, // name to look for
1365-
TI ownTi, // default owner subscript
1366-
record** _r1, // NULL or rcvs entry ptr if any found; rcvs NULL if no match
1367-
record** _r2) // NULL or receives duplicate entry ptr if ambiguous
1368-
{
1369-
1370-
record* r1Old = nullptr;
1371-
record* r2Old = nullptr;
1372-
1373-
RC rcOld = findRecByNmDefOX(_name, ownTi, &r1Old, &r2Old);
1374-
1375-
RC rcNew = FindRecByName(this, _name, ownTi|frnACCEPTNONOWNER, _r1, nullptr, _r2);
1376-
1377-
if (rcOld != rcNew || (_r1 != nullptr && r1Old != *_r1) || (_r2 != nullptr && r2Old != *_r2))
1378-
{
1379-
RC rcNewX = FindRecByName(this, _name, ownTi|frnACCEPTNONOWNER, _r1, nullptr, _r2);
1380-
err(PABT, "findRecByNmDefO mismatch");
1381-
}
1382-
1383-
return rcNew;
1384-
}
1385-
1386-
1387-
1388-
//---------------------------------------------------------------------------------------------------------------------------
1389-
RC basAnc::findRecByNmDefOX( // find record by name, and owner if ambiguous
1390-
1391-
// Accepts unambiguous match with another owner;
1392-
// returns info for caller to do detailed err msg if ambiguous; no msg here.
1393-
// DOUBLE CAUTION: following recoded 3-92 without specific test:
1394-
//// CAUTION: currently 1-92 does not check for multiple entries with same owner TI.
1395-
1396-
const char* _name, // name to look for
1397-
TI ownTi, // default owner subscript
1398-
record **_r1, // NULL or rcvs entry ptr if any found; rcvs NULL if no match
1399-
record **_r2 ) // NULL or receives duplicate entry ptr if ambiguous
1400-
1401-
/* returns found: RCOK, *_r1 set.
1402-
no match: RCBAD, *_r1 NULL.
1403-
ambiguous match: RCBAD2, *_r1 and *_r2 point to 1st 2 matching entries */
1404-
{
1405-
// add isOwnable check if it is possible for anchor to be non-ownAble, 2-92.
1406-
if (_r1) *_r1 = NULL; // init to "not found" as opposed to "ambiguous"
1407-
if (this==nullptr)
1408-
return RCBAD; // return NOT FOUND if called for NULL anc pointer (ocurs re types if .tyB 0)
1409-
SI oSeen=0, nHits=0; // no name matches found yet
1410-
record *r, *r1=NULL, *r2=NULL;
1411-
RLUPTHIS(r) // loop over records, setting r to point to each good one
1412-
{ if (!oSeen || ownTi==r->ownTi) // if no owned match yet or correct owner:
1413-
// do not test any more wrong-owner records after one ownTi+name match.
1414-
if (r->IsNameMatch( _name)) // if name matches
1415-
{
1416-
if (ownTi==r->ownTi && !oSeen++) // if first record with correct owner
1417-
nHits = 0; // forget any name matches with wrong owner
1418-
if (++nHits==1) r1 = r; // first match. Will be returned as uniquely found record if no more matches.
1419-
else if (nHits==2) r2 = r; // second match: save record pointer for "ambiguous" return
1420-
}
1421-
}
1422-
if (nHits==0) return RCBAD; // not found. Another NOT FOUND return above for NULL 'this'.
1423-
if (_r1) *_r1 = r1; // first found record address
1424-
if (nHits==1) return RCOK; // unique match: found
1425-
if (_r2) *_r2 = r2; // second found record address
1426-
return RCBAD2; // nHits > 1: ambiguous
1427-
} // basAnc::findRecByNmDefOX
1428-
1429-
#if 0
1430-
/*static*/ RC basAnc::FindRecByName(
1431-
const basAnc* _b, // basAnc in which to search
1432-
// may be nullptr (returns RCBAD)
1433-
const char* _name, // name to look for
1434-
TI ownerTIOpt, // options and/or required owner subscript
1435-
//
1436-
TI* pTi /*=nullptr*/, // NULL or receives subscript of entry if found
1437-
record** pRp /*=nullptr*/) // NULL or receives entry ptr if found
1438-
1439-
{
1440-
RC rc = FindRecByName(_b, _name, ownerTIOpt, pRp, pTi);
1441-
1442-
return RC
1443-
1444-
1445-
1446-
}
1447-
1448-
}
1449-
#endif
1450-
14511206
//---------------------------------------------------------------------------------------------------------------------------
1452-
/*static*/ RC basAnc::FindRecByName( // inner find record by unique name match
1453-
const basAnc* _b, // basAnc in which to search
1207+
/*static*/ RC basAnc::FindRecByName( // find record by name (and owner) match
1208+
const basAnc* _b, // basAnc in which to search (nullptr OK, returns RCBAD)
14541209
const char* _name, // record name to look for
14551210
int ownerTIOpt /*=0*/, // low bits = TI of owner (0=don't care)
14561211
// hi bits:
@@ -1461,6 +1216,8 @@ RC basAnc::findRecByNmDefOX( // find record by name, and owner if ambiguous
14611216
TI* pTi /*=nullptr*/, // nullptr or receives TI (subscript) of record found
14621217
record **pr2 /*=nullptr*/) // nullptr or receives 2nd entry found
14631218

1219+
// IMPORTANT: FindRecByName() is static to support _b == nullptr (happens when b->tyB == nullptr).
1220+
// Cannot be a member function because clang objects to this==nullptr.
14641221

14651222
// returns: found: RCOK, *pr1 set.
14661223
// no match: RCBAD, *pr1 nullptr

src/ancrec.h

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -103,24 +103,13 @@ class basAnc // base class for record anchors: basAnc<recordName>
103103
static RC ba_ValidateSafe(const basAnc* _this, const char* fcnName, int erOp = ABT, bool noStat = false);
104104
RC ba_Validate( const char* fcnName, int erOp=ABT, bool noStat=false) const; // check for valid anchor
105105
record* Get1stForOwner(int ss);
106-
RC findRecByNm1( const char* _name, TI *_i, record **_r); // find record by 1st match on name
107-
RC findRecByNm1X( const char* _name, TI *_i, record **_r); // find record by 1st match on name
108-
109-
RC findRecByNmU( const char* _name, TI *_i, record **_r); // find record by unique name match
110-
RC findRecByNmUX( const char* _name, TI *_i, record **_r); // find record by unique name match
111-
112-
RC findRecByNmO( const char* _name, TI ownTi, TI *_i, record **_r); // find record by name and owner subscript
113-
RC findRecByNmOX( const char* _name, TI ownTi, TI *_i, record **_r); // find record by name and owner subscript
114-
115-
RC findRecByNmDefO( const char* _name, TI ownTi, record **_r1, record **_r2 ); // find record by name, and owner if ambiguous
116-
RC findRecByNmDefOX( const char* _name, TI ownTi, record **_r1, record **_r2 ); // find record by name, and owner if ambiguous
117-
118-
106+
119107
static constexpr int frn1STMATCH = 0;
120108
static constexpr int frnUNIQUE = 0x40000000;
121109
static constexpr int frnACCEPTNONOWNER = 0x20000000;
122110
static constexpr int frnTIMASK = 0x01ffffff;
123111
static RC FindRecByName(const basAnc* _b, const char* _name, int ownerTIOpt=0, record** pr1=nullptr, TI* pTi=nullptr, record** pr2=nullptr);
112+
124113
const char* getChoiTx( int fn, int options=0, SI chan=-1, BOOL* bIsHid=NULL) const;
125114
const char* culMbrIdTx(int fn) const;
126115
int culMbrArrayDim(int fn) const;

0 commit comments

Comments
 (0)