-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileUtility.h
More file actions
29 lines (23 loc) · 1.01 KB
/
FileUtility.h
File metadata and controls
29 lines (23 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// CNFUtility.h
#ifndef FileUtility_H
#define FileUtility_H
#pragma once
#include "Q2.h"
#include <string>
#include <vector>
#include <map>
// Main function to build parse tree directly from CNF file
TreeNode* buildParseTreeFromFile(const std::string& filename);
// Helper: Build parse tree directly from CNF clauses (more efficient than string conversion)
TreeNode* buildParseTreeFromClauses(const std::vector<std::vector<int>>& clauses,
const std::map<int, std::string>& varMap);
// Helper: Read CNF file and extract clauses
bool readCNFFile(const std::string& filename,
std::vector<std::vector<int>>& clauses,
int& numVars,
int& numClauses);
// Helper: Create variable mapping (1->x1, 2->x2, etc.)
std::map<int, std::string> createVarMap(int numVars, const std::string& prefix = "x");
// Alternative: Convert CNF file to infix string (for compatibility)
std::string cnfFileToInfix(const std::string& filename);
#endif // FileUtility