-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/divyagayathri-hcl/sonic-s…
…wss-common into zmq_new
- Loading branch information
Showing
8 changed files
with
215 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#include <string> | ||
#include <vector> | ||
|
||
#include "../dbconnector.h" | ||
#include "../table.h" | ||
#include "table.h" | ||
#include "util.h" | ||
|
||
using namespace swss; | ||
using namespace std; | ||
|
||
SWSSTable SWSSTable_new(SWSSDBConnector db, const char *tableName) { | ||
SWSSTry(return (SWSSTable) new Table((DBConnector *)db, string(tableName))); | ||
} | ||
|
||
void SWSSTable_free(SWSSTable tbl) { | ||
SWSSTry(delete (Table *)tbl); | ||
} | ||
|
||
int8_t SWSSTable_get(SWSSTable tbl, const char *key, SWSSFieldValueArray *outValues) { | ||
SWSSTry({ | ||
vector<FieldValueTuple> fvs; | ||
bool exists = ((Table *)tbl)->get(string(key), fvs); | ||
if (exists) { | ||
*outValues = makeFieldValueArray(fvs); | ||
return 1; | ||
} else { | ||
return 0; | ||
} | ||
}); | ||
} | ||
|
||
int8_t SWSSTable_hget(SWSSTable tbl, const char *key, const char *field, SWSSString *outValue) { | ||
SWSSTry({ | ||
string s; | ||
bool exists = ((Table *)tbl)->hget(string(key), string(field), s); | ||
if (exists) { | ||
*outValue = makeString(move(s)); | ||
return 1; | ||
} else { | ||
return 0; | ||
} | ||
}); | ||
} | ||
|
||
void SWSSTable_set(SWSSTable tbl, const char *key, SWSSFieldValueArray values) { | ||
SWSSTry({ | ||
vector<FieldValueTuple> fvs = takeFieldValueArray(values); | ||
((Table *)tbl)->set(string(key), fvs); | ||
}); | ||
} | ||
|
||
void SWSSTable_hset(SWSSTable tbl, const char *key, const char *field, SWSSStrRef value) { | ||
SWSSTry({ ((Table *)tbl)->hset(string(key), string(field), takeStrRef(value)); }); | ||
} | ||
|
||
void SWSSTable_del(SWSSTable tbl, const char *key) { | ||
SWSSTry({ ((Table *)tbl)->del(string(key)); }); | ||
} | ||
|
||
void SWSSTable_hdel(SWSSTable tbl, const char *key, const char *field) { | ||
SWSSTry({ ((Table *)tbl)->hdel(string(key), string(field)); }); | ||
} | ||
|
||
SWSSStringArray SWSSTable_getKeys(SWSSTable tbl) { | ||
SWSSTry({ | ||
vector<string> keys; | ||
((Table *)tbl)->getKeys(keys); | ||
return makeStringArray(move(keys)); | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#ifndef SWSS_COMMON_C_API_TABLE_H | ||
#define SWSS_COMMON_C_API_TABLE_H | ||
|
||
#include "dbconnector.h" | ||
#include "util.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#include <stdint.h> | ||
|
||
typedef struct SWSSTableOpaque *SWSSTable; | ||
|
||
SWSSTable SWSSTable_new(SWSSDBConnector db, const char *tableName); | ||
|
||
void SWSSTable_free(SWSSTable tbl); | ||
|
||
// If the key exists, populates outValues with the table's values and returns 1. | ||
// If the key doesn't exist, returns 0. | ||
int8_t SWSSTable_get(SWSSTable tbl, const char *key, SWSSFieldValueArray *outValues); | ||
|
||
// If the key and field exist, populates outValue with the field's value and returns 1. | ||
// If the key doesn't exist, returns 0. | ||
int8_t SWSSTable_hget(SWSSTable tbl, const char *key, const char *field, SWSSString *outValue); | ||
|
||
void SWSSTable_set(SWSSTable tbl, const char *key, SWSSFieldValueArray values); | ||
|
||
void SWSSTable_hset(SWSSTable tbl, const char *key, const char *field, SWSSStrRef value); | ||
|
||
void SWSSTable_del(SWSSTable tbl, const char *key); | ||
|
||
void SWSSTable_hdel(SWSSTable tbl, const char *key, const char *field); | ||
|
||
SWSSStringArray SWSSTable_getKeys(SWSSTable tbl); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters